diff --git a/install/p25.sh b/install/p25.sh index ee3a768..8f18883 100644 --- a/install/p25.sh +++ b/install/p25.sh @@ -7,17 +7,18 @@ if [ -d "/opt/P25Reflector" ] then sudo rm -r /opt/P25Reflector fi -if [ -d "/var/log/p25reflector" ] +if [ -d "/var/log/P25Reflector" ] then - sudo rm -rf /var/log/p25reflector + sudo rm -rf /var/log/P25Reflector fi -mkdir /var/log/p25reflector -sudo chmod 777 /var/log/p25reflector +mkdir /var/log/P25Reflector +sudo chmod 777 /var/log/P25Reflector cd /opt git clone https://github.com/nostar/DVReflectors.git mv /opt/DVReflectors/P25Reflector /opt/ cd /opt/P25Reflector/ make clean all +make install sudo groupadd mmdvm sudo useradd mmdvm -g mmdvm -s /sbin/nologin sudo chmod +x * @@ -25,39 +26,10 @@ sudo rm -r /opt/DVReflectors #cp P25Reflector.sh /usr/local/bin/P25Reflector.sh #sudo chmod +x /usr/local/bin/P25Reflector.sh #sudo sed -i "s/PROG_ARGS=.*/PROG_ARGS=\"\/opt\/P25Reflector\/P25Reflector.ini\"/g" /usr/local/bin/P25Reflector.sh -#sudo sed -i "s/FilePath=.*/FilePath=\/var\/log\/p25reflector/g" /opt/P25Reflector/P25Reflector.ini -#sudo sed -i "s/Name=.*/Name=\/opt\/data-files\/DMRIds.dat/g" /opt/P25Reflector/P25Reflector.ini +sudo sed -i "s/FilePath=.*/FilePath=\/var\/log\/P25Reflector/g" /opt/P25Reflector/P25Reflector.ini +sudo sed -i "s/Name=.*/Name=\/opt\/data-files\/DMRIds.dat/g" /opt/P25Reflector/P25Reflector.ini #sudo sed -i "s/Daemon=.*/Daemon=0/g" /opt/P25Reflector/P25Reflector.ini - -sudo cat > /opt/P25Reflector/P25Reflector.ini <<- "EOF" -[General] -Daemon=0 - -[Info] -Name= P25Reflector -# 14 characters max -Description= Reflector_description -Contact= -Web= - -[Id Lookup] -Name=/opt/data-files/DMRIds.dat -Time=24 - -[Log] -# Logging levels, 0=No logging -DisplayLevel=1 -FileLevel=1 -FilePath=/var/log/p25reflector -FileRoot=P25Reflector -FileRotate=1 - -[Network] -Port=41000 -Debug=0 - -EOF - +cp /opt/P25Reflector/P25Reflector.ini /etc/P25Reflector.ini #/usr/local/bin/P25Reflector.sh stop sudo cat > /lib/systemd/system/P25Reflector.service <<- "EOF" [Unit] @@ -76,7 +48,7 @@ RestartSec=3 StandardOutput=null WorkingDirectory=/opt/P25Reflector #ExecStartPre = /bin/sh -c 'echo "Starting P25Reflector: [`date +%%T.%%3N`]" >> /var/log/netcheck' -ExecStart=/opt/P25Reflector/P25Reflector /opt/P25Reflector/P25Reflector.ini +ExecStart=/usr/local/bin/P25Reflector /etc/P25Reflector.ini ExecReload=/bin/kill -HUP $MAINPID KillMode=process @@ -102,12 +74,42 @@ Web-Dashboar-Port: 80 EOFX fi -if [ -d "/opt/p25reflector-dashboard" ] +if [ -d "/opt/P25Reflector-Dashboard" ] then - sudo rm -r /opt/p25reflector-dashboard + sudo rm -r /opt/P25Reflector-Dashboard +fi +if [ -d "/var/www/p25" ] +then + sudo rm -r /var/www/p25 fi cd /opt -git clone https://gitlab.com/hp3icc/p25reflector-dashboard.git /opt/p25reflector-dashboard +#git clone https://gitlab.com/hp3icc/p25reflector-dashboard.git /opt/p25reflector-dashboard +git clone https://github.com/ShaYmez/P25Reflector-Dashboard.git +if [ ! -d "/opt/P25Reflector-Dashboard/config" ] +then + mkdir /opt/P25Reflector-Dashboard/config +fi +sudo cat > /opt/P25Reflector-Dashboard/config/config.php <<- "EOF" + + +EOF #!/bin/bash # Obtener la zona horaria del sistema @@ -117,11 +119,15 @@ timezone=$(timedatectl show --property=Timezone --value) timezone_escaped=$(echo "$timezone" | sed 's/\//\\\//g') # Actualizar el archivo de configuración con la zona horaria -sudo sed -i "s/define(\"TIMEZONE.*/define(\"TIMEZONE\", \"$timezone_escaped\");/g" /opt/p25reflector-dashboard/config/config.php - -#echo "La zona horaria se ha actualizado a $timezone en el archivo de configuración." -sudo sed -i "s/define(\"P25REFLECTORLOGPATH.*/define(\"P25REFLECTORLOGPATH\", \"\/var\/log\/p25reflector\");/g" /opt/p25reflector-dashboard/config/config.php +sudo sed -i "s/define(\"TIMEZONE.*/define(\"TIMEZONE\", \"$timezone_escaped\");/g" /opt/P25Reflector-Dashboard/config/config.php # +mkdir /var/www/p25 +sudo cp -R /opt/P25Reflector-Dashboard/* /var/www/p25/ +rm /var/www/p25/setup.php +sudo chown -R www-data:www-data /var/www/p25 +sudo chmod -R 775 /var/www/p25 + + sudo cat > /lib/systemd/system/http.server-p25.service <<- "EOF" [Unit] Description=PHP http.server.p25 @@ -131,7 +137,7 @@ After=network.target User=root #ExecStartPre=/bin/sleep 30 # Modify for different other port -ExecStart=php -S 0.0.0.0:80 -t /opt/p25reflector-dashboard +ExecStart=php -S 0.0.0.0:80 -t /var/www/p25 [Install] WantedBy=multi-user.target diff --git a/menu/menu-dvs b/menu/menu-dvs index 9cee7d5..048264f 100644 --- a/menu/menu-dvs +++ b/menu/menu-dvs @@ -113,11 +113,16 @@ else if ! sudo systemctl status http.server-dvs.service |grep "service; enabled;" >/dev/null 2>&1 then sudo systemctl enable http.server-dvs.service + sudo systemctl start http.server-dvs.service + if ! sudo systemctl status webproxy.service |grep "service; enabled;" >/dev/null 2>&1 + then + sudo systemctl enable webproxy.service + sudo systemctl restart webproxy.service + fi fi - sudo systemctl start http.server-dvs.service fi ;; 6) -sudo systemctl stop http.server-dvs.service && sudo systemctl disable http.server-dvs.service ;; +sudo systemctl stop http.server-dvs.service && sudo systemctl disable http.server-dvs.service && sudo systemctl disable webproxy.service && sudo systemctl stop webproxy.service ;; 7) cp /opt/index-dvs.txt /var/www/dvs/index.php && bash -c "$(curl -fsSL https://gitlab.com/hp3icc/emq-TE1/-/raw/main/menu/dvs-nb.sh)" && @@ -142,8 +147,13 @@ else if ! sudo systemctl status http.server-dvs.service |grep "service; enabled;" >/dev/null 2>&1 then sudo systemctl enable http.server-dvs.service + sudo systemctl restart http.server-dvs.service + if ! sudo systemctl status webproxy.service |grep "service; enabled;" >/dev/null 2>&1 + then + sudo systemctl enable webproxy.service + sudo systemctl restart webproxy.service + fi fi - sudo systemctl start http.server-dvs.service fi ;; 8) break; @@ -233,6 +243,11 @@ else if sudo systemctl status http.server-dvs.service |grep "service; enabled;" >/dev/null 2>&1 then sudo systemctl start http.server-dvs.service + if ! sudo systemctl status webproxy.service |grep "service; enabled;" >/dev/null 2>&1 + then + sudo systemctl enable webproxy.service + sudo systemctl restart webproxy.service + fi fi fi ;; 6) @@ -258,11 +273,16 @@ else if ! sudo systemctl status http.server-dvs.service |grep "service; enabled;" >/dev/null 2>&1 then sudo systemctl enable http.server-dvs.service + sudo systemctl restart http.server-dvs.service + if ! sudo systemctl status webproxy.service |grep "service; enabled;" >/dev/null 2>&1 + then + sudo systemctl enable webproxy.service + sudo systemctl restart webproxy.service + fi fi - sudo systemctl start http.server-dvs.service fi ;; 7) -sudo systemctl stop http.server-dvs.service && sudo systemctl disable http.server-dvs.service ;; +sudo systemctl stop http.server-dvs.service && sudo systemctl disable http.server-dvs.service && sudo systemctl disable webproxy.service && sudo systemctl stop webproxy.service ;; 8) cp /opt/index-dvs.txt /var/www/dvs/index.php && bash -c "$(curl -fsSL https://gitlab.com/hp3icc/emq-TE1/-/raw/main/menu/dvs-nb.sh)" && @@ -287,8 +307,13 @@ else if ! sudo systemctl status http.server-dvs.service |grep "service; enabled;" >/dev/null 2>&1 then sudo systemctl enable http.server-dvs.service + sudo systemctl restart http.server-dvs.service + if ! sudo systemctl status webproxy.service |grep "service; enabled;" >/dev/null 2>&1 + then + sudo systemctl enable webproxy.service + sudo systemctl restart webproxy.service + fi fi - sudo systemctl start http.server-dvs.service fi ;; 9) break; diff --git a/menu/menu-p25r b/menu/menu-p25r index 67b9bf8..74a462f 100644 --- a/menu/menu-p25r +++ b/menu/menu-p25r @@ -22,8 +22,9 @@ choix=$(whiptail --title "Raspbian Proyect HP3ICC Menu P25Reflector" --menu "Sub 4 " Dashboard on " \ 5 " Dashboard off " \ 6 " Editar Puerto http " \ -7 " Editar HTML " \ -8 " Menu Principal " 3>&1 1>&2 2>&3) +7 " enable setup.php " \ +8 " remove setup.php " \ +9 " Menu Principal " 3>&1 1>&2 2>&3) exitstatus=$? #on recupere ce choix #exitstatus=$? @@ -35,16 +36,17 @@ fi # case : action en fonction du choix case $choix in 1) -sudo nano /opt/P25Reflector/P25Reflector.ini ;; +sudo nano /etc/P25Reflector.ini ;; 2) sudo systemctl stop P25Reflector.service && if ! sudo systemctl status P25Reflector.service |grep "service; enabled;" >/dev/null 2>&1 then sudo systemctl enable P25Reflector.service fi -if ! systemctl status P25Reflector.service |grep "Active: active" >/dev/null 2>&1 +if systemctl status P25Reflector.service |grep "Active: active" >/dev/null 2>&1 then sudo systemctl restart P25Reflector.service - + else + sudo systemctl start P25Reflector.service fi ;; 3) sudo systemctl stop P25Reflector.service && sudo systemctl disable P25Reflector.service ;; @@ -62,7 +64,7 @@ if [ -z "$variable80" ] then variable80=80 fi -sudo sed -i "s/ExecStart=.*/ExecStart=php -S 0.0.0.0:$variable80 -t \/opt\/p25reflector-dashboard/g" /lib/systemd/system/http.server-p25.service && +sudo sed -i "s/ExecStart=.*/ExecStart=php -S 0.0.0.0:$variable80 -t \/var\/www\/p25/g" /lib/systemd/system/http.server-p25.service && systemctl daemon-reload && if sudo netstat -tuln | grep -q "0.0.0.0:$variable80 "; then whiptail --title "Check Port" --msgbox "El puerto $variable80 esta ocupado , The port $variable80 is busy" 0 50 @@ -86,7 +88,7 @@ if [ -z "$variable80" ] then variable80=80 fi -sudo sed -i "s/ExecStart=.*/ExecStart=php -S 0.0.0.0:$variable80 -t \/opt\/p25reflector-dashboard/g" /lib/systemd/system/http.server-p25.service && +sudo sed -i "s/ExecStart=.*/ExecStart=php -S 0.0.0.0:$variable80 -t \/var\/www\/p25/g" /lib/systemd/system/http.server-p25.service && systemctl daemon-reload && if sudo netstat -tuln | grep -q "0.0.0.0:$variable80 "; then whiptail --title "Check Port" --msgbox "El puerto $variable80 esta ocupado , The port $variable80 is busy" 0 50 @@ -97,8 +99,17 @@ else fi fi ;; 7) -sudo nano /opt/p25reflector-dashboard/index.php ;; +cp /opt/P25Reflector-Dashboard/setup.php /var/www/p25/setup.php && +whiptail --title "P25Reflector" --msgbox "setup.php is ready to use, refresh your browser / Setup.php esta lista para usar, actualiza tu navegador" 0 50 ;; 8) +if [ -f "/var/www/p25/setup.php" ] + then + rm /var/www/p25/setup.php + whiptail --title "P25Reflector" --msgbox "setup.php has removed / setup.php a sido removido" 0 50 + else + whiptail --title "P25Reflector" --msgbox "setup.php is not enabled / setup.php no esta habilitado" 0 50 +fi ;; +9) break; esac done