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