summaryrefslogtreecommitdiff
path: root/package/base-files/default/etc/rc.common
diff options
context:
space:
mode:
authorFelix Fietkau <nbd@openwrt.org>2006-10-15 21:03:30 +0000
committerFelix Fietkau <nbd@openwrt.org>2006-10-15 21:03:30 +0000
commit8612d336918b408fd3abd844ccb8189f0d64acc5 (patch)
treedd043a8580746d6ee54912206a873228401c12f7 /package/base-files/default/etc/rc.common
parent6f8a93af7ef4eafdd3d6f678398e6f5df2a5560d (diff)
downloadmtk-20170518-8612d336918b408fd3abd844ccb8189f0d64acc5.zip
mtk-20170518-8612d336918b408fd3abd844ccb8189f0d64acc5.tar.gz
mtk-20170518-8612d336918b408fd3abd844ccb8189f0d64acc5.tar.bz2
init script cleanup, use /etc/rc.d/ for enabled scripts, /etc/init.d/<pkgname> (enable|disable) manages symlinks
SVN-Revision: 5128
Diffstat (limited to 'package/base-files/default/etc/rc.common')
-rwxr-xr-xpackage/base-files/default/etc/rc.common16
1 files changed, 13 insertions, 3 deletions
diff --git a/package/base-files/default/etc/rc.common b/package/base-files/default/etc/rc.common
index 20d1efa..a08f5e5 100755
--- a/package/base-files/default/etc/rc.common
+++ b/package/base-files/default/etc/rc.common
@@ -1,5 +1,9 @@
#!/bin/sh
-. /etc/functions.sh
+# Copyright (C) 2006 OpenWrt.org
+
+. $IPKG_INSTROOT/etc/functions.sh
+
+START=50
start() {
return 0
@@ -27,12 +31,14 @@ shutdown() {
}
disable() {
- rm -f /etc/rc.d/${initscript##*/}
+ name="$(basename "${initscript}")"
+ rm -f "$IPKG_INSTROOT/etc/rc.d/S??$name"
}
enable() {
+ name="$(basename "${initscript}")"
disable
- ln -s /etc/init.d/${initscript##*/} /etc/rc.d/${initscript##*/}
+ ln -s "/etc/init.d/$name" "$IPKG_INSTROOT/etc/rc.d/S${START}${name##S[0-9][0-9]}"
}
depends() {
@@ -48,6 +54,8 @@ Available commands:
stop Stop the service
restart Restart the service
reload Reload configuration files (or restart if that fails)
+ enable Enable service autostart
+ disable Disable service autostart
$EXTRA_HELP
EOF
}
@@ -68,6 +76,8 @@ eval "case \"\$action\" in
restart) restart;;
boot) boot;;
shutdown) shutdown;;
+ enable) enable;;
+ disable) disable;;
$cmds
*) help;;
esac"