]> git.ipfire.org Git - people/pmueller/ipfire-2.x.git/blame - src/initscripts/init.d/net/common/ipv4-static
kleine Aenderungen in der Gui und ein paar Dateien geloescht
[people/pmueller/ipfire-2.x.git] / src / initscripts / init.d / net / common / ipv4-static
CommitLineData
9c16cd92
MT
1#!/bin/sh
2########################################################################
3# Begin $network_devices/services/ipv4-static
4#
5# Description : IPV4 Static Boot Script
6#
7# Authors : Nathan Coulson - nathan@linuxfromscratch.org
8# Kevin P. Fleming - kpfleming@linuxfromscratch.org
9# Michael Tremer - mitch@ipfire.org
58b1108f 10# Maniacikarus - Maniacikarus@ipfire.org
9c16cd92
MT
11#
12# Version : 00.00
13#
14# Notes :
15#
16########################################################################
17
18. /etc/sysconfig/rc
19. ${rc_functions}
20eval $(/usr/local/bin/readhash /var/ipfire/ethernet/settings)
21
22if [ -z "${BROADCAST}" ]; then
23 boot_mesg "BROADCAST variable missing from input, cannot continue." ${FAILURE}
24 echo_failure
25 exit 1
26fi
27
28if [ -n "${ADDRESS}" -a -n "${NETMASK}" ]; then
29 PREFIX=`whatmask ${NETMASK} | grep -e ^CIDR | awk -F': ' '{ print $2 }' | cut -c 2-`
30 args="${args} ${ADDRESS}/${PREFIX} broadcast ${BROADCAST}"
31else
32 boot_mesg "ADDRESS and/or NETMASK variable missing from input, cannot continue." ${FAILURE}
33 echo_failure
34 exit 1
35fi
36
37case "${2}" in
38 up)
39 boot_mesg "Adding IPv4 address ${ADDRESS} to the ${1} interface..."
40 ip addr add ${args} dev ${1}
41 evaluate_retval
42
43 if [ -n "${GATEWAY}" ]; then
44 if ip route | grep -q default; then
45 boot_mesg "Gateway already setup; skipping." ${WARNING}
46 echo_warning
58b1108f
CS
47 elif [ "${CONFIG_TYPE}" == "0" ] || [ "${CONFIG_TYPE}" == "" ] && [ "${GATEWAY}" != "" ]; then
48 boot_mesg "Setting up default gateway for green only..."
49 ip route add default via ${GATEWAY} dev ${1}
50 evaluate_retval
51 if [ "${DNS1}" != "" ];then
52 boot_mesg "Registering DNS Server for green only..."
53 echo "nameserver $DNS1" > /etc/resolv.conf
54 fi
55 if [ "${DNS2}" != "" ];then
56 echo "nameserver $DNS2" >> /etc/resolv.conf
57 fi
9c16cd92
MT
58 else
59 boot_mesg "Setting up default gateway..."
f3770039 60 echo $DEFAULT_GATEWAY > /var/ipfire/red/remote-ipaddress
9c16cd92
MT
61 ip route add default via ${GATEWAY} dev ${1}
62 evaluate_retval
f3770039
MT
63 boot_mesg "Registering DNS server..."
64 echo $DNS1 > /var/ipfire/red/dns1
65 echo $DNS2 > /var/ipfire/red/dns2
66 echo $ADDRESS > /var/ipfire/red/local-ipaddress
67 evaluate_retval
68 fi
9c16cd92
MT
69 fi
70 ;;
71
72 down)
73 if [ -n "${GATEWAY}" ]; then
74 boot_mesg "Removing default gateway..."
75 ip route del default
76 evaluate_retval
77 fi
a56b5be4
CS
78
79 if [ "${CONFIG_TYPE}" == "0" ] || [ "${CONFIG_TYPE}" == "" ]; then
80 boot_mesg "Restoring default DNS Proxy Adress in resolv.conf..."
81 echo "nameserver 127.0.0.1" > /etc/resolv.conf
82 fi
83
9c16cd92
MT
84 boot_mesg "Removing IPv4 address ${ADDRESS} from the ${1} interface..."
85 ip addr del ${args} dev ${1}
86 evaluate_retval
87 ;;
88
89 *)
90 echo "Usage: ${0} [interface] {up|down}"
91 exit 1
92 ;;
93esac
94
95# End $network_devices/services/ipv4-static