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