2006-10-04 20:05:48 +00:00
|
|
|
#!/bin/sh
|
2009-07-26 12:34:09 +00:00
|
|
|
# Copyright (C) 2006-2009 OpenWrt.org
|
2006-10-15 21:03:30 +00:00
|
|
|
|
|
|
|
. $IPKG_INSTROOT/etc/functions.sh
|
|
|
|
|
2009-07-26 12:34:09 +00:00
|
|
|
initscript=$1
|
|
|
|
action=${2:-help}
|
|
|
|
shift 2
|
|
|
|
|
2006-10-04 20:05:48 +00:00
|
|
|
start() {
|
|
|
|
return 0
|
|
|
|
}
|
|
|
|
|
|
|
|
stop() {
|
|
|
|
return 0
|
|
|
|
}
|
|
|
|
|
|
|
|
reload() {
|
|
|
|
return 1
|
|
|
|
}
|
|
|
|
|
|
|
|
restart() {
|
2006-12-20 05:26:39 +00:00
|
|
|
trap '' TERM
|
2008-01-25 10:59:40 +00:00
|
|
|
stop "$@"
|
|
|
|
start "$@"
|
2006-10-04 20:05:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
boot() {
|
2008-01-25 10:59:40 +00:00
|
|
|
start "$@"
|
2006-10-04 20:05:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
shutdown() {
|
|
|
|
return 0
|
|
|
|
}
|
|
|
|
|
|
|
|
disable() {
|
2006-10-15 21:03:30 +00:00
|
|
|
name="$(basename "${initscript}")"
|
2006-10-15 21:22:51 +00:00
|
|
|
rm -f "$IPKG_INSTROOT"/etc/rc.d/S??$name
|
2007-05-10 10:38:53 +00:00
|
|
|
rm -f "$IPKG_INSTROOT"/etc/rc.d/K??$name
|
2006-10-04 20:05:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
enable() {
|
2006-10-15 21:03:30 +00:00
|
|
|
name="$(basename "${initscript}")"
|
2006-10-04 20:05:48 +00:00
|
|
|
disable
|
2008-09-23 12:35:34 +00:00
|
|
|
[ "$START" ] && ln -s "../init.d/$name" "$IPKG_INSTROOT/etc/rc.d/S${START}${name##S[0-9][0-9]}"
|
|
|
|
[ "$STOP" ] && ln -s "../init.d/$name" "$IPKG_INSTROOT/etc/rc.d/K${STOP}${name##K[0-9][0-9]}"
|
2006-10-04 20:05:48 +00:00
|
|
|
}
|
|
|
|
|
2006-12-08 17:56:05 +00:00
|
|
|
enabled() {
|
|
|
|
name="$(basename "${initscript}")"
|
|
|
|
[ -x "$IPKG_INSTROOT/etc/rc.d/S${START}${name##S[0-9][0-9]}" ]
|
|
|
|
}
|
|
|
|
|
2006-10-04 20:05:48 +00:00
|
|
|
depends() {
|
|
|
|
return 0
|
|
|
|
}
|
|
|
|
|
|
|
|
help() {
|
|
|
|
cat <<EOF
|
2006-10-04 20:09:14 +00:00
|
|
|
Syntax: $initscript [command]
|
2006-10-04 20:05:48 +00:00
|
|
|
|
|
|
|
Available commands:
|
|
|
|
start Start the service
|
|
|
|
stop Stop the service
|
|
|
|
restart Restart the service
|
|
|
|
reload Reload configuration files (or restart if that fails)
|
2006-10-15 21:03:30 +00:00
|
|
|
enable Enable service autostart
|
|
|
|
disable Disable service autostart
|
2006-10-04 20:05:48 +00:00
|
|
|
$EXTRA_HELP
|
|
|
|
EOF
|
|
|
|
}
|
|
|
|
|
|
|
|
. "$initscript"
|
|
|
|
|
2009-07-26 12:34:09 +00:00
|
|
|
ALL_COMMANDS="start stop reload restart boot shutdown enable disable enabled depends ${EXTRA_COMMANDS}"
|
|
|
|
list_contains ALL_COMMANDS "$action" || action=help
|
2010-03-29 03:58:17 +00:00
|
|
|
[ "$action" = "reload" ] && action='eval reload "$@" || restart "$@" && :'
|
2009-07-26 12:34:09 +00:00
|
|
|
$action "$@"
|