mirror of https://gitlab.com/hp3icc/emq-TE1.git
235 lines
8.1 KiB
Bash
235 lines
8.1 KiB
Bash
#!/bin/bash
|
|
####menu-dw
|
|
cat > /bin/menu-dw <<- "EOF"
|
|
#!/bin/bash
|
|
while : ; do
|
|
choix=$(whiptail --title "Raspbian Proyect HP3ICC Menu Direwolf" --menu "Suba o Baje con las flechas del teclado y seleccione el numero de opcion" 22 56 13 \
|
|
1 " Edit Direwolf Analogo " \
|
|
2 " Edit Direwolf SDR-RTL " \
|
|
3 " Edit Frecuency SDR-RTL " \
|
|
4 " Edit Direwolf Tracker " \
|
|
5 " Edit Dashboard " \
|
|
6 " Select Web Dashboard Port " \
|
|
7 " Start Direwolf SDR-RTL" \
|
|
8 " Start Direwolf Tracker" \
|
|
9 " Start Direwolf Analogo" \
|
|
10 " Start Direwolf Analogo + Dashboard" \
|
|
11 " Start Direwolf SDR-RTL + Dashboard" \
|
|
12 " Stop All Direwolf" \
|
|
13 " Menu Principal " 3>&1 1>&2 2>&3)
|
|
exitstatus=$?
|
|
#on recupere ce choix
|
|
#exitstatus=$?
|
|
if [ $exitstatus = 0 ]; then
|
|
echo "Your chosen option:" $choix
|
|
else
|
|
echo "You chose cancel."; break;
|
|
fi
|
|
# case : action en fonction du choix
|
|
case $choix in
|
|
1)
|
|
sudo nano /opt/direwolf/dw.conf;;
|
|
2)
|
|
sudo nano /opt/direwolf/sdr.conf;;
|
|
3)
|
|
sudo nano /opt/direwolf/rtl.sh ;;
|
|
4)
|
|
sudo nano /opt/direwolf/gpsd.conf;;
|
|
5)
|
|
sudo nano /opt/direwolf_webstat/config.php;;
|
|
6)
|
|
if sudo systemctl status http.server-dw.service |grep active >/dev/null 2>&1
|
|
then
|
|
sudo systemctl stop http.server-dw.service
|
|
fi
|
|
nano /opt/wdp2 &&
|
|
variable80=$(grep "Web-Dashboar-Port:" /opt/wdp2 | grep -Eo '[A.0-9]{1,9}')
|
|
if [ -z "$variable80" ]
|
|
then variable80=80
|
|
|
|
fi
|
|
sudo sed -i "s/ExecStart=.*/ExecStart=php -S 0.0.0.0:$variable80 -t \/opt\/direwolf_webstat\//g" /lib/systemd/system/http.server-dw.service &&
|
|
systemctl daemon-reload &&
|
|
if sudo netstat -tuln | grep -q "0.0.0.0:$variable80 "; then
|
|
whiptail --title "Check Port" --msgbox "El puerto $variable80 esta ocupado , The port $variable80 is busy" 0 50
|
|
else
|
|
if sudo systemctl status http.server-dw.service |grep "service; enabled;" >/dev/null 2>&1
|
|
then
|
|
sudo systemctl start http.server-dw.service
|
|
fi
|
|
fi ;;
|
|
7)
|
|
sudo systemctl stop direwolf.service
|
|
sudo systemctl stop http.server-dw.service
|
|
if systemctl status http.server-dw.service | grep enable >/dev/null 2>&1
|
|
then
|
|
sudo systemctl disable http.server-dw.service
|
|
fi
|
|
if [ "$(cat /proc/cpuinfo | grep 'Zero')" != "" ]; then
|
|
|
|
sudo cp /opt/direwolf/direwolf1 /usr/local/bin/direwolf
|
|
sudo chmod +x /usr/local/bin/direwolf
|
|
else
|
|
sudo cp /opt/direwolf/direwolf2 /usr/local/bin/direwolf
|
|
sudo chmod +x /usr/local/bin/direwolf
|
|
fi
|
|
sudo sed -i "s/ -l \/var\/log\/direwolf/#-l \/var\/log\/direwolf/" /opt/direwolf/rtl.sh
|
|
sudo sed -i "s/ExecStart=.*/ExecStart=\/bin\/sh \/opt\/direwolf\/rtl.sh/" /lib/systemd/system/direwolf.service
|
|
sudo systemctl daemon-reload
|
|
sudo systemctl start direwolf.service
|
|
sudo systemctl enable direwolf.service ;;
|
|
8)
|
|
sudo systemctl stop direwolf.service
|
|
sudo systemctl stop http.server-dw.service
|
|
if systemctl status gpsd.service | grep inactive >/dev/null 2>&1
|
|
then
|
|
sudo systemctl stop gpsd.socket gpsd.service &&
|
|
sudo systemctl start gpsd.socket gpsd.service
|
|
fi
|
|
if systemctl status gpsd.service | grep disable >/dev/null 2>&1
|
|
then
|
|
sudo systemctl enable gpsd.socket gpsd.service
|
|
fi
|
|
if systemctl status http.server-dw.service | grep enable >/dev/null 2>&1
|
|
then
|
|
sudo systemctl disable http.server-dw.service
|
|
fi
|
|
if [ "$(cat /proc/cpuinfo | grep 'Zero')" != "" ]; then
|
|
|
|
sudo cp /opt/direwolf/direwolf1 /usr/local/bin/direwolf
|
|
sudo chmod +x /usr/local/bin/direwolf
|
|
else
|
|
sudo cp /opt/direwolf/direwolf2 /usr/local/bin/direwolf
|
|
sudo chmod +x /usr/local/bin/direwolf
|
|
fi
|
|
sudo sed -i "s/ExecStart=.*/ExecStart=\/usr\/local\/bin\/direwolf -t 0 -c \/opt\/direwolf\/gpsd.conf/" /lib/systemd/system/direwolf.service
|
|
sudo systemctl daemon-reload
|
|
sudo systemctl start direwolf.service
|
|
sudo systemctl enable direwolf.service ;;
|
|
9)
|
|
sudo systemctl stop direwolf.service
|
|
sudo systemctl stop http.server-dw.service
|
|
if systemctl status http.server-dw.service | grep enable >/dev/null 2>&1
|
|
then
|
|
sudo systemctl disable http.server-dw.service
|
|
fi
|
|
if [ "$(cat /proc/cpuinfo | grep 'Zero')" != "" ]; then
|
|
|
|
sudo cp /opt/direwolf/direwolf1 /usr/local/bin/direwolf
|
|
sudo chmod +x /usr/local/bin/direwolf
|
|
else
|
|
sudo cp /opt/direwolf/direwolf2 /usr/local/bin/direwolf
|
|
sudo chmod +x /usr/local/bin/direwolf
|
|
fi
|
|
sudo sed -i "s/ExecStart=.*/ExecStart=sudo direwolf -t 0 -c \/opt\/direwolf\/dw.conf/" /lib/systemd/system/direwolf.service
|
|
sudo systemctl daemon-reload
|
|
sudo systemctl start direwolf.service
|
|
sudo systemctl enable direwolf.service ;;
|
|
10)
|
|
if systemctl status http.server-dw.service |grep "service; enabled;" >/dev/null 2>&1
|
|
then sudo systemctl disable http.server-dw.service
|
|
|
|
fi
|
|
if sudo systemctl status http.server-dw.service |grep active >/dev/null 2>&1
|
|
then
|
|
sudo systemctl stop http.server-dw.service
|
|
fi
|
|
if systemctl status direwolf.service |grep "service; enabled;" >/dev/null 2>&1
|
|
then sudo systemctl disable direwolf.service
|
|
|
|
fi
|
|
if sudo systemctl status direwolf.service |grep active >/dev/null 2>&1
|
|
then
|
|
sudo systemctl stop direwolf.service
|
|
fi
|
|
variable80=$(grep "Web-Dashboar-Port:" /opt/wdp2 | grep -Eo '[A.0-9]{1,9}')
|
|
if [ -z "$variable80" ]
|
|
then variable80=80
|
|
|
|
fi
|
|
sudo sed -i "s/ExecStart=.*/ExecStart=php -S 0.0.0.0:$variable80 -t \/opt\/direwolf_webstat\//g" /lib/systemd/system/http.server-dw.service &&
|
|
systemctl daemon-reload &&
|
|
if sudo netstat -tuln | grep -q "0.0.0.0:$variable80 "; then
|
|
whiptail --title "Check Port" --msgbox "El puerto $variable80 esta ocupado , The port $variable80 is busy" 0 50
|
|
else
|
|
if [ "$(cat /proc/cpuinfo | grep 'Zero')" != "" ]; then
|
|
|
|
sudo cp /opt/direwolf/direwolf1 /usr/local/bin/direwolf
|
|
sudo chmod +x /usr/local/bin/direwolf
|
|
else
|
|
sudo cp /opt/direwolf/direwolf2 /usr/local/bin/direwolf
|
|
sudo chmod +x /usr/local/bin/direwolf
|
|
fi
|
|
sudo sed -i "s/ExecStart=.*/ExecStart=\/usr\/local\/bin\/direwolf -t 0 -l \/var\/log\/direwolf -c \/opt\/direwolf\/dw.conf/" /lib/systemd/system/direwolf.service
|
|
sudo systemctl daemon-reload
|
|
sudo systemctl start direwolf.service
|
|
sudo systemctl start http.server-dw.service
|
|
sudo systemctl enable http.server-dw.service
|
|
sudo systemctl enable direwolf.service
|
|
fi ;;
|
|
11)
|
|
if systemctl status http.server-dw.service |grep "service; enabled;" >/dev/null 2>&1
|
|
then sudo systemctl disable http.server-dw.service
|
|
|
|
fi
|
|
if sudo systemctl status http.server-dw.service |grep active >/dev/null 2>&1
|
|
then
|
|
sudo systemctl stop http.server-dw.service
|
|
fi
|
|
if systemctl status direwolf.service |grep "service; enabled;" >/dev/null 2>&1
|
|
then sudo systemctl disable direwolf.service
|
|
|
|
fi
|
|
if sudo systemctl status direwolf.service |grep active >/dev/null 2>&1
|
|
then
|
|
sudo systemctl stop direwolf.service
|
|
fi
|
|
variable80=$(grep "Web-Dashboar-Port:" /opt/wdp2 | grep -Eo '[A.0-9]{1,9}')
|
|
if [ -z "$variable80" ]
|
|
then variable80=80
|
|
|
|
fi
|
|
sudo sed -i "s/ExecStart=.*/ExecStart=php -S 0.0.0.0:$variable80 -t \/opt\/direwolf_webstat\//g" /lib/systemd/system/http.server-dw.service &&
|
|
systemctl daemon-reload &&
|
|
if sudo netstat -tuln | grep -q "0.0.0.0:$variable80 "; then
|
|
whiptail --title "Check Port" --msgbox "El puerto $variable80 esta ocupado , The port $variable80 is busy" 0 50
|
|
else
|
|
sudo systemctl stop direwolf.service
|
|
if [ "$(cat /proc/cpuinfo | grep 'Zero')" != "" ]; then
|
|
|
|
sudo cp /opt/direwolf/direwolf1 /usr/local/bin/direwolf
|
|
sudo chmod +x /usr/local/bin/direwolf
|
|
else
|
|
sudo cp /opt/direwolf/direwolf2 /usr/local/bin/direwolf
|
|
sudo chmod +x /usr/local/bin/direwolf
|
|
fi
|
|
sudo sed -i "s/#-l \/var\/log\/direwolf/ -l \/var\/log\/direwolf/" /opt/direwolf/rtl.sh
|
|
sudo sed -i "s/ExecStart=.*/ExecStart=\/bin\/sh \/opt\/direwolf\/rtl.sh/" /lib/systemd/system/direwolf.service
|
|
sudo systemctl daemon-reload
|
|
sudo systemctl start direwolf.service
|
|
sudo systemctl start http.server-dw.service
|
|
sudo systemctl enable http.server-dw.service
|
|
sudo systemctl enable direwolf.service
|
|
fi ;;
|
|
12)
|
|
if systemctl status http.server-dw.service | grep enable >/dev/null 2>&1
|
|
then
|
|
sudo systemctl disable http.server-dw.service
|
|
fi
|
|
sudo systemctl stop http.server-dw.service
|
|
if systemctl status direwolf.service | grep enable >/dev/null 2>&1
|
|
then
|
|
sudo systemctl disable direwolf.service
|
|
fi
|
|
sudo systemctl stop direwolf.service
|
|
sudo systemctl stop gpsd.service ;;
|
|
13)
|
|
break;
|
|
esac
|
|
done
|
|
exit 0
|
|
EOF
|
|
##
|
|
chmod +x /bin/menu*
|
|
ln -sf /bin/menu-dw /bin/MENU-DW
|
|
chmod +x /bin/MENU* |