aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNicolas Thill <nico@openwrt.org>2011-11-08 22:47:41 +0000
committerNicolas Thill <nico@openwrt.org>2011-11-08 22:47:41 +0000
commitb86726c28374f37dc21894be17de734dd9f4c026 (patch)
tree3630d9ac32e7e0357d830ae7bfb25027fbc95820
parent9b971f64869c67736f2d1522605d5e1f3c6311db (diff)
downloadupstream-b86726c28374f37dc21894be17de734dd9f4c026.tar.gz
upstream-b86726c28374f37dc21894be17de734dd9f4c026.tar.bz2
upstream-b86726c28374f37dc21894be17de734dd9f4c026.zip
package/base-files: move service* functions from /etc/rc.common to /lib/functions.sh
git-svn-id: svn://svn.openwrt.org/openwrt/trunk@28864 3c298f89-4303-0410-b956-a3cf2f4a3e73
-rwxr-xr-xpackage/base-files/files/etc/rc.common82
-rwxr-xr-xpackage/base-files/files/lib/functions.sh82
2 files changed, 82 insertions, 82 deletions
diff --git a/package/base-files/files/etc/rc.common b/package/base-files/files/etc/rc.common
index ec1bb16f44..79424a637d 100755
--- a/package/base-files/files/etc/rc.common
+++ b/package/base-files/files/etc/rc.common
@@ -7,88 +7,6 @@ initscript=$1
action=${2:-help}
shift 2
-#
-# service: simple wrapper around start-stop-daemon
-#
-# Usage: service ACTION EXEC ARGS...
-#
-# Action:
-# -S,--start start EXEC, passing it ARGS as its arguments
-# -K,--stop stop EXEC (send it a $SERVICE_SIG_STOP signal)
-# -R,--reload reload EXEC (send it a $SERVICE_SIG_RELOAD signal)
-#
-# Environment variables used:
-# SERVICE_DAEMONIZE run EXEC in background
-# SERVICE_WRITE_PID create a pid file and use it
-# SERVICE_USE_PID assume EXEC creates its own pid file and use it
-# SERVICE_PID_FILE pid file to use (default to /var/run/EXEC.pid)
-# SERVICE_SIG_RELOAD signal used for reloading
-# SERVICE_SIG_STOP signal used for stopping
-# SERVICE_UID user EXEC should be run as
-# SERVICE_GID group EXEC should be run as
-#
-# SERVICE_DEBUG don't do anything, but show what would be done
-# SERVICE_QUIET don't print anything
-#
-
-SERVICE_QUIET=1
-SERVICE_SIG_RELOAD="HUP"
-SERVICE_SIG_STOP="TERM"
-
-service() {
- local ssd
- local ssd_pid_file
- local ssd_sig
- local ssd_start
- ssd="${SERVICE_DEBUG:+echo }start-stop-daemon${SERVICE_QUIET:+ -q}"
- case "$1" in
- -S|--start|start)
- ssd="$ssd -S"
- ssd_start=1
- ;;
- -K|--stop|stop)
- ssd="$ssd -K"
- ssd_sig="$SERVICE_SIG_STOP"
- ;;
- -R|--reload|reload)
- ssd="$ssd -K"
- ssd_sig="$SERVICE_SIG_RELOAD"
- ;;
- *)
- echo "ssd: unknow action '$1'" 1>&2
- return 1
- esac
- shift
- if [ -z "$1" ]; then
- echo "ssd: missing arguments" 1>&2
- return 1
- fi
- ssd="$ssd -x $1"
- if [ -n "$SERVICE_PID_FILE$SERVICE_USE_PID$SERVICE_WRITE_PID" ]; then
- ssd="$ssd -p ${SERVICE_PID_FILE:-/var/run/${1##*/}.pid}"
- fi
- ssd="$ssd${SERVICE_UID:+ -c $SERVICE_UID${SERVICE_GID:+:$SERVICE_GID}}"
- if [ -n "$ssd_start" ]; then
- ssd="$ssd${SERVICE_DAEMONIZE:+ -b}${SERVICE_WRITE_PID:+ -m}"
- else
- ssd="$ssd${ssd_sig:+ -s $ssd_sig}"
- fi
- shift
- $ssd${1:+ -- "$@"}
-}
-
-service_start() {
- service -S "$@"
-}
-
-service_stop() {
- service -K "$@"
-}
-
-service_reload() {
- service -R "$@"
-}
-
start() {
return 0
}
diff --git a/package/base-files/files/lib/functions.sh b/package/base-files/files/lib/functions.sh
index e4b3badb46..82e8932da1 100755
--- a/package/base-files/files/lib/functions.sh
+++ b/package/base-files/files/lib/functions.sh
@@ -275,6 +275,88 @@ uci_apply_defaults() {
uci commit
}
+#
+# service: simple wrapper around start-stop-daemon
+#
+# Usage: service ACTION EXEC ARGS...
+#
+# Action:
+# -S,--start start EXEC, passing it ARGS as its arguments
+# -K,--stop stop EXEC (send it a $SERVICE_SIG_STOP signal)
+# -R,--reload reload EXEC (send it a $SERVICE_SIG_RELOAD signal)
+#
+# Environment variables used:
+# SERVICE_DAEMONIZE run EXEC in background
+# SERVICE_WRITE_PID create a pid file and use it
+# SERVICE_USE_PID assume EXEC creates its own pid file and use it
+# SERVICE_PID_FILE pid file to use (default to /var/run/EXEC.pid)
+# SERVICE_SIG_RELOAD signal used for reloading
+# SERVICE_SIG_STOP signal used for stopping
+# SERVICE_UID user EXEC should be run as
+# SERVICE_GID group EXEC should be run as
+#
+# SERVICE_DEBUG don't do anything, but show what would be done
+# SERVICE_QUIET don't print anything
+#
+
+SERVICE_QUIET=1
+SERVICE_SIG_RELOAD="HUP"
+SERVICE_SIG_STOP="TERM"
+
+service() {
+ local ssd
+ local ssd_pid_file
+ local ssd_sig
+ local ssd_start
+ ssd="${SERVICE_DEBUG:+echo }start-stop-daemon${SERVICE_QUIET:+ -q}"
+ case "$1" in
+ -S|--start|start)
+ ssd="$ssd -S"
+ ssd_start=1
+ ;;
+ -K|--stop|stop)
+ ssd="$ssd -K"
+ ssd_sig="$SERVICE_SIG_STOP"
+ ;;
+ -R|--reload|reload)
+ ssd="$ssd -K"
+ ssd_sig="$SERVICE_SIG_RELOAD"
+ ;;
+ *)
+ echo "ssd: unknow action '$1'" 1>&2
+ return 1
+ esac
+ shift
+ if [ -z "$1" ]; then
+ echo "ssd: missing arguments" 1>&2
+ return 1
+ fi
+ ssd="$ssd -x $1"
+ if [ -n "$SERVICE_PID_FILE$SERVICE_USE_PID$SERVICE_WRITE_PID" ]; then
+ ssd="$ssd -p ${SERVICE_PID_FILE:-/var/run/${1##*/}.pid}"
+ fi
+ ssd="$ssd${SERVICE_UID:+ -c $SERVICE_UID${SERVICE_GID:+:$SERVICE_GID}}"
+ if [ -n "$ssd_start" ]; then
+ ssd="$ssd${SERVICE_DAEMONIZE:+ -b}${SERVICE_WRITE_PID:+ -m}"
+ else
+ ssd="$ssd${ssd_sig:+ -s $ssd_sig}"
+ fi
+ shift
+ $ssd${1:+ -- "$@"}
+}
+
+service_start() {
+ service -S "$@"
+}
+
+service_stop() {
+ service -K "$@"
+}
+
+service_reload() {
+ service -R "$@"
+}
+
service_kill() {
local name="${1}"
local pid="${2:-$(pidof "$name")}"