2006-10-05 04:05:48 +08:00
|
|
|
#!/bin/sh /etc/rc.common
|
2011-11-08 06:58:34 +08:00
|
|
|
# Copyright (C) 2006-2011 OpenWrt.org
|
2006-06-27 08:36:13 +08:00
|
|
|
|
2006-10-16 05:03:30 +08:00
|
|
|
START=10
|
2010-01-31 02:17:52 +08:00
|
|
|
STOP=98
|
2007-03-07 05:28:57 +08:00
|
|
|
|
|
|
|
system_config() {
|
|
|
|
local cfg="$1"
|
2009-08-07 08:07:51 +08:00
|
|
|
|
2013-07-09 00:35:02 +08:00
|
|
|
local hostname conloglevel buffersize timezone zonename
|
2009-08-07 08:07:51 +08:00
|
|
|
|
|
|
|
config_get hostname "$cfg" hostname 'OpenWrt'
|
|
|
|
echo "$hostname" > /proc/sys/kernel/hostname
|
2007-05-10 17:29:55 +08:00
|
|
|
|
2007-06-14 01:41:54 +08:00
|
|
|
config_get conloglevel "$cfg" conloglevel
|
2009-09-05 05:09:13 +08:00
|
|
|
config_get buffersize "$cfg" buffersize
|
|
|
|
[ -z "$conloglevel" -a -z "$buffersize" ] || dmesg ${conloglevel:+-n $conloglevel} ${buffersize:+-s $buffersize}
|
2011-11-17 09:18:22 +08:00
|
|
|
|
2009-08-07 08:07:51 +08:00
|
|
|
config_get timezone "$cfg" timezone 'UTC'
|
2008-06-12 03:59:16 +08:00
|
|
|
echo "$timezone" > /tmp/TZ
|
2007-06-14 01:41:54 +08:00
|
|
|
|
2011-09-26 10:28:04 +08:00
|
|
|
config_get zonename "$cfg" zonename
|
|
|
|
[ -n "$zonename" ] && [ -f "/usr/share/zoneinfo/$zonename" ] && ln -s "/usr/share/zoneinfo/$zonename" /tmp/localtime
|
|
|
|
|
2011-11-17 09:18:22 +08:00
|
|
|
# apply timezone to kernel
|
|
|
|
date -k
|
2007-03-07 05:28:57 +08:00
|
|
|
}
|
|
|
|
|
2009-12-09 23:15:25 +08:00
|
|
|
apply_uci_config() {
|
2012-06-06 00:04:23 +08:00
|
|
|
sh -c '. /lib/functions.sh; include /lib/config; uci_apply_defaults'
|
2009-12-09 23:15:25 +08:00
|
|
|
}
|
2007-05-10 04:54:41 +08:00
|
|
|
|
2006-10-05 04:05:48 +08:00
|
|
|
start() {
|
2013-11-07 20:45:57 +08:00
|
|
|
config_load system
|
|
|
|
config_foreach system_config system
|
|
|
|
}
|
|
|
|
|
|
|
|
boot() {
|
2006-10-05 04:05:48 +08:00
|
|
|
[ -f /proc/mounts ] || /sbin/mount_root
|
|
|
|
[ -f /proc/jffs2_bbc ] && echo "S" > /proc/jffs2_bbc
|
2008-05-13 17:21:17 +08:00
|
|
|
[ -f /proc/net/vlan/config ] && vconfig set_name_type DEV_PLUS_VID_NO_PAD
|
2007-05-10 04:54:41 +08:00
|
|
|
|
2006-10-05 04:05:48 +08:00
|
|
|
mkdir -p /var/run
|
|
|
|
mkdir -p /var/log
|
|
|
|
mkdir -p /var/lock
|
2007-06-16 08:01:33 +08:00
|
|
|
mkdir -p /var/state
|
2008-02-03 14:48:15 +08:00
|
|
|
mkdir -p /tmp/.uci
|
2009-01-07 05:53:45 +08:00
|
|
|
chmod 0700 /tmp/.uci
|
2006-10-05 04:05:48 +08:00
|
|
|
touch /var/log/wtmp
|
|
|
|
touch /var/log/lastlog
|
2008-08-28 22:10:55 +08:00
|
|
|
touch /tmp/resolv.conf.auto
|
2007-07-01 04:00:29 +08:00
|
|
|
ln -sf /tmp/resolv.conf.auto /tmp/resolv.conf
|
2013-12-28 05:15:09 +08:00
|
|
|
grep -q debugfs /proc/filesystems && /bin/mount -o noatime -t debugfs debugfs /sys/kernel/debug
|
2006-10-05 04:05:48 +08:00
|
|
|
[ "$FAILSAFE" = "true" ] && touch /tmp/.failsafe
|
2007-06-25 16:32:25 +08:00
|
|
|
|
2013-06-22 00:53:59 +08:00
|
|
|
/sbin/kmodloader
|
2011-11-04 04:02:25 +08:00
|
|
|
|
2012-05-07 05:25:42 +08:00
|
|
|
# allow wifi modules time to settle
|
|
|
|
sleep 1
|
|
|
|
|
2011-11-04 04:02:25 +08:00
|
|
|
/sbin/wifi detect > /tmp/wireless.tmp
|
|
|
|
[ -s /tmp/wireless.tmp ] && {
|
|
|
|
cat /tmp/wireless.tmp >> /etc/config/wireless
|
|
|
|
}
|
|
|
|
rm -f /tmp/wireless.tmp
|
|
|
|
|
|
|
|
apply_uci_config
|
2013-07-12 01:00:54 +08:00
|
|
|
|
|
|
|
# temporary hack until configd exists
|
|
|
|
/sbin/reload_config
|
2013-11-07 20:45:57 +08:00
|
|
|
|
|
|
|
start
|
2011-11-04 04:02:25 +08:00
|
|
|
|
2007-04-30 00:57:55 +08:00
|
|
|
# create /dev/root if it doesn't exist
|
2011-04-05 23:09:43 +08:00
|
|
|
[ -e /dev/root -o -h /dev/root ] || {
|
2007-04-30 00:57:55 +08:00
|
|
|
rootdev=$(awk 'BEGIN { RS=" "; FS="="; } $1 == "root" { print $2 }' < /proc/cmdline)
|
|
|
|
[ -n "$rootdev" ] && ln -s "$rootdev" /dev/root
|
|
|
|
}
|
2006-10-05 04:05:48 +08:00
|
|
|
}
|