]> git.ipfire.org Git - ipfire-2.x.git/blob - src/initscripts/system/localnet
localnet: Don't write local hostname to /etc/hosts
[ipfire-2.x.git] / src / initscripts / system / localnet
1 #!/bin/sh
2 ########################################################################
3 # Begin $rc_base/init.d/localnet
4 #
5 # Description : Loopback device
6 #
7 # Authors : Gerard Beekmans - gerard@linuxfromscratch.org
8 #
9 # Version : 00.00
10 #
11 # Notes :
12 #
13 ########################################################################
14
15 . /etc/sysconfig/rc
16 . ${rc_functions}
17
18 write_resolv_conf() {
19 (
20 [ -n "${DOMAINNAME}" ] && echo "search ${DOMAINNAME}"
21 echo "nameserver 127.0.0.1"
22 ) > /etc/resolv.conf
23 }
24
25 write_hosts() {
26 (
27 echo "127.0.0.1 localhost.localdomain localhost"
28 ) > /etc/hosts
29 }
30
31 case "${1}" in
32 start)
33 eval $(/usr/local/bin/readhash /var/ipfire/main/settings)
34 boot_mesg "Bringing up the loopback interface..."
35 ip addr add 127.0.0.1/8 label lo dev lo
36 ip link set lo up
37 evaluate_retval
38
39 boot_mesg "Setting hostname to ${HOSTNAME}..."
40 hostname ${HOSTNAME}
41 evaluate_retval
42
43 if [ -z "$DOMAINNAME" ]; then
44 boot_mesg "Setting domainname to ${DOMAINNAME}..."
45 domainname ${DOMAINNAME}
46 evaluate_retval
47 fi
48
49 # Update hosts
50 write_hosts
51
52 # Update resolv.conf
53 write_resolv_conf
54 ;;
55
56 stop)
57 boot_mesg "Bringing down the loopback interface..."
58 ip link set lo down
59 evaluate_retval
60 ;;
61
62 restart)
63 ${0} stop
64 sleep 1
65 ${0} start
66 ;;
67
68 status)
69 eval $(/usr/local/bin/readhash /var/ipfire/main/settings)
70 echo "Hostname is: $(hostname)"
71 ip link show lo
72 ;;
73
74 *)
75 echo "Usage: ${0} {start|stop|restart|status}"
76 exit 1
77 ;;
78 esac
79
80 # End $rc_base/init.d/localnet