summaryrefslogtreecommitdiffstats
path: root/rc.d/net-profiles
diff options
context:
space:
mode:
authorRémy Oudompheng <remy@archlinux.org>2011-08-20 13:13:35 +0200
committerRémy Oudompheng <remy@archlinux.org>2011-08-20 13:13:35 +0200
commit1227a80b24c943438757e933bd568ceddd00479b (patch)
treee88638495f85726377dfa6cf4279ab31c3f54534 /rc.d/net-profiles
parentec0e041a8eab919abef8e3af289c979ee1737382 (diff)
downloadnetctl-1227a80b24c943438757e933bd568ceddd00479b.tar.gz
netctl-1227a80b24c943438757e933bd568ceddd00479b.tar.xz
Reorganize files to match install location closer
Signed-off-by: Rémy Oudompheng <remy@archlinux.org>
Diffstat (limited to 'rc.d/net-profiles')
-rwxr-xr-xrc.d/net-profiles76
1 files changed, 76 insertions, 0 deletions
diff --git a/rc.d/net-profiles b/rc.d/net-profiles
new file mode 100755
index 0000000..cbaea30
--- /dev/null
+++ b/rc.d/net-profiles
@@ -0,0 +1,76 @@
+#!/bin/bash
+
+. /usr/lib/network/globals
+
+case "$1" in
+ start)
+ if ! ck_daemon net-profiles; then
+ exit_stderr "net-profiles has already been started. Try '/etc/rc.d/net-profiles restart'"
+ fi
+
+ # Ensure any device renaming has occurred as intended
+ for daemon in "${DAEMONS[@]}"; do
+ if [[ "$daemon" = "${daemon#!}" && "$daemon" = "net-rename" ]]; then
+ if ck_daemon net-rename; then
+ /etc/rc.d/net-rename start
+ fi
+ fi
+ done
+
+ # $NET env var is passed from the kernel boot line
+ [[ -z "$NETWORKS_MENU_TIMEOUT" ]] && NETWORKS_MENU_TIMEOUT=5
+
+ if [[ "$NET" = "menu" ]]; then
+ if /usr/bin/netcfg-menu "$NETWORKS_MENU_TIMEOUT"; then
+ mv "$STATE_DIR"/{menu,net-profiles} # JP: user may want to disconnect profile by calling net-profiles stop
+ add_daemon net-profiles
+ exit 0
+ fi
+ elif [[ -n "$NET" ]]; then
+ if /usr/bin/netcfg2 check-iface "$NET"; then
+ echo "$NET" > "$STATE_DIR/net-profiles" # JP: user may want to disconnect profile by calling net-profiles stop
+ add_daemon net-profiles
+ exit 0
+ fi
+ elif [[ $NETWORKS = "menu" ]]; then
+ if /usr/bin/netcfg-menu "$NETWORKS_MENU_TIMEOUT"; then
+ mv "$STATE_DIR"/menu "$STATE_DIR"/net-profiles
+ add_daemon net-profiles
+ exit 0
+ fi
+ else
+ # No NET= passed at boot, go to NETWORKS=()
+ for network in "${NETWORKS[@]}"; do
+ if [[ "$network" = "${network#!}" ]]; then
+ if /usr/bin/netcfg2 check-iface "$network"; then
+ echo "$network" >> "$STATE_DIR/net-profiles"
+ add_daemon net-profiles
+ fi
+ fi
+ done
+ fi
+ if [[ ! -f "$STATE_DIR"/net-profiles ]]; then
+ exit_err "No profile started." # JP: don't add_daemon unless we were successful (above)
+ fi
+ ;;
+ stop)
+ if ck_daemon net-profiles; then
+ exit_stderr "net-profiles not running"
+ fi
+
+ # shutdown any profiles started by netcfg (or from NET_PROFILES in rc.conf)
+ # JP: only attempt to disconnect the profiles _this daemon_ was told to control
+ for profile in $(cat "$STATE_DIR/net-profiles"); do
+ /usr/bin/netcfg2 down "$profile"
+ done
+ rm -f "$STATE_DIR/net-profiles"
+ rm_daemon net-profiles
+ ;;
+ restart)
+ "$0" stop; sleep 1; "$0" start
+ ;;
+ *)
+ exit_stderr "Usage: $0 {start|stop|restart}"
+esac
+
+# vim: ft=sh ts=4 et sw=4: