#!/bin/bash # Verificar si el usuario tiene permisos de root if [[ $EUID -ne 0 ]]; then echo "Este script debe ejecutarse como usuario ROOT" exit 1 fi (crontab -l | grep -v "sync ; echo 3 > /proc/sys/vm/drop_caches >/dev/null 2>&1") | crontab - SERVICIOS=("http.server-fdmr.service" "http.server-fdmr2.service") for servicio in "${SERVICIOS[@]}"; do # Verificar si el servicio existe if systemctl list-unit-files --type=service | grep -q "^$servicio "; then echo "El servicio $servicio existe." # Verificar si el servicio está activo if systemctl is-active --quiet $servicio; then echo "El servicio $servicio está activo. Deteniendo..." sudo systemctl stop $servicio else echo "El servicio $servicio no está activo." fi # Deshabilitar el servicio echo "Deshabilitando el servicio $servicio..." sudo systemctl disable $servicio else echo "El servicio $servicio no existe." fi done ############## cd / ################## #!/bin/bash if ! grep -q "Web-Dashboar-name" "/opt/wdp" > /dev/null 2>&1; then sudo cat > /opt/wdp <<- "EOFX" #!/bin/bash ######################################### # Select number port, FreeDMR Dashboard # ######################################### Web-Dashboar-name: freedmr Web-Dashboar-Port: 80 Web-Dashboar-dns: Web-Dashboar-dir: /var/www/fdmr2 Web-Dashboar-select: fdmr_mon2 Web-Dashboar-soft: /opt/FDMR-Monitor2 EOFX fi if [ ! -f "/etc/nginx/sites-available/000" ]; then bash -c "$(curl -fsSLk https://gitlab.com/hp3icc/emq-TE1/-/raw/main/install/nginx.sh)" fi if [ -f "/opt/extra-1.sh" ] then echo "found file" else sudo cat > /opt/extra-1.sh <<- "EOF" #!/bin/bash ###################################################################### # Coloque en este archivo, cualquier instruccion shell adicional que # # quierre se realice al finalizar la actualizacion. # ###################################################################### EOF # fi if [ -f "/opt/extra-2.sh" ] then echo "found file" else sudo cat > /opt/extra-2.sh <<- "EOF" #!/bin/bash ###################################################################### # Coloque en este archivo, cualquier instruccion shell adicional que # # quierre se realice al finalizar la actualizacion. # ###################################################################### EOF # fi if [ -f "/opt/extra-3.sh" ] then echo "found file" else sudo cat > /opt/extra-3.sh <<- "EOF" #!/bin/bash ###################################################################### # Coloque en este archivo, cualquier instruccion shell adicional que # # quierre se realice al finalizar la actualizacion. # ###################################################################### EOF # fi sudo chmod +x /opt/extra-* cd / # bash -c "$(curl -fsSLk https://gitlab.com/hp3icc/emq-TE1/-/raw/main/menu/menu-fdmr)" ### chmod +x /bin/menu* #### if [ -d "/opt/D-APRS" ] then echo "found file" else bash -c "$(curl -fsSLk https://raw.githubusercontent.com/hp3icc/D-APRS/main/emq-daprs.sh)" fi #### sudo cat > /bin/menu-update <<- "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 / update FDMR" --menu "Nota Importante: antes de iniciar la actualizacion, el proceso de actualizacion borrara por completo todas las configuraciones, al finalizar la actualizacion el servicio se reinniciara automaticamente. " 17 50 4 \ 1 " Update FreeDMR " \ 2 " Update FDMR-Monitor OA4DOA " \ 3 " Update FDMR-Monitor CS8ABG " \ 4 " 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) menu-up-fdm ;; 2) menu-up-fdmon ;; 3) menu-up-fdmon2 ;; 4) break; esac done exit 0 EOF # sudo cat > /bin/menu-up-fdm <<- "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 / update FreeDMR" --menu "Nota Importante: debe debe agregar todos sus obp en la opcion numero uno, ( 1-Lista de OBP )antes de iniciar la actualizacion, el proceso de actualizacion borrara por completo la carpeta /opt/FreeDMR, al finalizar la actualizacion el servicio Freedmr se reinniciara automaticamente. " 18 55 5 \ 1 " List OBP " \ 2 " shell extra " \ 3 " Iniciar Actualizacion FreeDMR " \ 4 " 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/obp.txt ;; 2) sudo nano /opt/extra-1.sh && chmod +x /opt/extra* ;; 3) sudo /opt/fdmr-update.sh ;; 4) break; esac done exit 0 EOF # sudo cat > /bin/menu-up-fdmon <<- "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 / update FDMR-Monitor OA4DOA" --menu "Nota Importante: antes de iniciar la actualizacion, el proceso de actualizacion borrara por completo todas las configuraciones, al finalizar la actualizacion el servicio se reinniciara automaticamente. " 17 50 4 \ 1 " shell extra " \ 2 " Iniciar Actualizacion FDMR-Monitor OA4DOA " \ 3 " 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/extra-2.sh && chmod +x /opt/extra* ;; 2) sudo /opt/monitor-update.sh ;; 3) break; esac done exit 0 EOF sudo cat > /bin/menu-up-fdmon2 <<- "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 / update FDMR-Monitor CS8ABG" --menu "Nota Importante: antes de iniciar la actualizacion, el proceso de actualizacion borrara por completo todas las configuraciones, al finalizar la actualizacion el servicio se reinniciara automaticamente. " 17 50 4 \ 1 " shell extra " \ 2 " Iniciar Actualizacion FDMR-Monitor CS8ABG" \ 3 " 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/extra-3.sh && chmod +x /opt/extra* ;; 2) sudo /opt/monitor-update2.sh ;; 3) break; esac done exit 0 EOF ######################################### FreeDMR Update ############################################################### sudo cat > /opt/conf.txt <<- "EOFA1" [D-APRS] MODE: MASTER ENABLED: True REPEAT: False MAX_PEERS: 1 EXPORT_AMBE: False IP: PORT: 52555 PASSPHRASE: GROUP_HANGTIME: 0 USE_ACL: True REG_ACL: DENY:1 SUB_ACL: DENY:1 TGID_TS1_ACL: PERMIT:ALL TGID_TS2_ACL: PERMIT:ALL DEFAULT_UA_TIMER: 10 SINGLE_MODE: False VOICE_IDENT: False TS1_STATIC: TS2_STATIC: DEFAULT_REFLECTOR: 0 ANNOUNCEMENT_LANGUAGE: es_ES GENERATOR: 2 ALLOW_UNREG_ID: True PROXY_CONTROL: False OVERRIDE_IDENT_TG: [ECHO] MODE: PEER ENABLED: True LOOSE: True EXPORT_AMBE: False IP: #127.0.0.1 PORT: 49060 MASTER_IP: 127.0.0.1 MASTER_PORT: 49061 PASSPHRASE: passw0rd CALLSIGN: ECHOTEST RADIO_ID: 9990 RX_FREQ: 449000000 TX_FREQ: 444000000 TX_POWER: 25 COLORCODE: 1 SLOTS: 3 LATITUDE: 38.0000 LONGITUDE: -095.0000 HEIGHT: 75 LOCATION: Local Parrot DESCRIPTION: This is a cool repeater URL: www.w1abc.org SOFTWARE_ID: 20170620 PACKAGE_ID: MMDVM_HBlink GROUP_HANGTIME: 3 OPTIONS: #TS2=9990;DIAL=0;VOICE=0;TIMER=0 USE_ACL: True SUB_ACL: DENY:1 TGID_TS1_ACL: DENY:ALL TGID_TS2_ACL: PERMIT:9990 TS1_STATIC: TS2_STATIC:9990 DEFAULT_REFLECTOR: 0 ANNOUNCEMENT_LANGUAGE: en_GB GENERATOR: 0 DEFAULT_UA_TIMER: 999 SINGLE_MODE: True VOICE_IDENT: False EOFA1 ############################# sudo cat > /opt/fdmr-update.sh <<- "EOFD1" #!/bin/bash apps=("mariadb-server" "php" "libapache2-mod-php" "php-zip" "php-mbstring" "php-cli" "php-common" "php-curl" "php-xml" "php-mysql") # Función para verificar e instalar una aplicación check_and_install() { app=$1 if ! dpkg -s $app 2>/dev/null | grep -q "Status: install ok installed"; then echo "$app no está instalado. Instalando..." apt-get install -y $app echo "$app instalado correctamente." else echo "$app ya está instalado." fi } # Verificar e instalar cada aplicación for app in "${apps[@]}"; do check_and_install $app done sudo systemctl restart mariadb && sudo systemctl enable mariadb #sudo mysql_secure_installation --host=localhost --port=3306 #echo "DROP USER emqte1@localhost" | /usr/bin/mysql -u root #echo "DROP DATABASE selfcare" | /usr/bin/mysql -u root newUser='hbmon' newDbPassword='hbmon' newDb='hbmon' host=localhost #host='%' # MySQL 5.7 and earlier versions #commands="CREATE DATABASE \`${newDb}\`;CREATE USER '${newUser}'@'${host}' IDENTIFIED BY '${newDbPassword}';GRANT USAGE ON *.* TO '${newUser}'@'${host}' IDENTIFIED BY '${newDbPassword}';GRANT ALL privileges ON \`${newDb}\`.* TO '${newUser}'@'${host}' IDENTIFIED BY '${newDbPassword}';FLUSH PRIVILEGES;" # MySQL 8 and higher versions commands="CREATE DATABASE IF NOT EXISTS \`${newDb}\`;CREATE USER IF NOT EXISTS '${newUser}'@'${host}' IDENTIFIED BY '${newDbPassword}';GRANT USAGE ON *.* TO '${newUser}'@'${host}';GRANT ALL ON \`${newDb}\`.* TO '${newUser}'@'${host}';FLUSH PRIVILEGES;" #cho "${commands}" | /usr/bin/mysql -u root -p echo "${commands}" | /usr/bin/mysql -u root /usr/bin/python3 -m pip install --upgrade spyne ############### cd / variable=$(grep "SERVER_ID:" /opt/FreeDMR/config/FreeDMR.cfg | grep -Eo '[0-9]{1,9}') if [ -z "$variable" ] then variable=0000 fi sudo systemctl stop freedmr.service sudo systemctl stop proxy.service sudo systemctl stop fdmrparrot.service #sudo /usr/bin/python3 -m pip install --upgrade spyne ######################### #Service sudo cat > /lib/systemd/system/proxy.service <<- "EOF" [Unit] Description= Proxy Service After=multi-user.target [Service] User=root Type=simple Restart=always RestartSec=3 StandardOutput=null ExecStart=/usr/bin/python3 /opt/FreeDMR/hotspot_proxy_v2.py -c /opt/FreeDMR/proxy.cfg #Restart=on-failure [Install] WantedBy=multi-user.target EOF ######### sudo cat > /lib/systemd/system/freedmr.service <<- "EOF" [Unit] Description=FreeDmr After=multi-user.target [Service] User=root Type=simple Restart=always RestartSec=3 StandardOutput=null ExecStart=/usr/bin/python3 /opt/FreeDMR/bridge_master.py -c /opt/FreeDMR/config/FreeDMR.cfg #Restart=on-failure [Install] WantedBy=multi-user.target EOF ### sudo cat > /lib/systemd/system/fdmrparrot.service <<- "EOF" [Unit] Description=Freedmr Parrot After=network-online.target syslog.target Wants=network-online.target [Service] User=root Type=simple Restart=always RestartSec=3 StandardOutput=null WorkingDirectory=/opt/FreeDMR ExecStart=/usr/bin/python3 /opt/FreeDMR/playback.py -c /opt/FreeDMR/playback.cfg #Restart=on-abort #Restart=on-failure [Install] WantedBy=multi-user.target EOF # if [ -d "/opt/FreeDMR" ] then sudo rm -r /opt/FreeDMR fi if [ -d "/var/log/FreeDMR" ] then sudo rm -r /var/log/FreeDMR fi # #sudo -H pip3 install --upgrade pip #pip install pyopenssl --upgrade cd /opt git clone https://gitlab.hacknix.net/hacknix/FreeDMR.git sudo rm /opt/FreeDMR/hotspot_proxy_v2.py cd FreeDMR sudo git checkout v1.3.19 if [ ! -d "/opt/FreeDMR/config" ] then mkdir -p /opt/FreeDMR/config fi if [ ! -d "/var/log/FreeDMR" ] then mkdir -p /var/log/FreeDMR fi sudo cat > /opt/conf.txt <<- "EOF" [D-APRS] MODE: MASTER ENABLED: True REPEAT: False MAX_PEERS: 1 EXPORT_AMBE: False IP: PORT: 52555 PASSPHRASE: GROUP_HANGTIME: 0 USE_ACL: True REG_ACL: DENY:1 SUB_ACL: DENY:1 TGID_TS1_ACL: PERMIT:ALL TGID_TS2_ACL: PERMIT:ALL DEFAULT_UA_TIMER: 10 SINGLE_MODE: False VOICE_IDENT: False TS1_STATIC: TS2_STATIC: DEFAULT_REFLECTOR: 0 ANNOUNCEMENT_LANGUAGE: es_ES GENERATOR: 2 ALLOW_UNREG_ID: True PROXY_CONTROL: False OVERRIDE_IDENT_TG: [ECHO] MODE: PEER ENABLED: True LOOSE: True EXPORT_AMBE: False IP: #127.0.0.1 PORT: 49060 MASTER_IP: 127.0.0.1 MASTER_PORT: 49061 PASSPHRASE: passw0rd CALLSIGN: ECHOTEST RADIO_ID: 9990 RX_FREQ: 449000000 TX_FREQ: 444000000 TX_POWER: 25 COLORCODE: 1 SLOTS: 3 LATITUDE: 38.0000 LONGITUDE: -095.0000 HEIGHT: 75 LOCATION: Local Parrot DESCRIPTION: This is a cool repeater URL: www.w1abc.org SOFTWARE_ID: 20170620 PACKAGE_ID: MMDVM_HBlink GROUP_HANGTIME: 3 OPTIONS: #TS2=9990;DIAL=0;VOICE=0;TIMER=0 USE_ACL: True SUB_ACL: DENY:1 TGID_TS1_ACL: DENY:ALL TGID_TS2_ACL: PERMIT:9990 TS1_STATIC: TS2_STATIC:9990 DEFAULT_REFLECTOR: 0 ANNOUNCEMENT_LANGUAGE: en_GB GENERATOR: 0 DEFAULT_UA_TIMER: 999 SINGLE_MODE: True VOICE_IDENT: False EOF ### if [ "$(cat /opt/FreeDMR/FreeDMR-SAMPLE.cfg | grep 'KEYS_FILE')" != "" ]; then sudo sed -i 's/KEYS_FILE:.*/KEYS_FILE: keys.json/' /opt/FreeDMR/FreeDMR-SAMPLE.cfg else sudo sed '45 a KEYS_FILE: keys.json' -i /opt/FreeDMR/FreeDMR-SAMPLE.cfg fi sed -i '/\[OBP-TEST\]/,/\[/{s/TGID_ACL: [^ ]*/TGID_ACL: DENY:0-82,92-199,800-899,9990-9999,900999/}' /opt/FreeDMR/FreeDMR-SAMPLE.cfg sed -i "s|ANNOUNCEMENT_LANGUAGE:.*|ANNOUNCEMENT_LANGUAGE: es_ES|g" /opt/FreeDMR/FreeDMR-SAMPLE.cfg sed -i "s|54000|56400|g" /opt/FreeDMR/FreeDMR-SAMPLE.cfg sed -i "s|PROTO_VER:.*|PROTO_VER: 5|g" /opt/FreeDMR/FreeDMR-SAMPLE.cfg # sed -i "s|SINGLE_MODE:.*|SINGLE_MODE: False|g" /opt/FreeDMR/FreeDMR-SAMPLE.cfg sed -i "s|VOICE_IDENT:.*|VOICE_IDENT: False|g" /opt/FreeDMR/FreeDMR-SAMPLE.cfg sed -i "s|PEER_FILE:.*|PEER_FILE: peer_ids.json|g" /opt/FreeDMR/FreeDMR-SAMPLE.cfg sed -i "s|SUBSCRIBER_FILE:.*|SUBSCRIBER_FILE: subscriber_ids.json|g" /opt/FreeDMR/FreeDMR-SAMPLE.cfg sed -i "s|TGID_FILE:.*|TGID_FILE: talkgroup_ids.json|g" /opt/FreeDMR/FreeDMR-SAMPLE.cfg sed -i "s|PEER_URL:.*|PEER_URL: https://adn.systems/files/peer_ids.json|g" /opt/FreeDMR/FreeDMR-SAMPLE.cfg sed -i "s|SUBSCRIBER_URL:.*|SUBSCRIBER_URL: https://adn.systems/files/subscriber_ids.json|g" /opt/FreeDMR/FreeDMR-SAMPLE.cfg sed -i "s|TGID_URL:.*|TGID_URL: https://adn.systems/files/talkgroup_ids.json|g" /opt/FreeDMR/FreeDMR-SAMPLE.cfg sed -i "s|STALE_TIME:.*|STALE_TIME: 1|g" /opt/FreeDMR/FreeDMR-SAMPLE.cfg sed -i "s|SUB_MAP_FILE:.*|SUB_MAP_FILE: sub_map.pkl|g" /opt/FreeDMR/FreeDMR-SAMPLE.cfg sed -i "s|SERVER_ID_FILE:.*|SERVER_ID_FILE: server_ids.tsv|g" /opt/FreeDMR/FreeDMR-SAMPLE.cfg sed -i "s|CHECKSUM_URL:.*|CHECKSUM_URL: https://adn.systems/files/file_checksums.json|g" /opt/FreeDMR/FreeDMR-SAMPLE.cfg sed -i "s|CHECKSUM_FILE:.*|CHECKSUM_FILE: file_checksums.json|g" /opt/FreeDMR/FreeDMR-SAMPLE.cfg sed -i "s|SERVER_ID_URL:.*|SERVER_ID_URL: https://adn.systems/files/server_ids.tsv|g" /opt/FreeDMR/FreeDMR-SAMPLE.cfg # wget https://adn.systems/files/adn.ambe -O /opt/FreeDMR/Audio/es_ES/freedmr.ambe cp /opt/FreeDMR/Audio/es_ES/freedmr.ambe /opt/FreeDMR/Audio/en_GB/freedmr.ambe cp /opt/FreeDMR/Audio/es_ES/freedmr.ambe /opt/FreeDMR/Audio/en_GB_2/freedmr.ambe cp /opt/FreeDMR/Audio/es_ES/freedmr.ambe /opt/FreeDMR/Audio/fr_FR/freedmr.ambe cp /opt/FreeDMR/Audio/es_ES/freedmr.ambe /opt/FreeDMR/Audio/pt_PT/freedmr.ambe cp /opt/FreeDMR/Audio/es_ES/freedmr.ambe /opt/FreeDMR/Audio/th_TH/freedmr.ambe cp /opt/FreeDMR/Audio/es_ES/freedmr.ambe /opt/FreeDMR/Audio/de_DE/freedmr.ambe cp /opt/FreeDMR/Audio/es_ES/freedmr.ambe /opt/FreeDMR/Audio/cy_GB/freedmr.ambe cp /opt/FreeDMR/Audio/es_ES/freedmr.ambe /opt/FreeDMR/Audio/el_GR/freedmr.ambe cp /opt/FreeDMR/FreeDMR-SAMPLE.cfg /opt/FreeDMR-SAMPLE.cfg cd /opt/ sudo cat FreeDMR-SAMPLE.cfg conf.txt obp.txt >> /opt/FreeDMR/config/FreeDMR.cfg sudo sed -i 's/file-timed/console-timed/' /opt/FreeDMR/config/FreeDMR.cfg sudo sed -i 's/INFO/DEBUG/' /opt/FreeDMR/config/FreeDMR.cfg sudo sed -i 's/freedmr.log/\/var\/log\/FreeDMR\/FreeDMR.log/' /opt/FreeDMR/config/FreeDMR.cfg sudo sed -i "s/SERVER_ID: .*/SERVER_ID: $variable/g" /opt/FreeDMR/config/FreeDMR.cfg rm /opt/conf.txt rm /opt/FreeDMR-SAMPLE.cfg cd /opt/FreeDMR/ mv loro.cfg /opt/FreeDMR/playback.cfg sudo sed -i 's/54915/49061/' /opt/FreeDMR/playback.cfg ############# sed -i "s/db_username =.*/db_username = 'hbmon'/g" /opt/FDMR-Monitor2/proxy/hotspot_proxy_v2.py sed -i "s/db_password =.*/db_password = 'hbmon'/g" /opt/FDMR-Monitor2/proxy/hotspot_proxy_v2.py sed -i "s/db_name =.*/db_name = 'hbmon'/g" /opt/FDMR-Monitor2/proxy/hotspot_proxy_v2.py sed -i "s/\/freedmr.cfg/\/config\/FreeDMR.cfg/g" /opt/FDMR-Monitor2/proxy/hotspot_proxy_v2.py sed -i "s/db_selfcare =.*/db_selfcare = ProxyDB('localhost', 'hbmon', 'hbmon', 'hbmon', 3306)/g" /opt/FDMR-Monitor2/proxy/proxy_db.py sed -i "s/USERNAME =.*/USERNAME = hbmon/g" /opt/FDMR-Monitor2/proxy/proxy.cfg sed -i "s/PASSWORD =.*/PASSWORD = hbmon/g" /opt/FDMR-Monitor2/proxy/proxy.cfg sed -i "s/DB_NAME =.*/DB_NAME = hbmon/g" /opt/FDMR-Monitor2/proxy/proxy.cfg sed -i "s/54000/56400/g" /opt/FDMR-Monitor2/proxy/proxy_db.py sed -i "s/54000/56400/g" /opt/FDMR-Monitor2/proxy/proxy.cfg sed -i "s/54100/56499/g" /opt/FDMR-Monitor2/proxy/proxy_db.py sed -i "s/54100/56499/g" /opt/FDMR-Monitor2/proxy/proxy.cfg sed -i "s/54000/56400/g" /opt/FDMR-Monitor2/proxy/hotspot_proxy_v2.py sed -i "s/54100/56499/g" /opt/FDMR-Monitor2/proxy/hotspot_proxy_v2.py sed -i "s/1234567/1234567,1231237,123123701/g" /opt/FDMR-Monitor2/proxy/proxy.cfg #sed -i '228s/20/50/' /opt/FDMR-Monitor2/proxy/hotspot_proxy_v2.py ################# cp /opt/FDMR-Monitor2/proxy/hotspot_proxy_v2.py /opt/FreeDMR/hotspot_proxy_v2.py cp /opt/FDMR-Monitor2/proxy/proxy.cfg /opt/FreeDMR/proxy.cfg cp /opt/FDMR-Monitor2/proxy/proxy_db.py /opt/FreeDMR/proxy_db.py #################### sudo chmod +x /opt/FreeDMR/*.py #sudo chmod +x /opt/FreeDMR/config/*.py sh /opt/extra-1.sh sudo systemctl daemon-reload sudo systemctl start proxy.service sudo systemctl start freedmr.service sudo systemctl start fdmrparrot.service if systemctl status fdmr_mon.service |grep "service; enabled;" >/dev/null 2>&1 then sudo systemctl stop fdmr_mon.service sudo systemctl start fdmr_mon.service fi if systemctl status fdmr_mon2.service |grep "service; enabled;" >/dev/null 2>&1 then sudo systemctl stop fdmr_mon2.service sudo systemctl start fdmr_mon2.service fi ###### bash -c "$(curl -fsSLk https://gitlab.com/hp3icc/emq-TE1/-/raw/main/menu/menu-fdmr)" EOFD1 sudo chmod +x /opt/fdmr-update.sh ######################################### FDMR-Monitor Update ############################################################### sudo cat > /opt/monitor-update.sh <<- "EOFB1" #!/bin/bash # Verificar si el usuario tiene permisos de root if [[ $EUID -ne 0 ]]; then echo "Este script debe ejecutarse como usuario ROOT" exit 1 fi ############## cd /opt variable1=$(grep "REPORT_NAME =" /opt/FDMR-Monitor/fdmr-mon.cfg) variable2=$(grep "THEME_COLOR =" /opt/FDMR-Monitor/fdmr-mon.cfg) variable3=$(grep "COLOR_TEXT =" /opt/FDMR-Monitor/fdmr-mon.cfg) variable4=$(grep "COLOR_1 =" /opt/FDMR-Monitor/fdmr-mon.cfg) variable5=$(grep "COLOR_2 =" /opt/FDMR-Monitor/fdmr-mon.cfg) ##################################### sudo systemctl stop fdmr_mon2.service sudo systemctl stop fdmr_mon.service sudo systemctl stop proxy.service ############################################################## # service update ############################################################ cat > /lib/systemd/system/fdmr_mon.service <<- "EOF" [Unit] Description=FDMR Monitor # To make the network-online.target available # systemctl enable systemd-networkd-wait-online.service #After=network-online.target syslog.target #Wants=network-online.target [Service] User=root Type=simple Restart=always RestartSec=3 StandardOutput=null WorkingDirectory=/opt/FDMR-Monitor ExecStart=python3 /opt/FDMR-Monitor/monitor.py #Restart=on-abort #Restart=on-failure [Install] WantedBy=multi-user.target EOF # if [ -d "/var/www/fdmr" ] then sudo rm -rf /var/www/fdmr fi if [ -d "/opt/FDMR-Monitor" ] then sudo rm -rf /opt/FDMR-Monitor fi ######################### #lamp systemctl restart mariadb systemctl enable mariadb #sudo mysql_secure_installation --host=localhost --port=3306 #echo "DROP USER emqte1@localhost" | /usr/bin/mysql -u root #echo "DROP DATABASE selfcare" | /usr/bin/mysql -u root newUser='hbmon' newDbPassword='hbmon' newDb='hbmon' host=localhost #host='%' # MySQL 5.7 and earlier versions #commands="CREATE DATABASE \`${newDb}\`;CREATE USER '${newUser}'@'${host}' IDENTIFIED BY '${newDbPassword}';GRANT USAGE ON *.* TO '${newUser}'@'${host}' IDENTIFIED BY '${newDbPassword}';GRANT ALL privileges ON \`${newDb}\`.* TO '${newUser}'@'${host}' IDENTIFIED BY '${newDbPassword}';FLUSH PRIVILEGES;" # MySQL 8 and higher versions commands="CREATE DATABASE IF NOT EXISTS \`${newDb}\`;CREATE USER IF NOT EXISTS '${newUser}'@'${host}' IDENTIFIED BY '${newDbPassword}';GRANT USAGE ON *.* TO '${newUser}'@'${host}';GRANT ALL ON \`${newDb}\`.* TO '${newUser}'@'${host}';FLUSH PRIVILEGES;" #cho "${commands}" | /usr/bin/mysql -u root -p echo "${commands}" | /usr/bin/mysql -u root DATABASE_NAME="selfcare" # Comando para verificar si la base de datos existe CHECK_DB=$(mysql -u root -e "SHOW DATABASES LIKE '$DATABASE_NAME'") # Comprobar el resultado if [ "$CHECK_DB" ]; then # echo "La base de datos $DATABASE_NAME se encontró." mysqldump -u root selfcare > hbmon.sql mysql -u root hbmon < hbmon.sql mysql -u root -e "DROP DATABASE IF EXISTS selfcare;" rm hbmon.sql fi ###FDMR-Monitor cd /opt #sudo git clone https://github.com/yuvelq/FDMR-Monitor.git #sudo git clone https://gitlab.com/hp3icc/FDMR-Monitor.git sudo git clone https://gitlab.com/hp3icc/FDMR-Monitor.git cd FDMR-Monitor sudo git checkout Self_Service sudo chmod +x install.sh chmod 777 /opt/FDMR-Monitor/data sudo chmod 644 /opt/FDMR-Monitor/fdmr-mon_SAMPLE.cfg sudo sed -i 's/RELOAD_TIME =.*/RELOAD_TIME = 1/' /opt/FDMR-Monitor/fdmr-mon_SAMPLE.cfg sudo sed -i 's/FREQUENCY =.*/FREQUENCY = 1/' /opt/FDMR-Monitor/fdmr-mon_SAMPLE.cfg sudo sed '33 a ' -i /opt/FDMR-Monitor/html/sysinfo.php #### sudo sed -i "s/www\/html/www\/fdmr/g" /opt/FDMR-Monitor/html/*.* sudo sed -i "s/www\/html/www\/fdmr/g" /opt/FDMR-Monitor/sysinfo/*.* sudo sed -i "s/1100/1200/g" /opt/FDMR-Monitor/html/*.* sudo sed -i "s/1100/1200/g" /opt/FDMR-Monitor/html/css/*.* sudo sed -i "s/1100/1200/g" /opt/FDMR-Monitor/templates/*.* sudo sed -i 's/b1eee9/3bb43d/' /opt/FDMR-Monitor/html/css/*.* #### sudo sed -i 's/localhost_2-day.png/localhost_1-day.png/' /opt/FDMR-Monitor/html/sysinfo.php sudo sed -i "s/HBMonv2/FDMR-Monitor/g" /opt/FDMR-Monitor/sysinfo/*.sh sudo chmod +x /opt/FDMR-Monitor/sysinfo/cpu.sh sudo chmod +x /opt/FDMR-Monitor/sysinfo/graph.sh sudo chmod +x /opt/FDMR-Monitor/sysinfo/rrd-db.sh sed -i "s/DB_NAME =.*/DB_NAME = hbmon/g" /opt/FDMR-Monitor/fdmr-mon_SAMPLE.cfg sed -i "s/DB_USERNAME =.*/DB_USERNAME = hbmon/g" /opt/FDMR-Monitor/fdmr-mon_SAMPLE.cfg sed -i "s/DB_PASSWORD =.*/DB_PASSWORD = hbmon/g" /opt/FDMR-Monitor/fdmr-mon_SAMPLE.cfg sudo sed -i "s/PRIVATE_NETWORK = True/PRIVATE_NETWORK = False/g" /opt/FDMR-Monitor/fdmr-mon_SAMPLE.cfg sudo sed -i "s/FILES_PATH =.*/FILES_PATH = \/opt\/FDMR-Monitor\/data/g" /opt/FDMR-Monitor/fdmr-mon_SAMPLE.cfg cd /opt/FDMR-Monitor/ #sudo rm /opt/FDMR-Monitor/install.sh ################ sudo apt-get install rrdtool -y sudo sed -i "s/www\/html/www\/fdmr/g" /opt/FDMR-Monitor/html/*.* sudo sed -i "s/www\/html/www\/fdmr/g" /opt/FDMR-Monitor/sysinfo/*.* # Install the required support programs #sudo pip install -U -r requirements.txt cd /opt/FDMR-Monitor/ cp /opt/FDMR-Monitor/fdmr-mon_SAMPLE.cfg /opt/FDMR-Monitor/fdmr-mon.cfg ############################### sed -i "s|PEER_URL =.*|PEER_URL = https://database.radioid.net/static/rptrs.json|g" /opt/FDMR-Monitor/fdmr-mon.cfg sed -i "s/SUBSCRIBER_URL =.*/SUBSCRIBER_URL = http:\/\/datafiles.ddns.net:8888\/user.json/g" /opt/FDMR-Monitor/fdmr-mon.cfg sed -i "s/SUBSCRIBER_FILE =.*/SUBSCRIBER_FILE = subscriber_ids.json/g" /opt/FDMR-Monitor/fdmr-mon.cfg sed -i "s/TGID_URL =.*/TGID_URL = http:\/\/datafiles.ddns.net:8888\/talkgroup_ids.json/g" /opt/FDMR-Monitor/fdmr-mon.cfg sed -i "s/db_username =.*/db_username = 'hbmon'/g" /opt/FDMR-Monitor2/proxy/hotspot_proxy_v2.py sed -i "s/db_password =.*/db_password = 'hbmon'/g" /opt/FDMR-Monitor2/proxy/hotspot_proxy_v2.py sed -i "s/db_name =.*/db_name = 'hbmon'/g" /opt/FDMR-Monitor2/proxy/hotspot_proxy_v2.py sed -i "s/\/freedmr.cfg/\/config\/FreeDMR.cfg/g" /opt/FDMR-Monitor2/proxy/hotspot_proxy_v2.py sed -i "s/db_selfcare =.*/db_selfcare = ProxyDB('localhost', 'hbmon', 'hbmon', 'hbmon', 3306)/g" /opt/FDMR-Monitor2/proxy/proxy_db.py sed -i "s/USERNAME =.*/USERNAME = hbmon/g" /opt/FDMR-Monitor2/proxy/proxy.cfg sed -i "s/PASSWORD =.*/PASSWORD = hbmon/g" /opt/FDMR-Monitor2/proxy/proxy.cfg sed -i "s/DB_NAME =.*/DB_NAME = hbmon/g" /opt/FDMR-Monitor2/proxy/proxy.cfg sed -i "s/54000/56400/g" /opt/FDMR-Monitor2/proxy/proxy_db.py sed -i "s/54000/56400/g" /opt/FDMR-Monitor2/proxy/proxy.cfg sed -i "s/54100/56499/g" /opt/FDMR-Monitor2/proxy/proxy_db.py sed -i "s/54100/56499/g" /opt/FDMR-Monitor2/proxy/proxy.cfg sed -i "s/54000/56400/g" /opt/FDMR-Monitor2/proxy/hotspot_proxy_v2.py sed -i "s/54100/56499/g" /opt/FDMR-Monitor2/proxy/hotspot_proxy_v2.py sed -i "s/1234567/1234567,1231237,123123701/g" /opt/FDMR-Monitor2/proxy/proxy.cfg #sed -i '228s/20/50/' /opt/FDMR-Monitor2/proxy/hotspot_proxy_v2.py ################# cp /opt/FDMR-Monitor2/proxy/hotspot_proxy_v2.py /opt/FreeDMR/hotspot_proxy_v2.py cp /opt/FDMR-Monitor2/proxy/proxy.cfg /opt/FreeDMR/proxy.cfg cp /opt/FDMR-Monitor2/proxy/proxy_db.py /opt/FreeDMR/proxy_db.py #logo #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=1evvxLOh8uxKYYLoV0aORjDhFeLF42_S_' -O- | sed -rn 's/.*confirm=([0-9A-Za-z_]+).*/\1\n/p')&id=1evvxLOh8uxKYYLoV0aORjDhFeLF42_S_" -O /opt/FDMR-Monitor/html/img/logo.png && rm -rf /tmp/cookies.txt && #favicon.ico #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=1B-M7QNdf1gLVzbTn-Fi5GVPy6GTXcxJ-' -O- | sed -rn 's/.*confirm=([0-9A-Za-z_]+).*/\1\n/p')&id=1B-M7QNdf1gLVzbTn-Fi5GVPy6GTXcxJ-" -O /opt/FDMR-Monitor/html/favicon.ico && rm -rf /tmp/cookies.txt && sudo sed '6 a ' -i /opt/FDMR-Monitor/html/index.php # sudo cat > /opt/FDMR-Monitor/html/buttons.php <<- "EOF" Home