missing optional parameters for restart and boot functions
[openwrt-10.03/.git] / package / base-files / files / etc / rc.common
index 7ca107817dcfe904306f2439640d049c376e3f93..6b3c213a1d81a38b34cbfc2a50b8002e7e182b3c 100755 (executable)
@@ -3,8 +3,6 @@
 
 . $IPKG_INSTROOT/etc/functions.sh
 
-START=50
-
 start() {
        return 0
 }
@@ -19,12 +17,12 @@ reload() {
 
 restart() {
        trap '' TERM
-       stop
-       start
+       stop "$@"
+       start "$@"
 }
 
 boot() {
-       start
+       start "$@"
 }
 
 shutdown() {
@@ -34,13 +32,14 @@ shutdown() {
 disable() {
        name="$(basename "${initscript}")"
        rm -f "$IPKG_INSTROOT"/etc/rc.d/S??$name
+       rm -f "$IPKG_INSTROOT"/etc/rc.d/K??$name
 }
 
 enable() {
        name="$(basename "${initscript}")"
        disable
-       ln -s "/etc/init.d/$name" "$IPKG_INSTROOT/etc/rc.d/S${START}${name##S[0-9][0-9]}"
-       [ "$STOP" ] && ln -s "/etc/init.d/$name" "$IPKG_INSTROOT/etc/rc.d/K${START}${name##K[0-9][0-9]}"
+       [ "$START" ] && ln -s "/etc/init.d/$name" "$IPKG_INSTROOT/etc/rc.d/S${START}${name##S[0-9][0-9]}"
+       [ "$STOP"  ] && ln -s "/etc/init.d/$name" "$IPKG_INSTROOT/etc/rc.d/K${STOP}${name##K[0-9][0-9]}"
 }
 
 enabled() {
@@ -68,24 +67,26 @@ EOF
 }
 
 initscript="$1"
-action="$2"
+[ "$#" -ge 1 ] && shift
+action="$1"
+[ "$#" -ge 1 ] && shift
 
 . "$initscript"
 
 cmds=
 for cmd in $EXTRA_COMMANDS; do
-       cmds="${cmds:+$cmds$N}$cmd) $cmd;;"
+       cmds="${cmds:+$cmds$N}$cmd) $cmd \"\$@\";;"
 done
 eval "case \"\$action\" in
-       start) start;;
-       stop) stop;;
-       reload) reload || restart;;
-       restart) restart;;
-       boot) boot;;
-       shutdown) shutdown;;
-       enable) enable;;
-       enabled) enabled;;
-       disable) disable;;
+       start) start \"\$@\";;
+       stop) stop \"\$@\";;
+       reload) reload \"\$@\" || restart \"\$@\";;
+       restart) restart \"\$@\";;
+       boot) boot \"\$@\";;
+       shutdown) shutdown \"\$@\";;
+       enable) enable \"\$@\";;
+       enabled) enabled \"\$@\";;
+       disable) disable \"\$@\";;
        $cmds
        *) help;;
 esac"