Print descriptive messages for several switches

* Print messages for terminating switches like --list, --stop,
  --fix-unmanaged and --daemon
* Minor change in help string
This commit is contained in:
Karthik K 2015-05-06 22:38:40 +05:30
parent 3f08801967
commit 3ca3663894
2 changed files with 8 additions and 2 deletions

View File

@ -111,7 +111,8 @@ _create_ap() {
# No Options # No Options
;; ;;
--stop) --stop)
opts=$("$1" --list) local stop_awk_cmd='$1 ~ /^[0-9]+$/'
opts=$("$1" --list | awk "$stop_awk_cmd")
;; ;;
--list) --list)
# No Options # No Options

View File

@ -47,7 +47,7 @@ usage() {
echo " --freq-band <GHz> Set frequency band. Valid inputs: 2.4, 5 (default: 2.4)" echo " --freq-band <GHz> Set frequency band. Valid inputs: 2.4, 5 (default: 2.4)"
echo " --driver Choose your WiFi adapter driver (default: nl80211)" echo " --driver Choose your WiFi adapter driver (default: nl80211)"
echo " --no-virt Do not create virtual interface" 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 " --fix-unmanaged If NetworkManager shows your interface as unmanaged after you"
echo " close create_ap, then use this option to switch your interface" echo " close create_ap, then use this option to switch your interface"
echo " back to managed" echo " back to managed"
@ -915,6 +915,7 @@ while :; do
esac esac
done 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 if [[ $# -lt 1 && $FIX_UNMANAGED -eq 0 && -z "$STOP_ID" && $LIST_RUNNING -eq 0 ]]; then
usage >&2 usage >&2
exit 1 exit 1
@ -934,6 +935,7 @@ trap "clean_exit" SIGINT SIGUSR1
trap "die" SIGUSR2 trap "die" SIGUSR2
if [[ $LIST_RUNNING -eq 1 ]]; then if [[ $LIST_RUNNING -eq 1 ]]; then
echo -e "List of running $PROGNAME instances:\n"
list_running list_running
exit 0 exit 0
fi fi
@ -944,11 +946,13 @@ if [[ $(id -u) -ne 0 ]]; then
fi fi
if [[ -n "$STOP_ID" ]]; then if [[ -n "$STOP_ID" ]]; then
echo "Trying to kill $PROGNAME instance associated with $STOP_ID..."
send_stop "$STOP_ID" send_stop "$STOP_ID"
exit 0 exit 0
fi fi
if [[ $FIX_UNMANAGED -eq 1 ]]; then if [[ $FIX_UNMANAGED -eq 1 ]]; then
echo "Trying to fix unmanaged status in NetworkManager..."
networkmanager_fix_unmanaged networkmanager_fix_unmanaged
exit 0 exit 0
fi fi
@ -959,6 +963,7 @@ if [[ $DAEMONIZE -eq 1 ]]; then
for x in "${ARGS[@]}"; do for x in "${ARGS[@]}"; do
[[ "$x" != "--daemon" ]] && NEW_ARGS+=( "$x" ) [[ "$x" != "--daemon" ]] && NEW_ARGS+=( "$x" )
done done
echo "Running as Daemon..."
# run a detached create_ap # run a detached create_ap
setsid "$0" "${NEW_ARGS[@]}" & setsid "$0" "${NEW_ARGS[@]}" &