7181f8b0043781713be9fde4bc1e03571a04d88c
[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 log_ip "$cfg" log_ip
17 syslogd -C16 ${log_ip:+-L -R $log_ip}
18 klogd
19 }
20
21 apply_uci_config() {(
22 include /lib/config
23 uci_apply_defaults
24 )}
25
26 start() {
27 [ -f /proc/mounts ] || /sbin/mount_root
28 [ -f /proc/jffs2_bbc ] && echo "S" > /proc/jffs2_bbc
29 vconfig set_name_type DEV_PLUS_VID_NO_PAD
30
31 apply_uci_config
32 config_load system
33 config_foreach system_config system
34
35 mkdir -p /var/run
36 mkdir -p /var/log
37 mkdir -p /var/lock
38 touch /var/log/wtmp
39 touch /var/log/lastlog
40 ln -s /tmp/resolv.conf.auto /tmp/resolv.conf
41 [ "$FAILSAFE" = "true" ] && touch /tmp/.failsafe
42
43 /sbin/hotplug2 --persistent --max-children 1 &
44
45 # the coldplugging of network interfaces needs to happen later, so we do it manually here
46 for iface in $(awk -F: '/:/ {print $1}' /proc/net/dev); do
47 /usr/bin/env -i ACTION=add INTERFACE="$iface" /sbin/hotplug-call net
48 done
49
50 # create /dev/root if it doesn't exist
51 [ -e /dev/root ] || {
52 rootdev=$(awk 'BEGIN { RS=" "; FS="="; } $1 == "root" { print $2 }' < /proc/cmdline)
53 [ -n "$rootdev" ] && ln -s "$rootdev" /dev/root
54 }
55
56 load_modules /etc/modules.d/*
57 }