simplified
authorRalph Ronnquist <ralph.ronnquist@gmail.com>
Mon, 5 Oct 2020 12:37:08 +0000 (23:37 +1100)
committerRalph Ronnquist <ralph.ronnquist@gmail.com>
Mon, 5 Oct 2020 12:37:08 +0000 (23:37 +1100)
rrqnet-ifupdown.sh

index 6c33d5fa38aeb50dda9374eb30333e327926cf8c..cdfd3b46a21e0daf4de02b75323cee913d5ed485 100755 (executable)
 # An rrqnet stanza may have the following settings:
 # rrqnet_port <port>
 # rrqnet_remote <remote declaration>
-# rrqnet_bridge <bridge>
+# rrqnet_options <options>
 # rrqnet_log <level> <pathname>
+# rrqnet_bridge <bridge>
 
 : ${RRQDAEMON:=/usr/local/sbin/rrqnet}
+: ${NAME:=rrqnet-${IFACE}}
 
 #function
 configure_tap_bridge() {
@@ -38,10 +40,10 @@ configure_tap_up() {
        grep -q "state UP" || ip link set dev $IFACE up
 }
 
-#function <env> start_cable <loglevel> <logfile>
+#function
 start_cable_pre_up() {
-    configure_tap_up
-    NAME="rrqnet-$IFACE"
+    configure_tap_up || return 1
+    configure_tap_bridge || return 1
     if [ -z "$IF_RRQNET_LOG" ] ; then
        daemon -U -r -n $NAME -- \
               $RRQDAEMON $IF_RRQNET_OPTIONS \
@@ -53,35 +55,16 @@ start_cable_pre_up() {
     fi
 }
 
-#function
-start_cable_post_up() {
-    configure_tap_bridge
-}
-
-#function
-stop_cable_pre_down() {
-    :
-}
-
 #function
 stop_cable_post_down() {
-    NAME="rrqnet-$IFACE"
     daemon -n $NAME --stop
 }
 
 # main script body
 
 case "$MODE-$PHASE" in
-    start-pre-up)
-       start_cable_pre_up
-       ;;
-    start-post-up)
-       start_cable_post_up
-       ;;
-    stop-pre-down)
-       :
-       ;;
-    stop-post-down)
-       stop_cable_post_down
-       ;;
+    start-pre-up) start_cable_pre_up ;;
+    start-post-up) : ;;
+    stop-pre-down) : ;;
+    stop-post-down) stop_cable_post_down ;;
 esac