44311c9e230ec5debc5305a12475035ba32da30f
[oweals/openwrt.git] / package / base-files / files / etc / init.d / boot
1 #!/bin/sh /etc/rc.common
2 # Copyright (C) 2006-2011 OpenWrt.org
3
4 START=10
5 STOP=90
6
7 uci_apply_defaults() {
8         . /lib/functions/system.sh
9
10         cd /etc/uci-defaults || return 0
11         files="$(ls)"
12         [ -z "$files" ] && return 0
13         mkdir -p /tmp/.uci
14         for file in $files; do
15                 ( . "./$(basename $file)" ) && rm -f "$file"
16         done
17         uci commit
18 }
19
20 boot() {
21         [ -f /proc/mounts ] || /sbin/mount_root
22         [ -f /proc/jffs2_bbc ] && echo "S" > /proc/jffs2_bbc
23         [ -f /proc/net/vlan/config ] && vconfig set_name_type DEV_PLUS_VID_NO_PAD
24
25         mkdir -p /var/run
26         mkdir -p /var/log
27         mkdir -p /var/lock
28         mkdir -p /var/state
29         mkdir -p /var/tmp
30         mkdir -p /tmp/.uci
31         chmod 0700 /tmp/.uci
32         touch /var/log/wtmp
33         touch /var/log/lastlog
34         mkdir -p /tmp/resolv.conf.d
35         touch /tmp/resolv.conf.d/resolv.conf.auto
36         ln -sf /tmp/resolv.conf.d/resolv.conf.auto /tmp/resolv.conf
37         grep -q debugfs /proc/filesystems && /bin/mount -o noatime -t debugfs debugfs /sys/kernel/debug
38         [ "$FAILSAFE" = "true" ] && touch /tmp/.failsafe
39
40         /sbin/kmodloader
41
42         [ ! -f /etc/config/wireless ] && {
43                 # compat for brcm47xx and mvebu
44                 sleep 1
45         }
46
47         /bin/config_generate
48         uci_apply_defaults
49         
50         # temporary hack until configd exists
51         /sbin/reload_config
52 }