base-files: fix /tmp/.jail permissions
[openwrt/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=98
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 /tmp/.uci
30 chmod 0700 /tmp/.uci
31 mkdir -p /tmp/.jail
32 touch /var/log/wtmp
33 touch /var/log/lastlog
34 touch /tmp/resolv.conf.auto
35 ln -sf /tmp/resolv.conf.auto /tmp/resolv.conf
36 grep -q debugfs /proc/filesystems && /bin/mount -o noatime -t debugfs debugfs /sys/kernel/debug
37 [ "$FAILSAFE" = "true" ] && touch /tmp/.failsafe
38
39 /sbin/kmodloader
40
41 # allow wifi modules time to settle
42 sleep 1
43
44 /sbin/wifi detect > /tmp/wireless.tmp
45 [ -s /tmp/wireless.tmp ] && {
46 cat /tmp/wireless.tmp >> /etc/config/wireless
47 }
48 rm -f /tmp/wireless.tmp
49
50 /bin/board_detect
51 uci_apply_defaults
52
53 # temporary hack until configd exists
54 /sbin/reload_config
55
56 # create /dev/root if it doesn't exist
57 [ -e /dev/root -o -h /dev/root ] || {
58 rootdev=$(awk 'BEGIN { RS=" "; FS="="; } $1 == "root" { print $2 }' < /proc/cmdline)
59 [ -n "$rootdev" ] && ln -s "$rootdev" /dev/root
60 }
61 }