summaryrefslogtreecommitdiff
path: root/net-services
diff options
context:
space:
mode:
Diffstat (limited to 'net-services')
-rwxr-xr-xnet-services/dhcpcd70
-rwxr-xr-xnet-services/ipv4-static83
-rwxr-xr-xnet-services/wpa89
3 files changed, 242 insertions, 0 deletions
diff --git a/net-services/dhcpcd b/net-services/dhcpcd
new file mode 100755
index 0000000..050413c
--- /dev/null
+++ b/net-services/dhcpcd
@@ -0,0 +1,70 @@
+#!/bin/bash
+# Begin services/dhcpcd
+
+# Origianlly dased upon lfs-bootscripts-1.12 $NETWORK_DEVICES/if{down,up}
+# Rewritten by Nathan Coulson <nathan@linuxfromscratch.org>
+# Adapted for dhcpcd by DJ Lucas <dj@linuxfromscratch.org>
+# Update for LFS 7.0 by Bruce Dubbs <bdubbs@linuxfromscratch,org>
+
+# Call with: IFCONFIG=<filename> /lib/services/dhcpcd <IFACE> <up | down>
+
+#$LastChangedBy: bdubbs $
+#$Date: 2012-04-09 19:48:51 +0000 (Mon, 09 Apr 2012) $
+
+#. /lib/lsb/init-functions
+. $IFCONFIG
+
+pidfile="/var/run/dhcpcd-$1.pid"
+
+case "$2" in
+ up)
+ # Cosmetic output not needed for multiple services
+ #if ! $(echo ${SERVICE} | grep -q " "); then
+ # log_info_msg2 "\n" # Terminate the previous message
+ #fi
+
+ echo "Starting dhcpcd on the $1 interface..."
+
+ # 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
+ echo "dhcpcd is already running!"
+ exit 2
+ fi
+ fi
+
+ /sbin/dhcpcd $1 $DHCP_START
+ #evaluate_retval
+ ;;
+
+ down)
+ echo "Stopping dhcpcd on the $1 interface..."
+
+ if [ -z "$DHCP_STOP" ]; then
+ kill -9 $(cat ${pidfile})
+ rm -f ${pidfile}
+
+ else
+ /sbin/dhcpcd $1 $DHCP_STOP &> /dev/null
+
+ if [ "$?" -eq 1 ]; then
+ echo "dhcpcd not running!"
+ exit 2
+ fi
+ fi
+
+ #evaluate_retval
+ ;;
+
+ *)
+ echo "Usage: $0 [interface] {up|down}"
+ exit 1
+ ;;
+esac
+
+# End services/dhcpcd
diff --git a/net-services/ipv4-static b/net-services/ipv4-static
new file mode 100755
index 0000000..51cfa20
--- /dev/null
+++ b/net-services/ipv4-static
@@ -0,0 +1,83 @@
+#!/bin/sh
+########################################################################
+# Begin /lib/services/ipv4-static
+#
+# Description : IPV4 Static Boot Script
+#
+# Authors : Nathan Coulson - nathan@linuxfromscratch.org
+# Kevin P. Fleming - kpfleming@linuxfromscratch.org
+# Update : Bruce Dubbs - bdubbs@linuxfromscratch.org
+#
+# Version : LFS 7.0
+#
+########################################################################
+
+#. /lib/lsb/init-functions
+. ${IFCONFIG}
+
+if [ -z "${IP}" ]; then
+ echo "IP variable missing from ${IFCONFIG}, cannot continue."
+ exit 1
+fi
+
+if [ -z "${PREFIX}" -a -z "${PEER}" ]; then
+ echo "PREFIX variable missing from ${IFCONFIG}, assuming 24."
+ PREFIX=24
+ args="${args} ${IP}/${PREFIX}"
+
+elif [ -n "${PREFIX}" -a -n "${PEER}" ]; then
+ echo "PREFIX and PEER both specified in ${IFCONFIG}, cannot continue."
+ exit 1
+
+elif [ -n "${PREFIX}" ]; then
+ args="${args} ${IP}/${PREFIX}"
+
+elif [ -n "${PEER}" ]; then
+ args="${args} ${IP} peer ${PEER}"
+fi
+
+if [ -n "${BROADCAST}" ]; then
+ args="${args} broadcast ${BROADCAST}"
+fi
+
+case "${2}" in
+ up)
+ if [ "$(ip addr show ${1} 2>/dev/null | grep ${IP}/)" = "" ]; then
+
+ # Cosmetic output not needed for multiple services
+ #if ! $(echo ${SERVICE} | grep -q " "); then
+ # echo "" # Terminate the previous message
+ #fi
+
+ echo "Adding IPv4 address ${IP} to the ${1} interface..."
+ ip addr add ${args} dev ${1}
+ #evaluate_retval
+ else
+ echo "Cannot add IPv4 address ${IP} to ${1}. Already present."
+ fi
+ ;;
+
+ down)
+ if [ "$(ip addr show ${1} 2>/dev/null | grep ${IP}/)" != "" ]; then
+ echo "Removing IPv4 address ${IP} from the ${1} interface..."
+ ip addr del ${args} dev ${1}
+ #evaluate_retval
+ fi
+
+ if [ -n "${GATEWAY}" ]; then
+ # Only remove the gateway if there are no remaining ipv4 addresses
+ if [ "$(ip addr show ${1} 2>/dev/null | grep 'inet ')" != "" ]; then
+ echo "Removing default gateway..."
+ ip route del default
+ #evaluate_retval
+ fi
+ fi
+ ;;
+
+ *)
+ echo "Usage: ${0} [interface] {up|down}"
+ exit 1
+ ;;
+esac
+
+# End /lib/services/ipv4-static
diff --git a/net-services/wpa b/net-services/wpa
new file mode 100755
index 0000000..bf176e9
--- /dev/null
+++ b/net-services/wpa
@@ -0,0 +1,89 @@
+#!/bin/bash
+# Begin services/wpa
+
+# Origianlly based upon lfs-bootscripts-1.12 $NETWORK_DEVICES/if{down,up}
+# Written by Armin K. <krejzi at email dot com>
+
+# Call with: IFCONFIG=<filename> /lib/services/wpa <IFACE> <up | down>
+
+#$LastChangedBy: krejzi $
+#$Date: 2013-03-24 15:39:14 +0000 (Sun, 24 Mar 2013) $
+
+#. /lib/lsb/init-functions
+. $IFCONFIG
+
+CFGFILE=/etc/sysconfig/wpa_supplicant-${IFCONFIG##*.}.conf
+PIDFILE=/run/wpa_supplicant/$1.pid
+CONTROL_IFACE=/run/wpa_supplicant/$1
+
+case "$2" in
+ up)
+
+ if [ -e ${PIDFILE} ]; then
+ ps $(cat ${PIDFILE}) | grep wpa_supplicant >/dev/null
+ if [ "$?" = "0" ]; then
+ echo "wpa_supplicant already running on $1."
+ exit 0
+ else
+ rm ${PIDFILE}
+ fi
+ fi
+
+ if [ ! -e ${CFGFILE} ]; then
+ echo "wpa_supplicant configuration file ${CFGFILE} not present."
+ echo "wpa_supplicant cannot be started."
+ exit 1
+ fi
+
+ echo "Starting wpa_supplicant on the $1 interface..."
+
+ mkdir -p /run/wpa_supplicant
+
+ /sbin/wpa_supplicant -q -B -Dnl80211,wext -P${PIDFILE} -C/run/wpa_supplicant -c${CFGFILE} -i$1 ${WPA_ARGS}
+
+ if [ "$?" != "0" ]; then
+ echo "wpa_supplicant failed to start."
+ exit 1
+ fi
+
+ echo "wpa_supplicant successfully started."
+
+ if [ -n "${WPA_SERVICE}" ]; then
+ if [ ! -e /lib/services/${WPA_SERVICE} -a ! -x /lib/services/${WPA_SERVICE} ]; then
+ echo "Cannot start ${WPA_SERVICE} on $1"
+ #log_failure_msg2
+ exit 1
+ fi
+
+ IFCONFIG=${IFCONFIG} /lib/services/${WPA_SERVICE} $1 up
+ fi
+ ;;
+
+ down)
+ if [ -n "${WPA_SERVICE}" ]; then
+ if [ ! -e /lib/services/${WPA_SERVICE} -a ! -x /lib/services/${WPA_SERVICE} ]; then
+ echo "Cannot stop ${WPA_SERVICE} on $1"
+ else
+ IFCONFIG=${IFCONFIG} /lib/services/${WPA_SERVICE} $1 down
+ fi
+ fi
+
+ echo "Stopping wpa_supplicant on the $1 interface..."
+
+ if [ -e ${PIDFILE} ]; then
+ kill -9 $(cat ${PIDFILE})
+ rm -f ${PIDFILE} ${CONTROL_IFACE}
+ #evaluate_retval
+ else
+ echo "wpa_supplicant already stopped on $1"
+ exit 0
+ fi
+ ;;
+
+ *)
+ echo "Usage: $0 [interface] {up|down}"
+ exit 1
+ ;;
+esac
+
+# End services/wpa