]> git.ipfire.org Git - ipfire-2.x.git/blame - src/initscripts/system/localnet
Use bash as shebang in network initscripts
[ipfire-2.x.git] / src / initscripts / system / localnet
CommitLineData
73d9a908 1#!/bin/sh
66c36198
PM
2###############################################################################
3# #
4# IPFire.org - A linux based firewall #
5# Copyright (C) 2007-2022 IPFire Team <info@ipfire.org> #
6# #
7# This program is free software: you can redistribute it and/or modify #
8# it under the terms of the GNU General Public License as published by #
9# the Free Software Foundation, either version 3 of the License, or #
10# (at your option) any later version. #
11# #
12# This program is distributed in the hope that it will be useful, #
13# but WITHOUT ANY WARRANTY; without even the implied warranty of #
14# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
15# GNU General Public License for more details. #
16# #
17# You should have received a copy of the GNU General Public License #
18# along with this program. If not, see <http://www.gnu.org/licenses/>. #
19# #
20###############################################################################
73d9a908
MT
21
22. /etc/sysconfig/rc
23. ${rc_functions}
73d9a908 24
cc60329d
AF
25write_resolv_conf() {
26 (
27 [ -n "${DOMAINNAME}" ] && echo "search ${DOMAINNAME}"
28 echo "nameserver 127.0.0.1"
cf7f5004 29 echo "options edns0 trust-ad"
cc60329d
AF
30 ) > /etc/resolv.conf
31}
32
fd52e82a 33write_hosts() {
fd52e82a
MT
34 (
35 echo "127.0.0.1 localhost.localdomain localhost"
fd52e82a
MT
36 ) > /etc/hosts
37}
38
73d9a908
MT
39case "${1}" in
40 start)
97de2cae 41 eval $(/usr/local/bin/readhash /var/ipfire/main/settings)
73d9a908
MT
42 boot_mesg "Bringing up the loopback interface..."
43 ip addr add 127.0.0.1/8 label lo dev lo
44 ip link set lo up
45 evaluate_retval
46
95b87f39
MT
47 boot_mesg "Setting hostname to ${HOSTNAME}.${DOMAINNAME}..."
48 hostname "${HOSTNAME}.${DOMAINNAME}"
4dc82852
MT
49 evaluate_retval
50
fd52e82a
MT
51 # Update hosts
52 write_hosts
53
cc60329d
AF
54 # Update resolv.conf
55 write_resolv_conf
73d9a908
MT
56 ;;
57
58 stop)
59 boot_mesg "Bringing down the loopback interface..."
60 ip link set lo down
61 evaluate_retval
62 ;;
63
64 restart)
65 ${0} stop
66 sleep 1
67 ${0} start
68 ;;
69
70 status)
97de2cae 71 eval $(/usr/local/bin/readhash /var/ipfire/main/settings)
73d9a908
MT
72 echo "Hostname is: $(hostname)"
73 ip link show lo
74 ;;
75
76 *)
77 echo "Usage: ${0} {start|stop|restart|status}"
78 exit 1
79 ;;
80esac