summaryrefslogtreecommitdiffstats
path: root/rc.d
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
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')
-rwxr-xr-xrc.d/net-auto-wired52
-rwxr-xr-xrc.d/net-auto-wireless65
-rwxr-xr-xrc.d/net-profiles76
-rwxr-xr-xrc.d/net-rename26
4 files changed, 219 insertions, 0 deletions
diff --git a/rc.d/net-auto-wired b/rc.d/net-auto-wired
new file mode 100755
index 0000000..9af8505
--- /dev/null
+++ b/rc.d/net-auto-wired
@@ -0,0 +1,52 @@
+#!/bin/bash
+
+. /etc/rc.conf
+. /etc/rc.d/functions
+
+if [[ ! -x /usr/sbin/ifplugd ]]; then
+ echo "Please install 'ifplugd' to use net-auto-wired"
+ exit 1
+fi
+
+CFG=/etc/ifplugd/ifplugd.conf
+ACTION=/etc/ifplugd/netcfg.action
+PIDFILE=/var/run/ifplugd.$WIRED_INTERFACE.pid
+[[ -f $PIDFILE ]] && PID=$(cat $PIDFILE)
+
+# Source ifplugd configuration
+[ -f $CFG ] && . $CFG
+
+case "$1" in
+ start)
+ stat_busy "Starting netcfg auto-wired mode for interface ${WIRED_INTERFACE}"
+ A="`eval echo \$\{ARGS_${WIRED_INTERFACE}\}`"
+ [ -z "$A" ] && A="$ARGS"
+ [ -z "$PID" ] && /usr/sbin/ifplugd -i $WIRED_INTERFACE -r $ACTION $A
+ # ifplugd may return non-zero, but still succeed if -w is passed, as default in upstream config.
+ sleep 1
+ if [[ ! -f $PIDFILE ]]; then
+ stat_fail
+ else
+ add_daemon net-auto-wired
+ stat_done
+ fi
+ ;;
+ stop)
+ stat_busy "Stopping netcfg auto-wired mode for interface ${WIRED_INTERFACE}"
+ [ -n "$PID" ] && /usr/sbin/ifplugd -k -i $WIRED_INTERFACE -r $ACTION
+ if [ $? -gt 0 ]; then
+ stat_fail
+ else
+ rm_daemon net-auto-wired
+ stat_done
+ fi
+ ;;
+ restart)
+ $0 stop
+ sleep 1
+ $0 start
+ ;;
+ *)
+ echo "usage: $0 {start|stop|restart}"
+esac
+exit 0
diff --git a/rc.d/net-auto-wireless b/rc.d/net-auto-wireless
new file mode 100755
index 0000000..d6a3c44
--- /dev/null
+++ b/rc.d/net-auto-wireless
@@ -0,0 +1,65 @@
+#!/bin/bash
+
+. /etc/rc.conf
+. /etc/rc.d/functions
+. /usr/lib/network/globals
+. /etc/conf.d/netcfg
+
+if [[ ! -x /usr/sbin/wpa_actiond ]]; then
+ echo "Please install 'wpa_actiond' to use net-auto-wireless"
+ exit 1
+fi
+
+if [ -z "${WIRELESS_INTERFACE}" ]; then
+ echo "No interface name set. Add to /etc/conf.d/netcfg a line"
+ echo " WIRELESS_INTERFACE=\"your_interface\""
+ exit 1
+fi
+
+case "$1" in
+ start)
+ if ! ck_daemon net-auto-wireless; then
+ exit_stderr "net-auto-wireless has already been started: try \"/etc/rc.d/net-auto-wireless 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
+
+ stat_busy "Starting netcfg auto-wireless mode for interface ${WIRELESS_INTERFACE}"
+ /usr/bin/netcfg-wpa_actiond "${WIRELESS_INTERFACE}" >/dev/null
+ if [ $? -eq 0 ]; then
+ add_daemon net-auto-wireless
+ stat_done
+ else
+ stat_fail
+ fi
+ ;;
+ stop)
+ if ! ck_daemon net-auto-wireless; then
+ stat_busy "Stopping netcfg auto-wireless mode for interface ${WIRELESS_INTERFACE}"
+ /usr/bin/netcfg-wpa_actiond stop "${WIRELESS_INTERFACE}" >/dev/null
+ if [ $? -eq 0 ]; then
+ rm_daemon net-auto-wireless
+ stat_done
+ else
+ stat_fail
+ fi
+ fi
+ ;;
+ restart)
+ "$0" stop
+ sleep 1
+ "$0" start
+ ;;
+ *)
+ echo "Usage: $0 {start|stop|restart}"
+ exit 1
+ ;;
+esac
+exit 0
+# vim: ft=sh ts=4 et sw=4:
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:
diff --git a/rc.d/net-rename b/rc.d/net-rename
new file mode 100755
index 0000000..1a51ffe
--- /dev/null
+++ b/rc.d/net-rename
@@ -0,0 +1,26 @@
+#!/bin/bash
+
+. /usr/lib/network/globals
+
+case "$1" in
+ start)
+ report_try "Renaming network devices"
+ ifrename -p -t
+ report_success
+
+ add_daemon net-rename
+ ;;
+ stop)
+ rm_daemon net-rename
+ # No stop neccesary, but add one to look nice on shutdown.
+ /bin/true
+ ;;
+ restart)
+ "$0" start
+ ;;
+ *)
+ exit_stderr "Usage: $0 {start|stop|restart}"
+ ;;
+esac
+
+# vim: ft=sh ts=4 et sw=4: