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/netctl | |
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/netctl')
-rwxr-xr-x | src/netctl | 106 |
1 files changed, 106 insertions, 0 deletions
diff --git a/src/netctl b/src/netctl new file mode 100755 index 0000000..f1d79e8 --- /dev/null +++ b/src/netctl @@ -0,0 +1,106 @@ +#!/bin/bash + +. /usr/lib/network/network + +NETCFG_VER=2-notpackaged + +version() +{ + echo "netcfg v$NETCFG_VER" +} + +usage() +{ + version + cat << END +Usage: + Start specified profile: netcfg profile + Other functions: netcfg argument profile +Arguments: + current Report currently running profiles +-a, all-down Take all active profiles down +-c, check-iface Do not start profile if interface is already up +-d, down Take specified profile down +-D, iface-down Take down profile active on specified interface +-h, help This help message +-l, list List all available profiles +-r, reconnect Disconnect and reconnect specified profile +-R, iface-recon Reconnect profile active on specified interface +-u, up Start specified profile +-v, version Output version information and exit + all-resume Resume previously suspended profiles and reconnect them + all-suspend Store a list of current running profiles and suspend them +END +} + +# TODO: Re-add ROOT check and rewrite with getopts from BashFAQ + +case "$1" in + --version|-v|version) + version + exit 0;; + --help|-h|help) + usage + exit 0;; + list|-l) + list_profiles + exit 0;; + current|-s|status) + if [[ -d "$STATE_DIR/profiles/" ]]; then + ls "$STATE_DIR/profiles/" + exit 0 + else + exit_stderr "No active profiles." + fi;; +esac + +if [[ $(id -u) -gt 0 ]]; then + exit_stderr "This script should be run as root." +fi + +# Ensure cwd is not in a transient directory, which may prevent unmounting due to netcfg children +cd / + +case "$1" in + -c|check-iface|-u|up) + CHECK="YES" + profile_up "$2";; + -d|down) + profile_down "$2";; + -D|iface-down) + interface_down "$2";; + -a|all-down) + all_down;; + -r|reconnect) + profile_down "$2" + profile_up "$2";; + -R|iface-recon) + interface_reconnect "$2";; + all-resume) + all_resume;; + all-suspend) + all_suspend;; + clean) + rm "$STATE_DIR/interfaces"/* 2> /dev/null + rm "$STATE_DIR/profiles"/* 2> /dev/null + rm "$STATE_DIR/suspend"/* 2> /dev/null + rm "$STATE_DIR/netcfg-daemon" 2> /dev/null + killall wpa_supplicant 2> /dev/null + killall dhcpcd 2> /dev/null + killall dhclient 2> /dev/null + ;; + -*|--*) + usage + exit 1;; + *) + if [[ -n "$1" ]]; then + profile_up "$1" + else + usage + exit 1 + fi + ;; +esac +exit $? + +# vim: ft=sh ts=4 et sw=4: |