From ecad94477e6aee3420d198120fc9fb78fea9231c Mon Sep 17 00:00:00 2001 From: Victor Tebar Date: Sun, 12 Nov 2023 21:53:26 +0000 Subject: [PATCH] fix some errors in venom-wifimanager script --- virootfs/usr/sbin/venom-wifimanager | 26 +++++++++++--------------- 1 file changed, 11 insertions(+), 15 deletions(-) diff --git a/virootfs/usr/sbin/venom-wifimanager b/virootfs/usr/sbin/venom-wifimanager index 020b03524..08e298838 100755 --- a/virootfs/usr/sbin/venom-wifimanager +++ b/virootfs/usr/sbin/venom-wifimanager @@ -18,26 +18,20 @@ printf "%s\n" "$@" # Ensure wi run as root [ "$(id -u)" != "0" ] && err "Must run this script as root." +# device +device="$(find /sys/class/net -iname w* -printf "%f\n" )" # we save network configs here conf_dir=/etc/wpa_supplicant [ -d "$conf_dir" ] || mkdir "$conf_dir" -checks() { - for i in wpa_supplicant dhcpcd ; do - command -v $i >/dev/null || err "You should install $i first" - done - device=$(find /sys/class/net -iname w* -printf "%f\n" ) - rfkill unblock all - ip link set dev $device up -} - hp() { cat< It'll guied you to config a new wifi network Connect --> It'll connect to a wifi network Help --> It'll show this help + Exit --> It'll exit the script EOF } @@ -87,16 +81,18 @@ msg "Network $name configured!!" connect() { [ -z "$1" ] && menu -killall wpa_supplicant -killall dhcpcd -wpa_supplicant -Dnl80211 -B -i "$device" -c "$conf_dir"/"$1".conf + rm -f /run/wpa_supplicant/$device +rfkill unblock all +ip link set dev "$device" up +wpa_supplicant -B -i "$device" -c "$conf_dir"/"$1".conf dhcpcd --waitip -h $(/bin/hostname) -z "$device" } choose_config() { - ssid=$(find $conf_dir -iname *.conf -printf "%f\n" | \ + ssid=$(find $conf_dir -iname *.conf -printf "%f\n" | sed 's|.conf||' | \ fzy -l 3 --prompt="Venom Wifi Manager : ") connect $ssid + exit 0 } menu() { @@ -106,9 +102,9 @@ opt=$(printf "Config\nConnect\nHelp\nExit" | \ [ -z "$opt" ] && break case $opt in Config) add ;; - Connect) choose_config ;; + Connect) choose_config ;; Help) hp ;; - Exit) exit ;; + Exit) exit 0 ;; esac done }