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