2006-10-05 04:05:48 +08:00
|
|
|
#!/bin/sh /etc/rc.common
|
2006-06-27 08:36:13 +08:00
|
|
|
# Copyright (C) 2006 OpenWrt.org
|
|
|
|
|
2006-10-16 05:03:30 +08:00
|
|
|
START=10
|
2007-03-07 05:28:57 +08:00
|
|
|
|
|
|
|
system_config() {
|
|
|
|
local cfg="$1"
|
|
|
|
local hostname
|
|
|
|
|
|
|
|
config_get hostname "$cfg" hostname
|
|
|
|
echo "${hostname:-OpenWrt}" > /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
|
|
|
|
[ -n "$conloglevel" ] && dmesg -n "$conloglevel"
|
2008-06-12 03:59:16 +08:00
|
|
|
|
|
|
|
config_get timezone "$cfg" timezone
|
|
|
|
[ -z "$timezone" ] && timezone=UTC
|
|
|
|
echo "$timezone" > /tmp/TZ
|
2007-06-14 01:41:54 +08:00
|
|
|
|
2008-06-17 03:37:00 +08:00
|
|
|
config_get log_ip "$cfg" log_ip
|
2008-03-07 18:44:13 +08:00
|
|
|
config_get log_size "$cfg" log_size
|
2009-02-04 04:26:00 +08:00
|
|
|
config_get log_port "$cfg" log_port
|
|
|
|
syslogd -C${log_size:-16} ${log_ip:+-L -R $log_ip${log_port:+:$log_port}}
|
2007-05-10 17:29:55 +08:00
|
|
|
klogd
|
2007-03-07 05:28:57 +08:00
|
|
|
}
|
|
|
|
|
2007-05-10 04:54:41 +08:00
|
|
|
apply_uci_config() {(
|
|
|
|
include /lib/config
|
|
|
|
uci_apply_defaults
|
|
|
|
)}
|
|
|
|
|
2006-10-05 04:05:48 +08:00
|
|
|
start() {
|
|
|
|
[ -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
|
|
|
|
2008-06-17 03:37:00 +08:00
|
|
|
apply_uci_config
|
|
|
|
config_load system
|
|
|
|
config_foreach system_config system
|
|
|
|
|
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
|
2006-10-05 04:05:48 +08:00
|
|
|
[ "$FAILSAFE" = "true" ] && touch /tmp/.failsafe
|
2007-06-25 16:32:25 +08:00
|
|
|
|
2008-08-01 11:01:42 +08:00
|
|
|
killall -q hotplug2
|
2007-11-28 10:36:10 +08:00
|
|
|
[ -x /sbin/hotplug2 ] && /sbin/hotplug2 --override --persistent \
|
|
|
|
--max-children 1 --no-coldplug &
|
2007-05-10 04:54:41 +08:00
|
|
|
|
2007-05-06 02:33:18 +08:00
|
|
|
# the coldplugging of network interfaces needs to happen later, so we do it manually here
|
2006-10-05 04:05:48 +08:00
|
|
|
for iface in $(awk -F: '/:/ {print $1}' /proc/net/dev); do
|
2007-03-05 04:31:53 +08:00
|
|
|
/usr/bin/env -i ACTION=add INTERFACE="$iface" /sbin/hotplug-call net
|
2006-10-05 04:05:48 +08:00
|
|
|
done
|
2007-03-05 04:31:53 +08:00
|
|
|
|
2007-04-30 00:57:55 +08:00
|
|
|
# create /dev/root if it doesn't exist
|
|
|
|
[ -e /dev/root ] || {
|
|
|
|
rootdev=$(awk 'BEGIN { RS=" "; FS="="; } $1 == "root" { print $2 }' < /proc/cmdline)
|
|
|
|
[ -n "$rootdev" ] && ln -s "$rootdev" /dev/root
|
|
|
|
}
|
|
|
|
|
2006-10-17 07:23:58 +08:00
|
|
|
load_modules /etc/modules.d/*
|
2006-10-05 04:05:48 +08:00
|
|
|
}
|