etc/rc.d/init.d/networking/any
etc/rc.d/init.d/networking/blue
etc/rc.d/init.d/networking/dhcpcd.exe
+etc/rc.d/init.d/networking/functions.network
etc/rc.d/init.d/networking/green
etc/rc.d/init.d/networking/orange
etc/rc.d/init.d/networking/red
etc/rc.d/init.d/networking/red.up/99-U-dialctrl.pl
etc/rc.d/init.d/networking/red.up/99-fireinfo
etc/rc.d/init.d/networking/red.up/99-pakfire-update
+etc/rc.d/init.d/networking/wpa_supplicant.exe
#etc/rc.d/init.d/nfs-server
etc/rc.d/init.d/ntp
#etc/rc.d/init.d/nut
etc/rc.d/rc0.d/K78snort
etc/rc.d/rc0.d/K79leds
etc/rc.d/rc0.d/K80network
+etc/rc.d/rc0.d/K82wlanclient
#etc/rc.d/rc0.d/K84bluetooth
#etc/rc.d/rc0.d/K85messagebus
etc/rc.d/rc0.d/K85tmpfs
#etc/rc.d/rc3.d/S16bluetooth
#etc/rc.d/rc3.d/S18cpufreq
etc/rc.d/rc3.d/S19smartenabler
+etc/rc.d/rc3.d/S19wlanclient
etc/rc.d/rc3.d/S20network
etc/rc.d/rc3.d/S21leds
etc/rc.d/rc3.d/S24cyrus-sasl
etc/rc.d/rc6.d/K78snort
etc/rc.d/rc6.d/K79leds
etc/rc.d/rc6.d/K80network
+etc/rc.d/rc6.d/K82wlanclient
#etc/rc.d/rc6.d/K84bluetooth
#etc/rc.d/rc6.d/K85messagebus
etc/rc.d/rc6.d/K85tmpfs
ln -sf ../init.d/localnet /etc/rc.d/rcsysinit.d/S80localnet
ln -sf ../init.d/sysctl /etc/rc.d/rcsysinit.d/S90sysctl
ln -sf ../init.d/network-vlans /etc/rc.d/rcsysinit.d/S91network-vlans
+ ln -sf ../init.d/wlanclient /etc/rc.d/rc0.d/K82wlanclient
+ ln -sf ../init.d/wlanclient /etc/rc.d/rc3.d/S19wlanclient
+ ln -sf ../init.d/wlanclient /etc/rc.d/rc6.d/K82wlanclient
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
--- /dev/null
+#!/bin/sh
+#
+########################################################################
+# Begin
+#
+# Description : A collection of functions for the IPFire network scripts
+#
+# Authors : IPFire Development Team <developers@ipfire.org>
+#
+# Version : 01.00
+#
+# Notes :
+#
+########################################################################
+
+. /etc/sysconfig/rc
+. $rc_functions
+
+
+eval $(/usr/local/bin/readhash /var/ipfire/ethernet/settings)
+eval $(/usr/local/bin/readhash /var/ipfire/dns/settings)
+
+dhcpcd_get_pid() {
+ # This function returns the pid of a dhcpcd by a given
+ # network device, if a pidfile exists.
+
+ local device="$1"
+ local pidfile="/var/run/dhcpcd-${device}.pid"
+
+ # Check if a pid file exists.
+ if [ -f "${pidfile}" ] ; then
+
+ # Get the pid from the file.
+ local pid="$(<"${pidfile}")"
+
+ echo "${pid}"
+ fi
+}
+
+dhcpcd_is_running() {
+ # This functions checks if a dhcpcd is running by a given pid.
+
+ local pid="$1"
+
+ # Check if a dhcpcd is running.
+ if [ -n "${pid}" -a -d "/proc/${pid}" ]; then
+ # Return "0" (True) if a dhcpcd is running.
+ return 0
+ fi
+
+ # Return 1 (False) no dhcpcd is running.
+ return 1
+}
+
+dhcpcd_start() {
+ # This function will start a dhcpcd on a speciefied device.
+
+ local device="$1"
+ local dhcp_start=""
+
+ boot_mesg -n "Starting dhcpcd on the ${device} interface..."
+
+ # Check if a dhcpcd is already running.
+ local pid="$(dhcpcd_get_pid "${device}")"
+
+ if dhcpcd_is_running "${pid}"; then
+ boot_mesg "dhcpcd already running!" ${WARNING}
+ echo_warning
+ exit 2
+ fi
+
+ # Check if a DHCP hostname has been set.
+ if [ -n "${RED_DHCP_HOSTNAME}" ]; then
+ dhcp_start+="-h ${RED_DHCP_HOSTNAME}"
+ fi
+
+ # Start dhcpcd.
+ /sbin/dhcpcd "${device}" "${dhcp_start}" >/dev/null 2>&1
+ ret="$?"
+
+ if [ "${ret}" -eq 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: $ip_address"
+ boot_mesg_flush
+
+ if [ -n "${RED_DHCP_HOSTNAME}" ]; then
+ boot_mesg " Hostname: $RED_DHCP_HOSTNAME"
+ boot_mesg_flush
+ fi
+
+ boot_mesg " Subnet Mask: $subnet_mask"
+ boot_mesg_flush
+ boot_mesg " Default Gateway: $routers"
+ boot_mesg_flush
+ boot_mesg " DNS Server: $domain_name_servers"
+ boot_mesg_flush
+ else
+ echo ""
+ $(exit "${ret}")
+ evaluate_retval
+ fi
+}
+
+dhcpcd_stop() {
+ # This function stops a previously started dhcpcd on a given device.
+
+ local device="$1"
+ local dhcp_stop="-k"
+ local leaseinfo="/var/ipfire/dhcpc/dhcpcd-${device}.info"
+
+ boot_mesg -n "Stopping dhcpcd on the ${device} interface..."
+
+ # Check if a dhcpcd is running.
+ local pid="$(dhcpcd_get_pid "${device}")"
+
+ if ! dhcpcd_is_running "${pid}"; then
+ boot_mesg "dhcpcd not running!" ${WARNING}
+ echo_warning
+ exit 1
+ fi
+
+ # Check if we got a valid lease.
+ if [ -e $leaseinfo ]; then
+ . $leaseinfo
+ if [ "$dchp_lease_time" = "4294967295" ]; then
+ # do nothing, just echo ok
+ echo_ok
+ else
+ # Stop dhcpcd.
+ /sbin/dhcpcd "${device}" "${dhcp_stop}" &> /dev/null
+ ret="$?"
+
+ # Wait until dhcpd has stopped.
+ while [ -d "/proc/${pid}" ]; do
+ sleep 1
+ done
+
+ # Display console message, depended on the exit code
+ # of the stopped dhcpcd.
+ if [ "${ret}" -eq 0 ]; then
+ echo_ok
+ elif [ "${ret}" -eq 1 ]; then
+ boot_mesg "failed to stop dhcpcd!" ${WARNING}
+ echo_warning
+ else
+ echo_failure
+ fi
+ fi
+ fi
+}
. /etc/sysconfig/rc
. ${rc_functions}
+. /etc/init.d/networking/functions.network
#Define some defaults
INET_VLAN=7
fi
fi
-PIDFILE="/var/run/dhcpcd-${DEVICE}.pid"
-LEASEINFO="/var/ipfire/dhcpc/dhcpcd-${DEVICE}.info"
-DHCP_START=" "
-DHCP_STOP="-k "
-
case "${1}" in
start)
if [ "${DEVICE}" != "${GREEN_DEV}" ] && [ "${DEVICE}" != "" ]; then
/usr/local/bin/setaliases
elif [ "${TYPE}" == "DHCP" ]; then
+ # Add firewall rules to allow comunication with the dhcp server on red.
+ 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 [ -e $LEASEINFO ]; then
- boot_mesg -n "Stopping dhcpcd on the ${DEVICE} interface..."
- . $LEASEINFO
- if [ "$dhcp_lease_time" = "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
- fi
-
- boot_mesg -n "Starting dhcpcd on the ${DEVICE} interface..."
echo -n "${DEVICE}" > /var/ipfire/red/iface
+ # Check if the wlan-client is used on red.
+ # To determine this we check if a wpa_supplicant is running.
+ pid="$(pidof wpa_supplicant)"
+
+ if [ -z "${pid}" ]; then
+ # No wpa_supplicant is running. So it's save to start dhcpcd.
+ dhcpcd_start "${DEVICE}"
+ fi
+
## Create & Enable vnstat
/usr/bin/vnstat -u -i ${DEVICE} -r --enable --force > /dev/null 2>&1
- # 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 "${RED_DHCP_HOSTNAME}" ]; then
- DHCP_START+="-h ${RED_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: $ip_address"
- boot_mesg_flush
- if [ -n "${RED_DHCP_HOSTNAME}" ]; then
- boot_mesg " Hostname: $RED_DHCP_HOSTNAME"
- boot_mesg_flush
- fi
- boot_mesg " Subnet Mask: $subnet_mask"
- boot_mesg_flush
- boot_mesg " Default Gateway: $routers"
- boot_mesg_flush
- boot_mesg " DNS Server: $domain_name_servers"
- boot_mesg_flush
- else
- echo ""
- $(exit "$RET")
- evaluate_retval
- fi
-
elif [ "$TYPE" == "PPPOE" ]; then
if ( ps ax | grep -q [p]ppd ); then
# Add a NaN value to ppp0 rrd to supress spikes at reconnect
rrdtool update $RRDLOG/collectd/localhost/interface/if_octets-ppp0.rrd \
$(date +%s):: > /dev/null 2>&1
- fi
- if [ -e $LEASEINFO ]; then
- boot_mesg -n "Stopping dhcpcd on the ${DEVICE} interface..."
- . $LEASEINFO
- if [ "$dchp_lease_time" = "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
+ elif [ "$TYPE" == "DHCP" ]; then
+ # Check if the wlan-client is used on red.
+ # To determine this we check if a wpa_supplicant is running.
+ pid="$(pidof wpa_supplicant)"
+
+ if [ -z "${pid}" ]; then
+ # Stop dhcpcd.
+ dhcpcd_stop "${DEVICE}"
fi
fi
--- /dev/null
+#!/bin/bash
+########################################################################
+# Begin
+#
+# Description : wpa_supplicant Script
+#
+# Authors : IPFire Development Team <developers@ipfire.org>
+#
+# Version : 01.00
+#
+# Notes : This script starts/stops the dhclient if a WPA/WPA2
+# connection to an AP successfull has been established
+# or disconnected.
+#
+########################################################################
+
+. /etc/sysconfig/rc
+. ${rc_functions}
+. /etc/init.d/networking/functions.network
+
+# Gather required information from wpa_cli.
+device="$1"
+wpa_state="$2"
+
+# Check if the RED device has been configured to use DHCP or exit immediately.
+eval $(/usr/local/bin/readhash /var/ipfire/ethernet/settings)
+if [ ! "${RED_TYPE}" == "DHCP" ] ; then
+ exit 0
+fi
+
+case "${wpa_state}" in
+ CONNECTED)
+ # Start dhcpcd.
+ dhcpcd_start "${device}"
+
+ exit 0
+ ;;
+
+ DISCONNECTED)
+ # Stop dhcpcd.
+ dhcpcd_stop "${device}"
+
+ exit 0
+ ;;
+
+ *)
+ # When we ever got here, there is a really big problem.
+ exit 1
+ ;;
+esac
boot_mesg "Stopping wireless event handler on ${RED_DEV}..."
killproc wpa_cli
+ # wpa_cli does not send a disconnect event when get stopped.
+ # So we manually have to send it to the wpa_supplicant.exe.
+ /etc/rc.d/init.d/networking/wpa_supplicant.exe "${RED_DEV}" DISCONNECTED
+
boot_mesg "Stopping wireless client on ${RED_DEV}..."
killproc wpa_supplicant
+
+ # Tidy up /tmp directory.
+ rm -f /tmp/wpa_ctrl_*
}
case "${1}" in