#!/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 / ###################################################################################################################### # Cronedit ###################################################################################################################### sudo cat > /usr/local/bin/cronedit.sh <<- "EOF" #!/bin/bash cronjob_editor () { # usage: cronjob_editor '' '' if [[ -z "$1" ]] ;then printf " no interval specified\n" ;fi if [[ -z "$2" ]] ;then printf " no command specified\n" ;fi if [[ -z "$3" ]] ;then printf " no action specified\n" ;fi if [[ "$3" == add ]] ;then # add cronjob, no duplication: ( sudo crontab -l | grep -v -F -w "$2" ; echo "$1 $2" ) | sudo crontab - elif [[ "$3" == remove ]] ;then # remove cronjob: ( sudo crontab -l | grep -v -F -w "$2" ) | sudo crontab - fi } cronjob_editor "$1" "$2" "$3" EOF sudo chmod +x /usr/local/bin/cronedit.sh if [ -f "/var/www/html/tgcount.php" ]; then sudo systemctl stop apache2 #echo "found file" else echo "file not found" fi if [ -f "/var/www/html/tgcount.php" ]; then sudo systemctl disable apache2 #echo "found file" else echo "file not found" fi 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}') else echo "id not found" fi if [ -z "$variable" ] then variable=0000 fi ################################### if [ -d "/var/log/FreeDMR" ] then sudo rm -rf /var/log/FreeDMR fi if [ -d "/opt/FreeDMR" ] then sudo rm -rf /opt/FreeDMR fi if [ -d "/var/www/fdmr2" ] then sudo rm -rf /var/www/fdmr2 fi if [ -d "/opt/FDMR-Monitor2" ] then sudo rm -rf /opt/FDMR-Monitor2 fi 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 ############################### 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/FreeDMR" ] then mkdir -p /var/log/FreeDMR 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 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 ################# #FDMR Server #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 mkdir config mkdir /var/log/FreeDMR sudo chmod +x /opt/FreeDMR/* #./install.sh 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|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|54000|56400|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 # cp /opt/FreeDMR/FreeDMR-SAMPLE.cfg /opt/FreeDMR-SAMPLE.cfg cd /opt/ cat FreeDMR-SAMPLE.cfg conf.txt obp.txt >> /opt/FreeDMR/config/FreeDMR.cfg sed -i 's/file-timed/console-timed/' /opt/FreeDMR/config/FreeDMR.cfg sed -i 's/INFO/DEBUG/' /opt/FreeDMR/config/FreeDMR.cfg sed -i 's/freedmr.log/\/var\/log\/FreeDMR\/FreeDMR.log/' /opt/FreeDMR/config/FreeDMR.cfg 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 sed -i 's/54915/49061/' /opt/FreeDMR/playback.cfg sudo chmod +x /opt/FreeDMR/config/* ####################### #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 755 /opt/FDMR-Monitor/data # sed -i 's/RELOAD_TIME =.*/RELOAD_TIME = 1/' /opt/FDMR-Monitor/fdmr-mon_SAMPLE.cfg sed -i 's/FREQUENCY =.*/FREQUENCY = 1/' /opt/FDMR-Monitor/fdmr-mon_SAMPLE.cfg sudo chmod 644 /opt/FDMR-Monitor/fdmr-mon_SAMPLE.cfg sed '33 a ' -i /opt/FDMR-Monitor/html/sysinfo.php #### sed -i "s/www\/html/www\/fdmr/g" /opt/FDMR-Monitor/html/*.* sed -i "s/www\/html/www\/fdmr/g" /opt/FDMR-Monitor/sysinfo/*.* sed -i "s/1100/1200/g" /opt/FDMR-Monitor/html/*.* sed -i "s/1100/1200/g" /opt/FDMR-Monitor/html/css/*.* sed -i "s/1100/1200/g" /opt/FDMR-Monitor/templates/*.* sed -i 's/b1eee9/3bb43d/' /opt/FDMR-Monitor/html/css/*.* #### sed -i 's/localhost_2-day.png/localhost_1-day.png/' /opt/FDMR-Monitor/html/sysinfo.php 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 sed -i "s/PRIVATE_NETWORK = True/PRIVATE_NETWORK = False/g" /opt/FDMR-Monitor/fdmr-mon_SAMPLE.cfg 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 ################ 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 ############################### 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 # #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 && # sed '6 a ' -i /opt/FDMR-Monitor/html/index.php #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 && # sudo cat > /opt/FDMR-Monitor/html/buttons.php <<- "EOF" Home   EOF # cp -r /opt/FDMR-Monitor/html/* /var/www/fdmr/ sudo chown www-data:www-data /var/www/fdmr/ -R cp /opt/FDMR-Monitor/utils/logrotate/fdmr_mon /etc/logrotate.d/ sudo cat > /opt/FDMR-Monitor/templates/main_table.html <<- "EOF"
 .: Server Activity :.  {% if _table['MASTERS']|length >0 %} {% for _master in _table['MASTERS'] %} {% for _client, _cdata in _table['MASTERS'][_master]['PEERS'].items() %} {% if _cdata[1]['TS'] == True or _cdata[2]['TS'] == True %} {% if _cdata[1]['TRX'] == "RX" %} {% endif %} {% if _cdata[2]['TRX'] == "RX" %} {% endif %} {% endif %} {% endfor %} {% endfor %} {% else %}
Systems M&P Source Destination
M: {{_master}} {{ _cdata[1]['SUB']|safe }} [TS {{ 1 if _cdata[1]['TS'] == True else 2 }}] {{ _cdata[1]['DEST']|safe }}M: {{_master}} {{ _cdata[2]['SUB']|safe }} [TS {{ 1 if _cdata[1]['TS'] == True else 2 }}] {{ _cdata[2]['DEST']|safe }}
Waiting for Data from FreeDMR Server ...
{% endif %} {% for _peer, _pdata in _table['PEERS'].items() %} {% if _pdata[1]['TS'] == True or _pdata[2]['TS'] == True %} {% if _pdata[1]['TRX'] == "RX" %} P: {{_peer}} {{ _pdata[1]['SUB']|safe }} [TS {{ 1 if _pdata[1]['TS'] == True else 2 }}] {{ _cdata[1]['DEST']|safe }} {% endif %} {% if _pdata[2]['TRX'] == "RX" %} P: {{_peer}} {{ _pdata[2]['SUB']|safe }} [TS {{ 1 if _pdata[1]['TS'] == True else 2 }}] {{ _pdata[2]['DEST']|safe }} {% endif %} {% endif %} {% endfor %}
{% if _table['OPENBRIDGES']|length >0 %} Systems OpenBridge Active Incoming Calls {% for _openbridge in _table['OPENBRIDGES'] %} {% set rx = namespace(value=0) %} {% if _table['OPENBRIDGES'][_openbridge]['STREAMS']|length >0 %} {% for entry in _table['OPENBRIDGES'][_openbridge]['STREAMS'] if _table['OPENBRIDGES'][_openbridge]['STREAMS'][entry][0]=='RX' %} {% set rx.value=1 %} {% endfor %} {% if rx.value == 1 %} {{ _openbridge}} {% for entry in _table['OPENBRIDGES'][_openbridge]['STREAMS'] if _table['OPENBRIDGES'][_openbridge]['STREAMS'][entry][0] == 'RX' %}[{{ _table['OPENBRIDGES'][_openbridge]['STREAMS'][entry][0] }}: {{ _table['OPENBRIDGES'][_openbridge]['STREAMS'][entry][1] }} >> {{ _table['OPENBRIDGES'][_openbridge]['STREAMS'][entry][2] }}]  {% endfor %} {% endif %} {% endif %} {% endfor %} {% endif %}
{% if _table['SETUP']['LASTHEARD'] == True %}
.: Lastheard :. {% for itm in lastheard %} {% if not itm[7] %} {% else %} {% endif %} {% endfor %}
Date Time Callsign (DMR-Id) Name TG# TG Name TX (s) System
{{ itm[0][:10] }} {{ itm[0][11:] }}{{ itm[6] }} {{ itm[7][0] }} ({{ itm[6] }}) {{ itm[7][1] }}{{ itm[4] }} {{ '' if not itm[5] else itm[5]|safe }} {{ 'DATA' if not itm[1] else itm[1]|int }} {{ itm[3] }}
{% endif %}
.: Connected to Server :.
{% if _table['MASTERS']|length >0 %}
  LINKS:
{% for _master in _table['MASTERS'] %} {% if _table['MASTERS'][_master]['PEERS']|length >0 %} {% for _client, _cdata in _table['MASTERS'][_master]['PEERS'].items() %} {{_cdata['CALLSIGN']}}    DMR ID: {{ _client }}
{% if _cdata['RX_FREQ'] == 'N/A' and _cdata['TX_FREQ'] == 'N/A' %}    Type: IP Network
{% else %}    Type: Radio ({{ _cdata['SLOTS'] }})
{% endif %}    Hardware: {{_cdata['PACKAGE_ID'] }}
   Soft_Ver: {{_cdata['SOFTWARE_ID'] }}
   Info: {{_cdata['LOCATION']}}
   Master: {{_master}}
  {% endfor %} {% endif %} {% endfor %}
{% endif %} {% if _table['PEERS']|length >0 %}

PEERS:

{% for _peer, _pdata in _table['PEERS'].items() %}
  {{_peer}}   {% if _table['PEERS'][_peer]['STATS']['CONNECTION'] == 'YES' %} Connected {% else %} Disconnected {% endif %}
{% endfor %}
{% endif %}
EOF # sed -i "s/1100/1200/g" /opt/FDMR-Monitor/templates/*.* #sed -i "s/Copyright (c) 2016-.*/Copyright (c) \"2016\") {\$cdate=\"2016-\".date(\"Y\");} echo \$cdate; ?>
/g" /var/www/fdmr/*.php #sed -i "s/meta name=\"description.*/meta name=\"description\" content=\"Copyright (c) 2016-22.The Regents of the K0USY Group. All rights reserved. Version OA4DOA 2022 (v270422)\">/g" /var/www/fdmr/*.php sed -i '166 s/hotpink/#ad02fd/g' /var/www/fdmr/css/styles.php sed -i '217 s/color:white/color:black/' /var/www/fdmr/css/styles.php sed -i "251d" /var/www/fdmr/css/styles.php sed '250 a ' -i /var/www/fdmr/css/styles.php sed '21 a # For custom color, select: pro' -i /opt/FDMR-Monitor/fdmr-mon.cfg sed '24 a COLOR_TEXT = #fff519' -i /opt/FDMR-Monitor/fdmr-mon.cfg sed '25 a COLOR_1 = #000080' -i /opt/FDMR-Monitor/fdmr-mon.cfg sed '26 a COLOR_2 = #193dff' -i /opt/FDMR-Monitor/fdmr-mon.cfg #sed '27 a COLOR_BACKGROUND = 5a5958' -i /opt/FDMR-Monitor/fdmr-mon.cfg sed '45 a $cd1 = strtolower($config["GLOBAL"]["COLOR_1"]);' -i /var/www/fdmr/include/config.php sed '46 a $cd2 = strtolower($config["GLOBAL"]["COLOR_2"]);' -i /var/www/fdmr/include/config.php sed '47 a $cd3 = strtolower($config["GLOBAL"]["COLOR_TEXT"]);' -i /var/www/fdmr/include/config.php sed '48 a $cd3 = strtolower($config["GLOBAL"]["COLOR_TEXT"]);' -i /var/www/fdmr/include/config.php sed '49 a $cd4 = strtolower($config["GLOBAL"]["COLOR_BACKGROUND"]);' -i /var/www/fdmr/include/config.php sed '66 a } elseif ($theme == "pro") {' -i /var/www/fdmr/include/config.php sed '67 a $tc = "background-image: linear-gradient(to bottom, $cd1 0%, $cd2 100%);color:$cd3;";' -i /var/www/fdmr/include/config.php #sed -i "s/THEME_COLOR =.*/THEME_COLOR = pro/g" /opt/FDMR-Monitor/fdmr-mon.cfg #sed -i "s/TGID_URL =.*/TGID_URL = https:\/\/freedmr.cymru\/talkgroups\/talkgroup_ids_json.php/g" /opt/FDMR-Monitor/fdmr-mon.cfg if [ -f "mon.db" ] then rm mon.db fi cd /opt/FDMR-Monitor python3 mon_db.py --create python3 mon_db.py --update systemctl stop apache2 systemctl disable apache2 ##################### sed -i 's/b1eee9/3bb43d/' /var/www/fdmr/css/*.* #sed -i "s/All rights reserved.
.*/All rights reserved.
, FreeDMR<\/a> by G7RZU hacknix<\/a>, Script project: \"2018\") {\$cdate=\"2018-\".date(\"Y\");} echo \$cdate; ?>\" target=\"_blank\" href=https:\/\/gitlab.com\/hp3icc\/fdmr\/>FDMR+<\/a>
/g" /var/www/fdmr/*.php chmod +x /opt/FDMR-Monitor/sysinfo/* sh /opt/FDMR-Monitor/sysinfo/rrd-db.sh (crontab -l; echo "*/5 * * * * sh /opt/FDMR-Monitor/sysinfo/graph.sh")|awk '!x[$0]++'|crontab - (crontab -l; echo "*/2 * * * * sh /opt/FDMR-Monitor/sysinfo/cpu.sh")|awk '!x[$0]++'|crontab - ################## #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 ######### bash -c "$(curl -fsSLk https://raw.githubusercontent.com/hp3icc/D-APRS/main/emq-daprs.sh)" ######### 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 # sudo 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 # bash -c "$(curl -fsSLk https://gitlab.com/hp3icc/emq-TE1/-/raw/main/menu/menu-fdmr)" ### chmod +x /bin/menu-fdmr ln -sf /bin/menu-fdmr /bin/MENU-FDMR sh /opt/extra-1.sh sh /opt/extra-2.sh #################################################################### #monitor2 cd /opt sudo git clone https://github.com/CS8ABG/FDMR-Monitor.git /opt/FDMR-Monitor2 cd /opt/FDMR-Monitor2 sudo git checkout Self_Service #sudo pip install -U -r requirements.txt chmod 755 /opt/FDMR-Monitor2/data #sed -i '72d' /opt/FDMR-Monitor2/html/include/navbar.php #sed '69 a \ ' -i /opt/FDMR-Monitor2/html/include/navbar.php sudo chmod 644 /opt/FDMR-Monitor/fdmr-mon_SAMPLE.cfg sed -i 's/RELOAD_TIME =.*/RELOAD_TIME = 1/' /opt/FDMR-Monitor2/fdmr-mon_SAMPLE.cfg sed -i 's/FREQUENCY =.*/FREQUENCY = 1/' /opt/FDMR-Monitor2/fdmr-mon_SAMPLE.cfg sed -i "s/LANGUAGE =.*/LANGUAGE = \"es\"/g" /opt/FDMR-Monitor2/fdmr-mon_SAMPLE.cfg sed -i "s/DB_NAME =.*/DB_NAME = hbmon/g" /opt/FDMR-Monitor2/fdmr-mon_SAMPLE.cfg sed -i "s/DB_USERNAME =.*/DB_USERNAME = hbmon/g" /opt/FDMR-Monitor2/fdmr-mon_SAMPLE.cfg sed -i "s/DB_PASSWORD =.*/DB_PASSWORD = hbmon/g" /opt/FDMR-Monitor2/fdmr-mon_SAMPLE.cfg sed -i "s/TELEGRAM/#TELEGRAM/g" /opt/FDMR-Monitor2/fdmr-mon_SAMPLE.cfg sed -i "s/configFile =.*/configFile = '\/opt\/FDMR-Monitor2\/fdmr-mon.cfg';/g" /opt/FDMR-Monitor2/html/config.php sed -i "s/PRIVATE_NETWORK = True/PRIVATE_NETWORK = False/g" /opt/FDMR-Monitor2/fdmr-mon_SAMPLE.cfg variable2=$(date +'%Y' | tail -c 5) #sed -i "s/CS8ABG<\/a> Dash/FDMR-Monitor2<\/a> by
CS8ABG<\/a>, FreeDMR<\/a> by G7RZU hacknix<\/a>, Script project: FDMR+<\/a>/g" /opt/FDMR-Monitor2/html/include/footer.php sed -i "s|PEER_URL =.*|PEER_URL = https://database.radioid.net/static/rptrs.json|g" /opt/FDMR-Monitor2/fdmr-mon_SAMPLE.cfg sed -i "s/SUBSCRIBER_FILE =.*/SUBSCRIBER_FILE = subscriber_ids.json/g" /opt/FDMR-Monitor2/fdmr-mon_SAMPLE.cfg sed -i "s/SUBSCRIBER_URL =.*/SUBSCRIBER_URL = http:\/\/datafiles.ddns.net:8888\/user.json/g" /opt/FDMR-Monitor2/fdmr-mon_SAMPLE.cfg sed -i "s/TGID_URL =.*/TGID_URL = http:\/\/datafiles.ddns.net:8888\/talkgroup_ids.json/g" /opt/FDMR-Monitor2/fdmr-mon_SAMPLE.cfg sed -i "s/FILES_PATH =.*/FILES_PATH = \/opt\/FDMR-Monitor2\/data/g" /opt/FDMR-Monitor2/fdmr-mon_SAMPLE.cfg sed -i "s/#fff/#d1d1d1/g" /opt/FDMR-Monitor2/html/plugins/adminlte/css/adminlte.min.css sed -i "s/f8f9fa/d0d0d0/g" /opt/FDMR-Monitor2/html/plugins/adminlte/css/adminlte.min.css sed -i "s/configFile =.*/configFile = '\/opt\/FDMR-Monitor2\/fdmr-mon.cfg';/g" /opt/FDMR-Monitor2/html/ssconfunc.php #sed -i "s/configFile =.*/configFile = '\/opt\/FDMR-Monitor2\/fdmr-mon.cfg';/g" /var/www/fdmr2/ssconfunc.php 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 "s228/20/50/g" /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 wget -q --no-check-certificate -r 'https://docs.google.com/uc?export=download&id=1cWqClH0FUxV5d-rVnibI_-iCypFnTDb3' -O /opt/FDMR-Monitor2/html/img/bk.jpg && wget -q --no-check-certificate -r 'https://docs.google.com/uc?export=download&id=1vsviKjpZmL_mWVEW2UstNODGPl8-uNVo' -O /opt/flags.zip && sudo unzip -o /opt/flags.zip -d /opt/FDMR-Monitor2/html/flags/ && rm /opt/flags.zip cp fdmr-mon_SAMPLE.cfg fdmr-mon.cfg sudo chmod 644 fdmr-mon.cfg sudo cp /opt/FDMR-Monitor2/html/* /var/www/fdmr2/ -r #***** mv /opt/FDMR-Monitor2/utils/logrotate/fdmr_mon /opt/FDMR-Monitor2/utils/logrotate/fdmr_mon2 mv /opt/FDMR-Monitor2/utils/systemd/fdmr_mon.service /opt/FDMR-Monitor2/utils/systemd/fdmr_mon2.service # \ sed -i "s/\/.*/\/opt\/FDMR-Monitor2\/log\/fdmr-mon.log {/g" /opt/FDMR-Monitor2/utils/logrotate/fdmr_mon2 sed -i "s/Description=.*/Description=FDMR Monitor2/g" /opt/FDMR-Monitor2/utils/systemd/fdmr_mon2.service sed -i "s/WorkingDirectory=.*/WorkingDirectory=\/opt\/FDMR-Monitor2/g" /opt/FDMR-Monitor2/utils/systemd/fdmr_mon2.service sed -i "s/ExecStart=.*/ExecStart=python3 \/opt\/FDMR-Monitor2\/monitor.py/g" /opt/FDMR-Monitor2/utils/systemd/fdmr_mon2.service sudo cp /opt/FDMR-Monitor2/utils/logrotate/fdmr_mon2 /etc/logrotate.d/fdmr_mon2 #sudo cp /opt/FDMR-Monitor2/utils/systemd/fdmr_mon2.service /lib/systemd/system/fdmr_mon2.service #sudo rm mon.db ############################################################## # service update ############################################################ cat > /lib/systemd/system/fdmr_mon2.service <<- "EOF" [Unit] Description=FDMR Monitor2 # 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-Monitor2 ExecStart=python3 /opt/FDMR-Monitor2/monitor.py #Restart=on-abort #Restart=on-failure [Install] WantedBy=multi-user.target EOF # if systemctl status mariadb.service |grep inactive >/dev/null 2>&1 then sudo systemctl start mariadb.service fi if systemctl status mariadb.service |grep disable >/dev/null 2>&1 then sudo systemctl enable mariadb.service fi if [ -f "mon.db" ] then rm mon.db fi cd /opt/FDMR-Monitor2 #python3 mon_db.py --create #python3 mon_db.py --update ############################# sudo systemctl daemon-reload