#!/bin/bash # Verificar si el usuario tiene permisos de root 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 if command -v apache2 >/dev/null 2>&1; then echo "Apache está instalado." # Verifica si Apache está activo (running) if systemctl is-active --quiet apache2; then echo "Apache está en ejecución. Deteniéndolo..." sudo systemctl stop apache2 fi # Verifica si Apache está habilitado if systemctl is-enabled --quiet apache2; then echo "Apache está habilitado. Deshabilitándolo..." sudo systemctl disable apache2 fi echo "Apache ha sido detenido y deshabilitado de forma permanente." else echo "Apache no está instalado en el sistema." fi ####### cd / if [ -f "/var/www/html/tgcount.php" ]; then sudo rm /var/www/html/* -r #echo "found file" else echo "file not found" fi if [ -f "/opt/FreeDMR/config/FreeDMR.cfg" ] then variable=$(grep "SERVER_ID:" /opt/FreeDMR/config/FreeDMR.cfg | grep -Eo '[0-9]{1,9}') fi if [ -f "/opt/adn-server/config/adn.cfg" ] then variable=$(grep "SERVER_ID:" /opt/adn-server/config/adn.cfg | grep -Eo '[0-9]{1,9}') fi if [ -f "/opt/ADN-DMR-Peer-Server/config/adn.cfg" ] then variable=$(grep "SERVER_ID:" /opt/ADN-DMR-Peer-Server/config/adn.cfg | grep -Eo '[0-9]{1,9}') fi if [ -z "$variable" ] then variable=0000 fi SERVICIOS="adn-server.service freedmr.service proxy.service adn-parrot.service fdmrparrot.service adn_server.service adn_proxy.service adn_parrot.service adn_dashboard" 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 if [ -f "/lib/systemd/system/adn-parrot.service" ]; then rm /lib/systemd/system/adn-parrot.service fi if [ -f "/lib/systemd/system/adn_parrot.service" ]; then rm /lib/systemd/system/adn_parrot.service fi if [ -f "/lib/systemd/system/fdmrparrot.service" ]; then rm /lib/systemd/system/fdmrparrot.service fi if [ -f "/lib/systemd/system/freedmr.service" ]; then rm /lib/systemd/system/freedmr.service fi if [ -f "/opt/FreeDMR/config/FreeDMR.cfg" ]; then mv /opt/FreeDMR/config/FreeDMR.cfg /opt/Old_Config-FreeDMR.cfg fi if [ -d "/opt/FreeDMR" ]; then rm -r /opt/FreeDMR/ fi ########################################################## if [ -d "/var/log/ADN" ];then sudo rm -r /var/log/ADN 2>/dev/null fi if [ -d "/opt/ADN-DMR-Peer-Server" ];then sudo rm -r /opt/ADN-DMR-Peer-Server 2>/dev/null fi if [ -d "/var/www/fdmr2" ];then sudo rm -r /var/www/fdmr2 2>/dev/null fi if [ -d "/opt/FDMR-Monitor2" ];then sudo rm -r /opt/FDMR-Monitor2 2>/dev/null fi if [ -d "/var/www/fdmr" ];then sudo rm -r /var/www/fdmr 2>/dev/null fi if [ -d "/opt/FDMR-Monitor" ];then sudo rm -r /opt/FDMR-Monitor 2>/dev/null fi ############################### if [ -f "/bin/menu-fdmr" ];then rm /bin/menu-fdmr #echo "found file" else echo "file not found" fi ######################## if [ ! -d "/var/www" ] then mkdir -p /var/www fi if [ ! -d "/var/www/fdmr" ] then mkdir -p /var/www/fdmr fi if [ ! -d "/var/www/fdmr2" ] then mkdir -p /var/www/fdmr2 fi if [ ! -d "/var/log/ADN" ] then mkdir -p /var/log/ADN fi ######################## if [ ! -f "/opt/wdp" ]; then cat > /opt/wdp <<- "EOFX" ############################################ # Select number port, ADN-Server Dashboard # ############################################ Web-Dashboar-name: adn Web-Dashboar-Port: 80 Web-Dashboar-dns: Web-Dashboar-dir: /opt/adn-dashboard/html Web-Dashboar-select: fdmr_mon3 Web-Dashboar-soft: /opt/FDMR-Monitor2 EOFX fi if [ -f "/opt/obp.txt" ] then echo "found file" else sudo cat > /opt/obp.txt <<- "EOF" #Coloque abajo su lista de obp y peer EOF 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-* ######################### #lamp #"libapache2-mod-php" apps="mariadb-server 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..." sudo 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 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 if ! systemctl is-active --quiet mariadb.service; then sudo systemctl start mariadb.service fi echo "${commands}" | /usr/bin/mysql -u root ################# #FDMR Server #sudo -H pip3 install --upgrade pip #pip install pyopenssl --upgrade cd /opt git clone https://github.com/Amateur-Digital-Network/ADN-DMR-Peer-Server.git cd ADN-DMR-Peer-Server sudo git checkout develop if [ ! -d "/var/log/ADN" ]; then mkdir /var/log/ADN fi if [ ! -d "/opt/ADN-DMR-Peer-Server/data" ]; then mkdir /opt/ADN-DMR-Peer-Server/data fi if [ "$(ls -A "/opt/ADN-DMR-Peer-Server/data/")" ]; then rm -rf "/opt/ADN-DMR-Peer-Server/data/"* fi sudo chmod -R +x /opt/ADN-DMR-Peer-Server/* sudo chmod -R 777 /opt/ADN-DMR-Peer-Server/* #./install.sh cp /opt/ADN-DMR-Peer-Server/config/ADN-SAMPLE.cfg /opt/ADN-DMR-Peer-Server/config/adn.cfg sed -i "s/SERVER_ID:.*/SERVER_ID: $variable/g" /opt/ADN-DMR-Peer-Server/config/adn.cfg cat /opt/obp.txt >> /opt/ADN-DMR-Peer-Server/config/adn.cfg # cd /opt/ADN-DMR-Peer-Server/ ############# wget https://gitlab.com/hp3icc/FDMR-Monitor2/-/raw/Self_Service/proxy/hotspot_proxy_v2.py -O /opt/ADN-DMR-Peer-Server/hotspot_proxy_v2.py wget https://gitlab.com/hp3icc/FDMR-Monitor2/-/raw/Self_Service/proxy/proxy_SAMPLE.cfg -O /opt/ADN-DMR-Peer-Server/proxy.cfg wget https://gitlab.com/hp3icc/FDMR-Monitor2/-/raw/Self_Service/proxy/proxy_db.py -O /opt/ADN-DMR-Peer-Server/proxy_db.py #################### sed -i "s/db_username =.*/db_username = 'hbmon'/g" /opt/ADN-DMR-Peer-Server/hotspot_proxy_v2.py sed -i "s/db_password =.*/db_password = 'hbmon'/g" /opt/ADN-DMR-Peer-Server/hotspot_proxy_v2.py sed -i "s/db_name =.*/db_name = 'hbmon'/g" /opt/ADN-DMR-Peer-Server/hotspot_proxy_v2.py sed -i "s/\/freedmr.cfg/\/config\/adn.cfg/g" /opt/ADN-DMR-Peer-Server/hotspot_proxy_v2.py sed -i "s/db_selfcare =.*/db_selfcare = ProxyDB('localhost', 'hbmon', 'hbmon', 'hbmon', 3306)/g" /opt/ADN-DMR-Peer-Server/proxy_db.py sed -i "s/USERNAME =.*/USERNAME = hbmon/g" /opt/ADN-DMR-Peer-Server/proxy.cfg sed -i "s/PASSWORD =.*/PASSWORD = hbmon/g" /opt/ADN-DMR-Peer-Server/proxy.cfg sed -i "s/DB_NAME =.*/DB_NAME = hbmon/g" /opt/ADN-DMR-Peer-Server/proxy.cfg sed -i "s/54000/56400/g" /opt/ADN-DMR-Peer-Server/proxy_db.py sed -i "s/54000/56400/g" /opt/ADN-DMR-Peer-Server/proxy.cfg sed -i "s/54100/56499/g" /opt/ADN-DMR-Peer-Server/proxy_db.py sed -i "s/54100/56499/g" /opt/ADN-DMR-Peer-Server/proxy.cfg sed -i "s/54000/56400/g" /opt/ADN-DMR-Peer-Server/hotspot_proxy_v2.py sed -i "s/54100/56499/g" /opt/ADN-DMR-Peer-Server/hotspot_proxy_v2.py sed -i "s/1234567/1234567,1231237,123123701/g" /opt/ADN-DMR-Peer-Server/proxy.cfg #sed -i '228s/20/50/' /opt/ADN-DMR-Peer-Server/hotspot_proxy_v2.py ####################### #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 -R 777 /opt/FDMR-Monitor/* chmod -R +x /opt/FDMR-Monitor/* # sudo chmod 644 /opt/FDMR-Monitor/fdmr-mon_SAMPLE.cfg #### 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 # cd /opt/FDMR-Monitor/ #sudo rm /opt/FDMR-Monitor/install.sh ################ apps=("rrdtool") for app in "${apps[@]}" do # Verificar apps if ! dpkg -s "$app" >/dev/null 2>&1; then # app no instalada sudo apt-get install -y "$app" else # app ya instalada echo "$app ya instalada" fi done sed -i "s/www\/html/www\/fdmr/g" /opt/FDMR-Monitor/html/*.* 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 ############################### #wget -O /opt/FDMR-Monitor/html/img/logo.png https://adn.systems/files/logo1.png #wget -O /opt/FDMR-Monitor/html/favicon.ico https://adn.systems/files/ADN_37x18_01.ico # sudo cat > /opt/FDMR-Monitor/html/buttons.php <<- "EOF" Home