#!/bin/bash
# Nombre del script
SCRIPT_NAME="dvswitch.sh"

# Registra el inicio en /opt/curl.txt
echo "Inicio: $SCRIPT_NAME" >> /opt/curl.txt
#############################################################################################################################
#                                                           dvswitch
#############################################################################################################################
bash -c "$(curl -fsSLk https://gitlab.com/hp3icc/Easy-DVSwitch/-/raw/main/install.sh)"
if [ -d "/var/www/dvs" ]; then
  rm -r /var/www/dvs
fi
mkdir /var/www/dvs
mv /var/www/html/* /var/www/dvs/ &&
#sed -i "s/'UTC'/'Africa\/Lagos'/"  /var/www/dvs/include/*.php
sed -i "s/www\/html/www\/dvs/g" /var/www/dvs/include/* &&
#sed -i "s/usrp.duckdns.org\/user.csv/datafiles.ddns.net:8888\/user.csv/g" /var/www/dvs/include/* &&
sed -i "s/Dashboard based on Pi-Star Dashboard, © Andy Taylor.*/Dashboard based on Pi-Star Dashboard, © Andy Taylor (MW0MWZ) and adapted to DVSwitch by SP2ONG<br> <a title=\"Script Proyect by HP3ICC © <?php \$cdate=date(\"Y\"); if (\$cdate > \"2018\") {\$cdate=\"2018-\".date(\"Y\");} echo \$cdate; ?>\" target=\"_blank\" href=https:\/\/gitlab.com\/hp3icc\/emq-TE1\/>Script project: emq-TE1+<\/a><\/span><\/center>/" /var/www/dvs/index.php &&
sed -i "s/<meta name=\"Description\".*/<meta name=\"Description\" content=\"Dashboard based on Pi-Star Dashboard, © Andy Taylor (MW0MWZ) and adapted to DVSwitch by SP2ONG\" \/>/" /var/www/dvs/index.php &&
sed -i "s/www\/html/www\/dvs/g" /usr/local/sbin/update-config.sh
sed -i "s/www\/html/www\/dvs/g" /var/lib/dpkg/info/dvswitch*
#####
sudo systemctl daemon-reload
sudo systemctl disable lighttpd.service
sudo systemctl stop lighttpd.service
sudo systemctl stop md380-emu.service
sudo systemctl stop analog_bridge.service
sudo systemctl stop mmdvm_bridge.service
sudo systemctl stop nxdngateway.service
sudo systemctl stop p25gateway.service
sudo systemctl stop ysfgateway.service
sudo systemctl stop quantar_bridge.service
sudo systemctl stop ircddbgatewayd.service
sudo systemctl stop p25parrot.service
sudo systemctl stop ysfparrot.service
sudo systemctl stop nxdnparrot.service
sudo systemctl stop monit.service
sudo systemctl stop webproxy.service
sudo systemctl disable md380-emu.service
sudo systemctl disable analog_bridge.service
sudo systemctl disable mmdvm_bridge.service
sudo systemctl disable nxdngateway.service
sudo systemctl disable p25gateway.service
sudo systemctl disable ysfgateway.service
sudo systemctl disable quantar_bridge.service
sudo systemctl disable ircddbgatewayd.service
sudo systemctl disable p25parrot.service
sudo systemctl disable ysfparrot.service
sudo systemctl disable nxdnparrot.service
sudo systemctl disable monit.service
sudo systemctl disable webproxy.service
#
systemctl daemon-reload 
# Registra el final en /opt/curl.txt
echo "Finalizado: $SCRIPT_NAME" >> /opt/curl.txt
