1 #!/bin/sh /etc/rc.common
2 # Copyright (C) 2006-2011 OpenWrt.org
10 local hostname conloglevel timezone
12 config_get hostname
"$cfg" hostname
'OpenWrt'
13 echo "$hostname" > /proc
/sys
/kernel
/hostname
15 config_get conloglevel
"$cfg" conloglevel
16 config_get buffersize
"$cfg" buffersize
17 [ -z "$conloglevel" -a -z "$buffersize" ] || dmesg
${conloglevel:+-n $conloglevel} ${buffersize:+-s $buffersize}
19 config_get timezone
"$cfg" timezone
'UTC'
20 echo "$timezone" > /tmp
/TZ
22 config_get zonename
"$cfg" zonename
23 [ -n "$zonename" ] && [ -f "/usr/share/zoneinfo/$zonename" ] && ln -s "/usr/share/zoneinfo/$zonename" /tmp
/localtime
25 if [ -x /sbin
/syslogd
]; then
26 local args log_ip log_size log_port log_type log_file
27 config_get log_ip
"$cfg" log_ip
28 config_get log_size
"$cfg" log_size
16
29 config_get log_port
"$cfg" log_port
514
30 config_get log_type
"$cfg" log_type circular
31 config_get log_file
"$cfg" log_file
"/var/log/messages"
32 args
="${log_ip:+-L -R ${log_ip}:${log_port}} ${conloglevel:+-l $conloglevel}"
33 if [ "$log_type" = "file" ]; then
34 args
="$args -s $log_size -O $log_file -S"
36 args
="$args -C${log_size}"
38 service_start
/sbin
/syslogd
$args
40 if [ -x /sbin
/klogd
]; then
41 config_get klogconloglevel
"$cfg" klogconloglevel
42 args
="${klogconloglevel:+-c $klogconloglevel}"
43 service_start
/sbin
/klogd
$args
48 sh
-c '. /etc/functions.sh; include /lib/config; uci_apply_defaults'
52 [ -f /proc
/mounts
] ||
/sbin
/mount_root
53 [ -f /proc
/jffs2_bbc
] && echo "S" > /proc
/jffs2_bbc
54 [ -f /proc
/net
/vlan
/config
] && vconfig set_name_type DEV_PLUS_VID_NO_PAD
63 touch /var
/log
/lastlog
64 touch /tmp
/resolv.conf.auto
65 ln -sf /tmp
/resolv.conf.auto
/tmp
/resolv.conf
66 grep -q debugfs
/proc
/filesystems
&& mount
-t debugfs debugfs
/sys
/kernel
/debug
67 [ "$FAILSAFE" = "true" ] && touch /tmp
/.failsafe
69 load_modules
/etc
/modules.d
/*
71 /sbin
/wifi detect
> /tmp
/wireless.tmp
72 [ -s /tmp
/wireless.tmp
] && {
73 cat /tmp
/wireless.tmp
>> /etc
/config
/wireless
75 rm -f /tmp
/wireless.tmp
79 config_foreach system_config system
82 [ -x /sbin
/hotplug2
] && /sbin
/hotplug2
--override --persistent \
83 --set-worker /lib
/hotplug
2/worker_fork.so \
84 --set-rules-file /etc
/hotplug2.rules \
85 --max-children 1 >/dev
/null
2>&1 &
87 # the coldplugging of network interfaces needs to happen later, so we do it manually here
88 for iface
in $
(awk -F: '/:/ {print $1}' /proc
/net
/dev
); do
89 /usr
/bin
/env
-i ACTION
=add INTERFACE
="$iface" /sbin
/hotplug-call net
92 # create /dev/root if it doesn't exist
93 [ -e /dev
/root
-o -h /dev
/root
] ||
{
94 rootdev
=$
(awk 'BEGIN { RS=" "; FS="="; } $1 == "root" { print $2 }' < /proc
/cmdline
)
95 [ -n "$rootdev" ] && ln -s "$rootdev" /dev
/root
98 # another round of USB coldplugging to kick devices into operation which lacked drivers before
99 for dev
in /sys
/bus
/usb
/devices
/*/uevent
; do
100 [ -e "$dev" ] && echo -n add
> "$dev"
105 service_stop
/sbin
/klogd
106 service_stop
/sbin
/syslogd