2006-10-04 20:05:48 +00:00
|
|
|
#!/bin/sh /etc/rc.common
|
2011-11-07 22:58:34 +00:00
|
|
|
# Copyright (C) 2006-2011 OpenWrt.org
|
2006-06-27 00:36:13 +00:00
|
|
|
|
2006-10-15 21:03:30 +00:00
|
|
|
START=10
|
2010-01-30 18:17:52 +00:00
|
|
|
STOP=98
|
2007-03-06 21:28:57 +00:00
|
|
|
|
|
|
|
system_config() {
|
|
|
|
local cfg="$1"
|
2009-08-07 00:07:51 +00:00
|
|
|
|
|
|
|
local hostname conloglevel timezone
|
|
|
|
|
|
|
|
config_get hostname "$cfg" hostname 'OpenWrt'
|
|
|
|
echo "$hostname" > /proc/sys/kernel/hostname
|
2007-05-10 09:29:55 +00:00
|
|
|
|
2007-06-13 17:41:54 +00:00
|
|
|
config_get conloglevel "$cfg" conloglevel
|
2009-09-04 21:09:13 +00:00
|
|
|
config_get buffersize "$cfg" buffersize
|
|
|
|
[ -z "$conloglevel" -a -z "$buffersize" ] || dmesg ${conloglevel:+-n $conloglevel} ${buffersize:+-s $buffersize}
|
2011-11-17 01:18:22 +00:00
|
|
|
|
2009-08-07 00:07:51 +00:00
|
|
|
config_get timezone "$cfg" timezone 'UTC'
|
2008-06-11 19:59:16 +00:00
|
|
|
echo "$timezone" > /tmp/TZ
|
2007-06-13 17:41:54 +00:00
|
|
|
|
2011-09-26 02:28:04 +00:00
|
|
|
config_get zonename "$cfg" zonename
|
|
|
|
[ -n "$zonename" ] && [ -f "/usr/share/zoneinfo/$zonename" ] && ln -s "/usr/share/zoneinfo/$zonename" /tmp/localtime
|
|
|
|
|
2011-11-17 01:18:22 +00:00
|
|
|
# apply timezone to kernel
|
|
|
|
date -k
|
|
|
|
|
2009-09-04 21:09:13 +00:00
|
|
|
if [ -x /sbin/syslogd ]; then
|
2011-11-07 22:58:34 +00:00
|
|
|
local args log_ip log_size log_port log_type log_file
|
2009-09-04 21:09:13 +00:00
|
|
|
config_get log_ip "$cfg" log_ip
|
|
|
|
config_get log_size "$cfg" log_size 16
|
|
|
|
config_get log_port "$cfg" log_port 514
|
|
|
|
config_get log_type "$cfg" log_type circular
|
|
|
|
config_get log_file "$cfg" log_file "/var/log/messages"
|
2011-11-07 22:58:34 +00:00
|
|
|
args="${log_ip:+-L -R ${log_ip}:${log_port}} ${conloglevel:+-l $conloglevel}"
|
2009-09-04 21:09:13 +00:00
|
|
|
if [ "$log_type" = "file" ]; then
|
2011-11-07 22:58:34 +00:00
|
|
|
args="$args -s $log_size -O $log_file -S"
|
2009-09-04 21:09:13 +00:00
|
|
|
else
|
2011-11-07 22:58:34 +00:00
|
|
|
args="$args -C${log_size}"
|
2009-09-04 21:09:13 +00:00
|
|
|
fi
|
2011-11-07 22:58:34 +00:00
|
|
|
service_start /sbin/syslogd $args
|
|
|
|
fi
|
|
|
|
if [ -x /sbin/klogd ]; then
|
|
|
|
config_get klogconloglevel "$cfg" klogconloglevel
|
|
|
|
args="${klogconloglevel:+-c $klogconloglevel}"
|
|
|
|
service_start /sbin/klogd $args
|
2009-09-04 21:09:13 +00:00
|
|
|
fi
|
2007-03-06 21:28:57 +00:00
|
|
|
}
|
|
|
|
|
2009-12-09 15:15:25 +00:00
|
|
|
apply_uci_config() {
|
|
|
|
sh -c '. /etc/functions.sh; include /lib/config; uci_apply_defaults'
|
|
|
|
}
|
2007-05-09 20:54:41 +00:00
|
|
|
|
2006-10-04 20:05:48 +00:00
|
|
|
start() {
|
|
|
|
[ -f /proc/mounts ] || /sbin/mount_root
|
|
|
|
[ -f /proc/jffs2_bbc ] && echo "S" > /proc/jffs2_bbc
|
2008-05-13 09:21:17 +00:00
|
|
|
[ -f /proc/net/vlan/config ] && vconfig set_name_type DEV_PLUS_VID_NO_PAD
|
2007-05-09 20:54:41 +00:00
|
|
|
|
2006-10-04 20:05:48 +00:00
|
|
|
mkdir -p /var/run
|
|
|
|
mkdir -p /var/log
|
|
|
|
mkdir -p /var/lock
|
2007-06-16 00:01:33 +00:00
|
|
|
mkdir -p /var/state
|
2008-02-03 06:48:15 +00:00
|
|
|
mkdir -p /tmp/.uci
|
2009-01-06 21:53:45 +00:00
|
|
|
chmod 0700 /tmp/.uci
|
2006-10-04 20:05:48 +00:00
|
|
|
touch /var/log/wtmp
|
|
|
|
touch /var/log/lastlog
|
2008-08-28 14:10:55 +00:00
|
|
|
touch /tmp/resolv.conf.auto
|
2007-06-30 20:00:29 +00:00
|
|
|
ln -sf /tmp/resolv.conf.auto /tmp/resolv.conf
|
2009-11-23 20:35:05 +00:00
|
|
|
grep -q debugfs /proc/filesystems && mount -t debugfs debugfs /sys/kernel/debug
|
2006-10-04 20:05:48 +00:00
|
|
|
[ "$FAILSAFE" = "true" ] && touch /tmp/.failsafe
|
2007-06-25 08:32:25 +00:00
|
|
|
|
2011-11-03 20:02:25 +00:00
|
|
|
load_modules /etc/modules.d/*
|
|
|
|
|
|
|
|
/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
|
|
|
|
config_load system
|
|
|
|
config_foreach system_config system
|
|
|
|
|
2008-08-01 03:01:42 +00:00
|
|
|
killall -q hotplug2
|
2007-11-28 02:36:10 +00:00
|
|
|
[ -x /sbin/hotplug2 ] && /sbin/hotplug2 --override --persistent \
|
2009-05-30 17:09:41 +00:00
|
|
|
--set-rules-file /etc/hotplug2.rules \
|
2012-01-22 21:14:22 +00:00
|
|
|
--set-coldplug-cmd /sbin/udevtrigger \
|
2009-05-28 18:48:54 +00:00
|
|
|
--max-children 1 >/dev/null 2>&1 &
|
2007-05-09 20:54:41 +00:00
|
|
|
|
2007-05-05 18:33:18 +00:00
|
|
|
# the coldplugging of network interfaces needs to happen later, so we do it manually here
|
2006-10-04 20:05:48 +00:00
|
|
|
for iface in $(awk -F: '/:/ {print $1}' /proc/net/dev); do
|
2007-03-04 20:31:53 +00:00
|
|
|
/usr/bin/env -i ACTION=add INTERFACE="$iface" /sbin/hotplug-call net
|
2006-10-04 20:05:48 +00:00
|
|
|
done
|
2007-03-04 20:31:53 +00:00
|
|
|
|
2007-04-29 16:57:55 +00:00
|
|
|
# create /dev/root if it doesn't exist
|
2011-04-05 15:09:43 +00:00
|
|
|
[ -e /dev/root -o -h /dev/root ] || {
|
2007-04-29 16:57:55 +00:00
|
|
|
rootdev=$(awk 'BEGIN { RS=" "; FS="="; } $1 == "root" { print $2 }' < /proc/cmdline)
|
|
|
|
[ -n "$rootdev" ] && ln -s "$rootdev" /dev/root
|
|
|
|
}
|
|
|
|
|
2011-05-08 10:25:58 +00:00
|
|
|
# another round of USB coldplugging to kick devices into operation which lacked drivers before
|
|
|
|
for dev in /sys/bus/usb/devices/*/uevent; do
|
|
|
|
[ -e "$dev" ] && echo -n add > "$dev"
|
|
|
|
done
|
2006-10-04 20:05:48 +00:00
|
|
|
}
|
2010-01-30 18:17:52 +00:00
|
|
|
|
|
|
|
stop() {
|
2011-11-07 22:58:34 +00:00
|
|
|
service_stop /sbin/klogd
|
|
|
|
service_stop /sbin/syslogd
|
2010-01-30 18:17:52 +00:00
|
|
|
}
|