]> git.ipfire.org Git - ipfire-2.x.git/blob - src/initscripts/system/localnet
Various rootfile fixes
[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 case "${1}" in
26 start)
27 eval $(/usr/local/bin/readhash /var/ipfire/main/settings)
28 boot_mesg "Bringing up the loopback interface..."
29 ip addr add 127.0.0.1/8 label lo dev lo
30 ip link set lo up
31 evaluate_retval
32
33 boot_mesg "Setting hostname to ${HOSTNAME}..."
34 hostname ${HOSTNAME}
35 evaluate_retval
36
37 if [ -z "$DOMAINNAME" ]; then
38 boot_mesg "Setting domainname to ${DOMAINNAME}..."
39 domainname ${DOMAINNAME}
40 evaluate_retval
41 fi
42
43 # Update resolv.conf
44 write_resolv_conf
45 ;;
46
47 stop)
48 boot_mesg "Bringing down the loopback interface..."
49 ip link set lo down
50 evaluate_retval
51 ;;
52
53 restart)
54 ${0} stop
55 sleep 1
56 ${0} start
57 ;;
58
59 status)
60 eval $(/usr/local/bin/readhash /var/ipfire/main/settings)
61 echo "Hostname is: $(hostname)"
62 ip link show lo
63 ;;
64
65 *)
66 echo "Usage: ${0} {start|stop|restart|status}"
67 exit 1
68 ;;
69 esac
70
71 # End $rc_base/init.d/localnet