diff options
author | Jouke Witteveen <j.witteveen@gmail.com> | 2012-12-28 02:38:58 +0100 |
---|---|---|
committer | Jouke Witteveen <j.witteveen@gmail.com> | 2012-12-28 02:38:58 +0100 |
commit | 4e457e0efd0e5fd5df24c7e9ed63b02d0196ea8d (patch) | |
tree | 09580c92ca78e8b9b54d7ed8d6b79d7fcd6fd9ff /src/lib/auto.action | |
parent | 6737a37e5666837a8f51a2f74bdebdd756151394 (diff) | |
download | netctl-4e457e0efd0e5fd5df24c7e9ed63b02d0196ea8d.tar.gz netctl-4e457e0efd0e5fd5df24c7e9ed63b02d0196ea8d.tar.xz |
Forking netcfg to netctl (1/2)
This commit contains the moving of files.
Diffstat (limited to 'src/lib/auto.action')
-rwxr-xr-x | src/lib/auto.action | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/src/lib/auto.action b/src/lib/auto.action new file mode 100755 index 0000000..1f29364 --- /dev/null +++ b/src/lib/auto.action @@ -0,0 +1,56 @@ +#! /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 + # Load interface specific config + [[ -f "$IFACE_DIR/$interface" ]] && source "$IFACE_DIR/$interface" + dhcpcd -qL -t "${DHCP_TIMEOUT:-10}" -K $DHCP_OPTIONS "$interface" + exit $? + fi + if ! DHCPCD_INTERNAL_OPTIONS="-K" $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 + |