Skip to content

Commit

Permalink
Made many enhancements and also closes issue #5
Browse files Browse the repository at this point in the history
  • Loading branch information
km4ack authored and nandub committed Dec 4, 2020
1 parent 1139df7 commit f9256f6
Show file tree
Hide file tree
Showing 10 changed files with 86 additions and 122 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ or by using the [Build-a-Pi](https://github.com/km4ack/pi-build) script.

# Install

git clone https://github.com/km4ack/hotspot-tools.git $HOME/hotspot-tools
git clone https://github.com/km4ack/hotspot-tools-lite.git $HOME/hotspot-tools-lite

cd ~/hotspot-tools
cd ~/hotspot-tools-lite

bash setup

Expand Down
12 changes: 7 additions & 5 deletions dhcp
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,22 @@

DHCP=$(cat /var/lib/misc/dnsmasq.leases)
HSS=$(cat /usr/bin/autohotspotN | grep "ip a add" | awk '{ print $4 }' | sed 's/\/24//')
CIP=$(ifconfig | grep -A 1 wlan0 | grep inet | awk '{ print $2 }')
CIP=$(ip address show dev wlan0 | grep -v inet6 | grep inet | awk '{ print $2 }' | sed 's/\/24//')
#CIP=$(ifconfig | grep -A 1 wlan0 | grep inet | awk '{ print $2 }')

if [ $HSS = $CIP ]
then
HSS=ACTIVE
HSS=ACTIVATED
else
HSS=INACTIVE
HSS=DEACTIVATED
fi

clear;echo;echo
echo "List of Current DHCP Addresses"
echo "$DHCP" | awk '{ print $3" "$4" "$5 }'
echo;echo
read -p "Flush DHCP Leases? y/n " ANS
if [ $HSS = 'ACTIVE' ] && [ $ANS = 'y' ] || [ $ANS = 'Y' ]
if [ $HSS = 'ACTIVATED' ] && [ $ANS = 'y' ] || [ $ANS = 'Y' ]
then
cat <<EOF
Hotspot is currently active.
Expand All @@ -39,4 +40,5 @@ echo "" | sudo tee /var/lib/misc/dnsmasq.leases
sudo systemctl start dnsmasq
echo "flushed"
sleep 2
fi
fi

5 changes: 2 additions & 3 deletions disable
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
#script to disable hotspot
#20200221
clear;echo;echo
STATUS=$(systemctl is-active autohotspot)
if [ $STATUS = 'inactive' ]
STATUS=$(systemctl is-enabled autohotspot)
if [ $STATUS = 'disabled' ]
then
echo
echo "Hotspot already disabled"
Expand Down Expand Up @@ -45,4 +45,3 @@ echo "No changes made"
sleep 2
fi


13 changes: 8 additions & 5 deletions enable
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
#20200221 km4ack

#check if already active
STATUS=$(systemctl is-active autohotspot)
if [ $STATUS = "active" ]
STATUS=$(systemctl is-enabled autohotspot)
if [ $STATUS = "enabled" ]
then
echo "Hotspot already active"
echo "Hotspot already enabled"
sleep 2
exit 0
fi
Expand All @@ -19,7 +19,9 @@ if [ $ANS = 'y' ] || [ $ANS = 'Y' ]
then
sudo systemctl enable autohotspot

sudo echo "nohook wpa_supplicant" >> /etc/dhcpcd.conf
sudo su -c 'echo "nohook wpa_supplicant" >> /etc/dhcpcd.conf'
# fails on my rpi2
#sudo echo "nohook wpa_supplicant" >> /etc/dhcpcd.conf

echo "Hotspot Enabled"
echo "Reboot required to apply changes"
Expand All @@ -34,4 +36,5 @@ echo
echo "Nothing Changed"
sleep 2
exit 0
fi
fi

102 changes: 48 additions & 54 deletions hotspot-menu
Original file line number Diff line number Diff line change
Expand Up @@ -9,95 +9,95 @@ VER=$(cat $DIR/changelog | grep version= | sed 's/version=//')
PS3='Please enter your choice: '
MAINMENU () {

HS=$(systemctl is-active autohotspot)
HS=$(systemctl is-enabled autohotspot)
HSR=$(systemctl is-active autohotspot)
CURRENTNAME=$(sudo cat /etc/hostapd/hostapd.conf | grep ssid= | head -1 | sed 's/ssid=//')
CURRENTPASS=$(sudo cat /etc/hostapd/hostapd.conf | grep wpa_passphrase= | sed 's/wpa_passphrase=//')
HSIP=$(cat /usr/bin/autohotspotN | grep "ip a add" | sed 's/ip\ a\ add\ //' | sed 's/\/24.*$//' | tr -d " ")
HSS=$(cat /usr/bin/autohotspotN | grep "ip a add" | awk '{ print $4 }' | sed 's/\/24//')
CIP=$(ifconfig | grep -A 1 wlan0 | grep inet | awk '{ print $2 }')
HSIP=$(cat /usr/bin/autohotspotN | grep "ip a add" | awk '{ print $4 }' | sed 's/\/24//')
CIP=$(ip address show dev wlan0 | grep -v inet6 | grep inet | awk '{ print $2 }' | sed 's/\/24//')
#CIP=$(ifconfig | grep -A 1 wlan0 | grep inet | awk '{ print $2 }')

if [ $HSS = $CIP ]
if [ $HSR = 'inactive' ]
then
HSS=ACTIVE
HS1="STOPPED ($HS)"
else
HSS=INACTIVE
HS1="RUNNING ($HS)"
fi

if [ $HS = 'active' ]
if [ $HSIP = $CIP ]
then
HS=Enabled
elif [ $HS = 'inactive' ]
then
HS=Disabled
HSS=ACTIVATED
else
HSS=DEACTIVATED
fi


clear;echo
echo "Hotspot Tools v"$VER" by KM4ACK"
echo
echo "------HOTSPOT PARAMETERS------"
echo " Status "$HS
echo " Status "$HS1
echo " State "$HSS
echo " SSID "$CURRENTNAME
echo " Password "$CURRENTPASS
echo " IP Addr "$HSIP
echo "------------------------------"
echo
options=("Change Name/Password" "Run Hotspot" "Disable Hotspot" "Enable Hotspot" "Manage IP" "Manage SSIDs" "Known SSIDs" "DHCP List" "Update" "Exit")
options=("Change Name/Password" "Run Hotspot" "Disable Hotspot" "Enable Hotspot" "Manage IP" "Manage SSIDs" "Known SSIDs" "DHCP List" "Reload" "Update" "Exit")
select opt in "${options[@]}"
do
case $opt in
"Change Name/Password")
$DIR/hotspotname
MAINMENU
MAINMENU
;;
"Run Hotspot")
if [ $HS = 'Enabled' ];then
echo "Standby......"
$DIR/runhs
#sudo /usr/bin/autohotspotN
#sleep 4
else
echo "Hotspot is disabled. Please enable and try again."
sleep 3
fi
MAINMENU
if [ $HS = 'enabled' ]; then
echo "Standby......"
$DIR/runhs
else
echo "Hotspot is disabled. Please enable and try again."
sleep 3
fi
MAINMENU
;;
"Disable Hotspot")
$DIR/disable
sleep 3
MAINMENU
sleep 3
MAINMENU
;;
"Enable Hotspot")
"Enable Hotspot")
$DIR/enable
sleep 3
MAINMENU
sleep 3
MAINMENU
;;
"Manage IP")
$DIR/manage-ip
MAINMENU
"Manage IP")
$DIR/manage-ip
MAINMENU
;;
"Manage SSIDs")
"Manage SSIDs")
sudo $DIR/wificonnect
MAINMENU
MAINMENU
;;
"Known SSIDs")
"Known SSIDs")
$DIR/knowssid
MAINMENU
MAINMENU
;;
"DHCP List")
"DHCP List")
$DIR/dhcp
MAINMENU
MAINMENU
;;
"Update")
echo "checking for updates"
"Reload")
MAINMENU
;;
"Update")
echo "checking for updates"
cd $DIR
git fetch --all
git reset --hard origin/dev
bash setup
echo "Please restart HotSpot-Tools script to see changes."
read -n 1 -s -r -p "Press any key to continue"
MAINMENU
git fetch --all
git reset --hard origin/master
bash setup
echo "Please restart HotSpot-Tools script to see changes."
read -n 1 -s -r -p "Press any key to continue"
MAINMENU
;;
"Exit")
exit 0
Expand All @@ -109,9 +109,3 @@ done

MAINMENU







10 changes: 0 additions & 10 deletions hotspotname
Original file line number Diff line number Diff line change
Expand Up @@ -93,13 +93,3 @@ echo "Nothing Changed"
sleep 2
fi











15 changes: 7 additions & 8 deletions knowssid
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,19 @@

DIR=$HOME/hotspot-tools
VER=$(cat $DIR/changelog | grep version= | sed 's/version=//')
HS=$(systemctl is-active autohotspot)
HS=$(systemctl is-enabled autohotspot)
HSR=$(systemctl is-active autohotspot)
CURRENTNAME=$(sudo cat /etc/hostapd/hostapd.conf | grep ssid= | head -1 | sed 's/ssid=//')
CURRENTPASS=$(sudo cat /etc/hostapd/hostapd.conf | grep wpa_passphrase= | sed 's/wpa_passphrase=//')
HSIP=$(cat /usr/bin/autohotspotN | grep "ip a add" | sed 's/ip\ a\ add\ //' | sed 's/\/24.*$//' | tr -d " ")

if [ $HS = 'active' ]
if [ $HSR = 'inactive' ]
then
HS=enabled
elif [ $HS = 'inactive' ]
then
HS=disabled
HS="STOPPED ($HS)"
else
HS="RUNNING ($HS)"
fi


clear;echo
echo "Hotspot Tools v"$VER" by KM4ACK"
echo
Expand All @@ -35,4 +34,4 @@ echo "List of currently known SSID's"
echo
echo "$SSID" | tr -d "[:blank:]"
echo
read -n 1 -s -r -p "Press any key to continue"
read -n 1 -s -r -p "Press any key to continue"
2 changes: 1 addition & 1 deletion manage-ip
Original file line number Diff line number Diff line change
Expand Up @@ -73,4 +73,4 @@ fi
echo "After connecting to your hotspot wifi"
echo "use IP address "$IP".10.10 in VNC to connect"
echo "Reboot required to apply changes"
read -n 1 -s -r -p "Press any key to continue"
read -n 1 -s -r -p "Press any key to continue"
16 changes: 8 additions & 8 deletions setup
Original file line number Diff line number Diff line change
Expand Up @@ -3,30 +3,30 @@
#setup script for hotspot tools
#20200221 km4ack

DIR=$HOME/hotspot-tools
DIR=$HOME/hotspot-tools-lite

#move menu file to menu folder
#chmod all files
#remove this script
cd $DIR
chmod +x disable enable hotspot-menu hotspotname knowssid manage-ip wificonnect
#create symlink in bin folder to use in pi main menu
sudo ln -sf $DIR/hotspot-menu /usr/local/bin/Hotspot-Tools
sudo ln -sf $DIR/hotspot-menu /usr/local/bin/Hotspot-Tools-Lite
#create symlink on desktop
ln -sf $DIR/hotspot-menu $HOME/Desktop/Hotspot-Tools
ln -sf $DIR/hotspot-menu $HOME/Desktop/Hotspot-Tools-Lite

#create menu item for hotspot tools
cat > hotspot-tools.desktop <<EOF
cat > hotspot-tools-lite.desktop <<EOF
[Desktop Entry]
Name=Hotspot Tools
Name=Hotspot Tools Lite
GenericName=Tools to Manage AutoHotSpot
Comment=Tools to Manage AutoHotSpot
Exec=/usr/local/bin/Hotspot-Tools
Icon=/home/pi/hotspot-tools/logo.png
Exec=/usr/local/bin/Hotspot-Tools-Lite
Icon=/home/pi/hotspot-tools-lite/logo.png
Terminal=true
Type=Application
Categories=Network;HamRadio;
EOF

sudo mv $DIR/hotspot-tools.desktop /usr/share/applications/
sudo mv $DIR/hotspot-tools-lite.desktop /usr/share/applications/

29 changes: 3 additions & 26 deletions wificonnect
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,7 @@

mkdir -p $HOME/temp
TEMPFILE=$HOME/temp/tempwifi
HS=$(systemctl is-active autohotspot)
if [ $HS = 'active' ]
then
HSS=ACTIVE
else
HSS=INACTIVE
fi
HS=$(systemctl is-enabled autohotspot)

ADD () {
# Generate List of Available SSIDs
Expand Down Expand Up @@ -72,11 +66,11 @@ key_mgmt=WPA-PSK
EOF
cat $TEMPFILE | tee -a /etc/wpa_supplicant/wpa_supplicant.conf
rm $TEMPFILE
if [ $HSS = 'ACTIVE' ]
if [ $HS = 'enabled' ]
then
echo "attempting to connect to new wifi"
/usr/bin/autohotspotN
elif [ $HSS = 'INACTIVE' ]
elif [ $HSS = 'disabled' ]
then
killall wpa_supplicant
sleep 1
Expand Down Expand Up @@ -157,20 +151,3 @@ fi

CHOICES


















0 comments on commit f9256f6

Please sign in to comment.