From d1e90efcaaed4ba1b39a92db863afeb35eb15344 Mon Sep 17 00:00:00 2001 From: ms Date: Tue, 14 Aug 2007 17:58:31 +0000 Subject: [PATCH] Neue und hoffentlich bessere Scripte fuer die Verwaltung der vielen Netzwerkschnittstellen... git-svn-id: http://svn.ipfire.org/svn/ipfire/trunk@765 ea5c0bd1-69bd-2848-81d8-4f18e57aeed8 --- config/rootfiles/common/coreutils | 2 +- config/rootfiles/common/startscripts | 22 -- doc/packages-list.txt | 1 + lfs/initscripts | 44 ++- src/initscripts/init.d/beep | 14 +- src/initscripts/init.d/dnsmasq | 51 +++ src/initscripts/init.d/net/common/dhcpcd | 138 --------- src/initscripts/init.d/net/common/ipv4-static | 95 ------ src/initscripts/init.d/net/ifdown | 83 ----- src/initscripts/init.d/net/ifup | 100 ------ src/initscripts/init.d/net/red/isdn | 70 ----- src/initscripts/init.d/net/red/pppoe | 129 -------- src/initscripts/init.d/net/red/update | 118 ------- src/initscripts/init.d/network | 275 +++++++---------- src/initscripts/init.d/networking/any | 93 ++++++ src/initscripts/init.d/networking/red | 291 ++++++++++++++++++ .../init.d/networking/red.down/10-ipsec | 3 + .../init.d/networking/red.up/10-multicast | 7 + .../init.d/networking/red.up/30-ddns | 3 + .../init.d/networking/red.up/40-ipac | 5 + .../init.d/networking/red.up/50-ipsec | 6 + src/paks/alsa/install.sh | 6 +- src/ppp/ip-down | 35 +-- src/ppp/ip-up | 70 ++--- 24 files changed, 644 insertions(+), 1017 deletions(-) delete mode 100644 config/rootfiles/common/startscripts create mode 100644 src/initscripts/init.d/dnsmasq delete mode 100644 src/initscripts/init.d/net/common/dhcpcd delete mode 100644 src/initscripts/init.d/net/common/ipv4-static delete mode 100644 src/initscripts/init.d/net/ifdown delete mode 100644 src/initscripts/init.d/net/ifup delete mode 100644 src/initscripts/init.d/net/red/isdn delete mode 100644 src/initscripts/init.d/net/red/pppoe delete mode 100644 src/initscripts/init.d/net/red/update create mode 100644 src/initscripts/init.d/networking/any create mode 100644 src/initscripts/init.d/networking/red create mode 100644 src/initscripts/init.d/networking/red.down/10-ipsec create mode 100644 src/initscripts/init.d/networking/red.up/10-multicast create mode 100644 src/initscripts/init.d/networking/red.up/30-ddns create mode 100644 src/initscripts/init.d/networking/red.up/40-ipac create mode 100644 src/initscripts/init.d/networking/red.up/50-ipsec diff --git a/config/rootfiles/common/coreutils b/config/rootfiles/common/coreutils index 50399d540..22094c7e2 100644 --- a/config/rootfiles/common/coreutils +++ b/config/rootfiles/common/coreutils @@ -73,7 +73,7 @@ usr/bin/test usr/bin/touch usr/bin/tr #usr/bin/tsort -#usr/bin/tty +usr/bin/tty usr/bin/unexpand usr/bin/uniq usr/bin/unlink diff --git a/config/rootfiles/common/startscripts b/config/rootfiles/common/startscripts deleted file mode 100644 index 518e71d49..000000000 --- a/config/rootfiles/common/startscripts +++ /dev/null @@ -1,22 +0,0 @@ -etc/init.d -#etc/init.d/applejuice -#etc/init.d/asterisk -#etc/init.d/cups -#etc/init.d/cyrus-sasl -#etc/init.d/gnump3d -#etc/init.d/init-functions -#etc/init.d/nfs-server -#etc/init.d/postfix -#etc/init.d/samba -#etc/init.d/winbind -#etc/init.d/xinetd -#usr/local/bin/rcapplejuice -#usr/local/bin/rcasterisk -#usr/local/bin/rccups -#usr/local/bin/rccyrus-sasl -#usr/local/bin/rcgnump3d -#usr/local/bin/rcnfs-server -#usr/local/bin/rcpostfix -#usr/local/bin/rcsamba -#usr/local/bin/rcwinbind -#usr/local/bin/rcxinetd diff --git a/doc/packages-list.txt b/doc/packages-list.txt index c272b2667..abeb3313c 100644 --- a/doc/packages-list.txt +++ b/doc/packages-list.txt @@ -157,6 +157,7 @@ * libxml2-2.6.26 * libxslt-1.1.17 * linux-2.6.16.50 +* linux-2.6.16.53 * linux-atm-2.4.1 * linux-libc-headers-2.6.12.0 * linuxigd-0.95 diff --git a/lfs/initscripts b/lfs/initscripts index 6239d51a5..9a773e4f1 100644 --- a/lfs/initscripts +++ b/lfs/initscripts @@ -55,9 +55,9 @@ $(TARGET) : install -d -m 755 /etc/rc.d/rc6.d install -d -m 755 /etc/rc.d/rcsysinit.d install -d -m 755 /etc/rc.d/init.d - install -d -m 755 /etc/rc.d/init.d/net - install -d -m 755 /etc/rc.d/init.d/net/common - install -d -m 755 /etc/rc.d/init.d/net/red + install -d -m 755 /etc/rc.d/init.d/networking + install -d -m 755 /etc/rc.d/init.d/networking/red.up + install -d -m 755 /etc/rc.d/init.d/networking/red.down install -d -m 755 /etc/rc.d/helper install -d -m 755 /etc/sysconfig -rm -rf /etc/init.d @@ -68,18 +68,18 @@ $(TARGET) : done chmod 644 /etc/rc.d/init.d/functions - for i in $(DIR_SRC)/src/initscripts/init.d/net/*; do \ + for i in $(DIR_SRC)/src/initscripts/init.d/networking/*; do \ if [ -f $$i ]; then \ - install -v -m 754 $$i /etc/rc.d/init.d/net/; \ + install -v -m 754 $$i /etc/rc.d/init.d/networking/; \ fi; \ done - for i in $(DIR_SRC)/src/initscripts/init.d/net/common/*; do \ - install -v -m 754 $$i /etc/rc.d/init.d/net/common/; \ + for i in $(DIR_SRC)/src/initscripts/init.d/networking/red.up/*; do \ + install -v -m 754 $$i /etc/rc.d/init.d/networking/red.up/; \ done - for i in $(DIR_SRC)/src/initscripts/init.d/net/red/*; do \ - install -v -m 754 $$i /etc/rc.d/init.d/net/red/; \ + for i in $(DIR_SRC)/src/initscripts/init.d/networking/red.down/*; do \ + install -v -m 754 $$i /etc/rc.d/init.d/networking/red.down/; \ done for i in $(DIR_SRC)/src/initscripts/sysconfig/*; do \ @@ -131,7 +131,27 @@ $(TARGET) : ln -sf ../init.d/console /etc/rc.d/rcsysinit.d/S70console ln -sf ../init.d/localnet /etc/rc.d/rcsysinit.d/S80localnet ln -sf ../init.d/sysctl /etc/rc.d/rcsysinit.d/S90sysctl - - chgrp nobody /etc/rc.d/init.d/red - chmod 4750 /etc/rc.d/init.d/red + + ln -sf ../../dnsmasq /etc/rc.d/init.d/networking/red.up/05-RS-dnsmasq + ln -sf ../../firewall /etc/rc.d/init.d/networking/red.up/20-RL-firewall + ln -sf ../../../../../usr/local/bin/setfilters \ + /etc/rc.d/init.d/networking/red.up/21-setfilters + ln -sf ../../../../../usr/local/bin/outgoingfwctrl \ + /etc/rc.d/init.d/networking/red.up/22-outgoingfwctrl + ln -sf ../../../../../usr/local/bin/snortctrl \ + /etc/rc.d/init.d/networking/red.up/23-RS-snort + ln -sf ../../../../../usr/local/bin/qosctrl \ + /etc/rc.d/init.d/networking/red.up/24-RS-qos + ln -sf ../../../../../usr/local/bin/setportfw \ + /etc/rc.d/init.d/networking/red.up/25-portfw + ln -sf ../../../../../usr/local/bin/setxtaccess \ + /etc/rc.d/init.d/networking/red.up/26-xtaccess + + ln -sf ../../dnsmasq /etc/rc.d/init.d/networking/red.down/05-RS-dnsmasq + ln -sf ../../firewall /etc/rc.d/init.d/networking/red.down/20-RL-firewall + + for i in green blue orange; do \ + ln -sf any /etc/rc.d/init.d/networking/$$i; \ + done + @$(POSTBUILD) diff --git a/src/initscripts/init.d/beep b/src/initscripts/init.d/beep index 971605f55..cee6548e3 100644 --- a/src/initscripts/init.d/beep +++ b/src/initscripts/init.d/beep @@ -36,9 +36,21 @@ case "${1}" in play $i done ;; + + up) + for i in 440 622 880; do + play $i + done + ;; + + down) + for i in 880 622 440; do + play $i + done + ;; *) - echo "Usage: ${0} {start|stop}" + echo "Usage: ${0} {start|stop|up|down}" exit 1 ;; esac diff --git a/src/initscripts/init.d/dnsmasq b/src/initscripts/init.d/dnsmasq new file mode 100644 index 000000000..29a59d3ea --- /dev/null +++ b/src/initscripts/init.d/dnsmasq @@ -0,0 +1,51 @@ +#!/bin/sh +######################################################################## +# Begin $rc_base/init.d/dnsmasq +# +# Description : dnsmasq init script +# +# Authors : Michael Tremer - mitch@ipfire.org +# +# Version : 01.00 +# +# Notes : +# +######################################################################## + +. /etc/sysconfig/rc +. ${rc_functions} + +case "${1}" in + start) + boot_mesg "Starting Domain Name Service Proxy..." + + eval $(/usr/local/bin/readhash /var/ipfire/ethernet/settings) + ARGS= + [ "$DOMAIN_NAME_GREEN" == "" ] && ARGS="-s $DOMAIN_NAME_GREEN " + [ -e "/var/ipfire/red/active" ] && ARGS+="-r /var/ipfire/red/resolv.conf" + + loadproc /usr/sbin/dnsmasq -l /var/state/dhcp/dhcpd.leases $ARGS + ;; + + stop) + boot_mesg "Stopping Domain Name Service Proxy..." + killproc /usr/sbin/dnsmasq + ;; + + restart) + ${0} stop + sleep 1 + ${0} start + ;; + + status) + statusproc /usr/sbin/dnsmasq + ;; + + *) + echo "Usage: ${0} {start|stop|restart|status}" + exit 1 + ;; +esac + +# End $rc_base/init.d/dnsmasq diff --git a/src/initscripts/init.d/net/common/dhcpcd b/src/initscripts/init.d/net/common/dhcpcd deleted file mode 100644 index b96f06c89..000000000 --- a/src/initscripts/init.d/net/common/dhcpcd +++ /dev/null @@ -1,138 +0,0 @@ -#!/bin/sh -# Begin $network-devices/services/dhcpcd - -# Based upon lfs-bootscripts-1.12 $network_devices/if{down,up} -# Rewritten by Nathan Coulson -# Adapted for dhcpcd by DJ Lucas -# Made compatible for ipfire by Michael Tremer mitch@ipfire.org - -. /etc/sysconfig/rc -. $rc_functions - -PIDFILE="/var/run/dhcpcd-$1.pid" -LEASEINFO="/var/ipfire/dhcpc/dhcpcd-$1.info" - -case "$2" in - up) - boot_mesg -n "Starting dhcpcd on the $1 interface..." - echo -n "${1}" > /var/ipfire/red/iface - - # Test to see if there is a stale pid file - if [ -f "$PIDFILE" ] - then - ps `cat "$PIDFILE"` | grep dhcpcd > /dev/null - if [ $? != 0 ] - then - rm -f /var/run/dhcpcd-$1.pid > /dev/null - else - boot_mesg "dhcpcd already running!" ${WARNING} - echo_warning - exit 2 - fi - fi - if [ "$NAME" == "red" ]; then - /sbin/iptables -A REDINPUT -p tcp --source-port 67 --destination-port 68 -i ${1} -j ACCEPT - /sbin/iptables -A REDINPUT -p udp --source-port 67 --destination-port 68 -i ${1} -j ACCEPT - fi - - DHCP_START="-N -R -L /var/ipfire/dhcpc -c /var/ipfire/dhcpc/dhcpcd.exe " - - if [ -n "${DHCP_HOSTNAME}" ]; then - DHCP_START+="-h ${DHCP_HOSTNAME} " - fi - /sbin/dhcpcd $1 $DHCP_START >/dev/null 2>&1 - # Save the return value - RET="$?" - # Print the assigned settings if requested - if [ "$RET" = "0" -a "$PRINTIP" = "yes" ]; then - . /var/ipfire/dhcpc/dhcpcd-$1.info - logger -t ipfire "DHCPCD Success" - if [ "$PRINTALL" = "yes" ]; then - echo "" - echo_ok - boot_mesg " DHCP Assigned Settings for ${1}:" - boot_mesg_flush - boot_mesg " IP Address: $IPADDR" - boot_mesg_flush - if [ -n "${DHCP_HOSTNAME}" ]; then - boot_mesg " Hostname: $DHCP_HOSTNAME" - boot_mesg_flush - fi - boot_mesg " Subnet Mask: $NETMASK" - boot_mesg_flush - boot_mesg " Default Gateway: $GATEWAY" - boot_mesg_flush - boot_mesg " DNS Server: $DNS" - boot_mesg_flush - else - boot_mesg " IP Addresss: ""$IPADDR" - echo_ok - fi - if [ "$DNS1" = "" ]; then - echo -n `/etc/rc.d/helper/getdnsfromdhcpc.pl 1` > /var/ipfire/red/dns1 - echo -n `/etc/rc.d/helper/getdnsfromdhcpc.pl 2` > /var/ipfire/red/dns2 - else - echo "$DNS1" > /var/ipfire/red/dns1 - echo "$DNS2" > /var/ipfire/red/dns2 - fi - . /var/ipfire/dhcpc/dhcpcd-${1}.info - echo "$IPADDR" > /var/ipfire/red/local-ipaddress - echo "$GATEWAY" > /var/ipfire/red/remote-ipaddress - else - echo "" - logger -t ipfire "DHCPCD Fail" - $(exit "$RET") - evaluate_retval - fi - ;; - - down) - boot_mesg -n "Stopping dhcpcd on the $1 interface..." - # Do nothing with the client daemon if we have an infinate - # lease time as the client exits when started in this case, - # just echo OK. - DHCP_STOP="-k -c /var/ipfire/dhcpc/dhcpcd.exe " - if [ -e $LEASEINFO ] - then - . $LEASEINFO - - if [ "$LEASETIME" = "4294967295" ] - then - # do nothing, just echo ok - echo "" - echo_ok - else - if [ -n "$DHCP_STOP" ] - then - /sbin/dhcpcd $1 $DHCP_STOP &> /dev/null - RET="$?" - if [ "$RET" -eq 0 ]; then - echo "" - echo_ok - elif [ "$RET" -eq 1 ]; then - boot_mesg "dhcpcd not running!" ${WARNING} - echo_warning - else - echo "" - echo_failure - fi - else - echo "" - killproc dhcpcd - fi - fi - else - boot_mesg -n "LEASEINFO Test failed! - " ${WARNING} - boot_mesg "dhcpcd is not running!" ${WARNING} - echo_warning - exit 1 - fi - ;; - - *) - echo "Usage: $0 [interface] {up|down}" - exit 1 - ;; -esac - -# End $network_devices/services/dhcpcd diff --git a/src/initscripts/init.d/net/common/ipv4-static b/src/initscripts/init.d/net/common/ipv4-static deleted file mode 100644 index 62a131037..000000000 --- a/src/initscripts/init.d/net/common/ipv4-static +++ /dev/null @@ -1,95 +0,0 @@ -#!/bin/sh -######################################################################## -# Begin $network_devices/services/ipv4-static -# -# Description : IPV4 Static Boot Script -# -# Authors : Nathan Coulson - nathan@linuxfromscratch.org -# Kevin P. Fleming - kpfleming@linuxfromscratch.org -# Michael Tremer - mitch@ipfire.org -# Maniacikarus - Maniacikarus@ipfire.org -# -# Version : 00.00 -# -# Notes : -# -######################################################################## - -. /etc/sysconfig/rc -. ${rc_functions} -eval $(/usr/local/bin/readhash /var/ipfire/ethernet/settings) - -if [ -z "${BROADCAST}" ]; then - boot_mesg "BROADCAST variable missing from input, cannot continue." ${FAILURE} - echo_failure - exit 1 -fi - -if [ -n "${ADDRESS}" -a -n "${NETMASK}" ]; then - PREFIX=`whatmask ${NETMASK} | grep -e ^CIDR | awk -F': ' '{ print $2 }' | cut -c 2-` - args="${args} ${ADDRESS}/${PREFIX} broadcast ${BROADCAST}" -else - boot_mesg "ADDRESS and/or NETMASK variable missing from input, cannot continue." ${FAILURE} - echo_failure - exit 1 -fi - -case "${2}" in - up) - boot_mesg "Adding IPv4 address ${ADDRESS} to the ${1} interface..." - ip addr add ${args} dev ${1} - evaluate_retval - - if [ -n "${GATEWAY}" ]; then - if ip route | grep -q default; then - boot_mesg "Gateway already setup; skipping." ${WARNING} - echo_warning - elif [ "${CONFIG_TYPE}" == "0" ] || [ "${CONFIG_TYPE}" == "" ] && [ "${GATEWAY}" != "" ]; then - boot_mesg "Setting up default gateway for green only..." - ip route add default via ${GATEWAY} dev ${1} - evaluate_retval - if [ "${DNS1}" != "" ];then - boot_mesg "Registering DNS Server for green only..." - echo "nameserver $DNS1" > /etc/resolv.conf - fi - if [ "${DNS2}" != "" ];then - echo "nameserver $DNS2" >> /etc/resolv.conf - fi - else - boot_mesg "Setting up default gateway..." - echo $DEFAULT_GATEWAY > /var/ipfire/red/remote-ipaddress - ip route add default via ${GATEWAY} dev ${1} - evaluate_retval - boot_mesg "Registering DNS server..." - echo $DNS1 > /var/ipfire/red/dns1 - echo $DNS2 > /var/ipfire/red/dns2 - echo $ADDRESS > /var/ipfire/red/local-ipaddress - evaluate_retval - fi - fi - ;; - - down) - if [ -n "${GATEWAY}" ]; then - boot_mesg "Removing default gateway..." - ip route del default - evaluate_retval - fi - - if [ "${CONFIG_TYPE}" == "0" ] || [ "${CONFIG_TYPE}" == "" ]; then - boot_mesg "Restoring default DNS Proxy Adress in resolv.conf..." - echo "nameserver 127.0.0.1" > /etc/resolv.conf - fi - - boot_mesg "Removing IPv4 address ${ADDRESS} from the ${1} interface..." - ip addr del ${args} dev ${1} - evaluate_retval - ;; - - *) - echo "Usage: ${0} [interface] {up|down}" - exit 1 - ;; -esac - -# End $network_devices/services/ipv4-static diff --git a/src/initscripts/init.d/net/ifdown b/src/initscripts/init.d/net/ifdown deleted file mode 100644 index a24d1e0ec..000000000 --- a/src/initscripts/init.d/net/ifdown +++ /dev/null @@ -1,83 +0,0 @@ -#!/bin/sh -######################################################################## -# Begin $network_devices/ifdown -# -# Description : Interface Down -# -# Authors : Nathan Coulson - nathan@linuxfromscratch.org -# Kevin P. Fleming - kpfleming@linuxfromscratch.org -# Michael Tremer - mitch@ipfire.org -# -# Version : 01.00 -# -# Notes : -# -######################################################################## - -. /etc/sysconfig/rc -. ${rc_functions} -eval $(/usr/local/bin/readhash /var/ipfire/ethernet/settings) - -if [ "$name" == "green" ]; then - DEVICE="${GREEN_DEV}" -elif [ "$name" == "blue" ]; then - DEVICE="${BLUE_DEV}" -elif [ "$name" == "orange" ]; then - DEVICE="${ORANGE_DEV}" -elif [ "$name" == "red" ]; then - DEVICE="${RED_DEV}" -fi - -if ip link show ${DEVICE} > /dev/null 2>&1 -then - if [ "$name" == "green" ]; then - NAME=${name} ADDRESS=${GREEN_ADDRESS} NETMASK=${GREEN_NETMASK}\ - NETADDRESS=${GREEN_NETADDRESS} BROADCAST=${GREEN_BROADCAST} \ - /etc/rc.d/init.d/net/common/ipv4-static ${GREEN_DEV} down - - elif [ "$name" == "blue" ]; then - NAME=${name} ADDRESS=${BLUE_ADDRESS} NETMASK=${BLUE_NETMASK}\ - NETADDRESS=${BLUE_NETADDRESS} BROADCAST=${BLUE_BROADCAST} \ - /etc/rc.d/init.d/net/common/ipv4-static ${BLUE_DEV} down - - elif [ "$name" == "orange" ]; then - NAME=${name} ADDRESS=${ORANGE_ADDRESS} NETMASK=${ORANGE_NETMASK}\ - NETADDRESS=${ORANGE_NETADDRESS} BROADCAST=${ORANGE_BROADCAST} \ - /etc/rc.d/init.d/net/common/ipv4-static ${ORANGE_DEV} down - - elif [ "$name" == "red" ]; then - if [ "${RED_TYPE}" == "PPPOE" ]; then - NAME=${name} /etc/rc.d/init.d/net/red/pppoe ${RED_DEV} down - elif [ "${RED_TYPE}" == "PPTP" ]; then - echo - elif [ "${RED_TYPE}" == "DHCP" ]; then - NAME=${name} DHCP_HOSTNAME=${RED_DHCP_HOSTNAME} \ - PRINTIP=yes PRINTALL=yes \ - /etc/rc.d/init.d/net/common/dhcpcd ${RED_DEV} down - elif [ "${RED_TYPE}" == "STATIC" ]; then - NAME=${name} ADDRESS=${RED_ADDRESS} NETMASK=${RED_NETMASK}\ - NETADDRESS=${RED_NETADDRESS} BROADCAST=${RED_BROADCAST} \ - DNS1=${DNS1} DNS2=${DNS2} GATEWAY=${DEFAULT_GATEWAY} \ - /etc/rc.d/init.d/net/common/ipv4-static ${RED_DEV} down - fi - - ### Cleanup the system when red goes down ### - /usr/local/bin/dialctrl.pl down - rm -f /var/ipfire/red/{active,iface,*-ipaddress,dns*} - - fi -else - boot_mesg "Interface ${DEVICE} doesn't exist." ${WARNING} - echo_warning -fi - -link_status=`ip link show $DEVICE 2> /dev/null` -if [ -n "${link_status}" ]; then - if echo "${link_status}" | grep -q UP; then - boot_mesg "Bringing down the ${DEVICE} interface..." - ip link set ${DEVICE} down - evaluate_retval - fi -fi - -# End $network_devices/ifdown diff --git a/src/initscripts/init.d/net/ifup b/src/initscripts/init.d/net/ifup deleted file mode 100644 index 0eef77933..000000000 --- a/src/initscripts/init.d/net/ifup +++ /dev/null @@ -1,100 +0,0 @@ -#!/bin/sh -######################################################################## -# Begin $network_devices/ifup -# -# Description : Interface Up -# -# Authors : Nathan Coulson - nathan@linuxfromscratch.org -# Kevin P. Fleming - kpfleming@linuxfromscratch.org -# Michael Tremer - mitch@ipfire.org -# Maniacikarus - Maniacikarus@ipfire.org -# -# Version : 01.00 -# -# Notes : the variables are passed to the scripts found -# in the services directory -# -######################################################################## - -. /etc/sysconfig/rc -. ${rc_functions} - -boot_mesg "Bringing up the $name interface..." -boot_mesg_flush - -( - eval $(/usr/local/bin/readhash /var/ipfire/ethernet/settings) - - if [ "$name" == "green" ]; then - DEVICE="${GREEN_DEV}" - elif [ "$name" == "blue" ]; then - DEVICE="${BLUE_DEV}" - elif [ "$name" == "orange" ]; then - DEVICE="${ORANGE_DEV}" - elif [ "$name" == "red" ]; then - DEVICE="${RED_DEV}" - fi - - # Check if an interface is there... - if ip link show ${DEVICE} > /dev/null 2>&1; then - link_status=`ip link show ${DEVICE} 2> /dev/null` - if [ -n "${link_status}" ]; then - if ! echo "${link_status}" | grep -q UP; then - ip link set ${DEVICE} up - fi - fi - - else - boot_mesg "Interface ${DEVICE} doesn't exist." ${FAILURE} - echo_failure - exit 1 - fi - - # Passing the variables to the script - if [ "$name" == "green" ]; then - if [ "${CONFIG_TYPE}" == "0" ] || [ "${CONFIG_TYPE}" == "" ]; then - NAME=${name} ADDRESS=${GREEN_ADDRESS} NETMASK=${GREEN_NETMASK} \ - NETADDRESS=${GREEN_NETADDRESS} BROADCAST=${GREEN_BROADCAST} \ - DNS1=${DNS1} DNS2=${DNS2} GATEWAY=${DEFAULT_GATEWAY} \ - /etc/rc.d/init.d/net/common/ipv4-static ${GREEN_DEV} up - else - NAME=${name} ADDRESS=${GREEN_ADDRESS} NETMASK=${GREEN_NETMASK} \ - NETADDRESS=${GREEN_NETADDRESS} BROADCAST=${GREEN_BROADCAST} \ - /etc/rc.d/init.d/net/common/ipv4-static ${GREEN_DEV} up - fi - - elif [ "$name" == "blue" ]; then - NAME=${name} ADDRESS=${BLUE_ADDRESS} NETMASK=${BLUE_NETMASK} \ - NETADDRESS=${BLUE_NETADDRESS} BROADCAST=${BLUE_BROADCAST} \ - /etc/rc.d/init.d/net/common/ipv4-static ${BLUE_DEV} up - - elif [ "$name" == "orange" ]; then - NAME=${name} ADDRESS=${ORANGE_ADDRESS} NETMASK=${ORANGE_NETMASK} \ - NETADDRESS=${ORANGE_NETADDRESS} BROADCAST=${ORANGE_BROADCAST} \ - /etc/rc.d/init.d/net/common/ipv4-static ${ORANGE_DEV} up - - elif [ "$name" == "red" ]; then - if [ "${RED_TYPE}" == "PPPOE" ]; then - NAME=${name} /etc/rc.d/init.d/net/red/pppoe ${RED_DEV} up - elif [ "${RED_TYPE}" == "PPTP" ]; then - echo - elif [ "${RED_TYPE}" == "DHCP" ]; then - NAME=${name} DHCP_HOSTNAME=${RED_DHCP_HOSTNAME} \ - DNS1=${DNS1} DNS2=${DNS2} \ - PRINTIP=yes PRINTALL=yes \ - /etc/rc.d/init.d/net/common/dhcpcd ${RED_DEV} up - elif [ "${RED_TYPE}" == "STATIC" ]; then - NAME=${name} ADDRESS=${RED_ADDRESS} NETMASK=${RED_NETMASK} \ - NETADDRESS=${RED_NETADDRESS} BROADCAST=${RED_BROADCAST} \ - DNS1=${DNS1} DNS2=${DNS2} GATEWAY=${DEFAULT_GATEWAY} \ - /etc/rc.d/init.d/net/common/ipv4-static ${RED_DEV} up - touch /var/ipfire/red/active - fi - - /usr/local/bin/dialctrl.pl up - /etc/rc.d/init.d/net/red/update -fi - -) - -# End $network_devices/ifup diff --git a/src/initscripts/init.d/net/red/isdn b/src/initscripts/init.d/net/red/isdn deleted file mode 100644 index 827b0024a..000000000 --- a/src/initscripts/init.d/net/red/isdn +++ /dev/null @@ -1,70 +0,0 @@ -#!/bin/bash -######################################################################## -# Begin $network_devices/services/isdn -# -# Description : ISDN Script -# -# Authors : Michael Tremer - mitch@ipfire.org -# -# Version : 01.00 -# -# Notes : -# -######################################################################## - -. /etc/sysconfig/rc -. ${rc_functions} -eval $(/usr/local/bin/readhash /var/ipfire/ppp/settings) - -case "${1}" in - up) - boot_mesg "Bringing up the ISDN interface..." - - if [ "$ENABLED" = "on" ]; then - modprobe -r hisax_st5481 2>/dev/null - modprobe -r hisax_fcpcipnp 2>/dev/null - modprobe -r hisax_isac 2>/dev/null - modprobe -r hisax 2>/dev/null - - if [ "$TYPE" = "998" ]; then - modprobe hisax_st5481 protocol=$PROTOCOL $MODULE_PARAMS - (exit $?) - evaluate_retval - elif [ "$TYPE" = "999" ]; then - modprobe hisax_fcpcipnp protocol=$PROTOCOL $MODULE_PARAMS - (exit $?) - evaluate_retval - else - modprobe hisax protocol=$PROTOCOL type=$TYPE $MODULE_PARAMS - (exit $?) - evaluate_retval - fi - - else - logger -t red "ISDN: "No ISDN enabled" - (exit 1) - evaluate_retval - fi - ;; - - down) - boot_mesg "Bringing down the ISDN interface..." - isdnctrl delif ippp1 2>/dev/null || failed=1 - isdnctrl delif ippp0 2>/dev/null || failed=1 - killproc ipppd 2>/dev/null || failed=1 - killproc ibod 2>/dev/null || failed=1 - modprobe -r hisax_st5481 2>/dev/null || failed=1 - modprobe -r hisax_fcpcipnp 2>/dev/null || failed=1 - modprobe -r hisax_isac 2>/dev/null || failed=1 - modprobe -r hisax 2>/dev/null || failed=1 - (exit ${failed}) - evaluate_retval - ;; - - *) - echo "Usage: ${0} {up|down}" - exit 1 - ;; -esac - -# End $network_devices/services/isdn diff --git a/src/initscripts/init.d/net/red/pppoe b/src/initscripts/init.d/net/red/pppoe deleted file mode 100644 index 8c3493c26..000000000 --- a/src/initscripts/init.d/net/red/pppoe +++ /dev/null @@ -1,129 +0,0 @@ -#!/bin/sh -######################################################################## -# Begin $network_devices/services/pppoe -# -# Description : PPPoE Script -# -# Authors : Michael Tremer - mitch@ipfire.org -# -# Version : 01.00 -# -# Notes : -# -######################################################################## - -. /etc/sysconfig/rc -. ${rc_functions} -eval $(/usr/local/bin/readhash /var/ipfire/ppp/settings) - -case "${2}" in - up) - boot_mesg "Bringing up the PPPoE interface on ${1}..." - ip addr add 1.1.1.1/24 broadcast 1.1.1.255 dev ${1} - - if [ "${METHOD}" != "PPPOE_PLUGIN" ]; then - PPPCOMMAND="/usr/sbin/pppd pty" - PPPOECOMMAND="/usr/sbin/pppoe -p /var/run/pppoe.pid -I ${1} -T 80 -U -m ${MTU}" - if [ -n ${SERVICENAME} ]; then - PPPOECOMMAND+=" -S ${SERVICENAME}" - fi - if [ -n ${CONCENTRATORNAME} ]; then - PPPOECOMMAND+=" -C ${CONCENTRATORNAME}" - fi - - if [ "${DNS}" == "Automatic" ]; then - ARGS+=" usepeerdns" - fi - - if [ "${AUTH}" == "pap" ]; then - ARGS+=" -chap" - elif [ "${AUTH}" == "chap" ]; then - ARGS+=" -pap" - fi - - if [ "${RECONNECTION}" != "persistent" ]; then - if [ "${TIMEOUT}" != "0" ] && [ "${TIMEOUT}" != "" ]; then - SECONDS=$[${TIMEOUT} * 60] - ARGS+=" idle ${SECONDS}" - fi - if [ "${RECONNECTION}" == "dialondemand" ]; then - touch /var/ipfire/red/dial-on-demand - ARGS+=" demand nopersist connect /bin/true" - fi - DEMAND+=" active-filter outbound and not icmp[0] == 3 and not tcp[13] & 4 != 0" - fi - - ARGS+=" noipdefault default-asyncmap defaultroute hide-password local mtu ${MTU}" - ARGS+=" mru ${MRU} noaccomp noccp nobsdcomp nodeflate nopcomp novj novjccomp" - ARGS+=" user ${USERNAME} lcp-echo-interval 20 lcp-echo-failure 3 lcp-max-configure 50" - ARGS+=" maxfail ${MAXRETRIES}" - - if [ "${DEBUG}" == "on" ]; then - ARGS+=" debug" - fi - - $PPPCOMMAND "${PPPOECOMMAND}" $ARGS $DEMAND >/dev/null 2>&1 - PID=$$ - evaluate_retval - echo $PID > /var/run/ppp-ipfire.pid - - else - modprobe pppoe - PPPCOMMAND="/usr/sbin/pppd plugin rp-pppoe.so ${1}" - if [ "${DNS}" == "Automatic" ]; then - PPPCOMMAND+=" usepeerdns" - fi - - if [ "${AUTH}" == "pap" ]; then - PPPCOMMAND+=" -chap" - elif [ "${AUTH}" == "chap" ]; then - PPPCOMMAND+=" -pap" - fi - - if [ "${RECONNECTION}" != "persistent" ]; then - if [ "${TIMEOUT}" != "0" ]; then - SECONDS=$[${TIMEOUT} * 60] - PPPCOMMAND+=" idle ${SECONDS}" - fi - if [ "${RECONNECTION}" == "dialondemand" ]; then - touch /var/ipfire/red/dial-on-demand - PPPCOMMAND+=" demand nopersist" - fi - DEMAND+="active-filter outbound and not icmp[0] == 3 & not tcp[13] & 4 != 0" - fi - - PPPCOMMAND+=" noipdefault defaultroute hide-password ipcp-accept-local" - PPPCOMMAND+=" ipcp-accept-remote passive noccp nopcomp novjccomp" - PPPCOMMAND+=" user ${USERNAME} lcp-echo-interval 20 lcp-echo-failure 3" - PPPCOMMAND+=" lcp-max-configure 50 maxfail ${MAXRETRIES}" - - if [ "${DEBUG}" == "on" ]; then - PPPCOMMAND+=" debug" - fi - - $PPPCOMMAND $DEMAND >/dev/null 2>&1 - PID=$$ - evaluate_retval - echo $PID > /var/run/ppp-ipfire.pid - fi - - ;; - - down) - boot_mesg "Bringing down the PPPoE interface on ${1}..." - - modprobe -r pppoe >/dev/null 2>&1 - kill $(head -1 /var/run/ppp-ipfire.pid) - sleep 2 - ip addr del 1.1.1.1/24 broadcast 1.1.1.255 dev ${1} - - evaluate_retval - ;; - - *) - echo "Usage: ${0} [interface] {up|down}" - exit 1 - ;; -esac - -# End $network_devices/services/pppoe diff --git a/src/initscripts/init.d/net/red/update b/src/initscripts/init.d/net/red/update deleted file mode 100644 index 566bb65ef..000000000 --- a/src/initscripts/init.d/net/red/update +++ /dev/null @@ -1,118 +0,0 @@ -#!/bin/sh -######################################################################## -# Begin $network_devices/red/update -# -# Description : Update red interface -# -# Authors : Michael Tremer - mitch@ipfire.org -# -# Version : 01.00 -# -# Notes : update the settings if red goes up or down -# -######################################################################## - -eval $(/usr/local/bin/readhash /var/ipfire/vpn/settings) -eval $(/usr/local/bin/readhash /var/ipfire/dhcp/settings) -eval $(/usr/local/bin/readhash /var/ipfire/ethernet/settings) -eval $(/usr/local/bin/readhash /var/ipfire/ppp/settings) - -if [ ! -e /var/lock/red.lock ]; then - touch /var/lock/red.lock - logger -p local0.info -t red[$$] "$0 locking for $$" -else - count=0 - while [ ! $count = 5 ]; do - sleep 3 - if [ ! -e /var/lock/red.lock ]; then - break - else - /usr/bin/logger -p local0.info -t red[$$] "$0 $$ waiting unlock" - fi - ((++count)) - done -fi - -IFACE=`cat /var/ipfire/red/iface 2>/dev/null | tr -d '\012'` -REMOTE=`cat /var/ipfire/red/remote-ipaddress 2>/dev/null | tr -d '\012'` - -### DNS Settings -DNS1=`cat /var/ipfire/red/dns1 2>/dev/null | tr -d '\012' 2>/dev/null` -DNS2=`cat /var/ipfire/red/dns2 2>/dev/null | tr -d '\012' 2>/dev/null` -echo > /var/ipfire/red/resolv.conf #clear it -[ "$DNS1" != "" ] && echo "nameserver $DNS1" > /var/ipfire/red/resolv.conf -[ "$DNS2" != "" ] && echo "nameserver $DNS2" >> /var/ipfire/red/resolv.conf - -### Restart DNSMASQ -killall -KILL dnsmasq 2> /dev/null -sleep 1 -ARGS="" -[ "$DOMAIN_NAME_GREEN" ] && ARGS="-s $DOMAIN_NAME_GREEN" -if [ -e "/var/ipfire/red/dial-on-demand" -a "$DIALONDEMANDDNS" == "on" -a ! -e "/var/ipfire/red/active" ]; then - /usr/sbin/dnsmasq -l /var/state/dhcp/dhcpd.leases $ARGS -r /var/ipfire/ppp/fake-resolv.conf -else - /usr/sbin/dnsmasq -l /var/state/dhcp/dhcpd.leases $ARGS -r /var/ipfire/red/resolv.conf -fi -unset ARGS - -### Reset default route to ippp0 for dial on demand -if [ -e "/var/ipfire/red/dial-on-demand" -a "$TYPE" == "isdn" -a ! -e "/var/ipfire/red/active" ]; then - ip route del default 2> /dev/null - if [ ! -z "$REMOTE" ]; then - ip route add default gw $REMOTE 2> /dev/null - else - ip route add default dev ippp0 2> /dev/null - fi -fi - -if ( echo $0 | /bin/grep -q 'dhcpcd.exe' ); then - eval $(/usr/local/bin/readhash "$1") - case "$2" in - up) - logger -p local0.info -t dhcpcd.exe[$$] "${INTERFACE} has been configured with old IP=${IPADDR}" - touch /var/ipfire/red/active - ;; - new) - logger -p local0.info -t dhcpcd.exe[$$] "${INTERFACE} has been configured with new IP=${IPADDR}" - if [ -e "/var/ipfire/red/active" ]; then - /usr/local/bin/setfilters - /usr/local/bin/setportfw - /usr/local/bin/setxtaccess - /usr/local/bin/setddns.pl -f - /usr/local/bin/snortctrl restart - sleep $VPN_DELAYED_START && /usr/local/bin/ipsecctrl S & - /bin/rm -f /var/lock/red.lock - logger -p local0.info -t red[$$] "unlocking from $$" - exit 0 - else - touch /var/ipfire/red/active - fi - ;; - down) - logger -p local0.info -t dhcpcd.exe[$$] "${INTERFACE} has been brought down" - rm -f /var/ipfire/red/active - ;; - esac -fi - -if [ -e "/var/ipfire/red/active" ]; then - [ "$IFACE" != "" ] && ifconfig $IFACE -multicast - /etc/rc.d/init.d/firewall reload - /usr/local/bin/setfilters - /usr/local/bin/outgoingfwctrl - /usr/local/bin/snortctrl restart - /usr/local/bin/qosctrl start - /usr/local/bin/setportfw - /usr/local/bin/setxtaccess - /usr/local/bin/setddns.pl -f - /etc/rc.d/helper/writeipac.pl - /usr/sbin/fetchipac -S - sleep $VPN_DELAYED_START && /usr/local/bin/ipsecctrl S & -else - /usr/local/bin/ipsecctrl D - /etc/rc.d/init.d/firewall reload -fi -/bin/rm -f /var/lock/red.lock -/usr/bin/logger -p local0.info -t red[$$] "unlocking from $$" - -# End $network_devices/red/update diff --git a/src/initscripts/init.d/network b/src/initscripts/init.d/network index 61d8c591d..579cbe026 100644 --- a/src/initscripts/init.d/network +++ b/src/initscripts/init.d/network @@ -4,7 +4,7 @@ # # Description : Network Control Script # -# Authors : Michael Tremer - m.s.tremer@googlemail.com +# Authors : Michael Tremer - mitch@ipfire.org # # Version : 01.00 # @@ -20,178 +20,121 @@ DO="${1}" shift if [ -n "${1}" ]; then - ALL=0 - for i in green red blue orange; do - eval "${i}=0" - done + ALL=0 + for i in green red blue orange; do + eval "${i}=0" + done else - ALL=1 - for i in green red blue orange; do - eval "${i}=1" - done + ALL=1 + for i in green red blue orange; do + eval "${i}=1" + done fi while [ ! $# = 0 ]; do - for i in green red blue orange; do - if [ "${i}" == "${1}" ]; then - eval "${i}=1" - shift - fi - done + for i in green red blue orange; do + if [ "${i}" == "${1}" ]; then + eval "${i}=1" + shift + fi + done done case "${DO}" in - start) - if [ "${ALL}" == "1" ]; then - boot_mesg "Loading iptables helper modules" - modprobe iptable_nat || failed=1 - modprobe ip_conntrack || failed=1 - modprobe ip_conntrack_ftp || failed=1 - modprobe ip_nat_ftp || failed=1 - modprobe ip_conntrack_h323 || failed=1 - modprobe ip_nat_h323 || failed=1 - modprobe ip_conntrack_irc || failed=1 - modprobe ip_nat_irc || failed=1 - modprobe ip_conntrack_mms || failed=1 - modprobe ip_nat_mms || failed=1 - modprobe ip_conntrack_pptp || failed=1 - modprobe ip_nat_pptp || failed=1 - modprobe ip_conntrack_sip || failed=1 - modprobe ip_nat_sip || failed=1 - (exit ${failed}) - evaluate_retval - - boot_mesg "Setting up IPFire firewall rules" - /etc/rc.d/init.d/firewall start; evaluate_retval - - boot_mesg "Setting up IP Accounting" - /etc/rc.d/helper/writeipac.pl || failed=1 - /usr/sbin/fetchipac -S || failed=1 - (exit ${failed}) - evaluate_retval - - boot_mesg "Setting IPFire DMZ pinholes" - /usr/local/bin/setdmzholes; evaluate_retval - - if [ "$CONFIG_TYPE" = "3" -o "$CONFIG_TYPE" = "4" ]; then - boot_mesg "Setting up wireless firewall rules" - /usr/local/bin/restartwireless; evaluate_retval - fi - - # Start DNSMASQ with defaults - killall -KILL dnsmasq 2> /dev/null - sleep 1 - if [ "$DOMAIN_NAME_GREEN" == "" ]; then - /usr/sbin/dnsmasq -l /var/state/dhcp/dhcpd.leases - else - /usr/sbin/dnsmasq -l /var/state/dhcp/dhcpd.leases -s "$DOMAIN_NAME_GREEN" - fi - fi - - # Starting interfaces... - # GREEN - if [ "$green" == "1" ]; then - name=green /etc/rc.d/init.d/net/ifup - fi - - # BLUE - if [ "$blue" == "1" ]; then - if [ "$CONFIG_TYPE" = "3" -o "$CONFIG_TYPE" = "4" ]; then - name=blue /etc/rc.d/init.d/net/ifup - fi - fi - - # ORANGE - if [ "$orange" == "1" ]; then - if [ "$CONFIG_TYPE" = "2" -o "$CONFIG_TYPE" = "4" ]; then - name=orange /etc/rc.d/init.d/net/ifup - fi - fi - - # RED - if [ "$red" == "1" ]; then - if [ "$CONFIG_TYPE" = "1" -o "$CONFIG_TYPE" = "2" -o "$CONFIG_TYPE" = "3" -o "$CONFIG_TYPE" = "4" ]; then - # Remove possible leftover files - rm -f /var/ipfire/red/{active,device,dial-on-demand,dns1,dns2,local-ipaddress,remote-ipaddress,resolv.conf} - if [ "$AUTOCONNECT" == "off" ]; then - echo -n # Do anything - else - name=red /etc/rc.d/init.d/net/ifup - fi - fi - fi - - if [ -f "/var/ipfire/ovpn/enable" -o -f "/var/ipfire/ovpn/enable_blue" -o -f "/var/ipfire/ovpn/enable_orange" ];then - boot_mesg "Setting OpenVPN Rules if enabled" - /etc/rc.d/init.d/firewall startovpn; evaluate_retval - - boot_mesg "Setting OpenVPN if enabled" - /usr/local/bin/openvpnctrl -s; evaluate_retval - fi - - if [ -f "/var/ipfire/snort/enable" -o -f "/var/ipfire/snort/enable_blue" -o -f "/var/ipfire/snort/enable_orange" ];then - boot_mesg "Starting Snort if enabled" - /etc/rc.d/init.d/snort start; evaluate_retval - fi - ;; - - stop) - # Stopping interfaces... - # GREEN - if [ "$green" == "1" ]; then - name=green /etc/rc.d/init.d/net/ifdown - fi - - # BLUE - if [ "$blue" == "1" ]; then - if [ "$CONFIG_TYPE" = "3" -o "$CONFIG_TYPE" = "4" ]; then - name=blue /etc/rc.d/init.d/net/ifdown - fi - fi - - # ORANGE - if [ "$orange" == "1" ]; then - if [ "$CONFIG_TYPE" = "2" -o "$CONFIG_TYPE" = "4" ]; then - name=orange /etc/rc.d/init.d/net/ifdown - fi - fi - - # RED - if [ "$red" == "1" ]; then - if [ "$CONFIG_TYPE" = "1" -o "$CONFIG_TYPE" = "2" -o "$CONFIG_TYPE" = "3" -o "$CONFIG_TYPE" = "4" ]; then - name=red /etc/rc.d/init.d/net/ifdown - fi - fi - - if [ -f "/var/ipfire/ovpn/enable" -o -f "/var/ipfire/ovpn/enable_blue" -o -f "/var/ipfire/ovpn/enable_orange" ];then - boot_mesg "Deleting OpenVPN Rules if enabled" - /etc/rc.d/init.d/firewall stopovpn; evaluate_retval - - boot_mesg "Stopping OpenVPN if enabled" - /usr/local/bin/openvpnctrl -k; evaluate_retval - fi - - if [ -f "/var/ipfire/snort/enable" -o -f "/var/ipfire/snort/enable_blue" -o -f "/var/ipfire/snort/enable_orange" ];then - boot_mesg "Stopping Snort if enabled" - /etc/rc.d/init.d/snort stop; evaluate_retval - fi - ;; - - restart) - for i in green red blue orange; do - if [ "${!i}" == "1" ]; then - ARGS+=" ${i}" - fi - done - ${0} stop ${ARGS} - sleep 1 - ${0} start ${ARGS} - ;; - - *) - echo "Usage: ${0} {start|stop|restart}" - exit 1 - ;; + start) + [ "${ALL}" == "1" ] && init_networking + + # Starting interfaces... + # GREEN + [ "$green" == "1" ] && /etc/rc.d/init.d/networking/green start + + # BLUE + [ "$blue" == "1" ] && [ "$CONFIG_TYPE" = "3" -o "$CONFIG_TYPE" = "4" ] && \ + /etc/rc.d/init.d/networking/blue start + + # ORANGE + [ "$orange" == "1" ] && [ "$CONFIG_TYPE" = "2" -o "$CONFIG_TYPE" = "4" ] && \ + /etc/rc.d/init.d/networking/orange start + + # RED + if [ "$red" == "1" ]; then + if [ "$CONFIG_TYPE" = "1" -o "$CONFIG_TYPE" = "2" -o "$CONFIG_TYPE" = "3" -o "$CONFIG_TYPE" = "4" ]; then + # Remove possible leftover files + rm -f /var/ipfire/red/{active,device,dial-on-demand,dns1,dns2,local-ipaddress,remote-ipaddress,resolv.conf} + [ "$AUTOCONNECT" == "off" ] || /etc/rc.d/init.d/networking/red start + fi + fi + ;; + + stop) + # Stopping interfaces... + # GREEN + [ "$green" == "1" ] && /etc/rc.d/init.d/networking/green stop + + # BLUE + [ "$blue" == "1" ] && [ "$CONFIG_TYPE" = "3" -o "$CONFIG_TYPE" = "4" ] && \ + /etc/rc.d/init.d/networking/blue stop + + # ORANGE + [ "$orange" == "1" ] && [ "$CONFIG_TYPE" = "2" -o "$CONFIG_TYPE" = "4" ] && \ + /etc/rc.d/init.d/networking/orange stop + + # RED + if [ "$red" == "1" ]; then + if [ "$CONFIG_TYPE" = "1" -o "$CONFIG_TYPE" = "2" -o "$CONFIG_TYPE" = "3" -o "$CONFIG_TYPE" = "4" ]; then + /etc/rc.d/init.d/networking/red stop + fi + fi + ;; + + restart) + for i in green red blue orange; do + if [ "${!i}" == "1" ]; then + ARGS+=" ${i}" + fi + done + ${0} stop ${ARGS} + sleep 1 + ${0} start ${ARGS} + ;; + + *) + echo "Usage: ${0} {start|stop|restart} [device(s)]" + exit 1 + ;; esac +init_networking() { + + boot_mesg "Loading firewall modules into the kernel" + modprobe iptable_nat || failed=1 + for i in $(find /lib/modules/$(uname -r) -name ip_conntrack*); do + modprobe $i || failed=1 + done + for i in $(find /lib/modules/$(uname -r) -name ip_nat*); do + modprobe $i || failed=1 + done + (exit ${failed}) + evaluate_retval + + boot_mesg "Setting up firewall" + /etc/rc.d/init.d/firewall start; evaluate_retval + + boot_mesg "Setting up traffic accounting" + /etc/rc.d/helper/writeipac.pl || failed=1 + /usr/sbin/fetchipac -S || failed=1 + (exit ${failed}) + evaluate_retval + + boot_mesg "Setting up DMZ pinholes" + /usr/local/bin/setdmzholes; evaluate_retval + + if [ "$CONFIG_TYPE" = "3" -o "$CONFIG_TYPE" = "4" ]; then + boot_mesg "Setting up wireless firewall rules" + /usr/local/bin/restartwireless; evaluate_retval + fi + + /etc/rc.d/init.d/dnsmasq start +} + # End /etc/rc.d/init.d/network diff --git a/src/initscripts/init.d/networking/any b/src/initscripts/init.d/networking/any new file mode 100644 index 000000000..6af04ff52 --- /dev/null +++ b/src/initscripts/init.d/networking/any @@ -0,0 +1,93 @@ +#!/bin/sh +######################################################################## +# Begin +# +# Description : ANY Device Script +# +# Authors : Nathan Coulson - nathan@linuxfromscratch.org +# Kevin P. Fleming - kpfleming@linuxfromscratch.org +# Michael Tremer - mitch@ipfire.org +# Maniacikarus - maniacikarus@ipfire.org +# +# Version : 01.00 +# +# Notes : +# +######################################################################## + +. /etc/sysconfig/rc +. ${rc_functions} +eval $(/usr/local/bin/readhash /var/ipfire/ethernet/settings) + +if [ "$0" == "green" ]; then + DEVICE="${GREEN_DEV}" + ADDRESS="${GREEN_ADDRESS}" + BROADCAST="${GREEN_BROADCAST}" + NETADDRESS="${GREEN_NETADDRESS}" + NETMASK="${GREEN_NETMASK}" + DEVICE="${GREEN_DEV}" +elif [ "$0" == "blue" ]; then + DEVICE="${BLUE_DEV}" + ADDRESS="${BLUE_ADDRESS}" + BROADCAST="${BLUE_BROADCAST}" + NETADDRESS="${BLUE_NETADDRESS}" + NETMASK="${BLUE_NETMASK}" + DEVICE="${BLUE_DEV}" +elif [ "$0" == "orange" ]; then + DEVICE="${ORANGE_DEV}" + ADDRESS="${ORANGE_ADDRESS}" + BROADCAST="${ORANGE_BROADCAST}" + NETADDRESS="${ORANGE_NETADDRESS}" + NETMASK="${ORANGE_NETMASK}" + DEVICE="${ORANGE_DEV}" +fi + +if [ -z "${BROADCAST}" ]; then + boot_mesg "BROADCAST variable missing from input, cannot continue." ${FAILURE} + echo_failure + exit 1 +fi + +if [ -n "${ADDRESS}" -a -n "${NETMASK}" ]; then + PREFIX=`whatmask ${NETMASK} | grep -e ^CIDR | awk -F': ' '{ print $2 }' | cut -c 2-` + args="${args} ${ADDRESS}/${PREFIX} broadcast ${BROADCAST}" +else + boot_mesg "ADDRESS and/or NETMASK variable missing from input, cannot continue." ${FAILURE} + echo_failure + exit 1 +fi + +case "${1}" do + + start) + boot_mesg "Bringing up the ${DEVICE} interface..." + boot_mesg_flush + + # Check if an interface is there... + if ip link show ${DEVICE} > /dev/null 2>&1; then + link_status=`ip link show ${DEVICE} 2> /dev/null` + if [ -n "${link_status}" ]; then + if ! echo "${link_status}" | grep -q UP; then + ip link set ${DEVICE} up + fi + fi + else + boot_mesg "Interface ${DEVICE} doesn't exist." ${FAILURE} + echo_failure + exit 1 + fi + + boot_mesg "Adding IPv4 address ${ADDRESS} to the ${DEVICE} interface..." + ip addr add ${args} dev ${DEVICE} + evaluate_retval + ;; + + stop) + boot_mesg "Removing IPv4 address ${ADDRESS} from the ${1} interface..." + ip addr del ${args} dev ${DEVICE} + evaluate_retval + ;; + +esac + +# End diff --git a/src/initscripts/init.d/networking/red b/src/initscripts/init.d/networking/red new file mode 100644 index 000000000..d32793a15 --- /dev/null +++ b/src/initscripts/init.d/networking/red @@ -0,0 +1,291 @@ +#!/bin/sh +######################################################################## +# Begin +# +# Description : RED Device Script +# +# Authors : Michael Tremer - mitch@ipfire.org +# Maniacikarus - maniacikarus@ipfire.org +# Inspired by : Nathan Coulson - nathan@linuxfromscratch.org +# Kevin P. Fleming - kpfleming@linuxfromscratch.org +# +# Version : 01.00 +# +# Notes : +# +######################################################################## + +. /etc/sysconfig/rc +. ${rc_functions} +eval $(/usr/local/bin/readhash /var/ipfire/ethernet/settings) + +TYPE="${RED_TYPE}" +DEVICE="${RED_DEV}" + +if [ "$TYPE" == "STATIC" ]; then + ADDRESS="${RED_ADDRESS}" + BROADCAST="${RED_BROADCAST}" + NETADDRESS="${RED_NETADDRESS}" + NETMASK="${RED_NETMASK}" + GATEWAY="${DEFAULT_GATEWAY}" + DNS1="${DNS1}" + DNS2="${DNS2}" + + if [ -z "${BROADCAST}" ]; then + boot_mesg "BROADCAST variable missing from input, cannot continue." ${FAILURE} + echo_failure + exit 1 + fi + if [ -n "${ADDRESS}" -a -n "${NETMASK}" ]; then + PREFIX=`whatmask ${NETMASK} | grep -e ^CIDR | awk -F': ' '{ print $2 }' | cut -c 2-` + args="${args} ${ADDRESS}/${PREFIX} broadcast ${BROADCAST}" + else + boot_mesg "ADDRESS and/or NETMASK variable missing from input, cannot continue." ${FAILURE} + echo_failure + exit 1 + fi + +elif [ "${TYPE}" == "DHCP" ]; then + + PIDFILE="/var/run/dhcpcd-${DEVICE}.pid" + LEASEINFO="/var/ipfire/dhcpc/dhcpcd-${DEVICE}.info" + DHCP_START="-N -R -L /var/ipfire/dhcpc -c /var/ipfire/dhcpc/dhcpcd.exe " + DHCP_STOP="-k -c /var/ipfire/dhcpc/dhcpcd.exe " + +fi + +case "${1}" in + start) + boot_mesg "Bringing up the ${DEVICE} interface..." + boot_mesg_flush + + # Check if an interface is there... + if ip link show ${DEVICE} > /dev/null 2>&1; then + link_status=`ip link show ${DEVICE} 2> /dev/null` + if [ -n "${link_status}" ]; then + if ! echo "${link_status}" | grep -q UP; then + ip link set ${DEVICE} up + fi + fi + else + boot_mesg "Interface ${DEVICE} doesn't exist." ${FAILURE} + echo_failure + exit 1 + fi + + if [ "${TYPE}" == "STATIC" ]; then + boot_mesg "Adding IPv4 address ${ADDRESS} to the ${DEVICE} interface..." + ip addr add ${args} dev ${DEVICE} + evaluate_retval + + elif [ "${TYPE}" == "DHCP" ]; then + boot_mesg -n "Starting dhcpcd on the ${DEVICE} interface..." + echo -n "${DEVICE}" > /var/ipfire/red/iface + + # Test to see if there is a stale pid file + if [ -f "$PIDFILE" ]; then + ps `cat "$PIDFILE"` | grep dhcpcd > /dev/null + if [ $? != 0 ]; then + rm -f /var/run/dhcpcd-${DEVICE}.pid > /dev/null + else + boot_mesg "dhcpcd already running!" ${WARNING} + echo_warning + exit 2 + fi + fi + + iptables -A REDINPUT -p tcp --source-port 67 --destination-port 68 -i ${DEVICE} -j ACCEPT + iptables -A REDINPUT -p udp --source-port 67 --destination-port 68 -i ${DEVICE} -j ACCEPT + + if [ -n "${DHCP_HOSTNAME}" ]; then + DHCP_START+="-h ${DHCP_HOSTNAME} " + fi + + /sbin/dhcpcd ${DEVICE} ${DHCP_START} >/dev/null 2>&1 + RET="$?" + + if [ "$RET" = "0" ]; then + . /var/ipfire/dhcpc/dhcpcd-${DEVICE}.info + echo "" + echo_ok + boot_mesg " DHCP Assigned Settings for ${DEVICE}:" + boot_mesg_flush + boot_mesg " IP Address: $IPADDR" + boot_mesg_flush + if [ -n "${DHCP_HOSTNAME}" ]; then + boot_mesg " Hostname: $DHCP_HOSTNAME" + boot_mesg_flush + fi + boot_mesg " Subnet Mask: $NETMASK" + boot_mesg_flush + boot_mesg " Default Gateway: $GATEWAY" + boot_mesg_flush + boot_mesg " DNS Server: $DNS" + boot_mesg_flush + + echo -n `/etc/rc.d/helper/getdnsfromdhcpc.pl 1` > /var/ipfire/red/dns1 + echo -n `/etc/rc.d/helper/getdnsfromdhcpc.pl 2` > /var/ipfire/red/dns2 + + . /var/ipfire/dhcpc/dhcpcd-${DEVICE}.info + echo "$IPADDR" > /var/ipfire/red/local-ipaddress + echo "$GATEWAY" > /var/ipfire/red/remote-ipaddress + else + echo "" + $(exit "$RET") + evaluate_retval + fi + + elif [ "$TYPE" == "PPPOE" ]; then + eval $(/usr/local/bin/readhash /var/ipfire/ppp/settings) + + boot_mesg "Bringing up the PPPoE interface on ${DEVICE}..." + ip addr add 1.1.1.1/24 broadcast 1.1.1.255 dev ${DEVICE} + + PPPOECONF=/etc/ppp/pppoe.conf + echo > $PPPOECONF #clear + + if [ "${METHOD}" != "PPPOE_PLUGIN" ]; then + echo "LINUX_PLUGIN=" >> $PPPOECONF + else + echo "LINUX_PLUGIN=/usr/lib/pppd/2.4.4/rp-pppoe.so" >> $PPPOECONF + fi + + echo "ETH=${DEVICE}" >> $PPPOECONF + echo "USER=${USERNAME}" >> $PPPOECONF + + echo "PPPOE_TIMEOUT=80" >> $PPPOECONF + + #echo "PPPD_EXTRA=\"-U\"" >> $PPPOECONF + #echo "PPPOE_EXTRA=\"-m ${MTU}\"" >> $PPPOECONF + + if [ -n ${SERVICENAME} ]; then + echo "SERVICENAME=${SERVICENAME}" >> $PPPOECONF + fi + if [ -n ${CONCENTRATORNAME} ]; then + echo "ACNAME=${CONCENTRATORNAME}" >> $PPPOECONF + fi + + if [ "${DNS}" == "Automatic" ]; then + echo "PEERDNS=yes" >> $PPPOECONF + echo "DNSTYPE=NOCHANGE" >> $PPPOECONF + fi + + if [ "${AUTH}" == "pap" ]; then + PPPD_EXTRA+="-chap " + elif [ "${AUTH}" == "chap" ]; then + PPPD_EXTRA+="-pap " + fi + + echo "FIREWALL=NONE" >> $PPPOECONF + + if [ "${RECONNECTION}" != "persistent" ]; then + if [ "${TIMEOUT}" != "0" ] && [ "${TIMEOUT}" != "" ]; then + SECONDS=$[${TIMEOUT} * 60] + fi + if [ "${RECONNECTION}" == "dialondemand" ]; then + touch /var/ipfire/red/dial-on-demand + echo "DEMAND=${SECONDS}" >> $PPPOECONF + fi + else + echo "DEMAND=no" >> $PPPOECONF + fi + + echo "LCP_INTERVAL=20" >> $PPPOECONF + echo "LCP_FAILURE=3" >> $PPPOECONF + + echo "PIDFILE=/var/run/ppp-ipfire.pid" >> $PPPOECONF + + #ARGS+=" maxfail ${MAXRETRIES}" + + [ "${METHOD}" != "PPPOE_PLUGIN" ] && [ "${DEBUG}" == "on" ] && export DEBUG=1 + /usr/sbin/pppoe-start + evaluate_retval + fi + + for i in $( ls -v ${rc_base}/init.d/networking/red.up/* 2> /dev/null); do + check_script_status + OUT=$(echo $(basename ${i}) | awk -F- '{ print $2 }') + case "$OUT" in + S) ${i} start ;; + K) ${i} stop ;; + RS) ${i} restart ;; + RL) ${i} reload ;; + *) ${i} ;; + esac + done + ;; + + stop) + if [ "$TYPE" == "STATIC" ]; then + boot_mesg "Removing IPv4 address ${ADDRESS} from the ${DEVICE} interface..." + ip addr del ${args} dev ${DEVICE} + evaluate_retval + + elif [ "$TYPE" == "DHCP" ]; then + boot_mesg -n "Stopping dhcpcd on the ${DEVICE} interface..." + if [ -e $LEASEINFO ]; then + . $LEASEINFO + if [ "$LEASETIME" = "4294967295" ]; then + # do nothing, just echo ok + echo "" + echo_ok + else + if [ -n "$DHCP_STOP" ]; then + /sbin/dhcpcd ${DEVICE} $DHCP_STOP &> /dev/null + RET="$?" + if [ "$RET" -eq 0 ]; then + echo "" + echo_ok + elif [ "$RET" -eq 1 ]; then + boot_mesg "dhcpcd not running!" ${WARNING} + echo_warning + else + echo "" + echo_failure + fi + else + echo "" + killproc dhcpcd + fi + fi + else + boot_mesg -n "LEASEINFO Test failed! - " ${WARNING} + boot_mesg "dhcpcd is not running!" ${WARNING} + echo_warning + exit 1 + fi + + elif [ "$TYPE" == "PPPOE" ]; then + boot_mesg "Bringing down the PPPoE interface on ${DEVICE}..." + + /usr/sbin/pppoe-stop + evaluate_retval + ip addr del 1.1.1.1/24 broadcast 1.1.1.255 dev ${DEVICE} + + fi + + link_status=`ip link show $DEVICE 2> /dev/null` + if [ -n "${link_status}" ]; then + if echo "${link_status}" | grep -q UP; then + boot_mesg "Bringing down the ${DEVICE} interface..." + ip link set ${DEVICE} down + evaluate_retval + fi + fi + + for i in $( ls -v ${rc_base}/init.d/networking/red.down/* 2> /dev/null); do + check_script_status + OUT=$(echo $(basename ${i}) | awk -F- '{ print $2 }') + case "$OUT" in + S) ${i} start ;; + K) ${i} stop ;; + RS) ${i} restart ;; + RL) ${i} reload ;; + *) ${i} ;; + esac + done + ;; + +esac + +# End diff --git a/src/initscripts/init.d/networking/red.down/10-ipsec b/src/initscripts/init.d/networking/red.down/10-ipsec new file mode 100644 index 000000000..301e81468 --- /dev/null +++ b/src/initscripts/init.d/networking/red.down/10-ipsec @@ -0,0 +1,3 @@ +#!/bin/bash + +/usr/local/bin/ipsecctrl D diff --git a/src/initscripts/init.d/networking/red.up/10-multicast b/src/initscripts/init.d/networking/red.up/10-multicast new file mode 100644 index 000000000..101934dc7 --- /dev/null +++ b/src/initscripts/init.d/networking/red.up/10-multicast @@ -0,0 +1,7 @@ +#!/bin/bash + +### This script disables multicast on the red interface + +IFACE=`cat /var/ipfire/red/iface 2>/dev/null | tr -d '\012'` + +[ "$IFACE" != "" ] && ifconfig $IFACE -multicast diff --git a/src/initscripts/init.d/networking/red.up/30-ddns b/src/initscripts/init.d/networking/red.up/30-ddns new file mode 100644 index 000000000..20ea743de --- /dev/null +++ b/src/initscripts/init.d/networking/red.up/30-ddns @@ -0,0 +1,3 @@ +#!/bin/bash + +/usr/local/bin/setddns.pl -f diff --git a/src/initscripts/init.d/networking/red.up/40-ipac b/src/initscripts/init.d/networking/red.up/40-ipac new file mode 100644 index 000000000..82bca9ecc --- /dev/null +++ b/src/initscripts/init.d/networking/red.up/40-ipac @@ -0,0 +1,5 @@ +#!/bin/bash + +/etc/rc.d/helper/writeipac.pl +/usr/sbin/fetchipac -S + diff --git a/src/initscripts/init.d/networking/red.up/50-ipsec b/src/initscripts/init.d/networking/red.up/50-ipsec new file mode 100644 index 000000000..325576d15 --- /dev/null +++ b/src/initscripts/init.d/networking/red.up/50-ipsec @@ -0,0 +1,6 @@ +#!/bin/bash + +eval $(/usr/local/bin/readhash /var/ipfire/vpn/settings) + +sleep $VPN_DELAYED_START && /usr/local/bin/ipsecctrl S & + diff --git a/src/paks/alsa/install.sh b/src/paks/alsa/install.sh index 87ea5b8b2..13789ac28 100644 --- a/src/paks/alsa/install.sh +++ b/src/paks/alsa/install.sh @@ -4,6 +4,6 @@ extract_files touch /etc/asound.state -ln -sf ../init.d/alsa /etc/rc.d/rc3.d/S65alsa -ln -sf ../init.d/alsa /etc/rc.d/rc0.d/K35alsa -ln -sf ../init.d/alsa /etc/rc.d/rc6.d/K35alsa +ln -svf ../init.d/alsa /etc/rc.d/rc3.d/S65alsa +ln -svf ../init.d/alsa /etc/rc.d/rc0.d/K35alsa +ln -svf ../init.d/alsa /etc/rc.d/rc6.d/K35alsa diff --git a/src/ppp/ip-down b/src/ppp/ip-down index 474fa95dd..76dc5ff6a 100644 --- a/src/ppp/ip-down +++ b/src/ppp/ip-down @@ -1,33 +1,10 @@ -#!/usr/bin/perl +#!/bin/sh # -# SmoothWall CGIs -# -# This code is distributed under the terms of the GPL -# -# (c) The SmoothWall Team -# -# $Id: ip-down,v 1.3.2.9 2005/01/26 12:23:26 riddles Exp $ -# - -use strict; -require 'CONFIG_ROOT/general-functions.pl'; - -&General::log("PPP has gone down on $ARGV[0]"); - -umask 022; -unlink "${General::swroot}/red/active"; -system "/etc/rc.d/init.d/net/red/update"; +rm -f /var/ipfire/red/active -# Beep when ppp goes up or down. Silence if 'nobeeps' file exists. -if ( ! -e "${General::swroot}/ppp/nobeeps") { - system('/usr/bin/beep','-l 75', '-f 880', '-n', '-l 75', '-f 440'); -} +[ -e "/var/ipfire/ppp/nobeeps" ] || /etc/rc.d/init.d/beep down -if ( -e "${General::swroot}/red/keepconnected") { - if ( system ('/bin/ps ax | /bin/grep -q "[r]c.connectioncheck reconnect"') ) { - system ('/etc/rc.d/init.d/connectioncheck reconnect &'); - } else { - &General::log ('connectioncheck reconnect already running'); - } -} +[ -e "/var/ipfire/red/keepconnected" ] && \ + (ps ax | grep -q "connectioncheck reconnect") && \ + /etc/rc.d/init.d/connectioncheck reconnect & diff --git a/src/ppp/ip-up b/src/ppp/ip-up index 4dc6c05a9..bd7a37ad4 100644 --- a/src/ppp/ip-up +++ b/src/ppp/ip-up @@ -1,58 +1,28 @@ -#!/usr/bin/perl +#!/bin/sh # -# SmoothWall CGIs -# -# This code is distributed under the terms of the GPL -# -# (c) The SmoothWall Team -# -# $Id: ip-up,v 1.3.2.3 2005/01/26 12:23:26 riddles Exp $ -# - -use strict; -require '/var/ipfire/general-functions.pl'; - -&General::log("PPP has gone up on $ARGV[0]"); -umask 022; - -my %pppsettings; -# read vars back from file. -&General::readhash("${General::swroot}/ppp/settings", \%pppsettings); +PRIMARY_DNS=$DNS1 +SECONDARY_DNS=$DNS2 -if ( ( $pppsettings{'TYPE'} eq 'isdn') && - ( $pppsettings{'COMPORT'} eq 'isdn2') && - ( $pppsettings{'USEIBOD'} eq 'off') ) { - system('/usr/sbin/isdnctrl', 'dial', 'ippp1'); -} +eval $(/usr/local/bin/readhash /var/ipfire/ppp/settings) -my $dns = $pppsettings{'DNS'}; -my $primarydns = $pppsettings{'DNS1'}; -my $secondarydns = $pppsettings{'DNS2'}; -if ($dns eq 'Automatic') { - if (!($pppsettings{'TYPE'} =~ /^isdn/)) - { - if (open(FILE, ">${General::swroot}/red/dns1")) { print FILE $ENV{'DNS1'}; close FILE; } - if (open(FILE, ">${General::swroot}/red/dns2")) { print FILE $ENV{'DNS2'}; close FILE; } - } +if [ "$DNS" == "Automatic" ]; then + if [ "$TYPE" == "isdn" ]; then + echo -n "$MS_DNS1" > /var/ipfire/red/dns1 + echo -n "$MS_DNS2" > /var/ipfire/red/dns2 else - { - if (open(FILE, ">${General::swroot}/red/dns1")) { print FILE $ENV{'MS_DNS1'}; close FILE; } - if (open(FILE, ">${General::swroot}/red/dns2")) { print FILE $ENV{'MS_DNS2'}; close FILE; } - } -} else { - if (open(FILE, ">${General::swroot}/red/dns1")) { print FILE $pppsettings{'DNS1'}; close FILE; } - if (open(FILE, ">${General::swroot}/red/dns2")) { print FILE $pppsettings{'DNS2'}; close FILE; } -} + echo -n "$PRIMARY_DNS" > /var/ipfire/red/dns1 + echo -n "$SECONDARY_DNS" > /var/ipfire/red/dns2 + fi +else + echo -n "$DNS1" > /var/ipfire/red/dns1 + echo -n "$DNS2" > /var/ipfire/red/dns2 +fi -if (open(FILE, ">${General::swroot}/red/iface")) { print FILE $ARGV[0]; close (FILE); } -if (open(FILE, ">${General::swroot}/red/local-ipaddress")) { print FILE $ARGV[3]; close (FILE); } -if (open(FILE, ">${General::swroot}/red/remote-ipaddress")) { print FILE $ARGV[4]; close (FILE); } +echo -n "$1" > /var/ipfire/red/iface +echo -n "$4" > /var/ipfire/red/local-ipaddress +echo -n "$5" > /var/ipfire/red/remote-ipaddress -system('/usr/bin/touch', "${General::swroot}/red/active"); -system('/etc/rc.d/init.d/net/red/update'); +touch /var/ipfire/red/active -# Beep when ppp goes up or down. Silence if 'nobeeps' file exists. -if ( ! -e "${General::swroot}/ppp/nobeeps") { - system "/bin/echo -en '\a' >/dev/console"; -} +[ -e "/var/ipfire/ppp/nobeeps" ] || /etc/rc.d/init.d/beep up -- 2.39.2