mirror of https://gitlab.com/hp3icc/emq-TE1.git
317 lines
11 KiB
Bash
317 lines
11 KiB
Bash
#!/bin/bash
|
|
if [ -f "/opt/wdp6" ]
|
|
then
|
|
echo "found file"
|
|
else
|
|
sudo cat > /opt/wdp6 <<- "EOFX"
|
|
##############################################
|
|
# Select number port, P25Reflector Dashboard #
|
|
##############################################
|
|
|
|
Web-Dashboar-Port: 80
|
|
|
|
EOFX
|
|
fi
|
|
sudo cat > /bin/menu-p25r <<- "EOF"
|
|
#!/bin/bash
|
|
while : ; do
|
|
choix=$(whiptail --title "Raspbian Proyect HP3ICC Menu P25Reflector" --menu "Suba o Baje con las flechas del teclado y seleccione el numero de opcion" 20 50 12 \
|
|
1 " Editar P25FReflector Server " \
|
|
2 " Iniciar Reflector " \
|
|
3 " Detener Reflector " \
|
|
4 " Dashboard on " \
|
|
5 " Dashboard off " \
|
|
6 " Editar Puerto http " \
|
|
7 " enable setup.php " \
|
|
8 " remove setup.php " \
|
|
9 " UPDATE Host & DMRId " \
|
|
10 " P25Bbridge <> XLX/DMR " \
|
|
11 " Menu Principal " 3>&1 1>&2 2>&3)
|
|
exitstatus=$?
|
|
|
|
if [ $exitstatus = 0 ]; then
|
|
echo "Your chosen option:" $choix
|
|
else
|
|
echo "You chose cancel."
|
|
break
|
|
fi
|
|
|
|
case $choix in
|
|
1)
|
|
sudo nano /etc/P25Reflector.ini ;;
|
|
2)
|
|
sudo systemctl stop P25Reflector.service &&
|
|
if ! sudo systemctl status P25Reflector.service |grep "service; enabled;" >/dev/null 2>&1
|
|
then
|
|
sudo systemctl enable P25Reflector.service
|
|
fi
|
|
if systemctl status P25Reflector.service |grep "Active: active" >/dev/null 2>&1
|
|
then sudo systemctl restart P25Reflector.service
|
|
else
|
|
sudo systemctl start P25Reflector.service
|
|
fi ;;
|
|
3)
|
|
sudo systemctl stop P25Reflector.service && sudo systemctl disable P25Reflector.service ;;
|
|
4)
|
|
if sudo systemctl status http.server-p25.service |grep "service; enabled;" >/dev/null 2>&1
|
|
then
|
|
sudo systemctl disable http.server-p25.service
|
|
fi
|
|
if sudo systemctl status http.server-p25.service |grep active >/dev/null 2>&1
|
|
then
|
|
sudo systemctl stop http.server-p25.service
|
|
fi
|
|
variable80=$(grep "Web-Dashboar-Port:" /opt/wdp6 | 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\/p25/g" /lib/systemd/system/http.server-p25.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-p25.service |grep "service; enabled;" >/dev/null 2>&1
|
|
then
|
|
sudo systemctl enable http.server-p25.service
|
|
fi
|
|
sudo systemctl start http.server-p25.service
|
|
fi ;;
|
|
5)
|
|
sudo systemctl stop http.server-p25.service && sudo systemctl disable http.server-p25.service ;;
|
|
6)
|
|
if sudo systemctl status http.server-p25.service |grep active >/dev/null 2>&1
|
|
then
|
|
sudo systemctl stop http.server-p25.service
|
|
fi
|
|
sudo nano /opt/wdp6 &&
|
|
variable80=$(grep "Web-Dashboar-Port:" /opt/wdp6 | 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\/p25/g" /lib/systemd/system/http.server-p25.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-p25.service |grep "service; enabled;" >/dev/null 2>&1
|
|
then
|
|
sudo systemctl start http.server-p25.service
|
|
fi
|
|
fi ;;
|
|
7)
|
|
cp /opt/P25Reflector-Dashboard/setup.php /var/www/p25/setup.php &&
|
|
whiptail --title "P25Reflector" --msgbox "setup.php is ready to use, refresh your browser / Setup.php esta lista para usar, actualiza tu navegador" 0 50 ;;
|
|
8)
|
|
if [ -f "/var/www/p25/setup.php" ]
|
|
then
|
|
rm /var/www/p25/setup.php
|
|
whiptail --title "P25Reflector" --msgbox "setup.php has removed / setup.php a sido removido" 0 50
|
|
else
|
|
whiptail --title "P25Reflector" --msgbox "setup.php is not enabled / setup.php no esta habilitado" 0 50
|
|
fi ;;
|
|
9)
|
|
clear
|
|
echo "Update Host files - please wait"
|
|
sudo /usr/local/sbin/DVSM_Update.sh
|
|
|
|
# Lista de servicios a reiniciar
|
|
servicios=("P25Reflector.service" "md380-emuP25b.service" "analog_bridge1.service" "analog_bridge2.service" "mmdvm_bridgeP25b.service" "p25gatewayP25b.service")
|
|
|
|
# Recorre la lista de servicios y verifica si están activos
|
|
for servicio in "${servicios[@]}"; do
|
|
if systemctl status "$servicio" | grep "Active: active" >/dev/null 2>&1; then
|
|
echo "Reiniciando el servicio $servicio"
|
|
sudo systemctl restart "$servicio"
|
|
fi
|
|
done
|
|
;;
|
|
10)
|
|
menu-p25b
|
|
;;
|
|
11)
|
|
break
|
|
;;
|
|
esac
|
|
done
|
|
exit 0
|
|
EOF
|
|
#############################################################
|
|
sudo cat > /bin/menu-p25b <<- "EOF"
|
|
#!/bin/bash
|
|
while : ; do
|
|
choix=$(whiptail --title "Raspbian Proyect HP3ICC Menu P25Bridge" --menu "Suba o Baje con las flechas del teclado y seleccione el numero de opcion" 20 50 11 \
|
|
1 " Easy setup P25Bridge " \
|
|
2 " Iniciar Bridge " \
|
|
3 " Detener Bridge " \
|
|
4 " Config P25Host " \
|
|
5 " Config P25Gateway.ini " \
|
|
6 " Config MMDVM_bridge.ini " \
|
|
7 " Menu Principal " 3>&1 1>&2 2>&3)
|
|
exitstatus=$?
|
|
|
|
if [ $exitstatus = 0 ]; then
|
|
echo "Your chosen option:" $choix
|
|
else
|
|
echo "You chose cancel."
|
|
break
|
|
fi
|
|
|
|
case $choix in
|
|
1)
|
|
mcall=""
|
|
mid=""
|
|
midg=""
|
|
p25id""
|
|
sbridge""
|
|
txtg""
|
|
sport""
|
|
spass""
|
|
sopti""
|
|
whiptail --title "Easy setup P25Bridge" --inputbox "Calsign:" 10 60 2>/tmp/mcall.txt
|
|
mcall=$(cat /tmp/mcall.txt)
|
|
mcall=$(echo "$mcall" | tr '[:lower:]' '[:upper:]')
|
|
whiptail --title "Easy setup P25Bridge" --inputbox "DMRId:" 10 60 2>/tmp/mid.txt
|
|
mid=$(cat /tmp/mid.txt)
|
|
whiptail --title "Easy setup P25Bridge" --inputbox "P25 Number ID Reflector:" 10 60 2>/tmp/p25id.txt
|
|
p25id=$(cat /tmp/p25id.txt)
|
|
network=$(whiptail --title "Easy setup P25Bridge" --menu "Select a network:" 10 60 2 \
|
|
"1" "Connect to DMR Network" \
|
|
"2" "Connect to XLX Network" 3>&1 1>&2 2>&3)
|
|
|
|
case "$network" in
|
|
"1")
|
|
whiptail --title "Easy setup P25Bridge" --inputbox "DMR Device id 01-99:" 10 60 2>/tmp/midg.txt
|
|
midg=$(cat /tmp/midg.txt)
|
|
|
|
whiptail --title "Easy setup P25Bridge" --inputbox "IP or dns server DMR:" 10 60 2>/tmp/sbridge.txt
|
|
sbridge=$(cat /tmp/sbridge.txt)
|
|
whiptail --title "Easy setup P25Bridge" --inputbox "Port server DMR:" 10 60 2>/tmp/sport.txt
|
|
sport=$(cat /tmp/sport.txt)
|
|
whiptail --title "Easy setup P25Bridge" --inputbox "Password server DMR:" 10 60 2>/tmp/spass.txt
|
|
spass=$(cat /tmp/spass.txt)
|
|
whiptail --title "Easy setup P25Bridge" --inputbox "TalkGroup / tg sample: 91" 10 60 2>/tmp/txtg.txt
|
|
txtg=$(cat /tmp/txtg.txt)
|
|
whiptail --title "Easy setup P25Bridge" --inputbox "Line Options / sample: TS2=91; " 10 60 2>/tmp/sopti.txt
|
|
sopti=$(cat /tmp/sopti.txt)
|
|
|
|
# Modify the MMDVM_Bridge.ini file for DMR
|
|
sudo sed -i "3s/Id=.*/Id=${mid}${midg}/" /opt/p25bridge/MMDVM_Bridge.ini
|
|
;;
|
|
"2")
|
|
whiptail --title "Easy setup P25Bridge" --inputbox "IP or dns server XLXD:" 10 60 2>/tmp/sbridge.txt
|
|
sbridge=$(cat /tmp/sbridge.txt)
|
|
whiptail --title "Easy setup P25Bridge" --inputbox "Port server XLXD:" 10 60 2>/tmp/sport.txt
|
|
sport=$(cat /tmp/sport.txt)
|
|
whiptail --title "Easy setup P25Bridge" --inputbox "Password server XLXD:" 10 60 2>/tmp/spass.txt
|
|
spass=$(cat /tmp/spass.txt)
|
|
whiptail --title "Easy setup P25Bridge" --inputbox "TalkGroup / tg sample: 91" 10 60 2>/tmp/txtg.txt
|
|
txtg=$(cat /tmp/txtg.txt)
|
|
whiptail --title "Easy setup P25Bridge" --inputbox "Line Options / sample: XLX:4001 " 10 60 2>/tmp/sopti.txt
|
|
sopti=$(cat /tmp/sopti.txt)
|
|
# Modify the MMDVM_Bridge.ini file for XLX
|
|
sudo sed -i "3s/Id=.*/Id=${mid}/" /opt/p25bridge/MMDVM_Bridge.ini
|
|
;;
|
|
*)
|
|
echo "Invalid selection"
|
|
;;
|
|
esac
|
|
|
|
sudo sed -i "13s/gatewayDmrId =.*/gatewayDmrId = ${mid}25/g" /opt/p25bridge/Analog_Bridge_DMR.ini
|
|
sudo sed -i "14s/repeaterID =.*/repeaterID = ${mid}26/g" /opt/p25bridge/Analog_Bridge_DMR.ini
|
|
sudo sed -i "15s/txTg =.*/txTg = ${txtg}/g" /opt/p25bridge/Analog_Bridge_DMR.ini
|
|
|
|
sudo sed -i "13s/gatewayDmrId =.*/gatewayDmrId = ${mid}25/g" /opt/p25bridge/Analog_Bridge_P25.ini
|
|
sudo sed -i "14s/repeaterID =.*/repeaterID = ${mid}26/g" /opt/p25bridge/Analog_Bridge_P25.ini
|
|
sudo sed -i "15s/txTg =.*/txTg = ${txtg}/g" /opt/p25bridge/Analog_Bridge_P25.ini
|
|
|
|
sudo sed -i "2s/Callsign=.*/Callsign=$mcall/g" /opt/p25bridge/MMDVM_Bridge.ini
|
|
#sudo sed -i "3s/Id=.*/Id=$mid$midg/" /opt/p25bridge/MMDVM_Bridge.ini
|
|
sudo sed -i "70s/Address=.*/Address=$sbridge/" /opt/p25bridge/MMDVM_Bridge.ini
|
|
sudo sed -i "71s/Port=.*/Port=$sport/" /opt/p25bridge/MMDVM_Bridge.ini
|
|
sudo sed -i "74s/Password=.*/Password=$spass/" /opt/p25bridge/MMDVM_Bridge.ini
|
|
sudo sed -i "77s/Options=.*/Options=$sopti/" /opt/p25bridge/MMDVM_Bridge.ini
|
|
|
|
sudo sed -i "2s/Callsign=.*/Callsign=$mcall/g" /opt/p25bridge/P25Gateway.ini
|
|
sudo sed -i "37s/Static=.*/Static=$p25id/g" /opt/p25bridge/P25Gateway.ini
|
|
sudo sed -i "38s/Startup=.*/Startup=$p25id/g" /opt/p25bridge/P25Gateway.ini
|
|
|
|
input_file="/var/lib/mmdvm/P25Hosts.txt"
|
|
output_file="/opt/P25Hosts2.txt"
|
|
grep -w "^$p25id" "$input_file" > "$output_file"
|
|
|
|
rm -f /tmp/mcall.txt /tmp/mid.txt /tmp/p25id.txt /tmp/sbridge.txt /tmp/sport.txt /tmp/sopti.txt /tmp/midg.txt /tmp/spass.txt
|
|
|
|
#!/bin/bash
|
|
|
|
# Lista de servicios a reiniciar
|
|
servicios=("md380-emuP25b.service" "analog_bridge1.service" "analog_bridge2.service" "mmdvm_bridgeP25b.service" "p25gatewayP25b.service")
|
|
|
|
# Recorre la lista de servicios y verifica si están activos
|
|
for servicio in "${servicios[@]}"; do
|
|
if systemctl status "$servicio" | grep "service; enabled;" >/dev/null 2>&1; then
|
|
echo "restart $servicio"
|
|
sudo systemctl restart "$servicio"
|
|
else
|
|
echo "start $servicio"
|
|
sudo systemctl restart "$servicio"
|
|
sudo systemctl enable "$servicio"
|
|
fi
|
|
done
|
|
whiptail --title "Easy setup P25Bridge" --msgbox "Configuracion finalizada" 0 50
|
|
|
|
;;
|
|
2)
|
|
#!/bin/bash
|
|
|
|
# Lista de servicios a reiniciar
|
|
servicios=("md380-emuP25b.service" "analog_bridge1.service" "analog_bridge2.service" "mmdvm_bridgeP25b.service" "p25gatewayP25b.service")
|
|
|
|
# Recorre la lista de servicios y verifica si están activos
|
|
for servicio in "${servicios[@]}"; do
|
|
if systemctl status "$servicio" | grep "service; enabled;" >/dev/null 2>&1; then
|
|
echo "restart $servicio"
|
|
sudo systemctl restart "$servicio"
|
|
else
|
|
echo "start $servicio"
|
|
sudo systemctl restart "$servicio"
|
|
sudo systemctl enable "$servicio"
|
|
fi
|
|
done
|
|
;;
|
|
3)
|
|
#!/bin/bash
|
|
|
|
# Lista de servicios a reiniciar
|
|
servicios=("md380-emuP25b.service" "analog_bridge1.service" "analog_bridge2.service" "mmdvm_bridgeP25b.service" "p25gatewayP25b.service")
|
|
|
|
# Recorre la lista de servicios y verifica si están activos
|
|
for servicio in "${servicios[@]}"; do
|
|
if systemctl status "$servicio" | grep "service; enabled;" >/dev/null 2>&1; then
|
|
echo "stop $servicio"
|
|
sudo systemctl disable "$servicio"
|
|
sudo systemctl stop "$servicio"
|
|
fi
|
|
done
|
|
;;
|
|
4)
|
|
sudo nano /opt/P25Hosts2.txt ;;
|
|
5)
|
|
sudo nano /opt/p25bridge/P25Gateway.ini ;;
|
|
6)
|
|
sudo nano /opt/p25bridge/MMDVM_Bridge.ini ;;
|
|
7)
|
|
break
|
|
;;
|
|
esac
|
|
done
|
|
exit 0
|
|
EOF
|
|
#########
|
|
sudo chmod +x /bin/menu-p25r
|
|
sudo chmod +x /bin/menu-p25b
|
|
ln -sf /bin/menu-p25r /bin/MENU-P25R
|
|
ln -sf /bin/menu-p25b /bin/MENU-P25B
|
|
sudo chmod +x /bin/MENU*
|