summaryrefslogtreecommitdiffstats
path: root/scripts
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 /scripts
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 'scripts')
-rw-r--r--scripts/ifplugd.action54
-rwxr-xr-xscripts/net-profiles76
-rwxr-xr-xscripts/net-rename26
-rwxr-xr-xscripts/netcfg2
-rwxr-xr-xscripts/netcfg-wpa_actiond90
-rwxr-xr-xscripts/netcfg-wpa_actiond-action54
6 files changed, 199 insertions, 103 deletions
diff --git a/scripts/ifplugd.action b/scripts/ifplugd.action
new file mode 100644
index 0000000..0c081df
--- /dev/null
+++ b/scripts/ifplugd.action
@@ -0,0 +1,54 @@
+#!/bin/sh
+#
+# ifplugd.action script for netcfg
+
+. /etc/rc.conf
+. /etc/rc.d/functions
+. /usr/lib/network/network
+shopt -s extglob
+
+case "$2" in
+ up)
+ # Look for a dhcp based profile to try first
+ # dhcp can actually outright fail, whereas
+ # it's difficult to tell if static succeeded
+ # Also check profile is same iface and is right connection
+ echo "up"
+ declare -a preferred_profiles
+ declare -a dhcp_profiles
+ declare -a static_profiles
+ for profile in $(list_profiles); do (
+ load_profile "$profile"
+ echo "loading $profile"
+ [[ "$INTERFACE" != "$1" ]] && continue
+ [[ "$CONNECTION" != @(ethernet|ethernet-iproute) ]] && continue
+ checkyesno "${AUTO_WIRED:-no}" && exit 1 # user preferred AUTO profile
+ [[ "$IP" == "dhcp" ]] && exit 2 # dhcp profile
+ exit 3 # static profile
+ )
+ case $? in
+ 1) preferred_profiles+=("$profile");;
+ 2) dhcp_profiles+=("$profile");;
+ 3) static_profiles+=("$profile");;
+ esac
+ done
+ if [[ ${#preferred_profiles[@]} > 1 ]]; then
+ echo "AUTO_WIRED flag for $1 set in more than one profile (${preferred_profiles[*]})"
+ else
+ for profile in "${preferred_profiles[@]}" "${dhcp_profiles[@]}" "${static_profiles[@]}"; do (
+ netcfg "$profile" && exit 1
+ exit 0
+ ) || exit 0; done
+ fi
+ ;;
+ down)
+ if check_iface "$1"; then
+ netcfg -i "$1" && exit 0
+ fi
+ ;;
+ *)
+ echo "Wrong arguments" > /dev/stderr
+ ;;
+esac
+
+exit 1
diff --git a/scripts/net-profiles b/scripts/net-profiles
deleted file mode 100755
index cbaea30..0000000
--- a/scripts/net-profiles
+++ /dev/null
@@ -1,76 +0,0 @@
-#!/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/scripts/net-rename b/scripts/net-rename
deleted file mode 100755
index 1a51ffe..0000000
--- a/scripts/net-rename
+++ /dev/null
@@ -1,26 +0,0 @@
-#!/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:
diff --git a/scripts/netcfg b/scripts/netcfg
index 82a9618..9d341e5 100755
--- a/scripts/netcfg
+++ b/scripts/netcfg
@@ -2,7 +2,7 @@
. /usr/lib/network/network
-NETCFG_VER=2.6.8
+NETCFG_VER=2.7
version()
{
diff --git a/scripts/netcfg-wpa_actiond b/scripts/netcfg-wpa_actiond
new file mode 100755
index 0000000..bb144c3
--- /dev/null
+++ b/scripts/netcfg-wpa_actiond
@@ -0,0 +1,90 @@
+#! /bin/bash
+. /usr/lib/network/network
+. $SUBR_DIR/8021x
+. $SUBR_DIR/rfkill
+. /etc/rc.conf
+. /etc/conf.d/netcfg
+
+AUTOWIFI="/usr/sbin/wpa_actiond -p /run/wpa_supplicant"
+ACTION_SCRIPT="/usr/bin/netcfg-wpa_actiond-action"
+
+case $1 in
+ help)
+ echo "netcfg-wpa_actiond <interface>"
+ echo "netcfg-wpa_actiond stop <interface>"
+ exit
+ ;;
+ stop)
+ [[ -z $2 ]] && echo "Please specify an interface to stop" && exit 1
+ interface=$2
+ [[ -f "$IFACE_DIR/$interface" ]] && source "$IFACE_DIR/$interface"
+ netcfg -i "$interface"
+ stop_wpa "$interface"
+ kill $(cat "/run/wpa_actiond_${2}.pid")
+ # only try to disable software rfkill switches (FS#25514)
+ if [[ "$RFKILL" == "soft" ]]; then
+ set_rf_state "$interface" disabled $RFKILL_NAME || exit $?
+ fi
+ exit
+ ;;
+ *)
+ interface=$1; shift
+ PIDFILE="/run/wpa_actiond_${interface}.pid"
+ EXTRA_AUTOWIFI_OPTIONS="$*"
+ ;;
+esac
+
+if [[ -z $interface ]]; then
+ echo "No interface specified"
+ exit 1
+fi
+
+# Load interface specific config
+[[ -f "$IFACE_DIR/$interface" ]] && source "$IFACE_DIR/$interface"
+
+if [[ -f "$CONN_DIR/interfaces/$interface" ]]; then
+ netcfg -i $interface
+fi
+
+if [[ -n "$RFKILL" ]]; then # Enable radio if necessary
+ enable_rf $interface $RFKILL $RFKILL_NAME || exit $?
+fi
+
+WPA_CONF="$(make_wpa_config_file $interface)"
+
+if [[ -n "${AUTO_PROFILES}" ]]; then
+ for prof in ${AUTO_PROFILES}; do echo $prof; done
+else
+ list_profiles
+fi | while read profile; do
+ echo "$profile"
+ (
+ load_profile "$profile"
+
+ [[ $CONNECTION != "wireless" ]] && exit 1
+ [[ $INTERFACE != $interface ]] && exit 1
+ # Exclude wpa-config, the wpa_conf is 'complete' and doesn't fit in this scheme
+ [[ -z "$SECURITY" ]] && SECURITY="none"
+ [[ $SECURITY == "wpa-config" ]] && exit 1
+
+ config=$(make_wpa_config)
+
+ echo -e "network={ \n$config \nid_str=\"$profile\" \n}" >> $WPA_CONF
+ )
+done
+
+
+[[ -z $WPA_DRIVER ]] && WPA_DRIVER="nl80211,wext"
+WPA_OPTS="-W $WPA_OPTS"
+
+# Kill any existing wpa_supplicant on this interface
+stop_wpa "$interface"
+
+if start_wpa $interface $WPA_CONF $WPA_DRIVER $WPA_OPTS; then
+ if $AUTOWIFI -i ${interface} -P ${PIDFILE} -a ${ACTION_SCRIPT} ${EXTRA_AUTOWIFI_OPTIONS}; then
+ exit 0
+ fi
+fi
+
+exit 1
+
diff --git a/scripts/netcfg-wpa_actiond-action b/scripts/netcfg-wpa_actiond-action
new file mode 100755
index 0000000..3547fef
--- /dev/null
+++ b/scripts/netcfg-wpa_actiond-action
@@ -0,0 +1,54 @@
+#! /bin/bash
+
+interface="$1"
+ssid="$2"
+profile="$3"
+action="$4"
+
+. /usr/lib/network/network
+[[ "$profile" ]] && load_profile "$profile"
+
+case $action in
+ CONNECT)
+ if [[ -z $profile ]]; then
+ dhcpcd "$interface"
+ exit $?
+ fi
+ if ! $CONN_DIR/ethernet up "$profile"; then
+ exit 1 # what to do if fail?
+ fi
+
+ set_profile up "$profile"
+
+ if ! ( eval $POST_UP ); then # JP: sandbox the eval
+ # failing POST_UP will take interface down
+ "$CONN_DIR/$ethernet" down "$profile"
+ exit 1
+ fi
+ ;;
+ DISCONNECT)
+ if [[ -z $profile ]]; then
+ dhcpcd -k "$interface"
+ exit $?
+ fi
+ if ! ( eval $PRE_DOWN ); then # JP: sandbox the eval
+ exit 1
+ fi
+ if ! "$CONN_DIR/ethernet" down "$profile"; then
+ exit 1
+ fi
+ if ! ( eval $POST_DOWN ); then # JP: sandbox the eval
+ exit 1
+ fi
+ set_profile down "$profile"
+ ;;
+ LOST|REESTABLISHED)
+ # Not handled.
+ exit 0
+ ;;
+ *)
+ # ???
+ exit 1
+ ;;
+esac
+