From 6fc8fa84a0bc944058fff04bd2c45db402f0ae0b Mon Sep 17 00:00:00 2001 From: Esteban Mackay Q Date: Fri, 28 Jul 2023 07:27:19 -0500 Subject: [PATCH] Update update.sh --- update.sh | 81 +++++++++++++++++++++++++++++++------------------------ 1 file changed, 46 insertions(+), 35 deletions(-) diff --git a/update.sh b/update.sh index d311339..76674b7 100644 --- a/update.sh +++ b/update.sh @@ -450,12 +450,9 @@ 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) -cronedit.sh '*/5 * * * *' 'sh /opt/FDMR-Monitor/sysinfo/graph.sh' remove -cronedit.sh '*/2 * * * *' 'sh /opt/FDMR-Monitor/sysinfo/cpu.sh' remove -cronedit.sh '* */24 * * *' 'rm /opt/FDMR-Monitor/data/*' remove -cronedit.sh '* */24 * * *' 'rm /opt/FDMR-Monitor2/data/*' remove ##################################### -if systemctl status http.server-fdmr2.service |grep active >/dev/null 2>&1 + +if systemctl status http.server-fdmr2.service |grep "active" >/dev/null 2>&1 then systemctl stop http.server-fdmr2.service fi @@ -471,7 +468,7 @@ if systemctl status fdmr_mon.service |grep active >/dev/null 2>&1 then sudo systemctl stop fdmr_mon.service fi -if systemctl status proxy.service |grep active >/dev/null 2>&1 +if systemctl status proxy.service |grep "active" >/dev/null 2>&1 then sudo systemctl stop proxy.service fi @@ -903,6 +900,15 @@ sh /opt/FDMR-Monitor/sysinfo/rrd-db.sh systemctl daemon-reload +############## +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 systemctl status http.server-fdmr2.service |grep "service; enabled;" >/dev/null 2>&1 then sudo systemctl disable http.server-fdmr2.service @@ -922,9 +928,9 @@ if ! systemctl status proxy.service | grep "service; enabled;" >/dev/null 2>&1; sudo systemctl enable proxy.service fi + ############## -if sudo systemctl status http.server-fdmr.service |grep "service; enabled;" >/dev/null 2>&1 -then + variable1=$(grep "Web-Dashboar-Port:" /opt/wdp | grep -Eo '[A.0-9]{1,9}') && if [ -z "$variable1" ] then variable1=80 @@ -933,11 +939,12 @@ then sudo sed -i "s/ExecStart=.*/ExecStart=php -S 0.0.0.0:$variable1 -t \/var\/www\/fdmr\//g" /lib/systemd/system/http.server-fdmr.service && sudo sed -i "s/ExecStart=.*/ExecStart=php -S 0.0.0.0:$variable1 -t \/var\/www\/fdmr2\//g" /lib/systemd/system/http.server-fdmr2.service && systemctl daemon-reload && - systemctl restart fdmr_mon.service - systemctl restart proxy.service - systemctl restart http.server-fdmr.service + systemctl start fdmr_mon.service + systemctl start proxy.service + systemctl start http.server-fdmr.service sh /opt/extra-2.sh -fi + +(crontab -l; echo "* */1 * * * sync ; echo 3 > /proc/sys/vm/drop_caches >/dev/null 2>&1")|awk '!x[$0]++'|crontab - cronedit.sh '*/5 * * * *' 'sh /opt/FDMR-Monitor/sysinfo/graph.sh' add && cronedit.sh '*/2 * * * *' 'sh /opt/FDMR-Monitor/sysinfo/cpu.sh' add && cronedit.sh '*/5 * * * *' 'sh /etc/freedmr/hbmon/sysinfo/graph.sh' remove && @@ -950,7 +957,7 @@ EOFB1 ######################################### FDMR-Monitor2 Update ############################################################### sudo cat > /opt/monitor-update2.sh <<- "EOFB2" #!/bin/bash -if systemctl status http.server-fdmr.service |grep active >/dev/null 2>&1 +if systemctl status http.server-fdmr.service |grep "active" >/dev/null 2>&1 then systemctl stop http.server-fdmr.service fi @@ -966,7 +973,7 @@ if systemctl status fdmr_mon2.service |grep active >/dev/null 2>&1 then sudo systemctl stop fdmr_mon2.service fi -if systemctl status proxy.service |grep active >/dev/null 2>&1 +if systemctl status proxy.service |grep "active" >/dev/null 2>&1 then sudo systemctl stop proxy.service fi @@ -1074,20 +1081,24 @@ Restart=on-failure WantedBy=multi-user.target EOF -variable1=$(grep "Web-Dashboar-Port:" /opt/wdp | grep -Eo '[A.0-9]{1,9}') && -if [ -z "$variable1" ] -then variable1=80 -fi && -sudo sed -i "s/ExecStart=.*/ExecStart=php -S 0.0.0.0:$variable1 -t \/var\/www\/fdmr\//g" /lib/systemd/system/http.server-fdmr.service && -sudo sed -i "s/ExecStart=.*/ExecStart=php -S 0.0.0.0:$variable1 -t \/var\/www\/fdmr2\//g" /lib/systemd/system/http.server-fdmr2.service && -systemctl daemon-reload && +##################################### + +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 systemctl status http.server-fdmr.service |grep "service; enabled;" >/dev/null 2>&1 then sudo systemctl disable http.server-fdmr.service fi if ! systemctl status http.server-fdmr2.service | grep "service; enabled;" >/dev/null 2>&1; then sudo systemctl enable http.server-fdmr2.service + fi if systemctl status fdmr_mon.service |grep "service; enabled;" >/dev/null 2>&1 then sudo systemctl disable fdmr_mon.service @@ -1100,22 +1111,22 @@ if ! systemctl status proxy.service | grep "service; enabled;" >/dev/null 2>&1; sudo systemctl enable proxy.service fi -##################################### -if sudo systemctl status http.server-fdmr.service |grep "service; enabled;" >/dev/null 2>&1 -then - variable1=$(grep "Web-Dashboar-Port:" /opt/wdp | grep -Eo '[A.0-9]{1,9}') && - if [ -z "$variable1" ] - then variable1=80 - fi && - sudo sed -i "s/ExecStart=.*/ExecStart=php -S 0.0.0.0:$variable1 -t \/var\/www\/fdmr\//g" /lib/systemd/system/http.server-fdmr.service && - sudo sed -i "s/ExecStart=.*/ExecStart=php -S 0.0.0.0:$variable1 -t \/var\/www\/fdmr2\//g" /lib/systemd/system/http.server-fdmr2.service && - systemctl daemon-reload && - systemctl restart fdmr_mon2.service - systemctl restart proxy.service - systemctl restart http.server-fdmr2.service +variable1=$(grep "Web-Dashboar-Port:" /opt/wdp | grep -Eo '[A.0-9]{1,9}') && +if [ -z "$variable1" ] +then variable1=80 + +fi && +sudo sed -i "s/ExecStart=.*/ExecStart=php -S 0.0.0.0:$variable1 -t \/var\/www\/fdmr\//g" /lib/systemd/system/http.server-fdmr.service && +sudo sed -i "s/ExecStart=.*/ExecStart=php -S 0.0.0.0:$variable1 -t \/var\/www\/fdmr2\//g" /lib/systemd/system/http.server-fdmr2.service && +systemctl daemon-reload && + + systemctl start fdmr_mon2.service + systemctl start proxy.service + systemctl start http.server-fdmr2.service sh /opt/extra-2.sh -fi + +(crontab -l; echo "* */1 * * * sync ; echo 3 > /proc/sys/vm/drop_caches >/dev/null 2>&1")|awk '!x[$0]++'|crontab - cronedit.sh '*/5 * * * *' 'sh /opt/FDMR-Monitor/sysinfo/graph.sh' remove && cronedit.sh '*/2 * * * *' 'sh /opt/FDMR-Monitor/sysinfo/cpu.sh' remove && cronedit.sh '*/5 * * * *' 'sh /etc/freedmr/hbmon/sysinfo/graph.sh' remove &&