283c02a1ae50b838cae4316bd74dfb194c8a41ac
[openwrt/svn-archive/archive.git] / package / base-files / files / etc / init.d / boot
1 #!/bin/sh /etc/rc.common
2 # Copyright (C) 2006 OpenWrt.org
3
4 START=10
5
6 system_config() {
7 local cfg="$1"
8 local hostname
9
10 config_get hostname "$cfg" hostname
11 echo "${hostname:-OpenWrt}" > /proc/sys/kernel/hostname
12
13 config_get conloglevel "$cfg" conloglevel
14 [ -n "$conloglevel" ] && dmesg -n "$conloglevel"
15
16 config_get timezone "$cfg" timezone
17 [ -z "$timezone" ] && timezone=UTC
18 echo "$timezone" > /tmp/TZ
19
20 config_get log_ip "$cfg" log_ip
21 config_get log_size "$cfg" log_size
22 config_get log_port "$cfg" log_port
23 [ -x /sbin/syslogd ] && syslogd -C${log_size:-16} ${log_ip:+-L -R $log_ip${log_port:+:$log_port}}
24 [ -x /sbin/klogd ] && klogd
25 }
26
27 apply_uci_config() {(
28 include /lib/config
29 uci_apply_defaults
30 )}
31
32 start() {
33 [ -f /proc/mounts ] || /sbin/mount_root
34 [ -f /proc/jffs2_bbc ] && echo "S" > /proc/jffs2_bbc
35 [ -f /proc/net/vlan/config ] && vconfig set_name_type DEV_PLUS_VID_NO_PAD
36
37 apply_uci_config
38 config_load system
39 config_foreach system_config system
40
41 mkdir -p /var/run
42 mkdir -p /var/log
43 mkdir -p /var/lock
44 mkdir -p /var/state
45 mkdir -p /tmp/.uci
46 chmod 0700 /tmp/.uci
47 touch /var/log/wtmp
48 touch /var/log/lastlog
49 touch /tmp/resolv.conf.auto
50 ln -sf /tmp/resolv.conf.auto /tmp/resolv.conf
51 [ "$FAILSAFE" = "true" ] && touch /tmp/.failsafe
52
53 killall -q hotplug2
54 [ -x /sbin/hotplug2 ] && /sbin/hotplug2 --override --persistent \
55 --set-worker /lib/hotplug2/worker_fork.so \
56 --set-rules-file /etc/hotplug2.rules \
57 --max-children 1 >/dev/null 2>&1 &
58
59 # the coldplugging of network interfaces needs to happen later, so we do it manually here
60 for iface in $(awk -F: '/:/ {print $1}' /proc/net/dev); do
61 /usr/bin/env -i ACTION=add INTERFACE="$iface" /sbin/hotplug-call net
62 done
63
64 # create /dev/root if it doesn't exist
65 [ -e /dev/root ] || {
66 rootdev=$(awk 'BEGIN { RS=" "; FS="="; } $1 == "root" { print $2 }' < /proc/cmdline)
67 [ -n "$rootdev" ] && ln -s "$rootdev" /dev/root
68 }
69
70 load_modules /etc/modules.d/*
71 }