redmine

Merge branch 'master' of https://gitlab.ut.mephi.ru/ut/ipw

Showing 1 changed file with 34 additions and 4 deletions
@@ -22,6 +22,14 @@ DEFAULT_BONDING_MODE='balance-tlb' @@ -22,6 +22,14 @@ DEFAULT_BONDING_MODE='balance-tlb'
22 22
23 modprobe bonding 23 modprobe bonding
24 24
  25 +if lockfile-check /run/ipw; then
  26 + eerror 'Another "ipw" instance is already running'
  27 + exit -1
  28 +fi
  29 +
  30 +trap 'lockfile-remove /run/ipw' SIGINT SIGTERM SIGHUP SIGQUIT SIGALRM SIGILL SIGABRT SIGPIPE EXIT
  31 +lockfile-create /run/ipw || exit
  32 +
25 eerror() { 33 eerror() {
26 echo "$@" >&2 34 echo "$@" >&2
27 } 35 }
@@ -156,8 +164,16 @@ ip_cmds() { @@ -156,8 +164,16 @@ ip_cmds() {
156 164
157 ip addr flush dev "$_IFACE" 165 ip addr flush dev "$_IFACE"
158 for IP_CMD in "${!IP_CMDS_VARIABLE}"; do 166 for IP_CMD in "${!IP_CMDS_VARIABLE}"; do
159 - [[ "$IP_CMD" != "" ]] && 167 + if [[ "$IP_CMD" != "" ]]; then
160 - ip $IP_CMD dev "$_IFACE" 168 + WORDS=($IP_CMD)
  169 + case "${WORDS[0]}" in
  170 + link)
  171 + ip $IP_CMD
  172 + ;;
  173 + *)
  174 + ip $IP_CMD dev "$_IFACE"
  175 + esac
  176 + fi
161 done 177 done
162 } 178 }
163 179
@@ -331,6 +347,17 @@ case "$CMD" in @@ -331,6 +347,17 @@ case "$CMD" in
331 fix) #fix all interfaces to config state 347 fix) #fix all interfaces to config state
332 #brctl addif bond0 eth2 348 #brctl addif bond0 eth2
333 349
  350 + if [[ "$IPW_DEBUG" -ge "2" ]]; then
  351 + cat "$IPW_CONFIG_PATH" > /tmp/ipw.conf-fix.$(date +'%Y%m%d%H%M%S')
  352 + fi
  353 +
  354 + if [[ "$IPW_CONFIG_PATH" != "/dev/null" ]]; then
  355 + if [[ "$(cat $IPW_CONFIG_PATH 2>/dev/null)" = "" ]]; then
  356 + eerror "Empty config file"
  357 + exit -1
  358 + fi
  359 + fi
  360 +
334 #GETTING INFORMATION ABOUT LXC INTERFACES IN BRIDGES 361 #GETTING INFORMATION ABOUT LXC INTERFACES IN BRIDGES
335 362
336 if [[ "$LXC_DIR" != "" ]]; then 363 if [[ "$LXC_DIR" != "" ]]; then
@@ -506,8 +533,11 @@ case "$CMD" in @@ -506,8 +533,11 @@ case "$CMD" in
506 533
507 # Creating bond-ifaces 534 # Creating bond-ifaces
508 if [[ "$D1Q_EXISTS" == 0 ]]; then #make all 535 if [[ "$D1Q_EXISTS" == 0 ]]; then #make all
509 - echo "+$D1Q_IFACE" > /sys/class/net/bonding_masters 536 + echo "+$D1Q_IFACE" > /sys/class/net/bonding_masters 2>/dev/null
510 - echo "$MODE" > /sys/class/net/"$D1Q_IFACE"/bonding/mode 537 +
  538 + if [[ -d /sys/class/net/"$D1Q_IFACE"/bonding ]]; then
  539 + echo "$MODE" > /sys/class/net/"$D1Q_IFACE"/bonding/mode
  540 + fi
511 541
512 for SLAVE in "${!SLAVES_VARIABLE}"; do 542 for SLAVE in "${!SLAVES_VARIABLE}"; do
513 ip link set dev "$SLAVE" down #enslaved int should be shutted down 543 ip link set dev "$SLAVE" down #enslaved int should be shutted down