add new rc.common for standardized init scripts, convert existing init scripts

SVN-Revision: 4915
This commit is contained in:
Felix Fietkau 2006-10-04 20:05:48 +00:00
parent 1bb321cbec
commit af5f6ac550
16 changed files with 1152 additions and 1024 deletions

View file

@ -1,8 +1,12 @@
#!/bin/sh #!/bin/sh /etc/rc.common
# ADAM2 patcher for Netgear DG834 and compatible # ADAM2 patcher for Netgear DG834 and compatible
# Copyright (C) 2006 OpenWrt.org
start() {
MD5="$(md5sum /dev/mtdblock/0 | awk '{print $1}')" MD5="$(md5sum /dev/mtdblock/0 | awk '{print $1}')"
[ "$MD5" = "0530bfdf00ec155f4182afd70da028c1" ] && { [ "$MD5" = "0530bfdf00ec155f4182afd70da028c1" ] && {
mtd unlock adam2 mtd unlock adam2
/sbin/adam2patcher /dev/mtdblock/0 /sbin/adam2patcher /dev/mtdblock/0
} }
rm -f /etc/init.d/S00adam2 /sbin/adam2patcher >&- 2>&- rm -f /etc/init.d/S00adam2 /sbin/adam2patcher >&- 2>&-
}

View file

@ -1,6 +1,7 @@
#!/bin/sh #!/bin/sh /etc/rc.common
# Copyright (C) 2006 OpenWrt.org # Copyright (C) 2006 OpenWrt.org
start() {
[ -e /etc/config/network ] && exit 0 [ -e /etc/config/network ] && exit 0
mkdir -p /etc/config mkdir -p /etc/config
@ -82,5 +83,5 @@ END {
print "config interface wan" print "config interface wan"
p("ifname", "wan_ifname") p("ifname", "wan_ifname")
print " option proto dhcp" print " option proto dhcp"
}' > /etc/config/network
} }
' > /etc/config/network

View file

@ -1,6 +1,7 @@
#!/bin/sh #!/bin/sh /etc/rc.common
# Copyright (C) 2006 OpenWrt.org # Copyright (C) 2006 OpenWrt.org
start() {
[ -e /etc/config/network ] && exit 0 [ -e /etc/config/network ] && exit 0
mkdir -p /etc/config mkdir -p /etc/config
@ -82,5 +83,5 @@ END {
print "config interface wan" print "config interface wan"
p("ifname", "wan_ifname") p("ifname", "wan_ifname")
print " option proto dhcp" print " option proto dhcp"
}' > /etc/config/network
} }
' > /etc/config/network

View file

@ -1,8 +1,7 @@
#!/bin/sh #!/bin/sh /etc/rc.common
# Copyright (C) 2006 OpenWrt.org # Copyright (C) 2006 OpenWrt.org
. /etc/functions.sh start() {
[ -f /proc/mounts ] || /sbin/mount_root [ -f /proc/mounts ] || /sbin/mount_root
[ -f /proc/jffs2_bbc ] && echo "S" > /proc/jffs2_bbc [ -f /proc/jffs2_bbc ] && echo "S" > /proc/jffs2_bbc
vconfig set_name_type DEV_PLUS_VID_NO_PAD vconfig set_name_type DEV_PLUS_VID_NO_PAD
@ -23,3 +22,4 @@ for iface in $(awk -F: '/:/ {print $1}' /proc/net/dev); do
done done
load_modules /etc/modules /etc/modules.d/* load_modules /etc/modules /etc/modules.d/*
}

View file

@ -1,9 +1,11 @@
#!/bin/sh #!/bin/sh /etc/rc.common
# Copyright (C) 2006 OpenWrt.org # Copyright (C) 2006 OpenWrt.org
start() {
setup_switch() { return 0; } setup_switch() { return 0; }
. /etc/functions.sh
include /lib/network include /lib/network
setup_switch setup_switch
/sbin/wifi /sbin/wifi
}

View file

@ -1,4 +1,10 @@
#!/bin/sh #!/bin/sh /etc/rc.common
# Copyright (C) 2006 OpenWrt.org # Copyright (C) 2006 OpenWrt.org
start() {
[ -d /www ] && httpd -p 80 -h /www -r OpenWrt [ -d /www ] && httpd -p 80 -h /www -r OpenWrt
}
stop() {
killall httpd
}

View file

@ -1,4 +1,10 @@
#!/bin/sh #!/bin/sh /etc/rc.common
# Copyright (C) 2006 OpenWrt.org # Copyright (C) 2006 OpenWrt.org
start() {
if awk -F: '/^root:/ && $2 !~ /\!/ {exit 1}' /etc/passwd 2>/dev/null; then telnetd -l /bin/login; fi if awk -F: '/^root:/ && $2 !~ /\!/ {exit 1}' /etc/passwd 2>/dev/null; then telnetd -l /bin/login; fi
}
stop() {
killall telnetd
}

View file

@ -1,6 +1,12 @@
#!/bin/sh #!/bin/sh /etc/rc.common
# Copyright (C) 2006 OpenWrt.org # Copyright (C) 2006 OpenWrt.org
start () {
mkdir -p /var/spool/cron mkdir -p /var/spool/cron
ln -s /etc/crontabs /var/spool/cron/crontabs ln -s /etc/crontabs /var/spool/cron/crontabs
crond -c /etc/crontabs crond -c /etc/crontabs
}
stop() {
killall crond
}

View file

@ -1,11 +0,0 @@
#!/bin/sh
# Copyright (C) 2006 OpenWrt.org
sysctl -p >&-
# automagically run firstboot
{ mount|grep "on / type tmpfs" 1>&-; } && {
lock /tmp/.switch2jffs
firstboot switch2jffs
lock -u /tmp/.switch2jffs
}

View file

@ -10,6 +10,17 @@ ${FAILSAFE:+exit}
syslogd -C 16 #${log_ipaddr:+-L -R $log_ipaddr} syslogd -C 16 #${log_ipaddr:+-L -R $log_ipaddr}
klogd klogd
(
for i in /etc/init.d/S*; do for i in /etc/init.d/S*; do
$i start 2>&1 $i start 2>&1
done | logger -s -p 6 -t '' & done
sysctl -p >&-
# automagically run firstboot
{ mount|grep "on / type tmpfs" 1>&-; } && {
lock /tmp/.switch2jffs
firstboot switch2jffs
lock -u /tmp/.switch2jffs
}
) | logger -s -p 6 -t '' &

View file

@ -0,0 +1,77 @@
#!/bin/sh
. /etc/functions.sh
start() {
return 0
}
stop() {
return 0
}
reload() {
return 1
}
restart() {
stop
start
}
boot() {
start
}
shutdown() {
return 0
}
disable() {
rm -f /etc/rc.d/${initscript##*/}
}
enable() {
disable
ln -s /etc/init.d/${initscript##*/} /etc/rc.d/${initscript##*/}
}
depends() {
return 0
}
help() {
cat <<EOF
Syntax: $0 [command]
Available commands:
start Start the service
stop Stop the service
restart Restart the service
reload Reload configuration files (or restart if that fails)
enable Enable the service (load at boot time)
disable Disable the service
$EXTRA_HELP
EOF
}
initscript="$1"
action="$2"
. "$initscript"
cmds=
for cmd in $EXTRA_COMMANDS; do
cmds="$cmd) $cmd;;"
done
eval "case \"\$action\" in
start) start;;
stop) stop;;
reload) reload || restart;;
restart) restart;;
enable) enable;;
disable) disable;;
boot) boot;;
shutdown) shutdown;;
$cmds
*) help;;
esac"

View file

@ -1,5 +1,7 @@
#!/bin/sh #!/bin/sh /etc/rc.common
. /etc/functions.sh # Copyright (C) 2006 OpenWrt.org
start() {
include /lib/network include /lib/network
scan_interfaces scan_interfaces
@ -48,3 +50,8 @@ dhcp_lease="${dhcp_lease:-12h}"
cat /etc/dnsmasq.conf cat /etc/dnsmasq.conf
) | awk -f /usr/lib/parse-config.awk | dnsmasq -C /proc/self/fd/0 ) | awk -f /usr/lib/parse-config.awk | dnsmasq -C /proc/self/fd/0
}
stop() {
killall dnsmasq
}

View file

@ -1,5 +1,7 @@
#!/bin/sh #!/bin/sh /etc/rc.common
# Copyright (C) 2006 OpenWrt.org
start() {
for type in rsa dss; do { for type in rsa dss; do {
# check for keys # check for keys
key=/etc/dropbear/dropbear_${type}_host_key key=/etc/dropbear/dropbear_${type}_host_key
@ -14,3 +16,4 @@ for type in rsa dss; do {
}; done }; done
/usr/sbin/dropbear /usr/sbin/dropbear
}

View file

@ -1,12 +1,12 @@
#!/bin/sh #!/bin/sh /etc/rc.common
# Copyright (C) 2006 OpenWrt.org # Copyright (C) 2006 OpenWrt.org
## Please make changes in /etc/firewall.user ## Please make changes in /etc/firewall.user
. /etc/functions.sh start() {
include /lib/network include /lib/network
scan_interfaces scan_interfaces
config_get WAN wan ifname config_get WAN wan ifname
config_get LAN lan ifname config_get LAN lan ifname
@ -101,3 +101,15 @@ iptables -A LAN_ACCEPT -j ACCEPT
[ -n "$WAN" -a -e /etc/config/firewall ] && { [ -n "$WAN" -a -e /etc/config/firewall ] && {
awk -f /usr/lib/common.awk -f /usr/lib/firewall.awk /etc/config/firewall | ash awk -f /usr/lib/common.awk -f /usr/lib/firewall.awk /etc/config/firewall | ash
} }
}
stop() {
iptables -P INPUT ACCEPT
iptables -P OUTPUT ACCEPT
iptables -P FORWARD ACCEPT
iptables -F
iptables -t nat -P PREROUTING ACCEPT
iptables -t nat -P POSTROUTING ACCEPT
iptables -t nat -P OUTPUT ACCEPT
iptables -t nat -F
}

View file

@ -1,2 +1,4 @@
#!/bin/sh #!/bin/sh /etc/rc.common
start() {
iwpriv ath0 mode 3 iwpriv ath0 mode 3
}

File diff suppressed because it is too large Load diff