2006-10-04 23:05:48 +03:00
|
|
|
#!/bin/sh
|
2012-06-13 20:10:41 +03:00
|
|
|
# Copyright (C) 2006-2012 OpenWrt.org
|
2006-10-16 00:03:30 +03:00
|
|
|
|
2012-03-20 16:29:50 +02:00
|
|
|
. $IPKG_INSTROOT/lib/functions.sh
|
|
|
|
. $IPKG_INSTROOT/lib/functions/service.sh
|
2006-10-16 00:03:30 +03:00
|
|
|
|
2009-07-26 15:34:09 +03:00
|
|
|
initscript=$1
|
|
|
|
action=${2:-help}
|
|
|
|
shift 2
|
|
|
|
|
2006-10-04 23:05:48 +03:00
|
|
|
start() {
|
|
|
|
return 0
|
|
|
|
}
|
|
|
|
|
|
|
|
stop() {
|
|
|
|
return 0
|
|
|
|
}
|
|
|
|
|
|
|
|
reload() {
|
|
|
|
return 1
|
|
|
|
}
|
|
|
|
|
|
|
|
restart() {
|
2006-12-20 07:26:39 +02:00
|
|
|
trap '' TERM
|
2008-01-25 12:59:40 +02:00
|
|
|
stop "$@"
|
|
|
|
start "$@"
|
2006-10-04 23:05:48 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
boot() {
|
2008-01-25 12:59:40 +02:00
|
|
|
start "$@"
|
2006-10-04 23:05:48 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
shutdown() {
|
2010-12-13 10:01:21 +02:00
|
|
|
stop
|
2006-10-04 23:05:48 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
disable() {
|
2006-10-16 00:03:30 +03:00
|
|
|
name="$(basename "${initscript}")"
|
2006-10-16 00:22:51 +03:00
|
|
|
rm -f "$IPKG_INSTROOT"/etc/rc.d/S??$name
|
2007-05-10 13:38:53 +03:00
|
|
|
rm -f "$IPKG_INSTROOT"/etc/rc.d/K??$name
|
2006-10-04 23:05:48 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
enable() {
|
2006-10-16 00:03:30 +03:00
|
|
|
name="$(basename "${initscript}")"
|
2006-10-04 23:05:48 +03:00
|
|
|
disable
|
2011-07-27 12:02:10 +03:00
|
|
|
[ -n "$START" -o -n "$STOP" ] || {
|
|
|
|
echo "/etc/init.d/$name does not have a START or STOP value"
|
|
|
|
return 1
|
|
|
|
}
|
2008-09-23 15:35:34 +03: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 23:05:48 +03:00
|
|
|
}
|
|
|
|
|
2006-12-08 19:56:05 +02:00
|
|
|
enabled() {
|
|
|
|
name="$(basename "${initscript}")"
|
|
|
|
[ -x "$IPKG_INSTROOT/etc/rc.d/S${START}${name##S[0-9][0-9]}" ]
|
|
|
|
}
|
|
|
|
|
2006-10-04 23:05:48 +03:00
|
|
|
depends() {
|
|
|
|
return 0
|
|
|
|
}
|
|
|
|
|
|
|
|
help() {
|
|
|
|
cat <<EOF
|
2006-10-04 23:09:14 +03:00
|
|
|
Syntax: $initscript [command]
|
2006-10-04 23:05:48 +03: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-16 00:03:30 +03:00
|
|
|
enable Enable service autostart
|
|
|
|
disable Disable service autostart
|
2006-10-04 23:05:48 +03:00
|
|
|
$EXTRA_HELP
|
|
|
|
EOF
|
|
|
|
}
|
|
|
|
|
2012-12-22 20:56:09 +02:00
|
|
|
# for procd
|
|
|
|
start_service() {
|
|
|
|
return 0
|
|
|
|
}
|
|
|
|
|
|
|
|
stop_service() {
|
|
|
|
return 0
|
|
|
|
}
|
|
|
|
|
2012-06-13 20:10:41 +03:00
|
|
|
${INIT_TRACE:+set -x}
|
|
|
|
|
2006-10-04 23:05:48 +03:00
|
|
|
. "$initscript"
|
|
|
|
|
2012-12-22 20:56:09 +02:00
|
|
|
[ -n "$USE_PROCD" ] && {
|
|
|
|
. $IPKG_INSTROOT/lib/functions/procd.sh
|
|
|
|
|
|
|
|
rc_procd() {
|
|
|
|
procd_open_service "$(basename "$initscript")" "$initscript"
|
|
|
|
"$@"
|
|
|
|
procd_close_service
|
|
|
|
}
|
|
|
|
|
|
|
|
start() {
|
|
|
|
rc_procd start_service "$@"
|
|
|
|
}
|
|
|
|
|
|
|
|
stop() {
|
|
|
|
procd_kill "$(basename "$initscript")" "$1"
|
|
|
|
}
|
|
|
|
|
|
|
|
reload() {
|
|
|
|
start
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-07-26 15:34:09 +03: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 06:58:17 +03:00
|
|
|
[ "$action" = "reload" ] && action='eval reload "$@" || restart "$@" && :'
|
2009-07-26 15:34:09 +03:00
|
|
|
$action "$@"
|