#!/bin/bash if ! grep -q "Web-Dashboar-name" "/opt/wdp10" > /dev/null 2>&1; then cat > /opt/wdp10 <<- "EOFX" ######################################### # Select number port, XLXD Dashboard # ######################################### Web-Dashboar-name: XLX Web-Dashboar-Port: 80 Web-Dashboar-dns: Web-Dashboar-dir: /opt/xlxd/dashboard XLX-DASH: XLX-XRFNUM: XLX-CONTRIE: XLX-DESCRIPTION: XLX-NMODU: XLX-YSFMODU: XLX-YSFPOR: XLX-AMBIP: XLX-AMBPOR: XLX-EMAIL: XLX-CALLSIGN: EOFX fi cat > /bin/menu-xlx <<- "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 while : ; do choix=$(whiptail --title "Raspbian Proyect HP3ICC Menu Easy-XLX" --menu "Suba o Baje con las flechas del teclado y seleccione el numero de opcion" 15 50 6 \ 1 " Easy Config XLX " \ 2 " Start & Restart XLX Reflector " \ 3 " Stop XLX Reflector " \ 4 " Select or Change Dashboard " \ 5 " 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) wdp=/opt/wdp10 if [ ! -d "/opt/xlx-bk" ]; then mkdir /opt/xlx-bk fi source_folder="/xlxd" backup_folder="/opt/xlx-bk" # Lista de archivos para realizar backup files_to_backup=( "xlxd.terminal" "xlxd.interlink" "xlxd.whitelist" ) # Verifica si la carpeta /xlxd/ no está vacía if [ "$(ls -A $source_folder)" ]; then # La carpeta no está vacía, realiza la copia de archivos for file in "${files_to_backup[@]}"; do if [ -e "$source_folder/$file" ]; then cp "$source_folder/$file" "$backup_folder/$file" echo "Copia de $file realizada con éxito." else echo "El archivo $file no existe en la carpeta $source_folder." fi done else # La carpeta está vacía echo "La carpeta $source_folder está vacía. No se realizará la copia." fi if [ -f "/tmp/w0dn0.txt" ]; then rm /tmp/w0dn0.txt fi if [ -f "/tmp/wd0p.txt" ]; then rm /tmp/wd0p.txt fi wsn0=$(grep "Web-Dashboar-name:" $wdp | grep -oP 'Web-Dashboar-name:\s*\K.*') if [ -f "/etc/nginx/sites-enabled/$wsn0" ]; then rm /etc/nginx/sites-enabled/$wsn0 fi if [ -f "/etc/nginx/sites-enabled/000" ]; then rm /etc/nginx/sites-enabled/000 fi sudo systemctl restart nginx whiptail --title "Easy Setup XLXD" --inputbox "XLX uses 3 digit numbers :" 10 60 2>/tmp/XRFNUM.txt exitstatus=$? if [ $exitstatus != 0 ]; then echo "You chose cancel. Exiting..." exit 1 # Salir del script con un código de error fi XRFNUM=XLX$(cat /tmp/XRFNUM.txt) XRFNUM=$(echo "$XRFNUM" | tr '[:lower:]' '[:upper:]') network=$(whiptail --title "Easy setup XLXD" --menu "Select Dashboard:" 10 60 2 \ "1" "XLX Dashboard 1 Clasic" \ "2" "XLX Dashboard 2 Dark" 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") sed -i "s|Web-Dashboar-dir:.*|Web-Dashboar-dir: /opt/xlxd/dashboard|g" $wdp ;; "2") sed -i "s|Web-Dashboar-dir:.*|Web-Dashboar-dir: /opt/xlxd/dashboard2|g" $wdp ;; *) echo "Invalid selection" ;; esac whiptail --title "Easy setup XLXD" --inputbox "Select HTTP port:" 10 60 2>/tmp/wd0p.txt exitstatus=$? if [ $exitstatus != 0 ]; then echo "You chose cancel. Exiting..." exit 1 # Salir del script con un código de error fi wd0p=$(cat /tmp/wd0p.txt) whiptail --title "Easy Setup XLXD" --inputbox "DNS Dashboard :" 10 60 2>/tmp/XLXDOMAIN.txt exitstatus=$? if [ $exitstatus != 0 ]; then echo "You chose cancel. Exiting..." exit 1 # Salir del script con un código de error fi XLXDOMAIN=$(cat /tmp/XLXDOMAIN.txt) DASH=$XLXDOMAIN if [[ ! "$XLXDOMAIN" =~ [a-zA-Z] ]]; then DASH=$(curl -s https://ifconfig.me) fi w0dn0=$XLXDOMAIN if [[ ! "$XLXDOMAIN" =~ [a-zA-Z] ]]; then w0dn0="" fi whiptail --title "Easy setup XLXD" --inputbox "What contrie your server? :" 10 60 2>/tmp/CONTRIE.txt exitstatus=$? if [ $exitstatus != 0 ]; then echo "You chose cancel. Exiting..." exit 1 # Salir del script con un código de error fi CONTRIE=$(cat /tmp/CONTRIE.txt) whiptail --title "Easy setup XLXD" --inputbox "description your server? :" 10 60 2>/tmp/DESCRIPTION.txt exitstatus=$? if [ $exitstatus != 0 ]; then echo "You chose cancel. Exiting..." exit 1 # Salir del script con un código de error fi DESCRIPTION=$(cat /tmp/DESCRIPTION.txt) whiptail --title "Easy setup XLXD" --inputbox "Enabled modules. sample 10 :" 10 60 2>/tmp/NMODU.txt exitstatus=$? if [ $exitstatus != 0 ]; then echo "You chose cancel. Exiting..." exit 1 # Salir del script con un código de error fi NMODU=$(cat /tmp/NMODU.txt) whiptail --title "Easy setup XLXD" --inputbox "Defauld YSF module. sample B :" 10 60 2>/tmp/YSFMODU.txt exitstatus=$? if [ $exitstatus != 0 ]; then echo "You chose cancel. Exiting..." exit 1 # Salir del script con un código de error fi YSFMODU=$(cat /tmp/YSFMODU.txt) YSFMODU=$(echo "$YSFMODU" | tr '[:lower:]' '[:upper:]') whiptail --title "Easy setup XLXD" --inputbox "ysf port sample defauld 42000 :" 10 60 2>/tmp/YSFPOR.txt exitstatus=$? if [ $exitstatus != 0 ]; then echo "You chose cancel. Exiting..." exit 1 # Salir del script con un código de error fi YSFPOR=$(cat /tmp/YSFPOR.txt) whiptail --title "Easy setup XLXD" --inputbox "ambe server addres sample defauld 127.0.0.1 :" 10 60 2>/tmp/AMBIP.txt exitstatus=$? if [ $exitstatus != 0 ]; then echo "You chose cancel. Exiting..." exit 1 # Salir del script con un código de error fi AMBIP=$(cat /tmp/AMBIP.txt) whiptail --title "Easy setup XLXD" --inputbox "ambe server port sample defauld 10100 :" 10 60 2>/tmp/AMBPOR.txt exitstatus=$? if [ $exitstatus != 0 ]; then echo "You chose cancel. Exiting..." exit 1 # Salir del script con un código de error fi AMBPOR=$(cat /tmp/AMBPOR.txt) whiptail --title "Easy setup XLXD" --inputbox "What E-Mail address can your users send questions to? :" 10 60 2>/tmp/EMAIL.txt exitstatus=$? if [ $exitstatus != 0 ]; then echo "You chose cancel. Exiting..." exit 1 # Salir del script con un código de error fi EMAIL=$(cat /tmp/EMAIL.txt) whiptail --title "Easy setup XLXD" --inputbox "What is the admins callsign? :" 10 60 2>/tmp/CALLSIGN.txt exitstatus=$? if [ $exitstatus != 0 ]; then echo "You chose cancel. Exiting..." exit 1 # Salir del script con un código de error fi CALLSIGN=$(cat /tmp/CALLSIGN.txt) CALLSIGN=$(echo "$CALLSIGN" | tr '[:lower:]' '[:upper:]') ################################################## if [ -z "$CONTRIE" ] then CONTRIE=USA fi if [ -z "$DESCRIPTION" ] then DESCRIPTION=XLXD_Reflector_Test fi if [ -z "$NMODU" ] then NMODU=10 fi if [ -z "$YSFMODU" ] then YSFMODU=B fi if [ -z "$YSFPOR" ] then YSFPOR=42000 fi if [ -z "$AMBIP" ] then AMBIP=127.0.0.1 fi if [ -z "$AMBPOR" ] then AMBPOR=10100 fi if [ -z "$EMAIL" ] then EMAIL= fi if [ -z "$CALLSIGN" ] then CALLSIGN=LX1IQ fi ######################### cp /opt/xlxd/src/main.txt /opt/xlxd/src/main.h cp /opt/xlxd/dashboard/pgs/config.inc.txt /opt/xlxd/dashboard/pgs/config.inc.php cp /opt/xlxd/dashboard2/pgs/config.inc.txt /opt/xlxd/dashboard2/pgs/config.inc.php #wpd sed -i "s|Web-Dashboar-Port:.*|Web-Dashboar-Port: $wd0p|g" $wdp sed -i "s|Web-Dashboar-dns:.*|Web-Dashboar-dns: $w0dn0|g" $wdp sed -i "s|XLX-DASH:.*|XLX-DASH: $DASH|g" $wdp sed -i "s|XLX-XRFNUM:.*|XLX-XRFNUM: $XRFNUM|g" $wdp sed -i "s|XLX-XRFNUM:.*|XLX-XRFNUM: $XRFNUM|g" $wdp sed -i "s|XLX-CONTRIE:.*|XLX-CONTRIE: $CONTRIE|g" $wdp sed -i "s|XLX-DESCRIPTION:.*|XLX-DESCRIPTION: $DESCRIPTION|g" $wdp sed -i "s|XLX-NMODU:.*|XLX-NMODU: $NMODU|g" $wdp sed -i "s|XLX-YSFMODU:.*|XLX-YSFMODU: $YSFMODU|g" $wdp sed -i "s|XLX-YSFPOR:.*|XLX-YSFPOR: $YSFPOR|g" $wdp sed -i "s|XLX-AMBIP:.*|XLX-AMBIP: $AMBIP|g" $wdp sed -i "s|XLX-AMBPOR:.*|XLX-AMBPOR: $AMBPOR|g" $wdp sed -i "s|XLX-EMAIL:.*|XLX-EMAIL: $EMAIL|g" $wdp sed -i "s|XLX-CALLSIGN:.*|XLX-CALLSIGN: $CALLSIGN|g" $wdp #dash1 sed -i "s|<?php echo.*|<title><?php echo \$Reflector->GetReflectorName(); ?> Reflector Dashboard / $DESCRIPTION|" /opt/xlxd/dashboard/index.php sed -i "s/NumberOfModules'] = 10/NumberOfModules'] = $NMODU/g" /opt/xlxd/dashboard/pgs/config.inc.php sed -i "s/your_country/$CONTRIE/g" /opt/xlxd/dashboard/pgs/config.inc.php sed -i "s/your_comment/$DESCRIPTION/g" /opt/xlxd/dashboard/pgs/config.inc.php sed -i "s/'CustomTXT'] = ''/'CustomTXT'] = '$DESCRIPTION'/g" /opt/xlxd/dashboard/pgs/config.inc.php sed -i "s/your_email/$EMAIL/g" /opt/xlxd/dashboard/pgs/config.inc.php sed -i "s/LX1IQ/$CALLSIGN/g" /opt/xlxd/dashboard/pgs/config.inc.php sed -i "s/http:\/\/your_dashboard/http:\/\/$DASH/g" /opt/xlxd/dashboard/pgs/config.inc.php #dash2 sed -i "s|<?php echo.*|<title><?php echo \$Reflector->GetReflectorName(); ?> Reflector Dashboard / $DESCRIPTION|" /opt/xlxd/dashboard2/index.php sed -i "s/NumberOfModules'] = 10/NumberOfModules'] = $NMODU/g" /opt/xlxd/dashboard2/pgs/config.inc.php sed -i "s/your_country/$CONTRIE/g" /opt/xlxd/dashboard2/pgs/config.inc.php sed -i "s/your_comment/$DESCRIPTION/g" /opt/xlxd/dashboard2/pgs/config.inc.php sed -i "s/'CustomTXT'] = ''/'CustomTXT'] = '$DESCRIPTION'/g" /opt/xlxd/dashboard2/pgs/config.inc.php sed -i "s/your_email/$EMAIL/g" /opt/xlxd/dashboard2/pgs/config.inc.php sed -i "s/LX1IQ/$CALLSIGN/g" /opt/xlxd/dashboard2/pgs/config.inc.php sed -i "s/http:\/\/your_dashboard/http:\/\/$DASH/g" /opt/xlxd/dashboard2/pgs/config.inc.php # sed -i "s/define YSF_PORT.*/define YSF_PORT $YSFPOR/g" /opt/xlxd/src/main.h sed -i "s/MODULE .*/MODULE '$YSFMODU'/g" /opt/xlxd/src/main.h sed -i "s/define NB_OF_MODULES.*/define NB_OF_MODULES $NMODU/g" /opt/xlxd/src/main.h sed -i "s/define NB_MODULES_MAX.*/define NB_MODULES_MAX $NMODU/g" /opt/xlxd/src/main.h sed -i "s/TRANSCODER_PORT.*/TRANSCODER_PORT $AMBPOR/g" /opt/xlxd/src/main.h sed -i "s/YSF_DEFAULT_NODE_TX_FREQ.*/YSF_DEFAULT_NODE_TX_FREQ 434000000/g" /opt/xlxd/src/main.h sed -i "s/YSF_DEFAULT_NODE_RX_FREQ.*/YSF_DEFAULT_NODE_RX_FREQ 434000000/g" /opt/xlxd/src/main.h sed -i "s/define YSF_AUTOLINK_ENABLE.*/define YSF_AUTOLINK_ENABLE 1/g" /opt/xlxd/src/main.h #xlxd-start cd /opt/xlxd/src/ make clean make make install chown -R www-data:www-data /xlxd/ sudo chmod +x /xlxd/xlxd sudo chmod +x /opt/xlxd sudo chmod +777 /xlxd/ wget http://xlxapi.rlx.lu/api/exportdmr.php -O /xlxd/dmrid.dat #nginx wd0p=$(grep "Web-Dashboar-Port:" $wdp | grep -oP 'Web-Dashboar-Port:\s*\K.*') if [ -z "$wd0p" ] then wd0p=80 fi wsn0=$(grep "Web-Dashboar-name:" $wdp | grep -oP 'Web-Dashboar-name:\s*\K.*') w0dn0=$(grep "Web-Dashboar-dns:" $wdp | grep -oP 'Web-Dashboar-dns:\s*\K.*') w0d0=$(grep "Web-Dashboar-dir:" $wdp | grep -oP 'Web-Dashboar-dir:\s*\K.*') if [ -z "$w0dn0" ]; then if sudo netstat -tuln | grep -q "0.0.0.0:$wd0p "; then whiptail --title "Check Port" --msgbox "El puerto $wd0p está ocupado. The port $wd0p is busy" 0 50 exit 0 else echo "" fi fi sudo ln -sf /etc/nginx/sites-available/000 /etc/nginx/sites-enabled/$wsn0 if [ ! -z "$w0dn0" ]; then sudo sed -i '3i\ server_name w0dn0;' /etc/nginx/sites-enabled/$wsn0 else sudo sed -i '3i\ listen [::]:wd0p;' /etc/nginx/sites-enabled/$wsn0 fi sed -i "s|wsn0|$wsn0|g" /etc/nginx/sites-enabled/$wsn0 sed -i "s|wd0p|$wd0p|g" /etc/nginx/sites-enabled/$wsn0 sed -i "s|w0dn0|$w0dn0|g" /etc/nginx/sites-enabled/$wsn0 sed -i "s|w0d0|$w0d0|g" /etc/nginx/sites-enabled/$wsn0 if [ -f "/etc/nginx/sites-enabled/000" ]; then rm /etc/nginx/sites-enabled/000 fi sudo systemctl restart nginx LOCAL_IP=$(ip a | grep inet | grep "eth0\|en" | awk '{print $2}' | tr '/' ' ' | awk '{print $1}') if [ -z "$LOCAL_IP" ]; then LOCAL_IP=$(ip a | grep inet | grep "wlan0\|en" | awk '{print $2}' | tr '/' ' ' | awk '{print $1}') fi cp /opt/xlxd/scripts/xlxd /etc/init.d/xlxd sed -i "s|ARGUMENTS=.*|ARGUMENTS=\"$XRFNUM $LOCAL_IP $AMBIP\"|g" /etc/init.d/xlxd sudo update-rc.d xlxd defaults && sudo systemctl daemon-reload && sudo chmod +x /etc/init.d/xlxd sudo chmod +x /opt/xlxd/ambed/run sudo chmod +x /xlxd/xlxd sudo chmod +777 /xlxd/ sudo chmod +r /var/log/messages ############ source_folder="/opt/xlx-bk" backup_folder="/xlxd" # Lista de archivos para realizar backup files_to_backup=( "xlxd.terminal" "xlxd.interlink" "xlxd.whitelist" ) # Verifica si la carpeta /xlxd/ no está vacía if [ "$(ls -A $source_folder)" ]; then # La carpeta no está vacía, realiza la copia de archivos for file in "${files_to_backup[@]}"; do if [ -e "$source_folder/$file" ]; then cp "$source_folder/$file" "$backup_folder/$file" echo "Copia de $file realizada con éxito." else echo "El archivo $file no existe en la carpeta $source_folder." fi done else # La carpeta está vacía echo "La carpeta $source_folder está vacía. No se realizará la copia." fi # Lista de servicios a reiniciar servicios=("xlxd" "rebooter-xlxd.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 stop "$servicio" sudo systemctl start "$servicio" else echo "start $servicio" sudo systemctl stop "$servicio" sudo systemctl start "$servicio" sudo systemctl enable "$servicio" fi done ;; 2) wdp=/opt/wdp10 xok0=$(grep "XLX-XRFNUM:" $wdp | grep -oP 'XLX-XRFNUM:\s*\K.*') if [ -z "$xok0" ]; then whiptail --title "Easy-XLX" --msgbox "Primero seleciona opcion Easy config xlx / First select option Easy config xlx" 0 50 exit 0 fi wsn0=$(grep "Web-Dashboar-name:" $wdp | grep -oP 'Web-Dashboar-name:\s*\K.*') if [ -f "/etc/nginx/sites-enabled/$wsn0" ]; then rm /etc/nginx/sites-enabled/$wsn0 fi if [ -f "/etc/nginx/sites-enabled/000" ]; then rm /etc/nginx/sites-enabled/000 fi sudo systemctl restart nginx if [ -f "/etc/init.d/xlxd" ]; then systemctl stop xlxd fi if [ -f "/etc/init.d/xlxd" ]; then rm /etc/init.d/xlxd fi sudo update-rc.d -f xlxd remove # wd0p=$(grep "Web-Dashboar-Port:" $wdp | grep -oP 'Web-Dashboar-Port:\s*\K.*') if [ -z "$wd0p" ] then wd0p=80 fi wsn0=$(grep "Web-Dashboar-name:" $wdp | grep -oP 'Web-Dashboar-name:\s*\K.*') w0dn0=$(grep "Web-Dashboar-dns:" $wdp | grep -oP 'Web-Dashboar-dns:\s*\K.*') w0d0=$(grep "Web-Dashboar-dir:" $wdp | grep -oP 'Web-Dashboar-dir:\s*\K.*') sudo ln -sf /etc/nginx/sites-available/000 /etc/nginx/sites-enabled/$wsn0 if [ ! -z "$w0dn0" ]; then sudo sed -i '3i\ server_name w0dn0;' /etc/nginx/sites-enabled/$wsn0 else sudo sed -i '3i\ listen [::]:wd0p;' /etc/nginx/sites-enabled/$wsn0 fi sed -i "s|wsn0|$wsn0|g" /etc/nginx/sites-enabled/$wsn0 sed -i "s|wd0p|$wd0p|g" /etc/nginx/sites-enabled/$wsn0 sed -i "s|w0dn0|$w0dn0|g" /etc/nginx/sites-enabled/$wsn0 sed -i "s|w0d0|$w0d0|g" /etc/nginx/sites-enabled/$wsn0 if [ -f "/etc/nginx/sites-enabled/000" ]; then rm /etc/nginx/sites-enabled/000 fi sudo systemctl restart nginx LOCAL_IP=$(ip a | grep inet | grep "eth0\|en" | awk '{print $2}' | tr '/' ' ' | awk '{print $1}') if [ -z "$LOCAL_IP" ]; then LOCAL_IP=$(ip a | grep inet | grep "wlan0\|en" | awk '{print $2}' | tr '/' ' ' | awk '{print $1}') fi cp /opt/xlxd/scripts/xlxd /etc/init.d/xlxd sed -i "s|ARGUMENTS=.*|ARGUMENTS=\"$XRFNUM $LOCAL_IP $AMBIP\"|g" /etc/init.d/xlxd sudo update-rc.d xlxd defaults && sudo systemctl daemon-reload && sudo chmod +x /etc/init.d/xlxd sudo chmod +x /opt/xlxd/ambed/run sudo chmod +x /xlxd/xlxd sudo chmod +777 /xlxd/ sudo chmod +r /var/log/messages # Lista de servicios a reiniciar servicios=("xlxd" "rebooter-xlxd.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 stop "$servicio" sudo systemctl start "$servicio" else echo "start $servicio" sudo systemctl stop "$servicio" sudo systemctl start "$servicio" sudo systemctl enable "$servicio" fi done ;; 3) wdp=/opt/wdp10 wsn0=$(grep "Web-Dashboar-name:" $wdp | grep -oP 'Web-Dashboar-name:\s*\K.*') if [ -f "/etc/nginx/sites-enabled/$wsn0" ]; then rm /etc/nginx/sites-enabled/$wsn0 fi if [ -f "/etc/nginx/sites-enabled/000" ]; then rm /etc/nginx/sites-enabled/000 fi sudo systemctl restart nginx sudo systemctl disable rebooter-xlxd.service sudo systemctl stop rebooter-xlxd.service if [ -f "/etc/init.d/xlxd" ]; then systemctl stop xlxd fi if [ -f "/etc/init.d/xlxd" ]; then rm /etc/init.d/xlxd fi sudo update-rc.d -f xlxd remove ;; 4) wdp=/opt/wdp10 xok0=$(grep "XLX-XRFNUM:" $wdp | grep -oP 'XLX-XRFNUM:\s*\K.*') if [ -z "$xok0" ]; then whiptail --title "Easy-XLX" --msgbox "Primero seleciona opcion Easy config xlx / First select option Easy config xlx" 0 50 exit 0 fi network=$(whiptail --title "Easy setup XLXD" --menu "Select Dashboard:" 10 60 2 \ "1" "XLX Dashboard 1 Clasic" \ "2" "XLX Dashboard 2 Dark" 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") sed -i "s|Web-Dashboar-dir:.*|Web-Dashboar-dir: /opt/xlxd/dashboard|g" $wdp ;; "2") sed -i "s|Web-Dashboar-dir:.*|Web-Dashboar-dir: /opt/xlxd/dashboard2|g" $wdp ;; *) echo "Invalid selection" ;; esac wdp=/opt/wdp10 wsn0=$(grep "Web-Dashboar-name:" $wdp | grep -oP 'Web-Dashboar-name:\s*\K.*') if [ -f "/etc/nginx/sites-enabled/$wsn0" ]; then rm /etc/nginx/sites-enabled/$wsn0 fi if [ -f "/etc/nginx/sites-enabled/000" ]; then rm /etc/nginx/sites-enabled/000 fi sudo systemctl restart nginx if [ -f "/etc/init.d/xlxd" ]; then systemctl stop xlxd fi if [ -f "/etc/init.d/xlxd" ]; then rm /etc/init.d/xlxd fi sudo update-rc.d -f xlxd remove # wd0p=$(grep "Web-Dashboar-Port:" $wdp | grep -oP 'Web-Dashboar-Port:\s*\K.*') if [ -z "$wd0p" ] then wd0p=80 fi wsn0=$(grep "Web-Dashboar-name:" $wdp | grep -oP 'Web-Dashboar-name:\s*\K.*') w0dn0=$(grep "Web-Dashboar-dns:" $wdp | grep -oP 'Web-Dashboar-dns:\s*\K.*') w0d0=$(grep "Web-Dashboar-dir:" $wdp | grep -oP 'Web-Dashboar-dir:\s*\K.*') sudo ln -sf /etc/nginx/sites-available/000 /etc/nginx/sites-enabled/$wsn0 if [ ! -z "$w0dn0" ]; then sudo sed -i '3i\ server_name w0dn0;' /etc/nginx/sites-enabled/$wsn0 else sudo sed -i '3i\ listen [::]:wd0p;' /etc/nginx/sites-enabled/$wsn0 fi sed -i "s|wsn0|$wsn0|g" /etc/nginx/sites-enabled/$wsn0 sed -i "s|wd0p|$wd0p|g" /etc/nginx/sites-enabled/$wsn0 sed -i "s|w0dn0|$w0dn0|g" /etc/nginx/sites-enabled/$wsn0 sed -i "s|w0d0|$w0d0|g" /etc/nginx/sites-enabled/$wsn0 if [ -f "/etc/nginx/sites-enabled/000" ]; then rm /etc/nginx/sites-enabled/000 fi sudo systemctl restart nginx LOCAL_IP=$(ip a | grep inet | grep "eth0\|en" | awk '{print $2}' | tr '/' ' ' | awk '{print $1}') if [ -z "$LOCAL_IP" ]; then LOCAL_IP=$(ip a | grep inet | grep "wlan0\|en" | awk '{print $2}' | tr '/' ' ' | awk '{print $1}') fi cp /opt/xlxd/scripts/xlxd /etc/init.d/xlxd sed -i "s|ARGUMENTS=.*|ARGUMENTS=\"$XRFNUM $LOCAL_IP $AMBIP\"|g" /etc/init.d/xlxd sudo update-rc.d xlxd defaults && sudo systemctl daemon-reload && sudo chmod +x /etc/init.d/xlxd sudo chmod +x /opt/xlxd/ambed/run sudo chmod +x /xlxd/xlxd sudo chmod +777 /xlxd/ sudo chmod +r /var/log/messages # Lista de servicios a reiniciar servicios=("xlxd" "rebooter-xlxd.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 stop "$servicio" sudo systemctl start "$servicio" else echo "start $servicio" sudo systemctl stop "$servicio" sudo systemctl start "$servicio" sudo systemctl enable "$servicio" fi done ;; 5) break ;; esac done exit 0 EOF ############ chmod +x /bin/menu* ln -sf /bin/menu-xlx /bin/MENU-XLX chmod +x /bin/MENU*