]> git.ipfire.org Git - ipfire-2.x.git/blame - src/initscripts/system/localnet
Fix merge conflicts during merge of next and the suricata branch
[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
39 boot_mesg "Setting hostname to ${HOSTNAME}..."
242cfc33 40 hostname "${HOSTNAME}"
4dc82852
MT
41 evaluate_retval
42
242cfc33 43 if [ -n "${DOMAINNAME}" ]; then
4dc82852 44 boot_mesg "Setting domainname to ${DOMAINNAME}..."
242cfc33 45 domainname "${DOMAINNAME}"
4dc82852 46 evaluate_retval
c78a77eb 47 fi
cc60329d 48
fd52e82a
MT
49 # Update hosts
50 write_hosts
51
cc60329d
AF
52 # Update resolv.conf
53 write_resolv_conf
73d9a908
MT
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)
97de2cae 69 eval $(/usr/local/bin/readhash /var/ipfire/main/settings)
73d9a908
MT
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 ;;
78esac
79
80# End $rc_base/init.d/localnet