aboutsummaryrefslogtreecommitdiffstats
path: root/packages/openslug-init/openslug-init-0.10/sysconfsetup
blob: f048dfc9bc19e4e17121e3555d87292b11b765a4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#!/bin/sh
if [ ! -e /etc/linksysconf ]
then

#  Ok this may be a little hack for now
#  but Make sure the kernel module info is updated
#  So the driver can actually load the first time
   /usr/sbin/update-modules

   dd if=/dev/mtdblock1 of=/etc/linksysconf
   cat <<EOF > /etc/original-network-settings
# /etc/network/interfaces -- configuration file for ifup(8), ifdown(8)

# The loopback interface
auto lo
iface lo inet loopback

auto eth0
iface eth0 inet static
EOF

   # Use the bootproto key to set "static" or "dhcp", then do other stuff based on that.
   # strings /etc/linksysconf | grep bootproto >> /etc/original-network-settings
   # sed -i -e 's/bootproto=//' /etc/original-network-settings

   strings /etc/linksysconf | grep ip_addr >> /etc/original-network-settings
   strings /etc/linksysconf | grep ^netmask >> /etc/original-network-settings
   strings /etc/linksysconf | grep ^gateway=. >> /etc/original-network-settings
   strings /etc/linksysconf | grep hw_addr >> /etc/original-network-settings
   sed -i -e 's/ip_addr=/        address /' /etc/original-network-settings
   sed -i -e 's/netmask=/        netmask /' /etc/original-network-settings
   sed -i -e 's/gateway=/        gateway /' /etc/original-network-settings
   sed -i -e 's/hw_addr=/        hwaddress ether /' /etc/original-network-settings

   mv /etc/network/interfaces /etc/network/interfaces.old
   cp /etc/original-network-settings /etc/network/interfaces

   echo "Configured /etc/network/interfaces from /etc/linksysconf"

   strings /etc/linksysconf | grep disk_server_name >> /tmp/hostname
   sed -i -e 's/disk_server_name=//' /tmp/hostname

   if [ -s /tmp/hostname ] ; then
       mv /etc/hostname /etc/hostname.old
       mv /tmp/hostname /etc/hostname
       echo "Configured /etc/hostname from /etc/linksysconf"
   fi

   strings /etc/linksysconf | grep dns_server1 >> /tmp/resolv.conf
   sed -i -e 's/dns_server1=/nameserver /' /tmp/resolv.conf

   if [ -s /tmp/resolv.conf ] ; then
       mv /etc/resolv.conf /etc/resolv.conf.old
       mv /tmp/resolv.conf /etc/resolv.conf
       echo "Configured /etc/resolv.conf from /etc/linksysconf"
   fi

fi

# Module loading handled more properly by update-modules and modprobe.conf