Nie jesteś zalogowany.
Jeśli nie posiadasz konta, zarejestruj je już teraz! Pozwoli Ci ono w pełni korzystać z naszego serwisu. Spamerom dziękujemy!
Prosimy o pomoc dla małej Julki — przekaż 1% podatku na Fundacji Dzieciom zdazyć z Pomocą.
Więcej informacji na dug.net.pl/pomagamy/.

Użytkownik


Staram sie zainstalowac "wifi-channel-watcher" ze strony: https://github.com/angela-d/wifi-channel-watcher/wiki/Installing
Takimi komendami:
sudo apt install libnotify-bin network-manager iw
git clone https://github.com/angela-d/wifi-channel-watcher.git
cd wifi-channel-watcher && ./channel-watcher
(find / -name wifi-channel-watcher)
cd wifi-channel-watcher
./channel-watchNiestety kiedy doszedlem do:
root@debian:/wifi-channel-watcher# ./channel-watch ./channel-watch: line 124: [: : integer expression expected
Pojawia sie ten blad.
Tresc pliku konfigu channel-watch:
root@debian:/wifi-channel-watcher# cat channel-watch
#!/bin/bash
# shellcheck source=/dev/null
CACHE_DIR="$HOME/.config/wifi-channel-watcher/"
# pull in user config (or create it, if it doesn't exist)
if [ ! "$1" == "uninstallservice" ] && [ ! -d "$CACHE_DIR" ];
then
mkdir -p "$CACHE_DIR" && cp icon.svg "$CACHE_DIR" && cp "$PWD/config.conf" "$CACHE_DIR"config.conf && echo "Created $CACHE_DIR (first run)"
sed -i -- "s|PROCESSED_DURING_SETUP|$CACHE_DIR|g" ~/.config/wifi-channel-watcher/config.conf && echo "Set cache directory"
source "$CACHE_DIR"config.conf
elif [ -e "$CACHE_DIR"config.conf ];
then
source "$CACHE_DIR"config.conf
fi
function debug() {
if [ "$1" == "1" ];
then
STATE="INFO"
elif [ "$1" == "2" ];
then
STATE="TEST"
else
STATE="WARN"
fi
echo "$STATE: $(date) $2" >> "$DEBUG_PATH"
}
# get the channel in use
[ "$DEBUG" == "1" ] && debug "1" "-- Start of debug for this run --"
INTERFACE="$(cat < /proc/net/wireless | awk '{print $1}' | tail -n1 | tr -d .:)"
[ "$DEBUG" == "1" ] && debug "0" "Interface check: $INTERFACE triggered."
# wifi active?
if [ "$(nmcli con show --active | awk '$3 ~ "wifi" || "*wireless"')" == "" ];
then
echo "Wifi interface appears to be inactive or is not detected. Using a Pi?"
echo "For troubleshooting: https://github.com/angela-d/wifi-channel-watcher/wiki/Troubleshooting"
exit 0
fi
# check if internal resources are accessible, general local cache
[[ ! $INTERNAL_CHECK == "" && "$(ping -c 1 "$INTERNAL_CHECK")" ]] && INTERNAL_CONN="yes" || INTERNAL_CONN=""
[ "$DEBUG" == "1" ] && debug "1" "Internal connection value (empty = unmet): $INTERNAL_CONN"
# MAC address lookup vendor
function macsearch() {
# look up macs without api keys from IEEE
# cache this mac address, since it won't change (if the script runs multiple times, no need to make new calls)
if [ ! -f "$CACHE_DIR""$1" ];
then
LOOKUP=$(echo "$1" | tr -d ':' | head -c 6)
# cache the mac lookups, this will almost never change so don't litter network requests
if [ -f "$CACHE_DIR"mac.cache ];
then
cat < "$CACHE_DIR"mac.cache | grep -i "$LOOKUP" | cut -d')' -f2 | tr -d '\t' > "$CACHE_DIR""$LOOKUP"
else
if [[ $INTERNAL_CONN == 'yes' ]];
then
# no cache exists, pull a copy for a local cache
curl -L -sS -C - "$MAC_LIST" > "$CACHE_DIR"mac.cache && cat < "$CACHE_DIR"mac.cache | grep -i "$LOOKUP" | cut -d')' -f2 | tr -d '\t' > "$CACHE_DIR""$LOOKUP"
sleep 4
else
# not on the internal network, obtain from the web and cache it
curl -L -sS -C - "http://standards-oui.ieee.org/oui.txt" > "$CACHE_DIR"mac.cache && cat < "$CACHE_DIR"mac.cache | grep -i "$LOOKUP" | cut -d')' -f2 | tr -d '\t' > "$CACHE_DIR""$LOOKUP"
sleep 4
fi
fi
# if the mac doesn't match a manufacturer, it's probably spoofed
[ -s "$CACHE_DIR""$LOOKUP" ] && cat "$CACHE_DIR""$LOOKUP" || echo "(spoofed)"
fi
}
# for enterprise lookups, ideal for environments with multiple access points using the same ssid
# and you want to know specifically which ap you're connected to
function apsearch() {
if [ "$INTERNAL_CONN" == "yes" ];
then
[ "$DEBUG" == "1" ] && debug "1" "AP List: $AP_LIST"
AP=$(echo "$1" | tr -d ':')
[ "$DEBUG" == "1" ] && debug "1" "Raw BSSID: $AP"
AP=$(curl -sS "$AP_LIST" | grep -i "$AP" | head -n1 | awk '{ print $1 }')
echo "$AP"
[ "$DEBUG" == "1" ] && debug "1" "apsearch function reached. AP: $AP"
fi
}
# get nearby channel usage
ME="$(/sbin/iwgetid -r)"
CHANNEL="$(/sbin/iw dev "$INTERFACE" info | grep channel | awk '{print $2}')"
# 2g or 5g? use for channel suggestions, if enabled
RADIO="$(echo $CHANNEL | awk '$1 ~ /^1$|^6$|^11$/' | sort | uniq -c | sort -n)"
[ "$DEBUG" == "1" ] && debug "1" "My SSID: $ME - Channel: $CHANNEL"
# iw scan needs elevation to scan, so nmcli is better to use, otherwise you have an equal amount of work to do to
# pass info to the userspace from root and/or specify sudo privs in visudo
#
# get a channel list into an array (needs work)
IFS=$'\n'
# shellcheck disable=SC2207
declare -a CHAN=($(nmcli -g chan dev wi list | sort | uniq -c))
[ "$DEBUG" == "1" ] && debug "2" "Unprocessed query: $(nmcli -g chan dev wi list | sort | uniq -c)"
# isolate the active usage
for ACTIVE_CHANNEL in "${CHAN[@]}";
do
if [[ $ACTIVE_CHANNEL =~ $CHANNEL ]];
then
# isolate the total on the active channel
TOTAL_ACTIVE=$(echo "$ACTIVE_CHANNEL" | awk '{print $1}')
# it will always be +1 because of me, so subtract
TOTAL_ACTIVE=$((TOTAL_ACTIVE-1))
[ "$DEBUG" == "1" ] && debug "1" "On my channel (incl me) extract: $ACTIVE_CHANNEL"
break
fi
done
[ "$DEBUG" == "1" ] && debug "1" "Total on my channel (excl me): $TOTAL_ACTIVE"
# check for notify-send and send a notification to the user
if [ "$TOTAL_ACTIVE" -ge "$THRESHOLD" ] && [ -f /usr/bin/notify-send ];
then
[ "$DEBUG" == "1" ] && debug "1" "/usr/bin/notify-send exists"
# display the ssid, if enabled
if [ "$DISPLAY_CHANNEL_BSSID" == "1" ];
then
[ "$DEBUG" == "1" ] && debug "1" "DISPLAY_CHANNEL_BSSID is true"
# redundant loop; merge with CHAN at some point
# shellcheck disable=SC2207
declare -a DETAILED=($(nmcli -f ssid,bssid,chan,bars dev wi list | awk -v CHANNEL="$CHANNEL" -v ME="$ME" '$3 == CHANNEL' | tail -n 1))
for NEIGHBOR in "${DETAILED[@]}"
do
SSID="$(printf "%s" "$NEIGHBOR" | awk '{ print $1 }')"
# ssid is sanitized since it returns values to the screen created by untrusted individuals, because, you never know :)
[ "$SSID" == "--" ] && SSID="[hidden]" || SSID="${SSID//[^a-zA-Z0-9\_-]/}"
BSSID="$(printf "%s" "$NEIGHBOR" | awk '{ print $2 }')"
[ "$DEBUG" == "1" ] && debug "1" "BSSID in neighbor loop: $BSSID"
# get the router manufacturer
BSSID_HUMAN_READABLE=$(macsearch "$BSSID")
BARS="$(printf "%s" "$NEIGHBOR" | awk '{ print $4 }')"
[[ "$INTERNAL_CONN" == "yes" ]] && AP_NAME=$(apsearch "$BSSID") || AP_NAME=""
BSSID_DETAIL+="\\n$BARS $SSID - $BSSID_HUMAN_READABLE\\n$AP_NAME"
[ "$DEBUG" == "1" ] && debug "1" "BSSID DETAIL: $BSSID_DETAIL"
done
else
[ "$DEBUG" == "1" ] && debug "1" "WARN: DISPLAY_CHANNEL_BSSID is false, or notify-send not seen"
BSSID_DETAIL=""
fi
# assess a lesser congested channel (vacant only)
if [ "$SUGGEST_CHANNEL" == "1" ];
then
function arraydiff() {
# thx fabian lee
# https://fabianlee.org/2020/09/06/bash-difference-between-two-arrays/
awk 'BEGIN{RS=ORS=" "}
{NR==FNR?a[$0]++:a[$0]--}
END{for(k in a)if(a[k])print k}' <(echo -n "${!1}") <(echo -n "${!2}")
}
IFS='|'
# if radio is unset, user is on a 5g radio; channel selections in user config
if [ ! "$RADIO" ];
then
# look for vacant 5GHz channels; ignoring dfs/radar + wider channels incompatible w/ some devices
read -a VACANTS <<< "$CHANNELS_5G"
read -a IGNORE <<< "$IGNORE_5G"
else
# 2GHz user
read -a VACANTS <<< "$CHANNELS_2G"
read -a IGNORE <<< "$IGNORE_2G"
fi
# splitter for the arraydiff
IFS=' '
# compare vacants arr w/ chan array to spot any unused channels
# shellcheck disable=SC2207
SUGGESTING=($(arraydiff CHAN[@] VACANTS[@]))
[ "$DEBUG" == "1" ] && debug "1" "Channels that appear vacant: ${SUGGESTING[*]}"
for ANALYZE in "${SUGGESTING[@]}";
do
[ "$DEBUG" == "1" ] && debug "1" "Channel suggestion (unfiltered/active channel): $ANALYZE"
# 40 gets regex clipped due to the presence of dfs 140 in ignore, despite shellcheck claiming this is a literal match
# shellcheck disable=SC2076
if [[ ! ${IGNORE[*]} =~ "$ANALYZE" ]] || [[ "$ANALYZE" -eq 40 && ! "$RADIO" ]]
then
SUGGEST="$ANALYZE"
fi
done
[ "$DEBUG" == "1" ] && debug "1" "Channel to suggest: $SUGGEST"
IFS=$'\n'
if [ -z "$SUGGEST" ] && [ "$RADIO" ];
then
# make a 2g suggestion based off the least-trafficked channel
CONGESTED="$(nmcli -f chan dev wi list | awk '$1 ~ /^1$|^6$|^11$/' | sort | uniq -c | sort -n | head -n1)"
SUGGEST="$(printf "%s" $CONGESTED | awk '{ print $2 }')"
[ "$DEBUG" == "1" ] && debug "1" "INFO: Congested 2G chanels: $CONGESTED"
elif [ -z "$SUGGEST" ] && [ ! "$RADIO" ];
then
# make a 5g suggestion based off the least-trafficked channel
CONGESTED="$(nmcli -f chan dev wi list | awk '$1 ~ /^36$|^40$|^44$|^48$|^149$|^153$|^157$|^161$|^165$/' | sort | uniq -c | sort -n | head -n1)"
SUGGEST="$(printf "%s" $CONGESTED | awk '{ print $2 }')"
fi
# if the suggested channel is the active channel, don't notify
[ "$SUGGESTED" == "$CHANNEL" ] && HIDE_PROMPT="true" && [ "$DEBUG" == "1" ] && debug "1" "You are on the best channel: $SUGGESTED"
SUGGESTED="\\nBetter channel: $SUGGEST"
fi
if [ -z "$HIDE_PROMPT" ];
then
# format the message to prevent notify-send from throwing errors
PROMPT="$TOTAL_ACTIVE neighboring APs also on channel $CHANNEL\\n$BSSID_DETAIL $SUGGESTED"
[ "$DEBUG" == "1" ] && debug "1" "Prompt output: $PROMPT"
# send the notification
notify-send -i "$HOME/.config/wifi-channel-watcher/icon.svg" "Wifi Channel Not Optimal" \
-u critical \ "$PROMPT"
fi
fi
[ "$DEBUG" == "1" ] && debug "1" "INFO: -- End of debug for this run --"
if [ "$1" == "installservice" ];
then
# checking for systemd
echo "Checking for systemd..."
if [ -d /usr/lib/systemd ];
then
echo "Found. Creating systemd service directory..."
[ ! -d ~/.config/systemd/user/ ] && mkdir -p ~/.config/systemd/user/
[ -f "$PWD/service/systemd/wifiwatcher.service" ] && cp "$PWD/service/systemd/wifiwatcher.service" ~/.config/systemd/user/wifiwatcher.service && echo "Unit file added."
[ -f "$PWD/service/systemd/wifiwatcher.timer" ] && cp "$PWD/service/systemd/wifiwatcher.timer" ~/.config/systemd/user/wifiwatcher.timer && echo "Timer file added."
echo "Modifying the path to this script (you'll need to modify the service file if you move the repo on your system)..."
echo -e "\\t$PWD/channel-watch"
sleep 3
sed -i -- "s|SERVICE_PATH|$PWD/channel-watch|g" ~/.config/systemd/user/wifiwatcher.service
echo "Enabling service..."
systemctl --user enable wifiwatcher && echo "Enabling scheduler (default every 10min, see wiki for adjusting)"
systemctl --user enable wifiwatcher.timer && echo "Starting services..."
systemctl --user start wifiwatcher --now && systemctl --user start wifiwatcher.timer --now && echo "Service setup complete!"
fi
elif [ "$1" == "uninstallservice" ];
then
# checking for systemd
echo "Checking for systemd..."
if [ -d /usr/lib/systemd ];
then
echo "Found. Stopping services..."
systemctl --user stop wifiwatcher.timer
systemctl --user stop wifiwatcher
systemctl --user disable wifiwatcher.timer && systemctl --user disable wifiwatcher && echo "Removed wifiwatcher from startup"
echo "Removing service files for wifiwatcher..."
[ -e ~/.config/systemd/user/wifiwatcher.service ] && rm ~/.config/systemd/user/wifiwatcher.service && echo "wifiwatcher service removed"
[ -e ~/.config/systemd/user/wifiwatcher.timer ] && rm ~/.config/systemd/user/wifiwatcher.timer && echo "wifiwatcher timer removed"
echo "Checking for cache directory..."
[ -d ~/.config/wifi-channel-watcher ] && rm -rf ~/.config/wifi-channel-watcher && echo "Cache directory removed"
echo "Uninstall complete!"
fi
fiCzy ktos znajdzie chwile czasu zeby pomoc rozwiazac ten problem?
Pozdro.
Ostatnio edytowany przez Karoll (2023-07-20 21:46:34)
Offline



Użytkownik




Linia 124
if [ "$TOTAL_ACTIVE" -ge "$THRESHOLD" ] && [ -f /usr/bin/notify-send ];
Strzelam, że brakuje Ci definicji $THRESHOLD
Add the new THRESHOLD variable to your ~/.config/wifi-channel-watcher/config.conf file:
THRESHOLD="1"
Threshold is the greater than or equal to value, for how many are on your channel (excluding you) before you get a notification.
Offline

Użytkownik


Niestety, po edycji:
[
if [ "$TOTAL_ACTIVE" -ge "$THRESHOLD" 1 ] && [ -f /usr/bin/notify-send ];
Komunikat
/wifi-channel-watcher$ ./channel-watch ./channel-watch: line 124: [: too many arguments
Probowalem zweryfikowac skrypt narzedziem on-line:
https://www.jdoodle.com/test-bash-shell-script-online/
Za male umiejetnosci w pisaniu skryptow, niestety.
Ostatnio edytowany przez Karoll (2023-07-19 10:21:45)
Offline



Użytkownik




Zamiast edycji skryptu i robienia "po swojemu", zrób to zgodnie z instrukcjami autora skryptu.
Powinieneś sobie tą zmienną zdefiniować w pliku konfiguracyjnym, który zacytowałem w poprzedniej wiadomości. Cytat pochodzi z instrukcji autora skryptu.
Podejrzewam, że inne zmienne też masz nie zdefiniowane i wyjdzie to w trakcie działania skryptu, dlatego poniżej zamieszczam link do gotowego pliku, bo widzę, że masz jakiś problem z czytaniem instrukcji.
https://github.com/angela-d/wifi-channel-watcher/bl … r/config.conf
Ostatnio edytowany przez arecki (2023-07-19 11:55:02)
Offline

Użytkownik


Tak u mnie wyglada plik: /wifi-channel-watcher/config.conf
GNU nano 5.4 /wifi-channel-watcher/config.conf DISPLAY_CHANNEL_BSSID="1" MAC_LIST="" AP_LIST="" INTERNAL_CHECK="" DEBUG="0" DEBUG_PATH="" CACHE_DIR="PROCESSED_DURING_SETUP" SUGGEST_CHANNEL="1" THRESHOLD="1" CHANNELS_5G="36|40|44|48|149|153|157|161|165" IGNORE_5G="1|2|3|4|5|6|7|8|9|10|11|12|13|52|56|60|64|100|104|108|112|116|120|12> CHANNELS_2G="1|6|11" IGNORE_2G="2|3|4|5|7|8|9|10|12|13|14|16|36|40|44|48|149|153|157|161|165|52|56|6>
Ten plik ma tylko 13 linii. xD
To jest inny plik, ktory moim zdaniem jest sprawca problemu:
/wifi-channel-watcher# ./channel-watch
./channel-watch: line 124: [: : integer expression expected
Oto jego zawartosc:
cat /wifi-channel-watcher/channel-watch
#!/bin/bash
# shellcheck source=/dev/null
CACHE_DIR="$HOME/.config/wifi-channel-watcher/"
# pull in user config (or create it, if it doesn't exist)
if [ ! "$1" == "uninstallservice" ] && [ ! -d "$CACHE_DIR" ];
then
mkdir -p "$CACHE_DIR" && cp icon.svg "$CACHE_DIR" && cp "$PWD/config.conf" "$CACHE_DIR"config.conf && echo "Created $CACHE_DIR (first run)"
sed -i -- "s|PROCESSED_DURING_SETUP|$CACHE_DIR|g" ~/.config/wifi-channel-watcher/config.conf && echo "Set cache directory"
source "$CACHE_DIR"config.conf
elif [ -e "$CACHE_DIR"config.conf ];
then
source "$CACHE_DIR"config.conf
fi
function debug() {
if [ "$1" == "1" ];
then
STATE="INFO"
elif [ "$1" == "2" ];
then
STATE="TEST"
else
STATE="WARN"
fi
echo "$STATE: $(date) $2" >> "$DEBUG_PATH"
}
# get the channel in use
[ "$DEBUG" == "1" ] && debug "1" "-- Start of debug for this run --"
INTERFACE="$(cat < /proc/net/wireless | awk '{print $1}' | tail -n1 | tr -d .:)"
[ "$DEBUG" == "1" ] && debug "0" "Interface check: $INTERFACE triggered."
# wifi active?
if [ "$(nmcli con show --active | awk '$3 ~ "wifi" || "*wireless"')" == "" ];
then
echo "Wifi interface appears to be inactive or is not detected. Using a Pi?"
echo "For troubleshooting: https://github.com/angela-d/wifi-channel-watcher/wiki/Troubleshooting"
exit 0
fi
# check if internal resources are accessible, general local cache
[[ ! $INTERNAL_CHECK == "" && "$(ping -c 1 "$INTERNAL_CHECK")" ]] && INTERNAL_CONN="yes" || INTERNAL_CONN=""
[ "$DEBUG" == "1" ] && debug "1" "Internal connection value (empty = unmet): $INTERNAL_CONN"
# MAC address lookup vendor
function macsearch() {
# look up macs without api keys from IEEE
# cache this mac address, since it won't change (if the script runs multiple times, no need to make new calls)
if [ ! -f "$CACHE_DIR""$1" ];
then
LOOKUP=$(echo "$1" | tr -d ':' | head -c 6)
# cache the mac lookups, this will almost never change so don't litter network requests
if [ -f "$CACHE_DIR"mac.cache ];
then
cat < "$CACHE_DIR"mac.cache | grep -i "$LOOKUP" | cut -d')' -f2 | tr -d '\t' > "$CACHE_DIR""$LOOKUP"
else
if [[ $INTERNAL_CONN == 'yes' ]];
then
# no cache exists, pull a copy for a local cache
curl -L -sS -C - "$MAC_LIST" > "$CACHE_DIR"mac.cache && cat < "$CACHE_DIR"mac.cache | grep -i "$LOOKUP" | cut -d')' -f2 | tr -d '\t' > "$CACHE_DIR""$LOOKUP"
sleep 4
else
# not on the internal network, obtain from the web and cache it
curl -L -sS -C - "http://standards-oui.ieee.org/oui.txt" > "$CACHE_DIR"mac.cache && cat < "$CACHE_DIR"mac.cache | grep -i "$LOOKUP" | cut -d')' -f2 | tr -d '\t' > "$CACHE_DIR""$LOOKUP"
sleep 4
fi
fi
# if the mac doesn't match a manufacturer, it's probably spoofed
[ -s "$CACHE_DIR""$LOOKUP" ] && cat "$CACHE_DIR""$LOOKUP" || echo "(spoofed)"
fi
}
# for enterprise lookups, ideal for environments with multiple access points using the same ssid
# and you want to know specifically which ap you're connected to
function apsearch() {
if [ "$INTERNAL_CONN" == "yes" ];
then
[ "$DEBUG" == "1" ] && debug "1" "AP List: $AP_LIST"
AP=$(echo "$1" | tr -d ':')
[ "$DEBUG" == "1" ] && debug "1" "Raw BSSID: $AP"
AP=$(curl -sS "$AP_LIST" | grep -i "$AP" | head -n1 | awk '{ print $1 }')
echo "$AP"
[ "$DEBUG" == "1" ] && debug "1" "apsearch function reached. AP: $AP"
fi
}
# get nearby channel usage
ME="$(/sbin/iwgetid -r)"
CHANNEL="$(/sbin/iw dev "$INTERFACE" info | grep channel | awk '{print $2}')"
# 2g or 5g? use for channel suggestions, if enabled
RADIO="$(echo $CHANNEL | awk '$1 ~ /^1$|^6$|^11$/' | sort | uniq -c | sort -n)"
[ "$DEBUG" == "1" ] && debug "1" "My SSID: $ME - Channel: $CHANNEL"
# iw scan needs elevation to scan, so nmcli is better to use, otherwise you have an equal amount of work to do to
# pass info to the userspace from root and/or specify sudo privs in visudo
#
# get a channel list into an array (needs work)
IFS=$'\n'
# shellcheck disable=SC2207
declare -a CHAN=($(nmcli -g chan dev wi list | sort | uniq -c))
[ "$DEBUG" == "1" ] && debug "2" "Unprocessed query: $(nmcli -g chan dev wi list | sort | uniq -c)"
# isolate the active usage
for ACTIVE_CHANNEL in "${CHAN[@]}";
do
if [[ $ACTIVE_CHANNEL =~ $CHANNEL ]];
then
# isolate the total on the active channel
TOTAL_ACTIVE=$(echo "$ACTIVE_CHANNEL" | awk '{print $1}')
# it will always be +1 because of me, so subtract
TOTAL_ACTIVE=$((TOTAL_ACTIVE-1))
[ "$DEBUG" == "1" ] && debug "1" "On my channel (incl me) extract: $ACTIVE_CHANNEL"
break
fi
done
[ "$DEBUG" == "1" ] && debug "1" "Total on my channel (excl me): $TOTAL_ACTIVE"
# check for notify-send and send a notification to the user
if [ "$TOTAL_ACTIVE" -ge "$THRESHOLD" ] && [ -f /usr/bin/notify-send ];
then
[ "$DEBUG" == "1" ] && debug "1" "/usr/bin/notify-send exists"
# display the ssid, if enabled
if [ "$DISPLAY_CHANNEL_BSSID" == "1" ];
then
[ "$DEBUG" == "1" ] && debug "1" "DISPLAY_CHANNEL_BSSID is true"
# redundant loop; merge with CHAN at some point
# shellcheck disable=SC2207
declare -a DETAILED=($(nmcli -f ssid,bssid,chan,bars dev wi list | awk -v CHANNEL="$CHANNEL" -v ME="$ME" '$3 == CHANNEL' | tail -n 1))
for NEIGHBOR in "${DETAILED[@]}"
do
SSID="$(printf "%s" "$NEIGHBOR" | awk '{ print $1 }')"
# ssid is sanitized since it returns values to the screen created by untrusted individuals, because, you never know :)
[ "$SSID" == "--" ] && SSID="[hidden]" || SSID="${SSID//[^a-zA-Z0-9\_-]/}"
BSSID="$(printf "%s" "$NEIGHBOR" | awk '{ print $2 }')"
[ "$DEBUG" == "1" ] && debug "1" "BSSID in neighbor loop: $BSSID"
# get the router manufacturer
BSSID_HUMAN_READABLE=$(macsearch "$BSSID")
BARS="$(printf "%s" "$NEIGHBOR" | awk '{ print $4 }')"
[[ "$INTERNAL_CONN" == "yes" ]] && AP_NAME=$(apsearch "$BSSID") || AP_NAME=""
BSSID_DETAIL+="\\n$BARS $SSID - $BSSID_HUMAN_READABLE\\n$AP_NAME"
[ "$DEBUG" == "1" ] && debug "1" "BSSID DETAIL: $BSSID_DETAIL"
done
else
[ "$DEBUG" == "1" ] && debug "1" "WARN: DISPLAY_CHANNEL_BSSID is false, or notify-send not seen"
BSSID_DETAIL=""
fi
# assess a lesser congested channel (vacant only)
if [ "$SUGGEST_CHANNEL" == "1" ];
then
function arraydiff() {
# thx fabian lee
# https://fabianlee.org/2020/09/06/bash-difference-between-two-arrays/
awk 'BEGIN{RS=ORS=" "}
{NR==FNR?a[$0]++:a[$0]--}
END{for(k in a)if(a[k])print k}' <(echo -n "${!1}") <(echo -n "${!2}")
}
IFS='|'
# if radio is unset, user is on a 5g radio; channel selections in user config
if [ ! "$RADIO" ];
then
# look for vacant 5GHz channels; ignoring dfs/radar + wider channels incompatible w/ some devices
read -a VACANTS <<< "$CHANNELS_5G"
read -a IGNORE <<< "$IGNORE_5G"
else
# 2GHz user
read -a VACANTS <<< "$CHANNELS_2G"
read -a IGNORE <<< "$IGNORE_2G"
fi
# splitter for the arraydiff
IFS=' '
# compare vacants arr w/ chan array to spot any unused channels
# shellcheck disable=SC2207
SUGGESTING=($(arraydiff CHAN[@] VACANTS[@]))
[ "$DEBUG" == "1" ] && debug "1" "Channels that appear vacant: ${SUGGESTING[*]}"
for ANALYZE in "${SUGGESTING[@]}";
do
[ "$DEBUG" == "1" ] && debug "1" "Channel suggestion (unfiltered/active channel): $ANALYZE"
# 40 gets regex clipped due to the presence of dfs 140 in ignore, despite shellcheck claiming this is a literal match
# shellcheck disable=SC2076
if [[ ! ${IGNORE[*]} =~ "$ANALYZE" ]] || [[ "$ANALYZE" -eq 40 && ! "$RADIO" ]]
then
SUGGEST="$ANALYZE"
fi
done
[ "$DEBUG" == "1" ] && debug "1" "Channel to suggest: $SUGGEST"
IFS=$'\n'
if [ -z "$SUGGEST" ] && [ "$RADIO" ];
then
# make a 2g suggestion based off the least-trafficked channel
CONGESTED="$(nmcli -f chan dev wi list | awk '$1 ~ /^1$|^6$|^11$/' | sort | uniq -c | sort -n | head -n1)"
SUGGEST="$(printf "%s" $CONGESTED | awk '{ print $2 }')"
[ "$DEBUG" == "1" ] && debug "1" "INFO: Congested 2G chanels: $CONGESTED"
elif [ -z "$SUGGEST" ] && [ ! "$RADIO" ];
then
# make a 5g suggestion based off the least-trafficked channel
CONGESTED="$(nmcli -f chan dev wi list | awk '$1 ~ /^36$|^40$|^44$|^48$|^149$|^153$|^157$|^161$|^165$/' | sort | uniq -c | sort -n | head -n1)"
SUGGEST="$(printf "%s" $CONGESTED | awk '{ print $2 }')"
fi
# if the suggested channel is the active channel, don't notify
[ "$SUGGESTED" == "$CHANNEL" ] && HIDE_PROMPT="true" && [ "$DEBUG" == "1" ] && debug "1" "You are on the best channel: $SUGGESTED"
SUGGESTED="\\nBetter channel: $SUGGEST"
fi
if [ -z "$HIDE_PROMPT" ];
then
# format the message to prevent notify-send from throwing errors
PROMPT="$TOTAL_ACTIVE neighboring APs also on channel $CHANNEL\\n$BSSID_DETAIL $SUGGESTED"
[ "$DEBUG" == "1" ] && debug "1" "Prompt output: $PROMPT"
# send the notification
notify-send -i "$HOME/.config/wifi-channel-watcher/icon.svg" "Wifi Channel Not Optimal" \
-u critical \ "$PROMPT"
fi
fi
[ "$DEBUG" == "1" ] && debug "1" "INFO: -- End of debug for this run --"
if [ "$1" == "installservice" ];
then
# checking for systemd
echo "Checking for systemd..."
if [ -d /usr/lib/systemd ];
then
echo "Found. Creating systemd service directory..."
[ ! -d ~/.config/systemd/user/ ] && mkdir -p ~/.config/systemd/user/
[ -f "$PWD/service/systemd/wifiwatcher.service" ] && cp "$PWD/service/systemd/wifiwatcher.service" ~/.config/systemd/user/wifiwatcher.service && echo "Unit file added."
[ -f "$PWD/service/systemd/wifiwatcher.timer" ] && cp "$PWD/service/systemd/wifiwatcher.timer" ~/.config/systemd/user/wifiwatcher.timer && echo "Timer file added."
echo "Modifying the path to this script (you'll need to modify the service file if you move the repo on your system)..."
echo -e "\\t$PWD/channel-watch"
sleep 3
sed -i -- "s|SERVICE_PATH|$PWD/channel-watch|g" ~/.config/systemd/user/wifiwatcher.service
echo "Enabling service..."
systemctl --user enable wifiwatcher && echo "Enabling scheduler (default every 10min, see wiki for adjusting)"
systemctl --user enable wifiwatcher.timer && echo "Starting services..."
systemctl --user start wifiwatcher --now && systemctl --user start wifiwatcher.timer --now && echo "Service setup complete!"
fi
elif [ "$1" == "uninstallservice" ];
then
# checking for systemd
echo "Checking for systemd..."
if [ -d /usr/lib/systemd ];
then
echo "Found. Stopping services..."
systemctl --user stop wifiwatcher.timer
systemctl --user stop wifiwatcher
systemctl --user disable wifiwatcher.timer && systemctl --user disable wifiwatcher && echo "Removed wifiwatcher from startup"
echo "Removing service files for wifiwatcher..."
[ -e ~/.config/systemd/user/wifiwatcher.service ] && rm ~/.config/systemd/user/wifiwatcher.service && echo "wifiwatcher service removed"
[ -e ~/.config/systemd/user/wifiwatcher.timer ] && rm ~/.config/systemd/user/wifiwatcher.timer && echo "wifiwatcher timer removed"
echo "Checking for cache directory..."
[ -d ~/.config/wifi-channel-watcher ] && rm -rf ~/.config/wifi-channel-watcher && echo "Cache directory removed"
echo "Uninstall complete!"
fi
fiOstatnio edytowany przez Karoll (2023-07-19 16:52:41)
Offline



Użytkownik




Ten skrypt, który listujesz z /wifi-channel-watcher/channel-watch pobiera zmienne z pliku konfiguracyjnego ~/.config/wifi-channel-watcher/config.conf m.in. zmienną $THRESHOLD.
Można się upewnić, że to w tej zmiennej leży problem przykładowo modyfikując linię 124:
if [ "$TOTAL_ACTIVE" -ge "1" ] && [ -f /usr/bin/notify-send ];
Poza tym bash dostarcza narzędzia do debugowania: https://tldp.org/LDP/Bash-Beginners-Guide/html/sect_02_03.html
Uruchom basha z opcją -x.
bash -x /wifi-channel-watcher/channel-watch
Offline

Użytkownik


Zmodyfikowalem linie 124 na:
if [ "$TOTAL_ACTIVE" -ge "1" ] && [ -f /usr/bin/notify-send ];
Wynik z opcja debugowania:
:bash -x /wifi-channel-watcher/channel-watch
+ CACHE_DIR=/root/.config/wifi-channel-watcher/
+ '[' '!' '' == uninstallservice ']'
+ '[' '!' -d /root/.config/wifi-channel-watcher/ ']'
+ '[' -e /root/.config/wifi-channel-watcher/config.conf ']'
+ '[' '' == 1 ']'
++ cat
++ awk '{print $1}'
++ tail -n1
++ tr -d .:
+ INTERFACE=wlx502b73a51266
+ '[' '' == 1 ']'
++ nmcli con show --active
++ awk '$3 ~ "wifi" || "*wireless"'
+ '[' 'NAME UUID TYPE DEVICE
Isaacs 35152540-213a-481e-8354-4fbc1a99f1b2 wifi wlp5s0 ' == '' ']'
+ [[ ! '' == '' ]]
+ INTERNAL_CONN=
+ '[' '' == 1 ']'
++ /sbin/iwgetid -r
+ ME=Isaacs
++ /sbin/iw dev wlx502b73a51266 info
++ grep channel
++ awk '{print $2}'
+ CHANNEL=
++ echo
++ awk '$1 ~ /^1$|^6$|^11$/'
++ sort
++ uniq -c
++ sort -n
+ RADIO=
+ '[' '' == 1 ']'
+ IFS='
'
++ nmcli -g chan dev wi list
++ sort
++ uniq -c
+ CHAN=(' 1 ' ' 15 1' ' 14 11' ' 5 36' ' 2 4' ' 9 40' ' 7 44' ' 3 48' ' 1 56' ' 16 6' ' 1 64')
+ declare -a CHAN
+ '[' '' == 1 ']'
+ for ACTIVE_CHANNEL in "${CHAN[@]}"
+ [[ 1 =~ '' ]]
++ echo ' 1 '
++ awk '{print $1}'
+ TOTAL_ACTIVE=1
+ TOTAL_ACTIVE=0
+ '[' '' == 1 ']'
+ break
+ '[' '' == 1 ']'
+ '[' 0 -ge 1 ']'
+ '[' '' == 1 ']'
+ '[' '' == installservice ']'
+ '[' '' == uninstallservice ']'
root@debian:~# ./wifi-channel-watcher/channel-watch
./wifi-channel-watcher/channel-watch: line 124: [: : integer expression expected
root@debian:~# bash -x /wifi-channel-watcher/channel-watch
+ CACHE_DIR=/root/.config/wifi-channel-watcher/
+ '[' '!' '' == uninstallservice ']'
+ '[' '!' -d /root/.config/wifi-channel-watcher/ ']'
+ '[' -e /root/.config/wifi-channel-watcher/config.conf ']'
+ '[' '' == 1 ']'
++ cat
++ awk '{print $1}'
++ tail -n1
++ tr -d .:
+ INTERFACE=wlx502b73a51266
+ '[' '' == 1 ']'
++ nmcli con show --active
++ awk '$3 ~ "wifi" || "*wireless"'
+ '[' 'NAME UUID TYPE DEVICE
Isaacs 35152540-213a-481e-8354-4fbc1a99f1b2 wifi wlp5s0 ' == '' ']'
+ [[ ! '' == '' ]]
+ INTERNAL_CONN=
+ '[' '' == 1 ']'
++ /sbin/iwgetid -r
+ ME=Isaacs
++ /sbin/iw dev wlx502b73a51266 info
++ grep channel
++ awk '{print $2}'
+ CHANNEL=
++ echo
++ awk '$1 ~ /^1$|^6$|^11$/'
++ sort
++ uniq -c
++ sort -n
+ RADIO=
+ '[' '' == 1 ']'
+ IFS='
'
++ nmcli -g chan dev wi list
++ sort
++ uniq -c
+ CHAN=(' 1 ' ' 15 1' ' 13 11' ' 6 36' ' 1 4' ' 9 40' ' 7 44' ' 3 48' ' 1 56' ' 18 6' ' 1 64')
+ declare -a CHAN
+ '[' '' == 1 ']'
+ for ACTIVE_CHANNEL in "${CHAN[@]}"
+ [[ 1 =~ '' ]]
++ echo ' 1 '
++ awk '{print $1}'
+ TOTAL_ACTIVE=1
+ TOTAL_ACTIVE=0
+ '[' '' == 1 ']'
+ break
+ '[' '' == 1 ']'
+ '[' 0 -ge 1 ']'
+ '[' '' == 1 ']'
+ '[' '' == installservice ']'
+ '[' '' == uninstallservice ']'Niestety - kiedy chce "odpalic"
./wifi-channel-watcher/channel-watch ./wifi-channel-watcher/channel-watch: line 124: [: : integer expression expected
Offline



Użytkownik




W debugu wygląda, że jest ok
+ '[' 0 -ge 1 ']'
więc ten skrypt masz chyba w dwóch różnych lokalizacjach.
Pokaż wyniki:
find / -name channel-watch
i
cat /root/.config/wifi-channel-watcher/config.conf
inna sprawa, że uruchamianie tego skryptu na koncie root to nie jest najlepszy pomysł.
Ostatnio edytowany przez arecki (2023-07-20 12:32:32)
Offline

Użytkownik


$ find / -name channel-watch find: ‘/data/lost+found’: Permission denied
root@debian:~# find / -name channel-watch
root@debian:~# cd wifi-channel-watcher root@debian:~/wifi-channel-watcher# ls channel-watch config.conf icon.svg LICENSE service channel-watch.save examples img README.md
mark@debian:~$ cat /root/.config/wifi-channel-watcher/config.conf cat: /root/.config/wifi-channel-watcher/config.conf: Permission denied mark@debian:~$
cat /wifi-channel-watcher/config.conf DISPLAY_CHANNEL_BSSID="1" MAC_LIST="" AP_LIST="" INTERNAL_CHECK="" DEBUG="0" DEBUG_PATH="" CACHE_DIR="PROCESSED_DURING_SETUP" SUGGEST_CHANNEL="1" THRESHOLD="1" CHANNELS_5G="36|40|44|48|149|153|157|161|165" IGNORE_5G="1|2|3|4|5|6|7|8|9|10|11|12|13|52|56|60|64|100|104|108|112|116|120|124|128|132|136|140|38|46|54|62|102|110|118|126|134|134|142|151|159|42|58|106|122|138|155" CHANNELS_2G="1|6|11" IGNORE_2G="2|3|4|5|7|8|9|10|12|13|14|16|36|40|44|48|149|153|157|161|165|52|56|60|64|100|104|108|112|116|120|124|128|132|136|140|38|46|54|62|102|110|118|126|134|134|142|151|159|42|58|106|122|138|155|161|165"
Podaje wszystkie komendy potrzebne do instalki (mozna u siebie sprawdzic):
sudo apt install libnotify-bin network-manager iw
git clone https://github.com/angela-d/wifi-channel-watcher.git
cd wifi-channel-watcher && ./channel-watcher
ls
./channel-watchOdpalam i efekt ten sam:
mark@debian:/$ cd wifi-channel-watcher && ./channel-watch ./channel-watch: line 124: [: : integer expression expected
Ostatnio edytowany przez Karoll (2023-07-20 13:25:40)
Offline



Użytkownik




Tego chyba nie trzeba tłumaczyć?
mark@debian:~$ cat /root/.config/wifi-channel-watcher/config.conf
cat: /root/.config/wifi-channel-watcher/config.conf: Permission denied
mark@debian:~$
Wygląda na to, że masz ten skrypt w dwóch lokalizacjach.
W jednej uruchamiasz, w drugiej edytujesz.
ls /
bash /wifi-channel-watcher/channel-watch
Ostatnio edytowany przez arecki (2023-07-20 14:13:26)
Offline

Użytkownik


ls / bin libssh-0.9.5 run boot libssh-0.9.5.tar.xz sbin cubicsdr-installer.sh libx32 sda3 data live snap data2 livecd sparrow-wifi dev lost+found srv Documents media sys etc mnt tmp fern-wifi-cracker opt usr home proc var initrd.img qemu vmlinuz initrd.img.old qemu-8.0.3.tar.xz vmlinuz.old lib qjournalctl wifi-channel-watcher lib32 root lib64 rtl8812au
mark@debian:~$ bash /wifi-channel-watcher/channel-watch /wifi-channel-watcher/channel-watch: line 124: [: : integer expression expected mark@debian:~$
Offline



Użytkownik




Do tego dochodzi jeszcze uruchamianie raz z konta root, innym razem z konta mark.
Pomieszanie z poplątaniem.
Usunąłbym obydwa katalogi ze skryptem i potem już z konta mark w swoim katalogu domowym wykonał instalację, potem utworzył lub skopiował plik konfiguracyjny do właściwej lokalizacji (wskazanej na samym początku wątku ~/.config/wifi-channel-watcher/config.conf).
Offline

Użytkownik


Z tym
Pomieszanie z poplątaniem.
to masz absolutna racje.
Zrobilem jak radzisz i pewne efekty sa.
mark@debian: cd /home/mark/wifi-channel-watcher mark@debian:~/wifi-channel-watcher$ ./channel-watch
Efekt: https://imgur.com/a/iqdFrDp
Jest mu tylko daleko do prezentowanego na tej stronie (nie ma zadnych ustawien):
https://www.gnome-look.org/p/1482365
https://github.com/angela-d/wifi-channel-watcher
Podziekowal za wsparcie. (:-)
Ostatnio edytowany przez Karoll (2023-07-20 21:56:39)
Offline



Użytkownik




A to już pewnie kwestia posiadanego sprzętu i właściwej konfiguracji.
Offline