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