summaryrefslogtreecommitdiffstats
path: root/initrd/initrd-stuff/bin/dhcpmkconfig
blob: b6c436a6cc8e5b04ed3efa1fa010393f87706bca (plain) (blame)
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
#!/bin/sh
#
# Description:  universal (distro independent) IP configuration writer for 
#		several dhcp clients. The result is written in unified form
#		to the /etc/machine-setup file
#
# Author(s):    Dirk von Suchodoletz <dirk@goe.net>, 26-03-2006
#
# Copyright:    (c) 2006 - RZ Universitaet Freiburg

# client variable should be exported via calling function
echo -e "\n# ip configuration written by $0" \
  >>/etc/machine-setup
case $0 in
  *dhcpcd*)
    sed -e "s,',\",g;s,IPADDR,clientip,;s,NETMASK,subnet_mask," \
      -e "s,GATEWAY,gateway,;s,BROADCAST,broadcast_address," \
      -e "s,HOSTNAME,host_name,;s,DOMAIN,domain_name," \
      -e "s,ROOTPATH,root_path,;s,DNS,domain_name_servers," \
      -e "s,NTPSERVERS,ntp_servers,;s,DHCPSID,serverip," \
      -e "s,WINSSERVERS,netbios_name_servers," \
      -e "s,NETWORK,network," \
      -e "s,DHCP..ADDR.*,,;s,.*TIME=.*,,;s,CL.*,,;/^$/d" \
      -e "s,INTER.*,,;s,DHCPSNAME.*,," /var/lib/dhcp/dhcpcd-eth0.info \
        >>/etc/machine-setup
  ;;
  *dhclient*)
    set | sed -n -e '/^new/p' | sed \
      -e "s,^new_,,;s,fixed_address,clientip," \
      -e "s,routers,gateway,;s,dhcp_server_identifier,serverip," \
      -e "s,.*_t[iy][mp]e.*,,;s,.*_message_.*,,;/^$/d" \
      -e "s,language=,country=,;s,ip_address,clientip," \
        >>/etc/machine-setup
  ;;
  *pump*)
    #
  ;;
esac