init script cleanup, use /etc/rc.d/ for enabled scripts, /etc/init.d/<pkgname> (enabl...
authorFelix Fietkau <nbd@openwrt.org>
Sun, 15 Oct 2006 21:03:30 +0000 (21:03 +0000)
committerFelix Fietkau <nbd@openwrt.org>
Sun, 15 Oct 2006 21:03:30 +0000 (21:03 +0000)
SVN-Revision: 5128

29 files changed:
package/Makefile
package/base-files/ar7-2.4/etc/init.d/S00adam2 [deleted file]
package/base-files/ar7-2.4/etc/init.d/adam2 [new file with mode: 0755]
package/base-files/brcm-2.4/etc/init.d/S05netconfig [deleted file]
package/base-files/brcm-2.4/etc/init.d/netconfig [new file with mode: 0755]
package/base-files/brcm-2.6/etc/init.d/S05netconfig [deleted file]
package/base-files/brcm-2.6/etc/init.d/netconfig [new file with mode: 0755]
package/base-files/default/etc/init.d/S10boot [deleted file]
package/base-files/default/etc/init.d/S40network [deleted file]
package/base-files/default/etc/init.d/S50httpd [deleted file]
package/base-files/default/etc/init.d/S50telnet [deleted file]
package/base-files/default/etc/init.d/S60cron [deleted file]
package/base-files/default/etc/init.d/boot [new file with mode: 0755]
package/base-files/default/etc/init.d/cron [new file with mode: 0755]
package/base-files/default/etc/init.d/httpd [new file with mode: 0755]
package/base-files/default/etc/init.d/network [new file with mode: 0755]
package/base-files/default/etc/init.d/rcS
package/base-files/default/etc/init.d/telnet [new file with mode: 0755]
package/base-files/default/etc/rc.common
package/dnsmasq/Makefile
package/dropbear/Makefile
package/iptables/Makefile
package/iptables/files/firewall.init
package/madwifi/Makefile
package/madwifi/files/madwifi.init
package/openswan/Makefile
package/openswan/files/ipsec.init [new file with mode: 0755]
package/qos-scripts/files/etc/init.d/S50qos [deleted file]
package/qos-scripts/files/etc/init.d/qos [new file with mode: 0755]

index 304343a2aa9d3f795c021332a0b7de5fa3a2f389..d1605afe9f9fd1d23c0eaf3f77bb503ec1f836d0 100644 (file)
@@ -55,6 +55,13 @@ install-targets: base-files-install $(INSTALL_PACKAGES)
 install:
        rm -rf $(BUILD_DIR)/root
        $(MAKE) install-targets
 install:
        rm -rf $(BUILD_DIR)/root
        $(MAKE) install-targets
+       @( \
+               cd $(BUILD_DIR)/root; \
+               for script in ./etc/init.d/*; do \
+                       grep '#!/bin/sh /etc/rc.common' $$script >/dev/null || continue; \
+                       IPKG_INSTROOT=$(BUILD_DIR)/root $(which bash) ./etc/rc.common $$script enable; \
+               done; \
+       )
 
 index: $(PACKAGE_DIR)/Packages
 
 
 index: $(PACKAGE_DIR)/Packages
 
diff --git a/package/base-files/ar7-2.4/etc/init.d/S00adam2 b/package/base-files/ar7-2.4/etc/init.d/S00adam2
deleted file mode 100755 (executable)
index 5f5b350..0000000
+++ /dev/null
@@ -1,12 +0,0 @@
-#!/bin/sh /etc/rc.common
-# ADAM2 patcher for Netgear DG834 and compatible
-# Copyright (C) 2006 OpenWrt.org
-
-start() {
-       MD5="$(md5sum /dev/mtdblock/0  | awk '{print $1}')"
-       [ "$MD5" = "0530bfdf00ec155f4182afd70da028c1" ] && {
-               mtd unlock adam2
-               /sbin/adam2patcher /dev/mtdblock/0
-       }
-       rm -f /etc/init.d/S00adam2 /sbin/adam2patcher >&- 2>&-
-}
diff --git a/package/base-files/ar7-2.4/etc/init.d/adam2 b/package/base-files/ar7-2.4/etc/init.d/adam2
new file mode 100755 (executable)
index 0000000..425bc15
--- /dev/null
@@ -0,0 +1,13 @@
+#!/bin/sh /etc/rc.common
+# ADAM2 patcher for Netgear DG834 and compatible
+# Copyright (C) 2006 OpenWrt.org
+
+START=00
+start() {
+       MD5="$(md5sum /dev/mtdblock/0  | awk '{print $1}')"
+       [ "$MD5" = "0530bfdf00ec155f4182afd70da028c1" ] && {
+               mtd unlock adam2
+               /sbin/adam2patcher /dev/mtdblock/0
+       }
+       rm -f /etc/init.d/S00adam2 /sbin/adam2patcher >&- 2>&-
+}
diff --git a/package/base-files/brcm-2.4/etc/init.d/S05netconfig b/package/base-files/brcm-2.4/etc/init.d/S05netconfig
deleted file mode 100755 (executable)
index 7c36183..0000000
+++ /dev/null
@@ -1,86 +0,0 @@
-#!/bin/sh /etc/rc.common
-# Copyright (C) 2006 OpenWrt.org
-
-start() {
-       [ -e /etc/config/network ] && exit 0
-
-       mkdir -p /etc/config
-
-       (
-               if grep -E 'mtd0: 000(6|a)0000' /proc/mtd 2>&- >&-; then
-                       # WGT634u
-                       echo boardtype=wgt634u
-               else
-                       strings /dev/mtdblock/3
-               fi
-       ) | awk '
-       function p(cfgname, name) {
-               if (c[name] != "") print "      option " cfgname "      \"" c[name] "\""
-       }
-       
-       BEGIN {
-               FS="="
-               c["lan_ifname"]="eth0.0"
-               c["wan_ifname"]="eth0.1"
-               c["vlan0ports"]="1 2 3 4 5*"
-               c["vlan1ports"]="0 5"
-       }
-       
-       ($1 == "boardnum") || ($1 == "boardtype") || ($1 == "boardflags") {
-               nvram[$1] = $2
-       }
-       
-       END {
-               # v1 hardware
-               if (nvram["boardtype"] == "bcm94710dev") {
-                       # Asus WL-500g
-                       if (nvram["boardnum"] == "asusX") {
-                               c["lan_ifname"]="eth0 eth1" # FIXME
-                               c["wan_ifname"]=""
-                       }
-               }
-               if (nvram["boardtype"] == "wgt634u") {
-                       c["vlan0ports"] = "0 1 2 3 5*"
-                       c["vlan1ports"] = "4 5"
-               }
-               if ((nvram["boardtype"] == "0x0467") || (nvram["boardtype"] == "0x042f")) {
-                       c["vlan0ports"] = "0 1 2 3 5*"
-                       c["vlan1ports"] = "4 5"
-               }
-       
-               # WAP54G
-               if ((nvram["boardnum"] == "2") || \
-                       (nvram["boardnum"] == "1024")) {
-                       c["lan_ifname"]="eth0"
-                       c["wan_ifname"]=""
-               }
-       
-               print "#### VLAN configuration "
-               print "config switch eth0"
-               p("vlan0", "vlan0ports")
-               p("vlan1", "vlan1ports")
-               print ""
-               print ""
-               print "#### Loopback configuration"
-               print "config interface loopback"
-               print " option ifname   \"lo\""
-               print " option proto    static"
-               print " option ipaddr   127.0.0.1"
-               print " option netmask  255.0.0.0"
-               print ""
-               print ""
-               print "#### LAN configuration"
-               print "config interface lan"
-               print " option type     bridge"
-               p("ifname", "lan_ifname")
-               print " option proto    static"
-               print " option ipaddr   192.168.1.1"
-               print " option netmask  255.255.255.0"
-               print ""
-               print ""
-               print "#### WAN configuration"
-               print "config interface wan"
-               p("ifname", "wan_ifname")
-               print " option proto    dhcp"
-       }' > /etc/config/network
-}
diff --git a/package/base-files/brcm-2.4/etc/init.d/netconfig b/package/base-files/brcm-2.4/etc/init.d/netconfig
new file mode 100755 (executable)
index 0000000..ca52ee7
--- /dev/null
@@ -0,0 +1,88 @@
+#!/bin/sh /etc/rc.common
+# Copyright (C) 2006 OpenWrt.org
+
+START=05
+
+start() {
+       [ -e /etc/config/network ] && exit 0
+
+       mkdir -p /etc/config
+
+       (
+               if grep -E 'mtd0: 000(6|a)0000' /proc/mtd 2>&- >&-; then
+                       # WGT634u
+                       echo boardtype=wgt634u
+               else
+                       strings /dev/mtdblock/3
+               fi
+       ) | awk '
+       function p(cfgname, name) {
+               if (c[name] != "") print "      option " cfgname "      \"" c[name] "\""
+       }
+       
+       BEGIN {
+               FS="="
+               c["lan_ifname"]="eth0.0"
+               c["wan_ifname"]="eth0.1"
+               c["vlan0ports"]="1 2 3 4 5*"
+               c["vlan1ports"]="0 5"
+       }
+       
+       ($1 == "boardnum") || ($1 == "boardtype") || ($1 == "boardflags") {
+               nvram[$1] = $2
+       }
+       
+       END {
+               # v1 hardware
+               if (nvram["boardtype"] == "bcm94710dev") {
+                       # Asus WL-500g
+                       if (nvram["boardnum"] == "asusX") {
+                               c["lan_ifname"]="eth0 eth1" # FIXME
+                               c["wan_ifname"]=""
+                       }
+               }
+               if (nvram["boardtype"] == "wgt634u") {
+                       c["vlan0ports"] = "0 1 2 3 5*"
+                       c["vlan1ports"] = "4 5"
+               }
+               if ((nvram["boardtype"] == "0x0467") || (nvram["boardtype"] == "0x042f")) {
+                       c["vlan0ports"] = "0 1 2 3 5*"
+                       c["vlan1ports"] = "4 5"
+               }
+       
+               # WAP54G
+               if ((nvram["boardnum"] == "2") || \
+                       (nvram["boardnum"] == "1024")) {
+                       c["lan_ifname"]="eth0"
+                       c["wan_ifname"]=""
+               }
+       
+               print "#### VLAN configuration "
+               print "config switch eth0"
+               p("vlan0", "vlan0ports")
+               p("vlan1", "vlan1ports")
+               print ""
+               print ""
+               print "#### Loopback configuration"
+               print "config interface loopback"
+               print " option ifname   \"lo\""
+               print " option proto    static"
+               print " option ipaddr   127.0.0.1"
+               print " option netmask  255.0.0.0"
+               print ""
+               print ""
+               print "#### LAN configuration"
+               print "config interface lan"
+               print " option type     bridge"
+               p("ifname", "lan_ifname")
+               print " option proto    static"
+               print " option ipaddr   192.168.1.1"
+               print " option netmask  255.255.255.0"
+               print ""
+               print ""
+               print "#### WAN configuration"
+               print "config interface wan"
+               p("ifname", "wan_ifname")
+               print " option proto    dhcp"
+       }' > /etc/config/network
+}
diff --git a/package/base-files/brcm-2.6/etc/init.d/S05netconfig b/package/base-files/brcm-2.6/etc/init.d/S05netconfig
deleted file mode 100755 (executable)
index 8465626..0000000
+++ /dev/null
@@ -1,86 +0,0 @@
-#!/bin/sh /etc/rc.common
-# Copyright (C) 2006 OpenWrt.org
-
-start() {
-       [ -e /etc/config/network ] && exit 0
-       
-       mkdir -p /etc/config
-       
-       (
-               if grep -E 'mtd0: 000(6|a)0000' /proc/mtd 2>&- >&-; then
-                       # WGT634u
-                       echo boardtype=wgt634u
-               else
-                       strings /dev/mtdblock/3
-               fi
-       ) | awk '
-       function p(cfgname, name) {
-               if (c[name] != "") print "      option " cfgname "      \"" c[name] "\""
-       }
-       
-       BEGIN {
-               FS="="
-               c["lan_ifname"]="eth0.0"
-               c["wan_ifname"]="eth0.1"
-               c["vlan0ports"]="1 2 3 4 5*"
-               c["vlan1ports"]="0 5"
-       }
-       
-       ($1 == "boardnum") || ($1 == "boardtype") || ($1 == "boardflags") {
-               nvram[$1] = $2
-       }
-       
-       END {
-               # v1 hardware
-               if (nvram["boardtype"] == "bcm94710dev") {
-                       # Asus WL-500g
-                       if (nvram["boardnum"] == "asusX") {
-                               c["lan_ifname"]="eth0 eth1" # FIXME
-                               c["wan_ifname"]=""
-                       }
-               }
-               if (nvram["boardtype"] == "wgt634u") {
-                       c["vlan0ports"] = "0 1 2 3 5*"
-                       c["vlan1ports"] = "4 5"
-               }
-               if ((nvram["boardtype"] == "0x0467") || (nvram["boardtype"] == "0x042f")) {
-                       c["vlan0ports"] = "0 1 2 3 5*"
-                       c["vlan1ports"] = "4 5"
-               }
-       
-               # WAP54G
-               if ((nvram["boardnum"] == "2") || \
-                       (nvram["boardnum"] == "1024")) {
-                       c["lan_ifname"]="eth0"
-                       c["wan_ifname"]=""
-               }
-       
-               print "#### VLAN configuration "
-               print "config switch eth0"
-               p("vlan0", "vlan0ports")
-               p("vlan1", "vlan1ports")
-               print ""
-               print ""
-               print "#### Loopback configuration"
-               print "config interface loopback"
-               print " option ifname   \"lo\""
-               print " option proto    static"
-               print " option ipaddr   127.0.0.1"
-               print " option netmask  255.0.0.0"
-               print ""
-               print ""
-               print "#### LAN configuration"
-               print "config interface lan"
-               print " option type     bridge"
-               p("ifname", "lan_ifname")
-               print " option proto    static"
-               print " option ipaddr   192.168.1.1"
-               print " option netmask  255.255.255.0"
-               print ""
-               print ""
-               print "#### WAN configuration"
-               print "config interface wan"
-               p("ifname", "wan_ifname")
-               print " option proto    dhcp"
-       }' > /etc/config/network
-}
diff --git a/package/base-files/brcm-2.6/etc/init.d/netconfig b/package/base-files/brcm-2.6/etc/init.d/netconfig
new file mode 100755 (executable)
index 0000000..7a818dc
--- /dev/null
@@ -0,0 +1,87 @@
+#!/bin/sh /etc/rc.common
+# Copyright (C) 2006 OpenWrt.org
+
+START=05
+start() {
+       [ -e /etc/config/network ] && exit 0
+       
+       mkdir -p /etc/config
+       
+       (
+               if grep -E 'mtd0: 000(6|a)0000' /proc/mtd 2>&- >&-; then
+                       # WGT634u
+                       echo boardtype=wgt634u
+               else
+                       strings /dev/mtdblock/3
+               fi
+       ) | awk '
+       function p(cfgname, name) {
+               if (c[name] != "") print "      option " cfgname "      \"" c[name] "\""
+       }
+       
+       BEGIN {
+               FS="="
+               c["lan_ifname"]="eth0.0"
+               c["wan_ifname"]="eth0.1"
+               c["vlan0ports"]="1 2 3 4 5*"
+               c["vlan1ports"]="0 5"
+       }
+       
+       ($1 == "boardnum") || ($1 == "boardtype") || ($1 == "boardflags") {
+               nvram[$1] = $2
+       }
+       
+       END {
+               # v1 hardware
+               if (nvram["boardtype"] == "bcm94710dev") {
+                       # Asus WL-500g
+                       if (nvram["boardnum"] == "asusX") {
+                               c["lan_ifname"]="eth0 eth1" # FIXME
+                               c["wan_ifname"]=""
+                       }
+               }
+               if (nvram["boardtype"] == "wgt634u") {
+                       c["vlan0ports"] = "0 1 2 3 5*"
+                       c["vlan1ports"] = "4 5"
+               }
+               if ((nvram["boardtype"] == "0x0467") || (nvram["boardtype"] == "0x042f")) {
+                       c["vlan0ports"] = "0 1 2 3 5*"
+                       c["vlan1ports"] = "4 5"
+               }
+       
+               # WAP54G
+               if ((nvram["boardnum"] == "2") || \
+                       (nvram["boardnum"] == "1024")) {
+                       c["lan_ifname"]="eth0"
+                       c["wan_ifname"]=""
+               }
+       
+               print "#### VLAN configuration "
+               print "config switch eth0"
+               p("vlan0", "vlan0ports")
+               p("vlan1", "vlan1ports")
+               print ""
+               print ""
+               print "#### Loopback configuration"
+               print "config interface loopback"
+               print " option ifname   \"lo\""
+               print " option proto    static"
+               print " option ipaddr   127.0.0.1"
+               print " option netmask  255.0.0.0"
+               print ""
+               print ""
+               print "#### LAN configuration"
+               print "config interface lan"
+               print " option type     bridge"
+               p("ifname", "lan_ifname")
+               print " option proto    static"
+               print " option ipaddr   192.168.1.1"
+               print " option netmask  255.255.255.0"
+               print ""
+               print ""
+               print "#### WAN configuration"
+               print "config interface wan"
+               p("ifname", "wan_ifname")
+               print " option proto    dhcp"
+       }' > /etc/config/network
+}
diff --git a/package/base-files/default/etc/init.d/S10boot b/package/base-files/default/etc/init.d/S10boot
deleted file mode 100755 (executable)
index 77b5ca7..0000000
+++ /dev/null
@@ -1,25 +0,0 @@
-#!/bin/sh /etc/rc.common
-# Copyright (C) 2006 OpenWrt.org
-
-start() {
-       [ -f /proc/mounts ] || /sbin/mount_root
-       [ -f /proc/jffs2_bbc ] && echo "S" > /proc/jffs2_bbc
-       vconfig set_name_type DEV_PLUS_VID_NO_PAD
-       
-       HOSTNAME=${wan_hostname%%.*}
-       echo ${HOSTNAME:=OpenWrt}>/proc/sys/kernel/hostname
-       
-       mkdir -p /var/run
-       mkdir -p /var/log
-       mkdir -p /var/lock
-       touch /var/log/wtmp
-       touch /var/log/lastlog
-       [ "$FAILSAFE" = "true" ] && touch /tmp/.failsafe
-       
-       # manually trigger hotplug before loading modules
-       for iface in $(awk -F: '/:/ {print $1}' /proc/net/dev); do
-               /usr/bin/env -i ACTION=add INTERFACE="$iface" /sbin/hotplug net
-       done
-       
-       load_modules /etc/modules /etc/modules.d/*
-}
diff --git a/package/base-files/default/etc/init.d/S40network b/package/base-files/default/etc/init.d/S40network
deleted file mode 100755 (executable)
index c772036..0000000
+++ /dev/null
@@ -1,13 +0,0 @@
-#!/bin/sh /etc/rc.common
-# Copyright (C) 2006 OpenWrt.org
-
-start() {
-       setup_switch() { return 0; }
-
-       include /lib/network
-       setup_switch
-       [ -e /etc/config/wireless ] || \
-               /sbin/wifi detect > /etc/config/wireless
-       /sbin/wifi up
-}
-
diff --git a/package/base-files/default/etc/init.d/S50httpd b/package/base-files/default/etc/init.d/S50httpd
deleted file mode 100755 (executable)
index a05b10c..0000000
+++ /dev/null
@@ -1,10 +0,0 @@
-#!/bin/sh /etc/rc.common
-# Copyright (C) 2006 OpenWrt.org
-
-start() {
-       [ -d /www ] && httpd -p 80 -h /www -r OpenWrt
-}
-
-stop() {
-       killall httpd
-}
diff --git a/package/base-files/default/etc/init.d/S50telnet b/package/base-files/default/etc/init.d/S50telnet
deleted file mode 100755 (executable)
index 228eac2..0000000
+++ /dev/null
@@ -1,10 +0,0 @@
-#!/bin/sh /etc/rc.common
-# Copyright (C) 2006 OpenWrt.org
-
-start() {
-       if awk -F: '/^root:/ && $2 !~ /\!/ {exit 1}' /etc/passwd 2>/dev/null; then telnetd -l /bin/login; fi
-}
-
-stop() {
-       killall telnetd
-}
diff --git a/package/base-files/default/etc/init.d/S60cron b/package/base-files/default/etc/init.d/S60cron
deleted file mode 100755 (executable)
index a450c36..0000000
+++ /dev/null
@@ -1,12 +0,0 @@
-#!/bin/sh /etc/rc.common
-# Copyright (C) 2006 OpenWrt.org
-
-start () {
-       mkdir -p /var/spool/cron
-       ln -s /etc/crontabs /var/spool/cron/crontabs
-       crond -c /etc/crontabs
-}
-
-stop() {
-       killall crond
-}
diff --git a/package/base-files/default/etc/init.d/boot b/package/base-files/default/etc/init.d/boot
new file mode 100755 (executable)
index 0000000..a5c8603
--- /dev/null
@@ -0,0 +1,26 @@
+#!/bin/sh /etc/rc.common
+# Copyright (C) 2006 OpenWrt.org
+
+START=10
+start() {
+       [ -f /proc/mounts ] || /sbin/mount_root
+       [ -f /proc/jffs2_bbc ] && echo "S" > /proc/jffs2_bbc
+       vconfig set_name_type DEV_PLUS_VID_NO_PAD
+       
+       HOSTNAME=${wan_hostname%%.*}
+       echo ${HOSTNAME:=OpenWrt}>/proc/sys/kernel/hostname
+       
+       mkdir -p /var/run
+       mkdir -p /var/log
+       mkdir -p /var/lock
+       touch /var/log/wtmp
+       touch /var/log/lastlog
+       [ "$FAILSAFE" = "true" ] && touch /tmp/.failsafe
+       
+       # manually trigger hotplug before loading modules
+       for iface in $(awk -F: '/:/ {print $1}' /proc/net/dev); do
+               /usr/bin/env -i ACTION=add INTERFACE="$iface" /sbin/hotplug net
+       done
+       
+       load_modules /etc/modules /etc/modules.d/*
+}
diff --git a/package/base-files/default/etc/init.d/cron b/package/base-files/default/etc/init.d/cron
new file mode 100755 (executable)
index 0000000..a450c36
--- /dev/null
@@ -0,0 +1,12 @@
+#!/bin/sh /etc/rc.common
+# Copyright (C) 2006 OpenWrt.org
+
+start () {
+       mkdir -p /var/spool/cron
+       ln -s /etc/crontabs /var/spool/cron/crontabs
+       crond -c /etc/crontabs
+}
+
+stop() {
+       killall crond
+}
diff --git a/package/base-files/default/etc/init.d/httpd b/package/base-files/default/etc/init.d/httpd
new file mode 100755 (executable)
index 0000000..a05b10c
--- /dev/null
@@ -0,0 +1,10 @@
+#!/bin/sh /etc/rc.common
+# Copyright (C) 2006 OpenWrt.org
+
+start() {
+       [ -d /www ] && httpd -p 80 -h /www -r OpenWrt
+}
+
+stop() {
+       killall httpd
+}
diff --git a/package/base-files/default/etc/init.d/network b/package/base-files/default/etc/init.d/network
new file mode 100755 (executable)
index 0000000..45d5311
--- /dev/null
@@ -0,0 +1,14 @@
+#!/bin/sh /etc/rc.common
+# Copyright (C) 2006 OpenWrt.org
+
+START=40
+start() {
+       setup_switch() { return 0; }
+
+       include /lib/network
+       setup_switch
+       [ -e /etc/config/wireless ] || \
+               /sbin/wifi detect > /etc/config/wireless
+       /sbin/wifi up
+}
+
index 7fae7f5b0563ac5411e39c5450ed8683edca8d60..27bc34b22005fe2afd505f5acf04c161c57a658d 100755 (executable)
@@ -11,8 +11,8 @@ syslogd -C 16 #${log_ipaddr:+-L -R $log_ipaddr}
 klogd
 
 (
 klogd
 
 (
-       for i in /etc/init.d/S*; do
-               $i start 2>&1
+       for i in /etc/rc.d/S*; do
+               $i boot 2>&1
        done 
        
        sysctl -p >&-
        done 
        
        sysctl -p >&-
diff --git a/package/base-files/default/etc/init.d/telnet b/package/base-files/default/etc/init.d/telnet
new file mode 100755 (executable)
index 0000000..228eac2
--- /dev/null
@@ -0,0 +1,10 @@
+#!/bin/sh /etc/rc.common
+# Copyright (C) 2006 OpenWrt.org
+
+start() {
+       if awk -F: '/^root:/ && $2 !~ /\!/ {exit 1}' /etc/passwd 2>/dev/null; then telnetd -l /bin/login; fi
+}
+
+stop() {
+       killall telnetd
+}
index 20d1efa402bcd382c6a72b0b9608cf474a94f942..a08f5e523c622f4373763a3173cf88d1be36f1b0 100755 (executable)
@@ -1,5 +1,9 @@
 #!/bin/sh
 #!/bin/sh
-. /etc/functions.sh
+# Copyright (C) 2006 OpenWrt.org
+
+. $IPKG_INSTROOT/etc/functions.sh
+
+START=50
 
 start() {
        return 0
 
 start() {
        return 0
@@ -27,12 +31,14 @@ shutdown() {
 }
 
 disable() {
 }
 
 disable() {
-       rm -f /etc/rc.d/${initscript##*/}
+       name="$(basename "${initscript}")"
+       rm -f "$IPKG_INSTROOT/etc/rc.d/S??$name"
 }
 
 enable() {
 }
 
 enable() {
+       name="$(basename "${initscript}")"
        disable
        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() {
 }
 
 depends() {
@@ -48,6 +54,8 @@ Available commands:
        stop    Stop the service
        restart Restart the service
        reload  Reload configuration files (or restart if that fails)
        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
 }
 $EXTRA_HELP
 EOF
 }
@@ -68,6 +76,8 @@ eval "case \"\$action\" in
        restart) restart;;
        boot) boot;;
        shutdown) shutdown;;
        restart) restart;;
        boot) boot;;
        shutdown) shutdown;;
+       enable) enable;;
+       disable) disable;;
        $cmds
        *) help;;
 esac"
        $cmds
        *) help;;
 esac"
index 6283fdc898c6b63d4bbc6bdf474b0d63fd7d74a0..d7e5f18b610c69a184859971987cf1caed80ca85 100644 (file)
@@ -49,7 +49,7 @@ define Package/dnsmasq/install
        install -m0755 -d $(1)/etc
        install -m0644 ./files/dnsmasq.conf $(1)/etc/dnsmasq.conf
        install -m0755 -d $(1)/etc/init.d
        install -m0755 -d $(1)/etc
        install -m0644 ./files/dnsmasq.conf $(1)/etc/dnsmasq.conf
        install -m0755 -d $(1)/etc/init.d
-       install -m0755 ./files/dnsmasq.init $(1)/etc/init.d/S50dnsmasq
+       install -m0755 ./files/dnsmasq.init $(1)/etc/init.d/dnsmasq
 endef
 
 $(eval $(call BuildPackage,dnsmasq))
 endef
 
 $(eval $(call BuildPackage,dnsmasq))
index b28b44ef9e6ee2306799985b29408ab92efbb18c..18e4a45708541c02d513409f89d978b9cb76a2b6 100644 (file)
@@ -107,7 +107,7 @@ define Package/dropbear/install
        ln -sf ../sbin/dropbear $(1)/usr/bin/dbclient
        ln -sf ../sbin/dropbear $(1)/usr/bin/dropbearkey
        install -d -m0755 $(1)/etc/init.d
        ln -sf ../sbin/dropbear $(1)/usr/bin/dbclient
        ln -sf ../sbin/dropbear $(1)/usr/bin/dropbearkey
        install -d -m0755 $(1)/etc/init.d
-       install -m0755 ./files/dropbear.init $(1)/etc/init.d/S50dropbear
+       install -m0755 ./files/dropbear.init $(1)/etc/init.d/dropbear
 endef
 
 define Package/dropbearconvert/install
 endef
 
 define Package/dropbearconvert/install
index d198a9271ad2db81314fca4bad21f7c87088d46b..ee0c0941b17ea3dea9e370659ab426eb37ff5be2 100644 (file)
@@ -195,7 +195,7 @@ define Package/iptables/install
        install -d -m0755 $(1)/etc/config
        install -m0644 ./files/firewall.config $(1)/etc/config/firewall
        install -d -m0755 $(1)/etc/init.d
        install -d -m0755 $(1)/etc/config
        install -m0644 ./files/firewall.config $(1)/etc/config/firewall
        install -d -m0755 $(1)/etc/init.d
-       install -m0755 ./files/firewall.init $(1)/etc/init.d/S45firewall
+       install -m0755 ./files/firewall.init $(1)/etc/init.d/firewall
        install -m0755 ./files/firewall.user $(1)/etc/
        install -d -m0755 $(1)/usr/lib
        install -m0644 ./files/firewall.awk $(1)/usr/lib
        install -m0755 ./files/firewall.user $(1)/etc/
        install -d -m0755 $(1)/usr/lib
        install -m0644 ./files/firewall.awk $(1)/usr/lib
index 731485bcdd74a17dd4099f1705c408079c088af5..1e39d05fd93d841a6f4c9b1012ec9cb433b28963 100755 (executable)
@@ -2,7 +2,7 @@
 # Copyright (C) 2006 OpenWrt.org
 
 ## Please make changes in /etc/firewall.user
 # Copyright (C) 2006 OpenWrt.org
 
 ## Please make changes in /etc/firewall.user
-
+START=45
 start() {
        include /lib/network
        scan_interfaces
 start() {
        include /lib/network
        scan_interfaces
index a4180063f4e341dd3bd50988c19e67d33cd12ece..7d06fe18975c4c50f58fdf63af5db246036fd455 100644 (file)
@@ -120,7 +120,7 @@ endif
 ifeq ($(findstring PCI,$(BUS)),PCI)
        echo ath_pci >> $(1)/etc/modules.d/20-madwifi
 endif
 ifeq ($(findstring PCI,$(BUS)),PCI)
        echo ath_pci >> $(1)/etc/modules.d/20-madwifi
 endif
-       install -m0755 ./files/madwifi.init $(1)/etc/init.d/S20madwifi
+       install -m0755 ./files/madwifi.init $(1)/etc/init.d/madwifi
        $(CP) \
                $(PKG_BUILD_DIR)/ath/ath_hal.$(LINUX_KMOD_SUFFIX) \
                $(BUS_MODULES) \
        $(CP) \
                $(PKG_BUILD_DIR)/ath/ath_hal.$(LINUX_KMOD_SUFFIX) \
                $(BUS_MODULES) \
index 73eb11017e6191b40cd536f931ee24b249f8ef5a..0c3ad3c3c170d4c2e7e16735db27cae046785bdd 100644 (file)
@@ -1,4 +1,5 @@
 #!/bin/sh /etc/rc.common
 #!/bin/sh /etc/rc.common
-start() {
+START=20
+boot() {
        iwpriv ath0 mode 3
 }
        iwpriv ath0 mode 3
 }
index 54b565efdd6fdbdc2d6759e91b9249a08f172758..b5adc542576f72c0bf3cfc30ad1c149409a405d2 100644 (file)
@@ -21,8 +21,6 @@ PKG_CAT:=zcat
 PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)-$(PKG_VERSION)
 PKG_INSTALL_DIR:=$(PKG_BUILD_DIR)/ipkg-install
 
 PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)-$(PKG_VERSION)
 PKG_INSTALL_DIR:=$(PKG_BUILD_DIR)/ipkg-install
 
-PKG_INIT_PRIO:=60
-
 include $(INCLUDE_DIR)/package.mk
 
 define Package/openswan/Default
 include $(INCLUDE_DIR)/package.mk
 
 define Package/openswan/Default
@@ -76,7 +74,7 @@ endef
 define Package/openswan/install
        $(CP) $(PKG_INSTALL_DIR)/* $(1)
        install -d -m0755 $(1)/etc/init.d
 define Package/openswan/install
        $(CP) $(PKG_INSTALL_DIR)/* $(1)
        install -d -m0755 $(1)/etc/init.d
-       $(CP) $(1)/etc/rc.d/init.d/ipsec $(1)/etc/init.d/S$(PKG_INIT_PRIO)ipsec
+       $(CP) ./files/ipsec.init $(1)/etc/init.d/ipsec
        rm -rf $(1)/usr/share
        rm -rf $(1)/usr/man
        rm -rf $(1)/var
        rm -rf $(1)/usr/share
        rm -rf $(1)/usr/man
        rm -rf $(1)/var
diff --git a/package/openswan/files/ipsec.init b/package/openswan/files/ipsec.init
new file mode 100755 (executable)
index 0000000..33c4163
--- /dev/null
@@ -0,0 +1,158 @@
+#!/bin/sh /etc/rc.common
+# IPsec startup and shutdown script
+# Copyright (C) 1998, 1999, 2001  Henry Spencer.
+# Copyright (C) 2002              Michael Richardson <mcr@freeswan.org>
+# Copyright (C) 2006              OpenWrt.org
+# 
+# This program is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License as published by the
+# Free Software Foundation; either version 2 of the License, or (at your
+# option) any later version.  See <http://www.fsf.org/copyleft/gpl.txt>.
+# 
+# This program is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+# or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+# for more details.
+#
+# RCSID $Id: setup.in,v 1.122.6.1 2005/07/25 19:17:03 ken Exp $
+#
+# ipsec         init.d script for starting and stopping
+#               the IPsec security subsystem (KLIPS and Pluto).
+#
+# This script becomes /etc/rc.d/init.d/ipsec (or possibly /etc/init.d/ipsec)
+# and is also accessible as "ipsec setup" (the preferred route for human
+# invocation).
+#
+# The startup and shutdown times are a difficult compromise (in particular,
+# it is almost impossible to reconcile them with the insanely early/late
+# times of NFS filesystem startup/shutdown).  Startup is after startup of
+# syslog and pcmcia support; shutdown is just before shutdown of syslog.
+#
+# chkconfig: 2345 47 76
+# description: IPsec provides encrypted and authenticated communications; \
+# KLIPS is the kernel half of it, Pluto is the user-level management daemon.
+
+START=60
+script_init() {
+       me='ipsec setup'                # for messages
+
+       # where the private directory and the config files are
+       IPSEC_EXECDIR="${IPSEC_EXECDIR-/usr/libexec/ipsec}"
+       IPSEC_LIBDIR="${IPSEC_LIBDIR-/usr/lib/ipsec}"
+       IPSEC_SBINDIR="${IPSEC_SBINDIR-/usr/sbin}"
+       IPSEC_CONFS="${IPSEC_CONFS-/etc}"
+
+       if test " $IPSEC_DIR" = " "     # if we were not called by the ipsec command
+       then
+           # we must establish a suitable PATH ourselves
+           PATH="${IPSEC_SBINDIR}":/sbin:/usr/sbin:/usr/local/bin:/bin:/usr/bin
+           export PATH
+
+           IPSEC_DIR="$IPSEC_LIBDIR"
+           export IPSEC_DIR IPSEC_CONFS IPSEC_LIBDIR IPSEC_EXECDIR
+       fi
+
+       # Check that the ipsec command is available.
+       found=
+       for dir in `echo $PATH | tr ':' ' '`
+       do
+               if test -f $dir/ipsec -a -x $dir/ipsec
+               then
+                       found=yes
+                       break                   # NOTE BREAK OUT
+               fi
+       done
+       if ! test "$found"
+       then
+               echo "cannot find ipsec command -- \`$1' aborted" |
+                       logger -s -p daemon.error -t ipsec_setup
+               exit 1
+       fi
+
+       # Pick up IPsec configuration (until we have done this, successfully, we
+       # do not know where errors should go, hence the explicit "daemon.error"s.)
+       # Note the "--export", which exports the variables created.
+       eval `ipsec _confread $config --optional --varprefix IPSEC --export --type config setup`
+
+       if test " $IPSEC_confreadstatus" != " "
+       then
+           case $1 in 
+           stop|--stop|_autostop) 
+               echo "$IPSEC_confreadstatus -- \`$1' may not work" |
+                       logger -s -p daemon.error -t ipsec_setup;;
+
+           *) echo "$IPSEC_confreadstatus -- \`$1' aborted" |
+                   logger -s -p daemon.error -t ipsec_setup;
+               exit 1;;
+           esac
+       fi
+
+       IPSEC_confreadsection=${IPSEC_confreadsection:-setup}
+       export IPSEC_confreadsection
+
+       IPSECsyslog=${IPSECsyslog-daemon.error}
+       export IPSECsyslog
+
+       # misc setup
+       umask 022
+
+       mkdir -p /var/run/pluto
+}
+
+script_command() {
+       if [ "${USER}" != "root" ]
+       then
+               echo "permission denied (must be superuser)" |
+                       logger -s -p $IPSECsyslog -t ipsec_setup 2>&1
+               exit 1
+       fi
+       # make sure all required directories exist
+       if [ ! -d /var/run/pluto ]
+       then
+               mkdir -p /var/run/pluto
+       fi
+       if [ ! -d /var/lock/subsys ]
+       then
+               mkdir -p /var/lock/subsys
+       fi
+       tmp=/var/run/pluto/ipsec_setup.st
+       outtmp=/var/run/pluto/ipsec_setup.out
+       (
+               ipsec _realsetup $1
+               echo "$?" >$tmp
+       ) > ${outtmp} 2>&1
+       st=$?
+       if test -f $tmp
+       then
+               st=`cat $tmp`
+               rm -f $tmp
+       fi
+       if [ -f ${outtmp} ]; then
+               cat ${outtmp} | logger -s -p $IPSECsyslog -t ipsec_setup 2>&1
+               rm -f ${outtmp}
+       fi
+}
+
+
+start() {
+       script_init start "$@"
+       script_command start "$@"
+}
+
+stop() {
+       script_init stop "$@"
+       script_command stop "$@"
+}
+
+restart() {
+       script_init stop "$@"
+       script_command stop "$@"
+       script_command start "$@"
+}
+
+status() {
+       script_init status "$@"
+       ipsec _realsetup status
+}
+EXTRA_COMMANDS=status
+EXTRA_HELP="   status  Show the status of the service"
diff --git a/package/qos-scripts/files/etc/init.d/S50qos b/package/qos-scripts/files/etc/init.d/S50qos
deleted file mode 100755 (executable)
index 87e18fb..0000000
+++ /dev/null
@@ -1,18 +0,0 @@
-#!/bin/sh /etc/rc.common
-# Copyright (C) 2006 OpenWrt.org
-
-boot() {
-       /usr/lib/qos.sh firewall | sh
-}
-
-start() {
-#      FIXME: after init script migration
-#      qos-start
-#
-
-       boot
-}
-
-stop() {
-       qos-stop
-}
diff --git a/package/qos-scripts/files/etc/init.d/qos b/package/qos-scripts/files/etc/init.d/qos
new file mode 100755 (executable)
index 0000000..4fa42d4
--- /dev/null
@@ -0,0 +1,16 @@
+#!/bin/sh /etc/rc.common
+# Copyright (C) 2006 OpenWrt.org
+
+START=50
+
+boot() {
+       /usr/lib/qos.sh firewall | sh
+}
+
+start() {
+       qos-start
+}
+
+stop() {
+       qos-stop
+}