mirror of
git://projects.qi-hardware.com/openwrt-xburst.git
synced 2025-04-21 12:27:27 +03:00
add new rc.common for standardized init scripts, convert existing init scripts
git-svn-id: svn://svn.openwrt.org/openwrt/branches/buildroot-ng/openwrt@4915 3c298f89-4303-0410-b956-a3cf2f4a3e73
This commit is contained in:
@@ -1,8 +1,12 @@
|
||||
#!/bin/sh
|
||||
#!/bin/sh /etc/rc.common
|
||||
# ADAM2 patcher for Netgear DG834 and compatible
|
||||
MD5="$(md5sum /dev/mtdblock/0 | awk '{print $1}')"
|
||||
[ "$MD5" = "0530bfdf00ec155f4182afd70da028c1" ] && {
|
||||
mtd unlock adam2
|
||||
/sbin/adam2patcher /dev/mtdblock/0
|
||||
# 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>&-
|
||||
}
|
||||
rm -f /etc/init.d/S00adam2 /sbin/adam2patcher >&- 2>&-
|
||||
|
||||
@@ -1,86 +1,87 @@
|
||||
#!/bin/sh
|
||||
#!/bin/sh /etc/rc.common
|
||||
# Copyright (C) 2006 OpenWrt.org
|
||||
|
||||
[ -e /etc/config/network ] && exit 0
|
||||
start() {
|
||||
[ -e /etc/config/network ] && exit 0
|
||||
|
||||
mkdir -p /etc/config
|
||||
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 wl0"
|
||||
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 wl0" # FIXME
|
||||
(
|
||||
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 wl0"
|
||||
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 wl0" # FIXME
|
||||
c["wan_ifname"]=""
|
||||
}
|
||||
}
|
||||
if (nvram["boardtype"] == "wgt634u") {
|
||||
c["vlan0ports"] = "0 1 2 3 5*"
|
||||
c["vlan1ports"] = "4 5"
|
||||
c["lan_ifname"] = "eth0.0 ath0"
|
||||
}
|
||||
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 wl0"
|
||||
c["wan_ifname"]=""
|
||||
}
|
||||
}
|
||||
if (nvram["boardtype"] == "wgt634u") {
|
||||
c["vlan0ports"] = "0 1 2 3 5*"
|
||||
c["vlan1ports"] = "4 5"
|
||||
c["lan_ifname"] = "eth0.0 ath0"
|
||||
}
|
||||
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 wl0"
|
||||
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"
|
||||
|
||||
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
|
||||
}
|
||||
' > /etc/config/network
|
||||
|
||||
@@ -1,86 +1,87 @@
|
||||
#!/bin/sh
|
||||
#!/bin/sh /etc/rc.common
|
||||
# Copyright (C) 2006 OpenWrt.org
|
||||
|
||||
[ -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 wl0"
|
||||
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 wl0" # FIXME
|
||||
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 wl0"
|
||||
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 wl0" # FIXME
|
||||
c["wan_ifname"]=""
|
||||
}
|
||||
}
|
||||
if (nvram["boardtype"] == "wgt634u") {
|
||||
c["vlan0ports"] = "0 1 2 3 5*"
|
||||
c["vlan1ports"] = "4 5"
|
||||
c["lan_ifname"] = "eth0.0 ath0"
|
||||
}
|
||||
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 wl0"
|
||||
c["wan_ifname"]=""
|
||||
}
|
||||
}
|
||||
if (nvram["boardtype"] == "wgt634u") {
|
||||
c["vlan0ports"] = "0 1 2 3 5*"
|
||||
c["vlan1ports"] = "4 5"
|
||||
c["lan_ifname"] = "eth0.0 ath0"
|
||||
}
|
||||
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 wl0"
|
||||
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"
|
||||
|
||||
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
|
||||
}
|
||||
' > /etc/config/network
|
||||
|
||||
@@ -1,25 +1,25 @@
|
||||
#!/bin/sh
|
||||
#!/bin/sh /etc/rc.common
|
||||
# Copyright (C) 2006 OpenWrt.org
|
||||
|
||||
. /etc/functions.sh
|
||||
|
||||
[ -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/*
|
||||
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/*
|
||||
}
|
||||
|
||||
@@ -1,9 +1,11 @@
|
||||
#!/bin/sh
|
||||
#!/bin/sh /etc/rc.common
|
||||
# Copyright (C) 2006 OpenWrt.org
|
||||
|
||||
setup_switch() { return 0; }
|
||||
start() {
|
||||
setup_switch() { return 0; }
|
||||
|
||||
include /lib/network
|
||||
setup_switch
|
||||
/sbin/wifi
|
||||
}
|
||||
|
||||
. /etc/functions.sh
|
||||
include /lib/network
|
||||
setup_switch
|
||||
/sbin/wifi
|
||||
|
||||
@@ -1,4 +1,10 @@
|
||||
#!/bin/sh
|
||||
#!/bin/sh /etc/rc.common
|
||||
# Copyright (C) 2006 OpenWrt.org
|
||||
|
||||
[ -d /www ] && httpd -p 80 -h /www -r OpenWrt
|
||||
start() {
|
||||
[ -d /www ] && httpd -p 80 -h /www -r OpenWrt
|
||||
}
|
||||
|
||||
stop() {
|
||||
killall httpd
|
||||
}
|
||||
|
||||
@@ -1,4 +1,10 @@
|
||||
#!/bin/sh
|
||||
#!/bin/sh /etc/rc.common
|
||||
# Copyright (C) 2006 OpenWrt.org
|
||||
|
||||
if awk -F: '/^root:/ && $2 !~ /\!/ {exit 1}' /etc/passwd 2>/dev/null; then telnetd -l /bin/login; fi
|
||||
start() {
|
||||
if awk -F: '/^root:/ && $2 !~ /\!/ {exit 1}' /etc/passwd 2>/dev/null; then telnetd -l /bin/login; fi
|
||||
}
|
||||
|
||||
stop() {
|
||||
killall telnetd
|
||||
}
|
||||
|
||||
@@ -1,6 +1,12 @@
|
||||
#!/bin/sh
|
||||
#!/bin/sh /etc/rc.common
|
||||
# Copyright (C) 2006 OpenWrt.org
|
||||
|
||||
mkdir -p /var/spool/cron
|
||||
ln -s /etc/crontabs /var/spool/cron/crontabs
|
||||
crond -c /etc/crontabs
|
||||
start () {
|
||||
mkdir -p /var/spool/cron
|
||||
ln -s /etc/crontabs /var/spool/cron/crontabs
|
||||
crond -c /etc/crontabs
|
||||
}
|
||||
|
||||
stop() {
|
||||
killall crond
|
||||
}
|
||||
|
||||
@@ -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
|
||||
}
|
||||
@@ -10,6 +10,17 @@ ${FAILSAFE:+exit}
|
||||
syslogd -C 16 #${log_ipaddr:+-L -R $log_ipaddr}
|
||||
klogd
|
||||
|
||||
for i in /etc/init.d/S*; do
|
||||
$i start 2>&1
|
||||
done | logger -s -p 6 -t '' &
|
||||
(
|
||||
for i in /etc/init.d/S*; do
|
||||
$i start 2>&1
|
||||
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 '' &
|
||||
|
||||
77
package/base-files/default/etc/rc.common
Executable file
77
package/base-files/default/etc/rc.common
Executable 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"
|
||||
Reference in New Issue
Block a user