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