Server IP : 127.0.0.2 / Your IP : 3.148.113.158 Web Server : Apache/2.4.18 (Ubuntu) System : User : www-data ( ) PHP Version : 7.0.33-0ubuntu0.16.04.16 Disable Function : disk_free_space,disk_total_space,diskfreespace,dl,exec,fpaththru,getmyuid,getmypid,highlight_file,ignore_user_abord,leak,listen,link,opcache_get_configuration,opcache_get_status,passthru,pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,php_uname,phpinfo,posix_ctermid,posix_getcwd,posix_getegid,posix_geteuid,posix_getgid,posix_getgrgid,posix_getgrnam,posix_getgroups,posix_getlogin,posix_getpgid,posix_getpgrp,posix_getpid,posix,_getppid,posix_getpwnam,posix_getpwuid,posix_getrlimit,posix_getsid,posix_getuid,posix_isatty,posix_kill,posix_mkfifo,posix_setegid,posix_seteuid,posix_setgid,posix_setpgid,posix_setsid,posix_setuid,posix_times,posix_ttyname,posix_uname,pclose,popen,proc_open,proc_close,proc_get_status,proc_nice,proc_terminate,shell_exec,source,show_source,system,virtual MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : ON Directory : /sbin/ |
Upload File : |
#!/bin/sh # Copyright (C) 2012-2013 Guus Sliepen <guus@debian.org> # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. set -e version() { echo 'ifenslave.sh version 2 (2013-05-05)' echo 'Copyright (c) 2012-2013 Guus Sliepen <guus@debian.org>' exit 0 } usage() { echo 'Usage: ifenslave [-acdfhuvV] <master> <slave> ...' exit 0 } error() { echo "$@" >&2 exit 1 } all_interfaces() { # I guess this was a debugging feature. ip link show exit 0 } # Parse options while true; do if [ "$1" = "-a" -o "$1" = "--all-interfaces" ]; then all_interfaces elif [ "$1" = "-c" -o "$1" = "--change-active" ]; then CHANGE_ACTIVE=1; shift elif [ "$1" = "-d" -o "$1" = "--detach" ]; then DETACH=1; shift elif [ "$1" = "-f" -o "$1" = "--force" ]; then FORCE=1; shift elif [ "$1" = "-h" -o "$1" = "--help" ]; then exec man 8 ifenslave elif [ "$1" = "-u" -o "$1" = "--usage" ]; then usage elif [ "$1" = "-v" -o "$1" = "--verbose" ]; then VERBOSE=1; shift elif [ "$1" = "-V" -o "$1" = "--version" ]; then version elif [ "$1" = "--" ]; then shift break else break fi done # Check that we have enough arguments remaining. [ -z "$2" ] && error "Not enough arguments" master="$1" shift # Check that the master is really a bonding interface. [ -d "/sys/class/net/$master" ] || error "$master: no such interface" [ -d "/sys/class/net/$master/bonding" ] || error "$master: is not a bonding interface" # Do we need to change the active interface? if [ "$CHANGE_ACTIVE" = 1 ]; then [ -z "$2" ] || error 'You can only set one interface to be the active slave!' [ "$VERBOSE" = 1 ] && echo "Changing active slave of $master to $slave" echo "$1" >"/sys/class/net/$master/bonding/active_slave" || error "$master: could not set $slave to active slave" exit 0 fi # Otherwise, loop over all slaves and either attach or detach them. for slave in "$@"; do [ -d "/sys/class/net/$slave" ] || error "$slave: no such interface" if [ -z "$DETACH" ]; then if [ -h "/sys/class/net/$master/slave_$slave" ] || [ -h "/sys/class/net/$master/lower_$slave" ]; then echo "$slave: already enslaved to $master" >&2 continue fi read type <"/sys/class/net/$slave/type" if [ -z "$FORCE" -a "$type" != "1" ]; then error "$slave: does not appear to be an Ethernet interface (use -f to force)" fi [ "$VERBOSE" = 1 ] && echo "Adding slave $slave to master $master" ip link set "$slave" down echo "+$slave" >"/sys/class/net/$master/bonding/slaves" || error "$slave: could not add interface" else if [ ! -h "/sys/class/net/$master/slave_$slave" ] || [ ! -h "/sys/class/net/$master/lower_$slave" ]; then echo "$slave: is not enslaved to $master" >&2 continue fi [ "$VERBOSE" = 1 ] && echo "Detaching slave $slave from master $master" echo "-$slave" >"/sys/class/net/$master/bonding/slaves" || error "$slave: could not detach interface" fi done exit 0