From 33a4c4b01bd9aacec19533add10884171b608f5b Mon Sep 17 00:00:00 2001 From: KatolaZ Date: Sun, 29 Jan 2017 15:20:14 +0000 Subject: Version 0.3 --- ChangeLog | 10 +++++ setnet.8 | 9 ++-- setnet.8.gz | Bin 3015 -> 3037 bytes setnet.sh | 136 ++++++++++++++++++++++-------------------------------------- 4 files changed, 65 insertions(+), 90 deletions(-) diff --git a/ChangeLog b/ChangeLog index 6d2d9a6..512f3bf 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,13 @@ +2017-01-29 KatolaZ + + * setnet.sh: + * removed "Load file" and "New File" in WiFi configuration + +2017-01-23 KatolaZ + + * setnet.sh: + * fixed a few minors bugs + 2017-01-20 KatolaZ * setnet.sh (0.3): diff --git a/setnet.8 b/setnet.8 index a312b88..7be6108 100644 --- a/setnet.8 +++ b/setnet.8 @@ -8,6 +8,7 @@ .Sh SYNOPSIS .Nm setnet.sh .Op Fl c Ar config_file +.Op Fl d Ar trace_file .Op Fl h .Op Fl v .Sh DESCRIPTION @@ -20,10 +21,8 @@ including ip(8), dhclient(8), and wpa_cli(8). .Pp setnet.sh allows to configure static and/or DHCP-based connections to a LAN/WLAN, and to manage the authentication to a Wi-Fi network. At -present, only open authentication (no key) and WPA-Personal -authentication (WPA-PSK/WPA2-PSK) are supported. The support for basic -WPA-Enterprise authentication (WPA-EAP-PEAP and WPA-EAP-TLS) is under -development. +present, open (no key), WPA-Personal (WPA-PSK and WPA2-PSK), and +WPA-Enterprise (EAP/PEAP or EAP/TLS) are supported. .Pp setnet.sh can be also used as a minimal interface to basic network @@ -40,6 +39,8 @@ setnet.sh recognises the following options: .Bl -tag -width Ds .It Fl c Ar config_file specify a configuration file +.It Fl d Ar trace_file +enable dialog debug, and write the trace to the provided trace_file .It Fl h print a minimal help and exit .It Fl v diff --git a/setnet.8.gz b/setnet.8.gz index 1565848..247c303 100644 Binary files a/setnet.8.gz and b/setnet.8.gz differ diff --git a/setnet.sh b/setnet.sh index c89a839..b5b4380 100755 --- a/setnet.sh +++ b/setnet.sh @@ -292,8 +292,24 @@ check_deps(){ } + +## +## Set debug mode -- dialog is instructed to dump a trace to the file +## TRACE_FILE provided by the user ## -## Generic function fo unimplemented features. It just pops up a + +##function +set_debug(){ + + TRACE_FILE=$1 + DEBUG_MODE="DEBUG" + DIALOG="${DIALOG} --trace ${TRACE_FILE}" + +} + + +## +## Generic function for unimplemented features. It just pops up a ## message-box and returns ## @@ -1123,7 +1139,7 @@ wifi_restart_wpa(){ ##local WPA_FILE=$2 - WPA_PID=$(ps ax | grep wpa_supplicant | grep " -i ${DEVNAME}" | + WPA_PID=$(ps ax | grep wpa_supplicant | grep " -i ${DEVNAME} " | sed -r -e 's/^\ +//g' | cut -d " " -f 1) log "wifi_restart_wpa" "WPA_PID: ${WPA_PID}" @@ -1217,60 +1233,6 @@ wifi_disable(){ - - -##function -wifi_load_file(){ - -##local - DEVNAME=$1 - - MSG="You are running setnet through sudo or sup!!!\nLoad file is - disabled!" check_sudo "${MSG}" - - if [ $? -eq 1 ]; then - return - fi - - - eval "${DIALOG} --fselect ${WPA_FILE} ${WINDOW_HEIGHT} ${WINDOW_WIDTH}" \ - 2>${TMPFILE} - - if [ $? -eq 0 ]; then - SEL_FILE=$(cat ${TMPFILE}) - while [ -d "${SEL_FILE}" ]; do - eval "${DIALOG} --fselect ${SEL_FILE} ${WINDOW_HEIGHT} ${WINDOW_WIDTH}" \ - 2>${TMPFILE} - if [ $? -eq 0 ]; then - SEL_FILE=$(cat ${TMPFILE}) - else - eval "${DIALOG} --msgbox 'WPA_FILE was not modified' \ - ${INFO_HEIGHT} ${INFO_WIDTH}" - return - fi - done - - if [ -f "${SEL_FILE}" ]; then - WPA_FILE=${SEL_FILE} - eval "${DIALOG} --defaultno --yesno \ - 'WPA_FILE changed to ${WPA_FILE}\nRestart wpa_supplicant?' \ - ${INFO_HEIGHT} ${INFO_WIDTH}" - if [ $? -eq 0 ]; then - wifi_restart_wpa ${DEVNAME} ${WPA_FILE} - fi - else - eval "${DIALOG} --msgbox 'Invalid file name!\n WPA_FILE *not* changed' \ - ${WINDOW_HEIGHT} ${WINDOW_WIDTH}" - return - fi - else - eval "${DIALOG} --msgbox 'WPA_FILE was not modified' \ - ${INFO_HEIGHT} ${INFO_WIDTH}" - fi - -} - - ##function config_wifi(){ @@ -1281,7 +1243,7 @@ config_wifi(){ while true; do CUR_NET=$(wpa_cli -i ${DEVNAME} status | grep "^ssid" | cut -d "=" -f 2) eval "${DIALOG} --cancel-label 'Up' \ - --menu 'Configuring ${DEVNAME}\tCurrent network: ${CUR_NET}\n(Current file: ${WPA_FILE})' \ + --menu 'Configuring ${DEVNAME}\nCurrent network: ${CUR_NET}\n(Current file: ${WPA_FILE})' \ ${WINDOW_HEIGHT} ${WINDOW_WIDTH} 12 \ 'Restart' 'Restart wpa_supplicant' \ 'Enable' 'Enable a configured network' \ @@ -1290,9 +1252,7 @@ config_wifi(){ 'Remove' 'Delete an existing network' \ 'Show' 'Show current configuration file' \ 'Edit' 'Edit current configuration file' \ - 'Save' 'Save configuration to file'\ - 'Load' 'Load configuration from file'\ - 'New' 'Create new configuration file' " \ + 'Save' 'Save configuration to file' "\ 2>${TMPFILE} if [ $? = "1" ]; then @@ -1326,12 +1286,6 @@ config_wifi(){ "Save") wifi_save_file ${DEVNAME} ;; - "Load") - wifi_load_file ${DEVNAME} - ;; - "New") - unimplemented "New" - ;; esac done @@ -2099,7 +2053,13 @@ initialise(){ chmod 600 ${LOGFILE} - log "setnet" "Starting afresh on $(date)" + log "initialise" "Starting afresh on $(date)" + log "initialise" "Using TMPFILE: ${TMPFILE}" + log "initialise" "Using LOGFILE: ${LOGFILE}" + + if [ -n ${DEBUG_MODE} ]; then + log "initialise" "Running in debug mode -- dumping dialog trace to ${TRACE_FILE}" + fi EUID=$(id -ru) if [ "${EUID}" = "0" ] && @@ -2186,30 +2146,34 @@ main(){ SETNETRC="" -while getopts ":c:hv" opt; do +while getopts ":c:d:hv" opt; do case $opt in c) - #echo "Got option -c ${OPTARG}" - SETNETRC=$(realpath ${OPTARG}) - #echo "SETNETRC: ${SETNETRC}" - ;; + #echo "Got option -c ${OPTARG}" + SETNETRC=$(realpath ${OPTARG}) + #echo "SETNETRC: ${SETNETRC}" + ;; h) - show_help $(basename $0) - exit 1 - ;; + show_help $(basename $0) + exit 1 + ;; v) - show_version $(basename $0) - exit 1 - ;; - \?) - echo "Invalid option: -${OPTARG}" - exit 1 - ;; - :) - echo "Option -${OPTARG} requires an argument" - exit 1 - ;; + show_version $(basename $0) + exit 1 + ;; + d) + TRACE_FILE=$(realpath ${OPTARG}) + set_debug ${TRACE_FILE} + ;; + \?) + echo "Invalid option: -${OPTARG}" + exit 1 + ;; + :) + echo "Option -${OPTARG} requires an argument" + exit 1 + ;; esac done -- cgit v1.2.3