changed startup for a few little things
[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 # bring the interface up for a bit
41 ifconfig eth0 up
42
43 # create the interfaces layout
44 echo "Setting up network interfaces configuration"
45 echo ".... loopback"
46 cat << EOF > /etc/network/interfaces
47 auto lo
48 iface lo inet loopback
49
50 EOF
51
52 # create network interfaces bit
53 if [ "x$INTERFACE" == "xdhcp" ]
54 then
55 echo ".... eth0 - dhcp"
56 cat << EOF >> /etc/network/interfaces
57 auto eth0
58 iface eth0 inet dhcp
59 EOF
60
61 else
62         # static network address
63         if [ "x$NET_ADDRESS" != "x" ]
64         then
65
66         echo ".... eth0 - static $NET_ADDRESS - $NET_MASK"
67 cat << EOF >> /etc/network/interfaces
68 auto eth0
69 iface eth0 inet static
70 address $NET_ADDRESS
71 netmask $NET_MASK
72 EOF
73         fi
74
75         # set gateway
76         if [ "x$NET_GW" != "x" ]
77         then
78         echo ".... eth0 - gateway $NET_GW"
79 cat << EOF >> /etc/network/interfaces
80 gateway $NET_GW
81 EOF
82         fi
83
84         # dns search domain
85         if [ "x$NET_SEARCH_DOMAIN" != "x" ]
86         then
87         echo ".... eth0 - search domain $NET_SEARCH_DOMAIN"
88 cat << EOF >> /etc/network/interfaces
89 dns-search $NET_SEARCH_DOMAIN
90 EOF
91         fi
92
93         # dns servers
94         if [ "x$NET_DNS_SERVERS" != "x" ]
95         then
96         echo ".... eth0 - dns servers $NET_DNS_SERVERS"
97 cat << EOF >> /etc/network/interfaces
98 dns-nameservers $NET_DNS_SERVERS
99 EOF
100         fi
101
102 fi
103
104 # create out gps0
105 echo "Creating serial devices"
106 echo ".... gps0"
107 ln -s /dev/ttyS0 /dev/gps0
108
109
110 # addatch the pps device
111 ldattach pps /dev/ttyS0
112 # find the minor/major numbers of the device and create
113 if [ -f /sys/class/pps/pps0/dev ]
114 then
115         PPSMAJOR=`cat /sys/class/pps/pps0/dev|cut -f1 -d:`
116         PPSMINOR=`cat /sys/class/pps/pps0/dev|cut -f2 -d:`
117         echo ".... pps0"
118         mknod -m 0664 /dev/pps0 c $PPSMAJOR $PPSMINOR
119         echo ".... gpspps0"
120         ln -s /dev/pps0 /dev/gpspps0
121 else
122         echo "Cant find pps device?"
123 fi
124
125 if [ "x$SYSLOG_HOST" != "x" ]
126 then
127         syslogd -R $SYSLOG_HOST
128 fi
129
130 # lastly, work around for thttpd problems
131 mv /var/www/thttpd_config /var/www/thttpd_config.orig
132 cat > /var/www/thttpd_config  << EOF
133 dir=/var/www/data
134 cgipat=**.cgi
135 pidfile=/var/run/thttpd.pid
136 logfile=/dev/null
137 EOF