]> git.ipfire.org Git - ipfire-2.x.git/blame - src/initscripts/system/localnet
unbound: check if red/iface exists before read it
[ipfire-2.x.git] / src / initscripts / system / localnet
CommitLineData
73d9a908
MT
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}
73d9a908 17
cc60329d
AF
18write_resolv_conf() {
19 (
20 [ -n "${DOMAINNAME}" ] && echo "search ${DOMAINNAME}"
21 echo "nameserver 127.0.0.1"
22 ) > /etc/resolv.conf
23}
24
fd52e82a 25write_hosts() {
fd52e82a
MT
26 (
27 echo "127.0.0.1 localhost.localdomain localhost"
fd52e82a
MT
28 ) > /etc/hosts
29}
30
73d9a908
MT
31case "${1}" in
32 start)
97de2cae 33 eval $(/usr/local/bin/readhash /var/ipfire/main/settings)
73d9a908
MT
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
95b87f39
MT
39 boot_mesg "Setting hostname to ${HOSTNAME}.${DOMAINNAME}..."
40 hostname "${HOSTNAME}.${DOMAINNAME}"
4dc82852
MT
41 evaluate_retval
42
fd52e82a
MT
43 # Update hosts
44 write_hosts
45
cc60329d
AF
46 # Update resolv.conf
47 write_resolv_conf
73d9a908
MT
48 ;;
49
50 stop)
51 boot_mesg "Bringing down the loopback interface..."
52 ip link set lo down
53 evaluate_retval
54 ;;
55
56 restart)
57 ${0} stop
58 sleep 1
59 ${0} start
60 ;;
61
62 status)
97de2cae 63 eval $(/usr/local/bin/readhash /var/ipfire/main/settings)
73d9a908
MT
64 echo "Hostname is: $(hostname)"
65 ip link show lo
66 ;;
67
68 *)
69 echo "Usage: ${0} {start|stop|restart|status}"
70 exit 1
71 ;;
72esac
73
74# End $rc_base/init.d/localnet