This commit is contained in:
Esteban Mackay Q 2023-10-14 14:10:42 -05:00
parent 5ab44d073f
commit 31d2b4d536
4 changed files with 361 additions and 6 deletions

View File

@ -83,6 +83,7 @@ rustup default 1.72.0
/usr/bin/python3 -m pip install --upgrade maidenhead /usr/bin/python3 -m pip install --upgrade maidenhead
/usr/bin/python3 -m pip install --upgrade Twisted /usr/bin/python3 -m pip install --upgrade Twisted
/usr/bin/python3 -m pip install --upgrade spyne /usr/bin/python3 -m pip install --upgrade spyne
/usr/bin/python3 -m pip install --upgrade Pyro5
echo "Instalación completa." echo "Instalación completa."

View File

@ -70,12 +70,12 @@ fi
cd /opt cd /opt
git clone https://github.com/g4klx/MMDVMHost.git git clone https://github.com/g4klx/MMDVMHost.git
cd /opt/MMDVMHost cd /opt/MMDVMHost
sudo make clean #sudo make clean
git clone https://github.com/hallard/ArduiPi_OLED #git clone https://github.com/hallard/ArduiPi_OLED
cd ArduiPi_OLED #cd ArduiPi_OLED
sudo make #sudo make
cd /opt/MMDVMHost/ #cd /opt/MMDVMHost/
make clean make clean
sudo make -f Makefile.Pi.OLED sudo make -f Makefile.Pi.OLED
sudo make install sudo make install

354
menu/menu-fdmr-bridge Normal file
View File

@ -0,0 +1,354 @@
#!/bin/bash
if [ -f "/opt/wdp7" ]
then
echo "found file"
else
cat > /opt/wdp7 <<- "EOFX"
################################################
# Select number port, FreeDMR-Bridge Dashboard #
################################################
Web-Dashboar-Port: 80
EOFX
fi
sudo cat > /bin/menu-fdmr-b <<- "EOF"
#!/bin/bash
if [[ $EUID -ne 0 ]]; then
whiptail --title "sudo su" --msgbox "requiere ser usuario root , escriba (sudo su) antes de entrar a menu / requires root user, type (sudo su) before entering menu" 0 50
exit 0
fi
while : ; do
choix=$(whiptail --title "Raspbian Proyect HP3ICC FreeDMR-Bridge" --menu "move up or down with the keyboard arrows and select your option by pressing enter:" 23 56 13 \
1 " Edit FreeDMR-Bridger " \
2 " Edit Rules " \
3 " Edit FDMR-Monitor " \
4 " Start Dashboard " \
5 " Start-Restart FreeDMR-Bridger " \
6 " Stop FreeDMR-Bridge " \
7 " Stop Dashboard " \
8 " Proxy " \
9 " Menu update " 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/FreeDMR-Bridge/config/FreeDMR.cfg &&
if sudo systemctl status freedmr-bridge.service |grep "service; enabled;" >/dev/null 2>&1
then
sudo systemctl restart freedmr-bridge.service
fi ;;
2)
sudo nano /opt/FreeDMR-Bridge/config/rules.py &&
if sudo systemctl status freedmr-bridge.service |grep "service; enabled;" >/dev/null 2>&1
then
sudo systemctl restart freedmr-bridge.service
fi ;;
3)
network=$(whiptail --title "Easy FreeDMR Bridge" --menu "Select a option:" 10 60 3 \
"1" "Edit FDMR-Monitor OA4DOA" \
"2" "Edit FDMR-Monitor CS8ABG" \
"3" "Edit Web Port" 3>&1 1>&2 2>&3)
if [ $? != 0 ]; then
echo "You chose cancel. Returning to main menu."
continue # Regresar al inicio del bucle sin procesar el resto del caso 1
fi
case "$network" in
"1")
sudo nano /opt/FDMR-Monitor-B/fdmr-mon.cfg ;;
"2")
sudo nano /opt/FDMR-Monitor-B2/fdmr-mon.cfg ;;
"3")
sudo nano /opt/wdp7 &&
if sudo systemctl status http.server-fdmr-b.service |grep active >/dev/null 2>&1
then
sudo systemctl stop http.server-fdmr-b.service
fi &&
if sudo systemctl status http.server-fdmr-b2.service |grep active >/dev/null 2>&1
then
sudo systemctl stop http.server-fdmr-b2.service
fi &&
variable80=$(grep "Web-Dashboar-Port:" /opt/wdp7 | 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 \/var\/www\/fdmr-b\//g" /lib/systemd/system/http.server-fdmr-b.service &&
sudo sed -i "s/ExecStart=.*/ExecStart=php -S 0.0.0.0:$variable80 -t \/var\/www\/fdmr-b2\//g" /lib/systemd/system/http.server-fdmr-b2.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-fdmr-b.service |grep "service; enabled;" >/dev/null 2>&1
then
sudo systemctl start http.server-fdmr-b.service
else
if sudo systemctl status http.server-fdmr-b2.service |grep "service; enabled;" >/dev/null 2>&1
then
sudo systemctl start http.server-fdmr-b2.service
fi
fi
fi ;;
*)
echo "Invalid selection"
;;
esac
;;
4)
network=$(whiptail --title "Easy FreeDMR Bridge" --menu "Select a option:" 10 60 2 \
"1" "Select FDMR-Monitor OA4DOA" \
"2" "Select FDMR-Monitor CS8ABG" 3>&1 1>&2 2>&3)
if [ $? != 0 ]; then
echo "You chose cancel. Returning to main menu."
continue # Regresar al inicio del bucle sin procesar el resto del caso 1
fi
case "$network" in
"1")
if systemctl status http.server-fdmr-b.service |grep "service; enabled;" >/dev/null 2>&1
then sudo systemctl disable http.server-fdmr-b.service
fi
if systemctl status http.server-fdmr-b2.service |grep "service; enabled;" >/dev/null 2>&1
then sudo systemctl disable http.server-fdmr-b2.service
fi
if systemctl status fdmr_mon-b.service |grep "service; enabled;" >/dev/null 2>&1
then sudo systemctl disable fdmr_mon-b.service
fi
if systemctl status fdmr_mon-b2.service |grep "service; enabled;" >/dev/null 2>&1
then sudo systemctl disable fdmr_mon-b2.service
fi
if sudo systemctl status http.server-fdmr-b.service |grep active >/dev/null 2>&1
then
sudo systemctl stop http.server-fdmr-b.service
fi
if sudo systemctl status http.server-fdmr-b2.service |grep active >/dev/null 2>&1
then
sudo systemctl stop http.server-fdmr-b2.service
fi
if sudo systemctl status fdmr_mon-b.service |grep active >/dev/null 2>&1
then
sudo systemctl stop fdmr_mon-b.service
fi
if sudo systemctl status fdmr_mon-b2.service |grep active >/dev/null 2>&1
then
sudo systemctl stop fdmr_mon-b2.service
fi
variable80=$(grep "Web-Dashboar-Port:" /opt/wdp7 | 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 \/var\/www\/fdmr-b\//g" /lib/systemd/system/http.server-fdmr-b.service &&
sudo sed -i "s/ExecStart=.*/ExecStart=php -S 0.0.0.0:$variable80 -t \/var\/www\/fdmr-b2\//g" /lib/systemd/system/http.server-fdmr-b2.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
(crontab -l; echo "* */1 * * * sync ; echo 3 > /proc/sys/vm/drop_caches >/dev/null 2>&1")|awk '!x[$0]++'|crontab -
(crontab -l; echo "* */24 * * * rm /opt/FDMR-Monitor-B2/data/*")|awk '!x[$0]++'|crontab -
(crontab -l | grep -v "rm /opt/FDMR-Monitor-B/data/*") | crontab -
(crontab -l | grep -v "rm /etc/freedmr/hbmon/data/*") | crontab -
(crontab -l | grep -v "sh /etc/freedmr/hbmon/sysinfo/cpu.sh") | crontab -
(crontab -l | grep -v "sh /etc/freedmr/hbmon/sysinfo/graph.sh") | crontab -
(crontab -l | grep -v "sh /opt/FDMR-Monitor-B/sysinfo/cpu.sh") | crontab -
(crontab -l | grep -v "sh /opt/FDMR-Monitor-B/sysinfo/graph.sh") | crontab -
#####################################
rm /opt/FDMR-Monitor-B2/data/*
cd /opt/FDMR-Monitor-B2
python3 mon_db.py --create &&
python3 mon_db.py --update
sudo systemctl start fdmr_mon-b2.service
sudo systemctl enable fdmr_mon-b2.service
sudo systemctl start http.server-fdmr-b2.service
sudo systemctl enable http.server-fdmr-b2.service
fi ;;
"2")
if systemctl status http.server-fdmr-b.service |grep "service; enabled;" >/dev/null 2>&1
then sudo systemctl disable http.server-fdmr-b.service
fi
if systemctl status http.server-fdmr-b2.service |grep "service; enabled;" >/dev/null 2>&1
then sudo systemctl disable http.server-fdmr-b2.service
fi
if systemctl status fdmr_mon-b.service |grep "service; enabled;" >/dev/null 2>&1
then sudo systemctl disable fdmr_mon-b.service
fi
if systemctl status fdmr_mon-b2.service |grep "service; enabled;" >/dev/null 2>&1
then sudo systemctl disable fdmr_mon-b2.service
fi
if sudo systemctl status http.server-fdmr-b.service |grep active >/dev/null 2>&1
then
sudo systemctl stop http.server-fdmr-b.service
fi
if sudo systemctl status http.server-fdmr-b2.service |grep active >/dev/null 2>&1
then
sudo systemctl stop http.server-fdmr-b2.service
fi
if sudo systemctl status fdmr_mon-b.service |grep active >/dev/null 2>&1
then
sudo systemctl stop fdmr_mon-b.service
fi
if sudo systemctl status fdmr_mon-b2.service |grep active >/dev/null 2>&1
then
sudo systemctl stop fdmr_mon-b2.service
fi
variable80=$(grep "Web-Dashboar-Port:" /opt/wdp7 | 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 \/var\/www\/fdmr-b\//g" /lib/systemd/system/http.server-fdmr-b.service &&
sudo sed -i "s/ExecStart=.*/ExecStart=php -S 0.0.0.0:$variable80 -t \/var\/www\/fdmr-b2\//g" /lib/systemd/system/http.server-fdmr-b2.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
(crontab -l; echo "* */1 * * * sync ; echo 3 > /proc/sys/vm/drop_caches >/dev/null 2>&1")|awk '!x[$0]++'|crontab -
(crontab -l; echo "* */24 * * * rm /opt/FDMR-Monitor-B/data/*")|awk '!x[$0]++'|crontab -
(crontab -l; echo "*/2 * * * * sh /opt/FDMR-Monitor-B/sysinfo/cpu.sh")|awk '!x[$0]++'|crontab -
(crontab -l; echo "*/5 * * * * sh /opt/FDMR-Monitor-B/sysinfo/graph.sh")|awk '!x[$0]++'|crontab -
(crontab -l | grep -v "sh /etc/freedmr/hbmon/sysinfo/cpu.sh") | crontab -
(crontab -l | grep -v "sh /etc/freedmr/hbmon/sysinfo/graph.sh") | crontab -
(crontab -l | grep -v "rm /etc/freedmr/hbmon/data/*") | crontab -
(crontab -l | grep -v "rm /opt/FDMR-Monitor-B2/data/*") | crontab -
#####################################
rm /opt/FDMR-Monitor-B/data/*
cd /opt/FDMR-Monitor-B
python3 mon_db.py --create &&
python3 mon_db.py --update
sudo systemctl start fdmr_mon-b.service
sudo systemctl enable fdmr_mon-b.service
sudo systemctl start http.server-fdmr-b.service
sudo systemctl enable http.server-fdmr-b.service
fi ;;
*)
echo "Invalid selection"
;;
esac
;;
5)
if systemctl status freedmr-bridge.service |grep disable >/dev/null 2>&1
then sudo systemctl enable freedmr-bridge.service
fi
if systemctl status freedmr-bridge.service |grep active >/dev/null 2>&1
then sudo systemctl stop freedmr-bridge.service
fi
sudo systemctl start freedmr-bridge.service ;;
6)
sudo systemctl stop freedmr-bridge.service
sudo systemctl disable freedmr-bridge.service ;;
7)
(crontab -l | grep -v "rm /opt/FDMR-Monitor-B2/data/*") | crontab -
(crontab -l | grep -v "rm /opt/FDMR-Monitor-B/data/*") | crontab -
(crontab -l | grep -v "sh /opt/FDMR-Monitor-B/sysinfo/cpu.sh") | crontab -
(crontab -l | grep -v "sh /opt/FDMR-Monitor-B/sysinfo/graph.sh") | crontab -
sudo systemctl stop fdmr_mon-b2.service
sudo systemctl disable fdmr_mon-b2.service
sudo systemctl stop http.server-fdmr-b2.service
sudo systemctl disable http.server-fdmr-b2.service
sudo systemctl stop fdmr_mon-b.service
sudo systemctl disable fdmr_mon-b.service
sudo systemctl stop http.server-fdmr-b.service
sudo systemctl disable http.server-fdmr-b.service
;;
8)
network=$(whiptail --title "Easy FreeDMR Bridge" --menu "Select a option:" 10 60 4 \
"1" "Wizar Config Proxy" \
"2" "Start Proxy" \
"3" "Stop Proxy" \
"4" "Edit Proxy" 3>&1 1>&2 2>&3)
if [ $? != 0 ]; then
echo "You chose cancel. Returning to main menu."
continue # Regresar al inicio del bucle sin procesar el resto del caso 1
fi
case "$network" in
"1")
whiptail --title "Wizar Config Proxy" --inputbox "External Port:" 10 60 2>/tmp/eport.txt
exitstatus=$?
if [ $exitstatus != 0 ]; then
echo "You chose cancel. Exiting..."
exit 1 # Salir del script con un código de error
fi
eport=$(cat /tmp/eport.txt)
eport=$(echo "$eport" | tr '[:lower:]' '[:upper:]')
whiptail --title "Wizar Config Proxy" --inputbox "Local Port:" 10 60 2>/tmp/iport.txt
exitstatus=$?
if [ $exitstatus != 0 ]; then
echo "You chose cancel. Exiting..."
exit 1 # Salir del script con un código de error
fi
iport=$(cat /tmp/iport.txt)
whiptail --title "Wizar Config Proxy" --inputbox "Generator port, Sample: 100" 10 60 2>/tmp/genport.txt
exitstatus=$?
if [ $exitstatus != 0 ]; then
echo "You chose cancel. Exiting..."
exit 1 # Salir del script con un código de error
fi
genport=$(cat /tmp/genport.txt)1
generat=$((iport + genport - 1))
sudo sed -i "s/LISTENPORT =.*/LISTENPORT = $eport/g" /opt/FDMR-Monitor-B/proxy.cfg
sudo sed -i "s/DESTPORTSTART =.*/DESTPORTSTART = $iport/g" /opt/FDMR-Monitor-B/proxy.cfg
sudo sed -i "s/DESTPORTEND = .*/DESTPORTEND = $generat/g" /opt/FDMR-Monitor-B/proxy.cfg
rm -f /tmp/eport.txt /tmp/iport.txt /tmp/genport.txt
systemctl stop proxy2.service
if ! systemctl status proxy2.service |grep "service; enabled;" >/dev/null 2>&1
then sudo systemctl enable proxy2.service
fi
systemctl start proxy2.service ;;
"2")
systemctl stop proxy2.service
if ! systemctl status proxy2.service |grep "service; enabled;" >/dev/null 2>&1
then sudo systemctl enable proxy2.service
fi
systemctl start proxy2.service ;;
"3")
systemctl disable proxy2.service && systemctl stop proxy2.service ;;
"4")
sudo nano /opt/FDMR-Monitor-B/proxy.cfg &&
if systemctl status proxy2.service |grep "service; enabled;" >/dev/null 2>&1
then sudo systemctl restar proxy2.service
fi ;;
*)
echo "Invalid selection"
;;
esac
;;
9)
bash -c "$(curl -fsSL https://gitlab.com/hp3icc/fdmr/-/raw/main/update-b.sh)" ;;
esac
done
exit 0
EOF
################
sudo chmod +x /bin/menu*
ln -sf /bin/menu-fdmr-b /bin/MENU-FDMR-B
chmod +x /bin/MENU*

View File

@ -189,7 +189,7 @@ case $choix in
exitstatus=$? exitstatus=$?
if [ $exitstatus != 0 ]; then if [ $exitstatus != 0 ]; then
echo "You chose cancel. Exiting..." echo "You chose cancel. Exiting..."
exit 1 # Salir del script con un código de error exit 1 # Salir del script con un código de error
fi fi
p25id=$(cat /tmp/p25id.txt) p25id=$(cat /tmp/p25id.txt)
network=$(whiptail --title "Easy setup P25Bridge" --menu "Select a network:" 10 60 2 \ network=$(whiptail --title "Easy setup P25Bridge" --menu "Select a network:" 10 60 2 \