32ffa1624cb3de5a72904348cfc554acaca8179f
[wyse_ntpd.git] / src / buildroot-2013.05 / custom / filesystem / etc / init.d / S01custom_pre_startup
1 #!/bin/sh
2
3 # deal with our mounts
4 echo "Mounting info file systems"
5 echo ".... proc"
6 mkdir /proc > /dev/null 2>&1
7 mount -t proc proc /proc
8 mkdir /sys > /dev/null 2>&1
9 echo ".... sys"
10 mount -t sysfs sys /sys
11 mkdir -p /dev/pts > /dev/null 2>&1
12 echo ".... devpts"
13 mount -t devpts devpts /dev/pts
14 echo ".... tmpfs"
15 mount /tmp > /dev/null 2>&1
16
17
18 # mount the config file system
19 mkdir /fs > /dev/null 2>&1
20 echo "Mounting /fs"
21 mount /dev/sda1 /fs > /dev/null 2>&1
22
23 echo "Looking for system config"
24 if [ -f /fs/config/system ]
25 then
26         echo ".... found - loading"
27         . /fs/config/system
28 fi
29
30 echo "Looking for dropbear config"
31 if [ -f /fs/config/dropbear.tar ]
32 then
33         RD=`pwd`
34         cd /
35         echo ".... found - installing"
36         tar xf /fs/config/dropbear.tar > /dev/null 2>&1
37         cd $RD
38 fi
39
40 # create the interfaces layout
41 echo "Setting up network interfaces configuration"
42 echo ".... loopback"
43 cat << EOF > /etc/network/interfaces
44 auto lo
45 iface lo inet loopback
46
47 EOF
48
49 # create network interfaces bit
50 if [ "x$INTERFACE" == "xdhcp" ]
51 then
52 echo ".... eth0 - dhcp"
53 cat << EOF >> /etc/network/interfaces
54 auto eth0
55 iface eth0 inet dhcp
56 EOF
57
58 else
59         # static network address
60         if [ "x$NET_ADDRESS" != "x" ]
61         then
62
63         echo ".... eth0 - static $NET_ADDRESS - $NET_MASK"
64 cat << EOF >> /etc/network/interfaces
65 auto eth0
66 iface eth0 inet static
67 address $NET_ADDRESS
68 netmask $NET_MASK
69 EOF
70         fi
71
72         # set gateway
73         if [ "x$NET_GW" != "x" ]
74         then
75         echo ".... eth0 - gateway $NET_GW"
76 cat << EOF >> /etc/network/interfaces
77 gateway $NET_GW
78 EOF
79         fi
80
81         # dns search domain
82         if [ "x$NET_SEARCH_DOMAIN" != "x" ]
83         then
84         echo ".... eth0 - search domain $NET_SEARCH_DOMAIN"
85 cat << EOF >> /etc/network/interfaces
86 gateway $NET_SEARCH_DOMAIN
87 EOF
88         fi
89
90         # dns servers
91         if [ "x$NET_DNS_SERVERS" != "x" ]
92         then
93         echo ".... eth0 - dns servers $NET_DNS_SERVERS"
94 cat << EOF >> /etc/network/interfaces
95 gateway $NET_DNS_SERVERS
96 EOF
97         fi
98
99 fi
100
101 # create out gps0
102 echo "Creating serial devices"
103 echo ".... gps0"
104 ln -s /dev/ttyS0 /dev/gps0
105
106
107 # addatch the pps device
108 ldattach pps /dev/ttyS0
109 # find the minor/major numbers of the device and create
110 if [ -f /sys/class/pps/pps*/dev ]
111 then
112         PPSMAJOR=`cat /sys/class/pps/pps*/dev|cut -f1 -d:`
113         PPSMINOR=`cat /sys/class/pps/pps*/dev|cut -f2 -d:`
114         echo ".... pps0"
115         mknod -m 0664 /dev/pps0 c $PPSMAJOR $PPSMINOR
116         echo ".... gpspps0"
117         ln -s /dev/pps0 /dev/gpspps0
118 else
119         echo "Cant find pps device?"
120 fi
121
122 if [ "x$SYSLOG_HOST" != "x" ]
123 then
124         syslogd -R $SYSLOG_HOST
125 fi
126
127 # lastly, work around for thttpd problems
128 mv /var/www/thttpd_config /var/www/thttpd_config.orig
129 cat > /var/www/thttpd_config  << EOF
130 dir=/var/www/data
131 cgipat=**.cgi
132 pidfile=/var/run/thttpd.pid
133 logfile=/dev/null
134 EOF