update
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
VERS='3.03222023'
|
VERS='3.03232023'
|
||||||
|
|
||||||
MMFOLDER="/opt/idssys/mediamanager"
|
MMFOLDER="/opt/idssys/mediamanager"
|
||||||
MMSRV=$(/sbin/ip -o -4 addr list eth0 | awk '{print $4}' | cut -d/ -f1)
|
MMSRV=$(/sbin/ip -o -4 addr list eth0 | awk '{print $4}' | cut -d/ -f1)
|
||||||
|
|||||||
@@ -49,6 +49,8 @@ MMSTART(){
|
|||||||
GOFORSTART=true;
|
GOFORSTART=true;
|
||||||
echo "$(date) - Attempting to restart systems after VPN failure..." >> $logfile
|
echo "$(date) - Attempting to restart systems after VPN failure..." >> $logfile
|
||||||
echo -e "${idsCL[LightCyan]}Attempting to restart systems after VPN failure...${idsCL[Default]}"
|
echo -e "${idsCL[LightCyan]}Attempting to restart systems after VPN failure...${idsCL[Default]}"
|
||||||
|
SENDNOTICE "Attempting to start systems after VPN failure..."
|
||||||
|
|
||||||
else
|
else
|
||||||
GOFORSTART=false;
|
GOFORSTART=false;
|
||||||
|
|
||||||
@@ -115,8 +117,8 @@ PersistentKeepalive = 25" >> /etc/wireguard/${VPN_INTERFACE}.conf
|
|||||||
rm -f ${MMFOLDER}/mm.vpn.fail
|
rm -f ${MMFOLDER}/mm.vpn.fail
|
||||||
MMSTOP
|
MMSTOP
|
||||||
sleep 5m
|
sleep 5m
|
||||||
"${VPN_START[@]}" >/dev/null 2>&1
|
# "${VPN_START[@]}" >/dev/null 2>&1
|
||||||
sleep 10s
|
# sleep 10s
|
||||||
rm -f ${MMFOLDER}/mm.stop*
|
rm -f ${MMFOLDER}/mm.stop*
|
||||||
[ $VERBOSE = true ] && DEBUGLOGSTOP
|
[ $VERBOSE = true ] && DEBUGLOGSTOP
|
||||||
exit 1
|
exit 1
|
||||||
@@ -133,8 +135,8 @@ PersistentKeepalive = 25" >> /etc/wireguard/${VPN_INTERFACE}.conf
|
|||||||
touch ${MMFOLDER}/mm.vpn.fail
|
touch ${MMFOLDER}/mm.vpn.fail
|
||||||
MMSTOP
|
MMSTOP
|
||||||
sleep 30s
|
sleep 30s
|
||||||
"${VPN_START[@]}" >/dev/null 2>&1
|
# "${VPN_START[@]}" >/dev/null 2>&1
|
||||||
sleep 10s
|
# sleep 10s
|
||||||
rm -f ${MMFOLDER}/mm.stop*
|
rm -f ${MMFOLDER}/mm.stop*
|
||||||
[ $VERBOSE = true ] && DEBUGLOGSTOP
|
[ $VERBOSE = true ] && DEBUGLOGSTOP
|
||||||
exit 1
|
exit 1
|
||||||
@@ -179,8 +181,8 @@ PersistentKeepalive = 25" >> /etc/wireguard/${VPN_INTERFACE}.conf
|
|||||||
touch ${MMFOLDER}/mm.vpn.fail
|
touch ${MMFOLDER}/mm.vpn.fail
|
||||||
MMSTOP
|
MMSTOP
|
||||||
sleep 30s
|
sleep 30s
|
||||||
"${VPN_START[@]}" >/dev/null 2>&1
|
# "${VPN_START[@]}" >/dev/null 2>&1
|
||||||
sleep 10s
|
# sleep 10s
|
||||||
rm -f ${MMFOLDER}/mm.stop*
|
rm -f ${MMFOLDER}/mm.stop*
|
||||||
[ $VERBOSE = true ] && DEBUGLOGSTOP
|
[ $VERBOSE = true ] && DEBUGLOGSTOP
|
||||||
exit 1
|
exit 1
|
||||||
@@ -230,8 +232,8 @@ PersistentKeepalive = 25" >> /etc/wireguard/${VPN_INTERFACE}.conf
|
|||||||
touch ${MMFOLDER}/mm.vpn.fail
|
touch ${MMFOLDER}/mm.vpn.fail
|
||||||
MMSTOP
|
MMSTOP
|
||||||
sleep 30s
|
sleep 30s
|
||||||
"${VPN_START[@]}" >/dev/null 2>&1
|
# "${VPN_START[@]}" >/dev/null 2>&1
|
||||||
sleep 10s
|
# sleep 10s
|
||||||
rm -f ${MMFOLDER}/mm.stop*
|
rm -f ${MMFOLDER}/mm.stop*
|
||||||
[ $VERBOSE = true ] && DEBUGLOGSTOP
|
[ $VERBOSE = true ] && DEBUGLOGSTOP
|
||||||
exit 1
|
exit 1
|
||||||
@@ -322,6 +324,14 @@ MMSTOP(){
|
|||||||
fi
|
fi
|
||||||
echo
|
echo
|
||||||
touch ${MMFOLDER}/mm.stop
|
touch ${MMFOLDER}/mm.stop
|
||||||
|
|
||||||
|
echo -en "${idsCL[LightCyan]}Stopping background MM scripts... ${idsCL[Default]}"
|
||||||
|
getMMbash=$(pgrep -f '/mm')
|
||||||
|
for i in $getMMbash; do
|
||||||
|
/bin/kill $i
|
||||||
|
done
|
||||||
|
echo -e "${idsCL[Green]} done${idsCL[Default]}"
|
||||||
|
|
||||||
echo -en "${idsCL[LightCyan]}Stopping Services... ${idsCL[Default]}"
|
echo -en "${idsCL[LightCyan]}Stopping Services... ${idsCL[Default]}"
|
||||||
#for srvc in "${SERVICES_CHECK[@]}"; do
|
#for srvc in "${SERVICES_CHECK[@]}"; do
|
||||||
for i in "${!NM_SERVICES[@]}"; do
|
for i in "${!NM_SERVICES[@]}"; do
|
||||||
@@ -366,9 +376,11 @@ MMSTOP(){
|
|||||||
done
|
done
|
||||||
|
|
||||||
[ "$(/sbin/ip route show | grep default | cut -d' ' -f 3)" != "10.10.0.1" ] && /bin/ip route add default via 10.10.0.1 && ip route del $(cat ${MMFOLDER}/vpninfo.address)
|
[ "$(/sbin/ip route show | grep default | cut -d' ' -f 3)" != "10.10.0.1" ] && /bin/ip route add default via 10.10.0.1 && ip route del $(cat ${MMFOLDER}/vpninfo.address)
|
||||||
|
[ $VERBOSE = true ] && echo "$(date) - Added default route back in" >> $logfile
|
||||||
|
|
||||||
rm -f ${MMFOLDER}/vpninfo.*
|
rm -f ${MMFOLDER}/vpninfo.*
|
||||||
rm -f ${MMFOLDER}/noservices*
|
rm -f ${MMFOLDER}/noservices*
|
||||||
[ $VERBOSE = true ] && echo "$(date) - Added default route back in" >> $logfile
|
rm -f ${MMFOLDER}/mm.stop.checking
|
||||||
|
|
||||||
echo -e "${idsCL[Green]} done${idsCL[Default]}"
|
echo -e "${idsCL[Green]} done${idsCL[Default]}"
|
||||||
echo "$(date) - Media Management systems stopped" >> $logfile
|
echo "$(date) - Media Management systems stopped" >> $logfile
|
||||||
@@ -406,16 +418,19 @@ MMSTATUS(){
|
|||||||
if [ "${zerogw}" == "${defaultgw}" ] && [ "${zerogw}" == "${VPN_INTERFACE}" ]; then
|
if [ "${zerogw}" == "${defaultgw}" ] && [ "${zerogw}" == "${VPN_INTERFACE}" ]; then
|
||||||
echo -e "${idsCL[Green]}$defaultgw${idsCL[Default]}"
|
echo -e "${idsCL[Green]}$defaultgw${idsCL[Default]}"
|
||||||
else
|
else
|
||||||
echo -e "${idsCL[Red]}Not correct${idsCL[Default]}"
|
echo -e "${idsCL[Red]}$defaultgw - Incorrect Gateways${idsCL[Default]}"
|
||||||
if [ ! -f ${MMFOLDER}/mm.stop ] && [ ! -f ${MMFOLDER}/mm.stop.checking ]; then
|
if ([ ! -f ${MMFOLDER}/mm.stop* ] && [ "${1}" == "fix" ]) || ([ ! -f ${MMFOLDER}/mm.stop ] && [ -f ${MMFOLDER}/mm.stop.checking ] && [ "${1}" == "fix" ]); then
|
||||||
echo
|
echo
|
||||||
echo -e "${idsCL[LightCyan]}Restarting system...${idsCL[Default]}"
|
echo -e "${idsCL[LightCyan]}Restarting system...${idsCL[Default]}"
|
||||||
MMSTOP
|
MMSTOP
|
||||||
echo -en "${idsCL[LightCyan]}Pausing for 30secs... ${idsCL[Default]}"
|
echo -en "${idsCL[LightCyan]}Pausing for 10secs... ${idsCL[Default]}"
|
||||||
sleep 30s
|
sleep 10s
|
||||||
echo -e "${idsCL[Green]}Done${idsCL[Default]}"
|
echo -e "${idsCL[Green]}Done${idsCL[Default]}"
|
||||||
|
echo
|
||||||
|
echo -e "${idsCL[LightCyan]}Starting system back up...${idsCL[Default]}"
|
||||||
|
echo
|
||||||
MMSTART
|
MMSTART
|
||||||
|
|
||||||
echo -e " ${NM_SERVICES[wireguard]} : ${idsCL[Green]}Running${idsCL[Default]}"
|
echo -e " ${NM_SERVICES[wireguard]} : ${idsCL[Green]}Running${idsCL[Default]}"
|
||||||
zerogw=$(/sbin/ip route show | grep 0.0.0.0 | cut -d' ' -f 3)
|
zerogw=$(/sbin/ip route show | grep 0.0.0.0 | cut -d' ' -f 3)
|
||||||
defaultgw=$(/sbin/ip route show | grep default | cut -d' ' -f 3)
|
defaultgw=$(/sbin/ip route show | grep default | cut -d' ' -f 3)
|
||||||
@@ -424,7 +439,7 @@ MMSTATUS(){
|
|||||||
if [ "${zerogw}" == "${defaultgw}" ] && [ "${zerogw}" == "${VPN_INTERFACE}" ]; then
|
if [ "${zerogw}" == "${defaultgw}" ] && [ "${zerogw}" == "${VPN_INTERFACE}" ]; then
|
||||||
echo -e "${idsCL[Green]}$defaultgw${idsCL[Default]}"
|
echo -e "${idsCL[Green]}$defaultgw${idsCL[Default]}"
|
||||||
else
|
else
|
||||||
echo -e "${idsCL[Red]}Not correct${idsCL[Default]}"
|
echo -e "${idsCL[Red]}$defaultgw - Incorrect Gateways${idsCL[Default]}"
|
||||||
echo
|
echo
|
||||||
if [ ! -f ${MMFOLDER}/mm.stop.checking ]; then
|
if [ ! -f ${MMFOLDER}/mm.stop.checking ]; then
|
||||||
echo -e "${idsCL[LightCyan]}Shutting down system... fix yo shit${idsCL[Default]}"
|
echo -e "${idsCL[LightCyan]}Shutting down system... fix yo shit${idsCL[Default]}"
|
||||||
@@ -442,14 +457,17 @@ MMSTATUS(){
|
|||||||
if [ "${scip}" != "${mmip}" ]; then
|
if [ "${scip}" != "${mmip}" ]; then
|
||||||
echo -e "${idsCL[Green]}Good${idsCL[Default]}"
|
echo -e "${idsCL[Green]}Good${idsCL[Default]}"
|
||||||
else
|
else
|
||||||
echo -e "${idsCL[Red]}Not Good${idsCL[Default]}"
|
echo -e "${idsCL[Red]}Not Routing${idsCL[Default]}"
|
||||||
if [ ! -f ${MMFOLDER}/mm.stop ] && [ ! -f ${MMFOLDER}/mm.stop.checking ]; then
|
if ([ ! -f ${MMFOLDER}/mm.stop* ] && [ "${1}" == "fix" ]) || ([ ! -f ${MMFOLDER}/mm.stop ] && [ -f ${MMFOLDER}/mm.stop.checking ] && [ "${1}" == "fix" ]); then
|
||||||
echo
|
echo
|
||||||
echo -e "${idsCL[LightCyan]}Restarting system...${idsCL[Default]}"
|
echo -e "${idsCL[LightCyan]}Restarting system...${idsCL[Default]}"
|
||||||
MMSTOP
|
MMSTOP
|
||||||
echo -en "${idsCL[LightCyan]}Pausing for 30secs... ${idsCL[Default]}"
|
echo -en "${idsCL[LightCyan]}Pausing for 10secs... ${idsCL[Default]}"
|
||||||
sleep 30s
|
sleep 10s
|
||||||
echo -e "${idsCL[Green]}Done${idsCL[Default]}"
|
echo -e "${idsCL[Green]}Done${idsCL[Default]}"
|
||||||
|
echo
|
||||||
|
echo -e "${idsCL[LightCyan]}Starting system back up...${idsCL[Default]}"
|
||||||
|
echo
|
||||||
MMSTART
|
MMSTART
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
@@ -470,10 +488,10 @@ if [ ! -f ${MMFOLDER}/mm.update.stop ]; then
|
|||||||
fi
|
fi
|
||||||
case $action in
|
case $action in
|
||||||
start | check)
|
start | check)
|
||||||
if [ -f ${MMFOLDER}/mm.stop ] && [ "${action}" = "check" ]; then
|
if ([ -f ${MMFOLDER}/mm.stop ] || [ -f ${MMFOLDER}/mm.stop.checking ]) && [ "${action}" = "check" ]; then
|
||||||
if [ -f ${MMFOLDER}/mm.stop.checking ]; then
|
if [ -f ${MMFOLDER}/mm.stop.checking ]; then
|
||||||
checkstopped=`expr $(date +%s) - $(stat -c %Y ${MMFOLDER}/mm.stop.checking)`
|
checkstopped=`expr $(date +%s) - $(stat -c %Y ${MMFOLDER}/mm.stop.checking)`
|
||||||
if [ $checkstopped -gt 1800 ]; then
|
if [ $checkstopped -gt 900 ]; then
|
||||||
rm -f ${MMFOLDER}/mm.stop*
|
rm -f ${MMFOLDER}/mm.stop*
|
||||||
getStuckMM=$(pgrep -f '/mm')
|
getStuckMM=$(pgrep -f '/mm')
|
||||||
for i in $getStuckMM; do
|
for i in $getStuckMM; do
|
||||||
@@ -496,7 +514,7 @@ if [ ! -f ${MMFOLDER}/mm.update.stop ]; then
|
|||||||
echo
|
echo
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
touch ${MMFOLDER}/mm.stop
|
# touch ${MMFOLDER}/mm.stop
|
||||||
[ "${action}" = "check" ] && touch ${MMFOLDER}/mm.stop.checking
|
[ "${action}" = "check" ] && touch ${MMFOLDER}/mm.stop.checking
|
||||||
MMSTART ${action} ${2};;
|
MMSTART ${action} ${2};;
|
||||||
|
|
||||||
@@ -520,7 +538,7 @@ if [ ! -f ${MMFOLDER}/mm.update.stop ]; then
|
|||||||
echo -e "${stopmsg}"
|
echo -e "${stopmsg}"
|
||||||
echo
|
echo
|
||||||
fi
|
fi
|
||||||
MMSTATUS;;
|
MMSTATUS ${2};;
|
||||||
|
|
||||||
update);;
|
update);;
|
||||||
clear) echo -e "${idsCL[LightCyan]}Clearing all mm.* files ${idsCL[Default]}"
|
clear) echo -e "${idsCL[LightCyan]}Clearing all mm.* files ${idsCL[Default]}"
|
||||||
|
|||||||
6
run.sh
6
run.sh
@@ -74,7 +74,7 @@ else
|
|||||||
#fd=$(expr $(date +%s) - $(stat -L --format %Y ${MMFOLDER}/mm.stop.checking))
|
#fd=$(expr $(date +%s) - $(stat -L --format %Y ${MMFOLDER}/mm.stop.checking))
|
||||||
if [ $(expr $(date +%s) - $(stat -L --format %Y ${MMFOLDER}/mm.stop.checking)) -gt 900 ]; then
|
if [ $(expr $(date +%s) - $(stat -L --format %Y ${MMFOLDER}/mm.stop.checking)) -gt 900 ]; then
|
||||||
rm -f ${MMFOLDER}/mm.stop*
|
rm -f ${MMFOLDER}/mm.stop*
|
||||||
elif [ "${1}" = "check" ] && [ "$(ip link | grep "${VPN_INTERFACE}")" = "" ] && [ ! -f ${MMFOLDER}/mm.vpn* ] && [ $(uptime_minutes) -lt 2 ]; then
|
elif [ "${1}" = "check" ] && [ "$(ip link | grep "${VPN_INTERFACE}")" = "" ] && [ ! -f ${MMFOLDER}/mm.vpn* ] && [ $(uptime_minutes) -lt 3 ]; then
|
||||||
rm -f ${MMFOLDER}/mm.stop*
|
rm -f ${MMFOLDER}/mm.stop*
|
||||||
else
|
else
|
||||||
echo -e "${idsCL[LightCyan]}Try again later, 'mm' program currently in use...${idsCL[Default]}"
|
echo -e "${idsCL[LightCyan]}Try again later, 'mm' program currently in use...${idsCL[Default]}"
|
||||||
@@ -82,9 +82,9 @@ else
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
if [ ! -f ${MMFOLDER}/mm.stop.checking ] || [ "${1}" == "status" ]; then
|
if [ ! -f ${MMFOLDER}/mm.stop.checking ] || [ "${1}" == "status" ]; then
|
||||||
touch ${MMFOLDER}/mm.stop.checking
|
[ "${1}" != "status" ] && touch ${MMFOLDER}/mm.stop.checking
|
||||||
${MMFOLDER}/mm-scripts.sh ${1} ${2} ${3} ${4} ${5} ${6} ${7} ${8} ${9} ${10} ${11} ${12} ${13} ${14}
|
${MMFOLDER}/mm-scripts.sh ${1} ${2} ${3} ${4} ${5} ${6} ${7} ${8} ${9} ${10} ${11} ${12} ${13} ${14}
|
||||||
rm -f ${MMFOLDER}/mm.stop.checking
|
[ "${1}" != "status" ] && rm -f ${MMFOLDER}/mm.stop.checking
|
||||||
fi
|
fi
|
||||||
|
|
||||||
fi
|
fi
|
||||||
|
|||||||
Reference in New Issue
Block a user