summaryrefslogtreecommitdiffstats
path: root/scripts/netcfg-daemon
diff options
context:
space:
mode:
authorJouke Witteveen <j.witteveen@gmail.com>2012-12-28 02:38:58 +0100
committerJouke Witteveen <j.witteveen@gmail.com>2012-12-28 02:38:58 +0100
commit4e457e0efd0e5fd5df24c7e9ed63b02d0196ea8d (patch)
tree09580c92ca78e8b9b54d7ed8d6b79d7fcd6fd9ff /scripts/netcfg-daemon
parent6737a37e5666837a8f51a2f74bdebdd756151394 (diff)
downloadnetctl-4e457e0efd0e5fd5df24c7e9ed63b02d0196ea8d.tar.gz
netctl-4e457e0efd0e5fd5df24c7e9ed63b02d0196ea8d.tar.xz
Forking netcfg to netctl (1/2)
This commit contains the moving of files.
Diffstat (limited to 'scripts/netcfg-daemon')
-rwxr-xr-xscripts/netcfg-daemon102
1 files changed, 0 insertions, 102 deletions
diff --git a/scripts/netcfg-daemon b/scripts/netcfg-daemon
deleted file mode 100755
index b3111da..0000000
--- a/scripts/netcfg-daemon
+++ /dev/null
@@ -1,102 +0,0 @@
-#!/bin/bash
-#
-# This script implements support for the NETWORKS array in /etc/conf.d/netcfg.
-
-. /usr/lib/network/globals
-. /etc/conf.d/netcfg
-STATE_FILE="$STATE_DIR/netcfg-daemon"
-LAST_STATE="/var/lib/netcfg/netcfg.state"
-
-case "$1" in
- start)
- (( $(id -u) )) && exit_stderr "This script should be run as root."
- [[ -e $STATE_FILE ]] && exit_err "netcfg-daemon is already started"
- [[ ${NETWORKS+x} != x ]] && exit_err "NETWORKS is not set in /etc/conf.d/netcfg"
-
- if [[ ${#NETWORKS[@]} -eq 1 ]]; then
- case $NETWORKS in
- last)
- if [[ ! -e $LAST_STATE ]]; then
- report_err "No recorded netcfg state to restore"
- # This counts as successful startup since the daemon
- # should be stopped on shutdown.
- exit 0
- fi
-
- # The order in LAST_STATE is meaningless so we can just as
- # well start the profiles in parallel.
- while read profile; do
- if /usr/bin/netcfg up "$profile"; then
- echo "$profile" >> "$STATE_FILE"
- fi &
- done < "$LAST_STATE"
- wait
- exit $? ;;
- menu)
- /usr/bin/netcfg-menu ${NETWORKS_MENU_TIMEOUT-5} && \
- mv "$STATE_DIR/menu" "$STATE_FILE"
- exit $? ;;
- esac
- fi
-
- for profile in "${NETWORKS[@]}"; do
- if [[ "$profile" = "${profile#@}" ]]; then
- if /usr/bin/netcfg check-iface "$profile"; then
- echo "$profile" >> "$STATE_FILE"
- fi
- else
- # It is up to the user to make sure no backgrounded profile
- # uses an interface that is used by another active profile.
- if /usr/bin/netcfg up "${profile#@}"; then
- echo "$profile" >> "$STATE_FILE"
- fi >/dev/null &
- PROFILE_BKGD=1
- fi
- done
- # Generate a return value.
- [[ -f $STATE_FILE || -n $PROFILE_BKGD ]]
- ;;
- stop)
- (( $(id -u) )) && exit_stderr "This script should be run as root."
-
- if [[ ${#NETWORKS[@]} -eq 1 && $NETWORKS = last ]]; then
- mkdir -p "$(dirname "$LAST_STATE")"
- /usr/bin/netcfg current > "$LAST_STATE"
- /usr/bin/netcfg all-down
- exit $?
- fi
-
- [[ ! -e $STATE_FILE ]] && exit_err "netcfg-daemon was not started"
- # Stop the profiles in the reverse order they were started.
- tac "$STATE_FILE" | (
- while read profile; do
- if [[ -e "$STATE_DIR/profiles/${profile#@}" ]]; then
- if [[ "$profile" = "${profile#@}" ]]; then
- /usr/bin/netcfg down "$profile" || exit $?
- else
- /usr/bin/netcfg down "${profile#@}" &
- fi
- fi
- done
- rm "$STATE_FILE"
- # Generate a return value and make sure we are good to restart.
- wait
- )
- ;;
- restart)
- "$0" stop
- sleep 1
- "$0" start
- ;;
- status)
- if [[ -e $STATE_FILE ]]; then
- report_notice "profiles started by netcfg-daemon:"
- sed 's/^@//' "$STATE_FILE"
- else
- report_notice "netcfg-daemon was not started"
- fi
- ;;
- *)
- echo "Usage: $0 {start|stop|restart|status}"
-esac
-