emq-TE1/menu/menu-asl

485 lines
17 KiB
Bash

#!/bin/bash
cat > /bin/menu-asl <<- "EOF"
#!/bin/bash
if [[ $EUID -ne 0 ]]; then
whiptail --title "root" --msgbox "Cambie a usuario root / Change to user root" 0 50
exit 0
fi
if ! [ -d "/etc/asterisk" ]; then
whiptail --title "Easy-ASL" --msgbox "AllStarLink not Found / AllStarLink no instalado" 0 50
exit 0
fi
while : ; do
choix=$(whiptail --title "Raspbian Proyect HP3ICC Menu AllStarLink" --menu "Suba o Baje con las flechas del teclado y seleccione el numero de opcion" 15 50 5 \
1 " Easy ASL-Config Echolink " \
2 " Easy ASL-Bridge-DMR " \
3 " asl-menu " \
4 " 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)
menu-asle
;;
2)
menu-aslb
;;
4)
asl-menu
;;
9)
break
;;
esac
done
exit 0
EOF
cat > /bin/menu-asle <<- "EOF"
#!/bin/bash
if [[ $EUID -ne 0 ]]; then
whiptail --title "root" --msgbox "Cambie a usuario root / Change to user root" 0 50
exit 0
fi
if ! [ -d "/etc/asterisk" ]; then
whiptail --title "Easy-ASL" --msgbox "AllStarLink not Found / AllStarLink no instalado" 0 50
exit 0
fi
while : ; do
choix=$(whiptail --title "Raspbian Proyect HP3ICC Menu ASL-Config Echolink" --menu "Suba o Baje con las flechas del teclado y seleccione el numero de opcion" 20 55 10 \
1 " Easy Setup ASL-Config Echolink " \
2 " Iniciar AllStarLink " \
3 " Detener AllStarLink " \
4 " Edit echolink.conf " \
5 " Edit rpt.conf " \
6 " Edit iax.conf " \
7 " Edit manager.conf " \
8 " Restore defauld ASL-Config Echolink " \
9 " 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)
whiptail --title "Easy setup AllStarLink" --inputbox "Echolink Calsign:" 10 60 2>/tmp/echoc.txt
exitstatus=$?
if [ $exitstatus != 0 ]; then
echo "You chose cancel. Exiting..."
exit 1 # Salir del script con un código de error
fi
echoc=$(cat /tmp/echoc.txt)
echoc=$(echo "$echoc" | tr '[:lower:]' '[:upper:]')
whiptail --title "Easy setup AllStarLink" --inputbox "Echolink Password:" 10 60 2>/tmp/echop.txt
exitstatus=$?
if [ $exitstatus != 0 ]; then
echo "You chose cancel. Exiting..."
exit 1 # Salir del script con un código de error
fi
echop=$(cat /tmp/echop.txt)
whiptail --title "Easy setup AllStarLink" --inputbox "Echolink Name:" 10 60 2>/tmp/echon.txt
exitstatus=$?
if [ $exitstatus != 0 ]; then
echo "You chose cancel. Exiting..."
exit 1 # Salir del script con un código de error
fi
echon=$(cat /tmp/echon.txt)
whiptail --title "Easy setup AllStarLink" --inputbox "Echolink Qth:" 10 60 2>/tmp/echoq.txt
exitstatus=$?
if [ $exitstatus != 0 ]; then
echo "You chose cancel. Exiting..."
exit 1 # Salir del script con un código de error
fi
echoq=$(cat /tmp/echoq.txt)
whiptail --title "Easy setup AllStarLink" --inputbox "Echolink email:" 10 60 2>/tmp/echoe.txt
exitstatus=$?
if [ $exitstatus != 0 ]; then
echo "You chose cancel. Exiting..."
exit 1 # Salir del script con un código de error
fi
echoe=$(cat /tmp/echoe.txt)
whiptail --title "Easy setup AllStarLink" --inputbox "Echolink Node Number:" 10 60 2>/tmp/echox.txt
exitstatus=$?
if [ $exitstatus != 0 ]; then
echo "You chose cancel. Exiting..."
exit 1 # Salir del script con un código de error
fi
echox=$(cat /tmp/echox.txt)
whiptail --title "Easy setup AllStarLink" --inputbox "Allstartlink Node Number:" 10 60 2>/tmp/asln.txt
exitstatus=$?
if [ $exitstatus != 0 ]; then
echo "You chose cancel. Exiting..."
exit 1 # Salir del script con un código de error
fi
asln=$(cat /tmp/asln.txt)
whiptail --title "Easy setup AllStarLink" --inputbox "Allstartlink Node Password:" 10 60 2>/tmp/aslk.txt
exitstatus=$?
if [ $exitstatus != 0 ]; then
echo "You chose cancel. Exiting..."
exit 1 # Salir del script con un código de error
fi
aslk=$(cat /tmp/aslk.txt)
whiptail --title "Easy setup AllStarLink" --inputbox "AllMon web manage Password:" 10 60 2>/tmp/asld.txt
exitstatus=$?
if [ $exitstatus != 0 ]; then
echo "You chose cancel. Exiting..."
exit 1 # Salir del script con un código de error
fi
asld=$(cat /tmp/asld.txt)
if [ -f "/lib/systemd/system/asterisk.service" ]; then
systemctl stop asterisk
systemctl disable asterisk
fi
if [ -f "/lib/systemd/system/asl-asterisk.service" ]; then
systemctl stop asl-asterisk
systemctl disable asl-asterisk
fi
rm /etc/asterisk/* -r > output.log 2>&1
wget --load-cookies /tmp/cookies.txt "https://docs.google.com/uc?export=download&confirm=$(wget --quiet --save-cookies /tmp/cookies.txt --keep-session-cookies --no-check-certificate 'https://docs.google.com/uc?export=download&id=1qBsyd47X_lLc4nOOXLwmb9ojJi0YrqgF' -O- | sed -rn 's/.*confirm=([0-9A-Za-z_]+).*/\1\n/p')&id=1qBsyd47X_lLc4nOOXLwmb9ojJi0YrqgF" -O /etc/asterisk/asl-wizard.zip && rm -rf /tmp/cookies.txt &&
unzip /etc/asterisk/asl-wizard.zip -d /etc/asterisk/
cat > /var/www/html/allmon2/allmon.ini.php <<- "EOFX"
<?php
[Off-site Link]
url=http://allstarlink.org
[a5a4a3a2a1]
host=127.0.0.1:5038
user=admin
passwd=a2b2c2d2e2
nomenu=no
hideNodeURL=no
?>
EOFX
#allstar
sed -i "s/secret =.*/secret = $asld/g" /etc/asterisk/manager.conf
find /etc/asterisk/ -type f -exec sed -i "s/a5a4a3a2a1/$asln/g" {} + #node allstarlink
find /etc/asterisk/ -type f -exec sed -i "s/a1b1c1d1e1/$aslk/g" {} + #key allstarlink
find /etc/asterisk/ -type f -exec sed -i "s/a2b2c2d2e2/$asld/g" {} + #allstar dashboard key
find /etc/asterisk/ -type f -exec sed -i "s/a3b3c3d3e3/$echoc/g" {} + #callsign
# Crear archivos temporales
touch "/etc/asterisk/simpleusb_tune_usb_${asln}.conf"
touch "/etc/asterisk/usbradio_tune_usb_${asln}.conf"
#
# Configuración de Echolink
#sed -i "s/call =.*/call = $echoc/g" /etc/asterisk/echolink.conf
sed -i "s/pwd =.*/pwd = $echop/g" /etc/asterisk/echolink.conf
sed -i "s/name =.*/name = $echon/g" /etc/asterisk/echolink.conf
sed -i "s/qth =.*/qth = $echoq/g" /etc/asterisk/echolink.conf
sed -i "s/email =.*/email = $echoe/g" /etc/asterisk/echolink.conf
sed -i "s/node =.*/node = $echox/g" /etc/asterisk/echolink.conf
sed -i "s/astnode =.*/astnode = $asln/g" /etc/asterisk/echolink.conf
#
if [ -d "/var/www/html/allmon2" ]; then
sed -i "s/a5a4a3a2a1/$asln/g" /var/www/html/allmon2/allmon.ini.php
sed -i "s/a2b2c2d2e2/$asld/g" /var/www/html/allmon2/allmon.ini.php
fi
#
if [ -f "/lib/systemd/system/asterisk.service" ]; then
systemctl stop asterisk &&
systemctl start asterisk
systemctl enable asterisk
fi
if [ -f "/lib/systemd/system/asl-asterisk.service" ]; then
systemctl stop asl-asterisk &&
systemctl start asl-asterisk
systemctl enable asl-asterisk
fi
;;
2)
if [ -f "/lib/systemd/system/asterisk.service" ]; then
systemctl stop asterisk &&
systemctl start asterisk
systemctl enable asterisk
fi
if [ -f "/lib/systemd/system/asl-asterisk.service" ]; then
systemctl stop asl-asterisk &&
systemctl start asl-asterisk
systemctl enable asl-asterisk
fi
;;
3)
if [ -f "/lib/systemd/system/asterisk.service" ]; then
systemctl stop asterisk
systemctl disable asterisk
fi
if [ -f "/lib/systemd/system/asl-asterisk.service" ]; then
systemctl stop asl-asterisk
systemctl disable asl-asterisk
fi
;;
4)
nano /etc/asterisk/echolink.conf
;;
5)
nano /etc/asterisk/rpt.conf
;;
6)
nano /etc/asterisk/iax.conf
;;
7)
nano /etc/asterisk/manager.conf
;;
8)
if [ -f "/lib/systemd/system/asterisk.service" ]; then
systemctl stop asterisk
systemctl disable asterisk
fi
if [ -f "/lib/systemd/system/asl-asterisk.service" ]; then
systemctl stop asl-asterisk
systemctl disable asl-asterisk
fi
rm /etc/asterisk/* -r > output.log 2>&1
wget --load-cookies /tmp/cookies.txt "https://docs.google.com/uc?export=download&confirm=$(wget --quiet --save-cookies /tmp/cookies.txt --keep-session-cookies --no-check-certificate 'https://docs.google.com/uc?export=download&id=1qBsyd47X_lLc4nOOXLwmb9ojJi0YrqgF' -O- | sed -rn 's/.*confirm=([0-9A-Za-z_]+).*/\1\n/p')&id=1qBsyd47X_lLc4nOOXLwmb9ojJi0YrqgF" -O /etc/asterisk/asl-wizard.zip && rm -rf /tmp/cookies.txt &&
unzip /etc/asterisk/asl-wizard.zip -d /etc/asterisk/
if [ -d "/var/www/html/allmon2" ]; then
cat > /var/www/html/allmon2/allmon.ini.php <<- "EOFX"
<?php
[Off-site Link]
url=http://allstarlink.org
[a5a4a3a2a1]
host=127.0.0.1:5038
user=admin
passwd=a2b2c2d2e2
nomenu=no
hideNodeURL=no
?>
EOFX
fi
;;
9)
break
;;
esac
done
exit 0
EOF
#############################################################
cat > /bin/menu-aslb <<- "EOF"
#!/bin/bash
if [[ $EUID -ne 0 ]]; then
whiptail --title "root" --msgbox "Cambie a usuario root / Change to user root" 0 50
exit 0
fi
if ! [ -d "/etc/asterisk" ]; then
whiptail --title "Easy-ASL" --msgbox "AllStarLink not Found / AllStarLink no instalado" 0 50
exit 0
fi
while : ; do
choix=$(whiptail --title "Raspbian Proyect HP3ICC Menu ASL-Bridge-DMR" --menu "Suba o Baje con las flechas del teclado y seleccione el numero de opcion" 20 50 11 \
1 " Easy setup ASLBridge DMR" \
2 " Iniciar Bridge " \
3 " Detener Bridge " \
4 " Config MMDVM_bridge.ini " \
5 " Restore Defauld " \
6 " 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)
# Lista de servicios a reiniciar
servicios=("mmdvm_bridge99.service" "analog_bridge99.service" "md380-emu99.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"
systemctl disable "$servicio"
systemctl stop "$servicio"
fi
done
mcall=""
mid=""
did=""
midg=""
sbridge=""
txtg=""
sport=""
spass=""
sopti=""
whiptail --title "Easy setup ASL-Bridge-DMR" --inputbox "Calsign:" 10 60 2>/tmp/mcall.txt
exitstatus=$?
if [ $exitstatus != 0 ]; then
echo "You chose cancel. Exiting..."
exit 1 # Salir del script con un código de error
fi
mcall=$(cat /tmp/mcall.txt)
mcall=$(echo "$mcall" | tr '[:lower:]' '[:upper:]')
whiptail --title "Easy setup ASL-Bridge-DMR" --inputbox "DMRId:" 10 60 2>/tmp/mid.txt
exitstatus=$?
if [ $exitstatus != 0 ]; then
echo "You chose cancel. Exiting..."
exit 1 # Salir del script con un código de error
fi
mid=$(cat /tmp/mid.txt)
whiptail --title "Easy setup ASL-Bridge-DMR" --inputbox "Device ID: 01-99" 10 60 2>/tmp/did.txt
exitstatus=$?
if [ $exitstatus != 0 ]; then
echo "You chose cancel. Exiting..."
exit 1 # Salir del script con un código de error
fi
did=$(cat /tmp/did.txt)
whiptail --title "Easy setup ASL-Bridge-DMR" --inputbox "IP or dns server DMR:" 10 60 2>/tmp/sbridge=.txt
exitstatus=$?
if [ $exitstatus != 0 ]; then
echo "You chose cancel. Exiting..."
exit 1 # Salir del script con un código de error
fi
sbridge=$(cat /tmp/sbridge=.txt)
whiptail --title "Easy set=up ASL-Bridge-DMR" --inputbox "Port server DMR:" 10 60 2>/tmp/sport.txt
exitstatus=$?
if [ $exitstatus != 0 ]; then
echo "You chose cancel. Exiting..."
exit 1 # Salir del script con un código de error
fi
sport=$(cat /tmp/sport.txt)
whiptail --title "Easy setup ASL-Bridge-DMR" --inputbox "Password server DMR:" 10 60 2>/tmp/spass.txt
exitstatus=$?
if [ $exitstatus != 0 ]; then
echo "You chose cancel. Exiting..."
exit 1 # Salir del script con un código de error
fi
spass=$(cat /tmp/spass.txt)
whiptail --title "Easy setup ASL-Bridge-DMR" --inputbox "TalkGroup / tg sample: 91" 10 60 2>/tmp/txtg.txt
exitstatus=$?
if [ $exitstatus != 0 ]; then
echo "You chose cancel. Exiting..."
exit 1 # Salir del script con un código de error
fi
txtg=$(cat /tmp/txtg.txt)
whiptail --title "Easy setup ASL-Bridge-DMR" --inputbox "Line Options / sample: TS2=91; " 10 60 2>/tmp/sopti.txt
exitstatus=$?
if [ $exitstatus != 0 ]; then
echo "You chose cancel. Exiting..."
exit 1 # Salir del script con un código de error
fi
sopti=$(cat /tmp/sopti.txt)
# Modify the MMDVM_Bridge.ini file for DMR
sed -i "3s/Id=.*/Id=${mid}${did}/" /opt/user99/MMDVM_Bridge.ini
sed -i "69s/Enable=.*/Enable=1/" /opt/user99/MMDVM_Bridge.ini
sed -i "84s/Enable=.*/Enable=0/" /opt/user99/MMDVM_Bridge.ini
sed -i "44s/Enable=.*/Enable=1/" /opt/user99/MMDVM_Bridge.ini
sed -i "50s/Enable=.*/Enable=0/" /opt/user99/MMDVM_Bridge.ini
sed -i "s/gatewayDmrId =.*/gatewayDmrId = ${mid}/g" /opt/user99/Analog_Bridge.ini
sed -i "s/repeaterID =.*/repeaterID = ${mid}${did}/" /opt/user99/Analog_Bridge.ini
sed -i "s/txTg =.*/txTg = ${txtg}/g" /opt/user99/Analog_Bridge.ini
sed -i "2s/Callsign=.*/Callsign=$mcall/g" /opt/user99/MMDVM_Bridge.ini
sed -i "70s/Address=.*/Address=$sbridge/g" /opt/user99/MMDVM_Bridge.ini
sed -i "71s/Port=.*/Port=$sport/g" /opt/user99/MMDVM_Bridge.ini
sed -i "74s/Password=.*/Password=$spass/g" /opt/user99/MMDVM_Bridge.ini
sed -i "77s/Options=.*/Options=$sopti/g" /opt/user99/MMDVM_Bridge.ini
rm -f /tmp/mcall.txt /tmp/mid.txt /tmp/sbridge.txt /tmp/sport.txt /tmp/sopti.txt /tmp/midg.txt /tmp/spass.txt /tmp/did.txt
# Lista de servicios a reiniciar
servicios=("mmdvm_bridge99.service" "analog_bridge99.service" "md380-emu99.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"
systemctl stop "$servicio"
systemctl start "$servicio"
else
echo "start $servicio"
systemctl stop "$servicio"
systemctl start "$servicio"
systemctl enable "$servicio"
fi
done
whiptail --title "Easy setup ASL-Bridge-DMR" --msgbox "Configuracion finalizada" 0 50
;;
2)
# Lista de servicios a reiniciar
servicios=("mmdvm_bridge99.service" "analog_bridge99.service" "md380-emu99.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"
systemctl stop "$servicio"
systemctl start "$servicio"
else
echo "start $servicio"
systemctl stop "$servicio"
systemctl start "$servicio"
systemctl enable "$servicio"
fi
done
;;
3)
# Lista de servicios a reiniciar
servicios=("mmdvm_bridge99.service" "analog_bridge99.service" "md380-emu99.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"
systemctl disable "$servicio"
systemctl stop "$servicio"
fi
done
;;
4)
nano /opt/user99/MMDVM_Bridge.ini ;;
5)
# Lista de servicios a reiniciar
servicios=("mmdvm_bridge99.service" "analog_bridge99.service" "md380-emu99.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"
systemctl disable "$servicio"
systemctl stop "$servicio"
fi
done
rm /opt/user99/ -r > output.log 2>&1
mkdir /opt/user99/
wget --load-cookies /tmp/cookies.txt "https://docs.google.com/uc?export=download&confirm=$(wget --quiet --save-cookies /tmp/cookies.txt --keep-session-cookies --no-check-certificate 'https://docs.google.com/uc?export=download&id=144oOBmVahtoKggYhYLmGhvH_TgsjhBPi' -O- | sed -rn 's/.*confirm=([0-9A-Za-z_]+).*/\1\n/p')&id=144oOBmVahtoKggYhYLmGhvH_TgsjhBPi" -O /opt/user99/user99.zip && rm -rf /tmp/cookies.txt &&
unzip /opt/user99/user99.zip -d /opt/user99/
cp /opt/Analog_Bridge/Analog_Bridge /opt/user99/Analog_Bridge
cp /opt/MMDVM_Bridge/MMDVM_Bridge /opt/user99/MMDVM_Bridge
cp /opt/md380-emu/md380-emu /opt/user99/md380-emu
chmod +x /opt/user99/*
;;
6)
break
;;
esac
done
exit 0
EOF
#########
chmod +x /bin/menu-asl
chmod +x /bin/menu-aslb
chmod +x /bin/menu-asle
ln -sf /bin/menu-aslb /bin/MENU-ASLB
ln -sf /bin/menu-asle /bin/MENU-ASLE
ln -sf /bin/menu-asl /bin/MENU-ASL
chmod +x /bin/MENU*