From 3ca36638947f69755e956e432fa4f926f42a3faf Mon Sep 17 00:00:00 2001 From: Karthik K Date: Wed, 6 May 2015 22:38:40 +0530 Subject: [PATCH] Print descriptive messages for several switches * Print messages for terminating switches like --list, --stop, --fix-unmanaged and --daemon * Minor change in help string --- bash_completion | 3 ++- create_ap | 7 ++++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/bash_completion b/bash_completion index 19f996b..23acf2d 100644 --- a/bash_completion +++ b/bash_completion @@ -111,7 +111,8 @@ _create_ap() { # No Options ;; --stop) - opts=$("$1" --list) + local stop_awk_cmd='$1 ~ /^[0-9]+$/' + opts=$("$1" --list | awk "$stop_awk_cmd") ;; --list) # No Options diff --git a/create_ap b/create_ap index e1b93e4..4edf172 100755 --- a/create_ap +++ b/create_ap @@ -47,7 +47,7 @@ usage() { echo " --freq-band Set frequency band. Valid inputs: 2.4, 5 (default: 2.4)" echo " --driver Choose your WiFi adapter driver (default: nl80211)" echo " --no-virt Do not create virtual interface" - echo " --no-haveged Do not run \`haveged' automatically when needed" + echo " --no-haveged Do not run 'haveged' automatically when needed" echo " --fix-unmanaged If NetworkManager shows your interface as unmanaged after you" echo " close create_ap, then use this option to switch your interface" echo " back to managed" @@ -915,6 +915,7 @@ while :; do esac done +# Check if required number of positional args are present if [[ $# -lt 1 && $FIX_UNMANAGED -eq 0 && -z "$STOP_ID" && $LIST_RUNNING -eq 0 ]]; then usage >&2 exit 1 @@ -934,6 +935,7 @@ trap "clean_exit" SIGINT SIGUSR1 trap "die" SIGUSR2 if [[ $LIST_RUNNING -eq 1 ]]; then + echo -e "List of running $PROGNAME instances:\n" list_running exit 0 fi @@ -944,11 +946,13 @@ if [[ $(id -u) -ne 0 ]]; then fi if [[ -n "$STOP_ID" ]]; then + echo "Trying to kill $PROGNAME instance associated with $STOP_ID..." send_stop "$STOP_ID" exit 0 fi if [[ $FIX_UNMANAGED -eq 1 ]]; then + echo "Trying to fix unmanaged status in NetworkManager..." networkmanager_fix_unmanaged exit 0 fi @@ -959,6 +963,7 @@ if [[ $DAEMONIZE -eq 1 ]]; then for x in "${ARGS[@]}"; do [[ "$x" != "--daemon" ]] && NEW_ARGS+=( "$x" ) done + echo "Running as Daemon..." # run a detached create_ap setsid "$0" "${NEW_ARGS[@]}" &