Update mm-scripts.sh

This commit is contained in:
2023-03-25 09:14:48 -05:00
parent 077d02d9ed
commit 265944f236

View File

@@ -240,6 +240,7 @@ PersistentKeepalive = 25" >> /etc/wireguard/${VPN_INTERFACE}.conf
fi fi
echo -en "${idsCL[LightCyan]}Verifying Plex Media is Mounted : ${idsCL[Default]}"
### CHECK FOR PLEX MOUNT ### CHECK FOR PLEX MOUNT
files=$(shopt -s nullglob dotglob; echo ${PLEX_MOUNT}/*) files=$(shopt -s nullglob dotglob; echo ${PLEX_MOUNT}/*)
if (( ! ${#files} )); then if (( ! ${#files} )); then
@@ -255,7 +256,6 @@ PersistentKeepalive = 25" >> /etc/wireguard/${VPN_INTERFACE}.conf
fd=$(( `date +%s` - `stat -L --format %Y ${MMFOLDER}/mm.plexmount.fail` )) fd=$(( `date +%s` - `stat -L --format %Y ${MMFOLDER}/mm.plexmount.fail` ))
if [ ${fd} -gt 3600 ]; then if [ ${fd} -gt 3600 ]; then
PMFS=true PMFS=true
rm -f ${MMFOLDER}/mm.plexmount.fail
else else
PMFS=false PMFS=false
fi fi
@@ -265,21 +265,29 @@ PersistentKeepalive = 25" >> /etc/wireguard/${VPN_INTERFACE}.conf
if [ "${EMAIL_NOTICE}" != "" ] && [ ${PMFS} = true ]; then if [ "${EMAIL_NOTICE}" != "" ] && [ ${PMFS} = true ]; then
SENDNOTICE "Plex Media Not Mounted" "Could not mount the Plex Media Folder" 1 SENDNOTICE "Plex Media Not Mounted" "Could not mount the Plex Media Folder" 1
touch ${MMFOLDER}/mm.plexmount.fail
echo "$(date) - Plex Media could not be mounted" >> $logfile echo "$(date) - Plex Media could not be mounted" >> $logfile
fi fi
touch ${MMFOLDER}/mm.plexmount.fail
echo -e "${idsCL[Red]}Not Mounted, stopping services${idsCL[Default]}"
for srvc in "${SERVICES_CHECK[@]}"; do
/bin/systemctl stop ${srvc}
done
else else
echo -e "${idsCL[Green]}Mounted, fixed${idsCL[Default]}"
rm -f ${MMFOLDER}/mm.plexmount.fail
echo "$(date) - Plex Media now mounted, stopping services to restart them" >> $logfile echo "$(date) - Plex Media now mounted, stopping services to restart them" >> $logfile
for srvc in "${SERVICES_CHECK[@]}"; do for srvc in "${SERVICES_CHECK[@]}"; do
/bin/systemctl stop ${srvc} /bin/systemctl stop ${srvc}
done done
fi fi
else else
echo -e "${idsCL[Green]}Mounted${idsCL[Default]}"
rm -f ${MMFOLDER}/mm.plexmount.fail rm -f ${MMFOLDER}/mm.plexmount.fail
fi fi
[ "${1}" == "start" ] && rm -f ${MMFOLDER}/mm.noservices [ "${1}" == "start" ] && rm -f ${MMFOLDER}/mm.noservices
if [ "${2}" != "vpn" ] && [ ! -f ${MMFOLDER}/mm.noservices ]; then if [ "${2}" != "vpn" ] && [ ! -f ${MMFOLDER}/mm.noservices ] && [ ! -f ${MMFOLDER}/mm.plexmount.fail ]; then
echo -en "${idsCL[LightCyan]}${mmsv} Services :${idsCL[Default]}" echo -en "${idsCL[LightCyan]}${mmsv} Services :${idsCL[Default]}"
for srvc in "${SERVICES_CHECK[@]}"; do for srvc in "${SERVICES_CHECK[@]}"; do
/bin/systemctl start ${srvc} /bin/systemctl start ${srvc}
@@ -287,7 +295,6 @@ PersistentKeepalive = 25" >> /etc/wireguard/${VPN_INTERFACE}.conf
echo -e "${idsCL[Green]} done${idsCL[Default]}" echo -e "${idsCL[Green]} done${idsCL[Default]}"
else else
echo -e "${idsCL[LightYellow]}Skipping ${mmsv} Services ${idsCL[Default]}" echo -e "${idsCL[LightYellow]}Skipping ${mmsv} Services ${idsCL[Default]}"
touch ${MMFOLDER}/mm.noservices
fi fi
echo echo
@@ -402,13 +409,20 @@ MMSTATUS(){
echo -en " ${NM_SERVICES[${srvc}]}$spc: " echo -en " ${NM_SERVICES[${srvc}]}$spc: "
if [ "$(systemctl is-active ${srvc})" != "active" ] && [ "${srvc}" != "wireguard" ]; then if [ "$(systemctl is-active ${srvc})" != "active" ] && [ "${srvc}" != "wireguard" ]; then
echo -e "${idsCL[Red]}Not Running${idsCL[Default]}" if [ ! -f ${MMFOLDER}/mm.noservices ] && [ ! -f ${MMFOLDER}/mm.plexmount.fail ]; then
echo -e "${idsCL[Red]}Not Running${idsCL[Default]}"
elif [ ! -f ${MMFOLDER}/mm.noservices ]; then
echo -e "${idsCL[Red]}Skipping, started wtih VPN only${idsCL[Default]}"
elif [ ! -f ${MMFOLDER}/mm.plexmount.fail ]; then
echo -e "${idsCL[Red]}Skipping, Plex Media not mounted${idsCL[Default]}"
fi
elif [ "${srvc}" == "wireguard" ] && [ "$(/sbin/ip link | grep $VPN_INTERFACE)" == "" ]; then elif [ "${srvc}" == "wireguard" ] && [ "$(/sbin/ip link | grep $VPN_INTERFACE)" == "" ]; then
echo -e "${idsCL[Red]}Not Running${idsCL[Default]}" echo -e "${idsCL[Red]}Not Running${idsCL[Default]}"
else else
echo -e "${idsCL[Green]}Running${idsCL[Default]}" echo -e "${idsCL[Green]}Running${idsCL[Default]}"
if [[ ${srvc} == *"vpn"* ]] || [[ ${srvc} == *"wireguard"* ]]; then if [[ ${srvc} == *"vpn"* ]] || [[ ${srvc} == *"wireguard"* ]]; then
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)
@@ -472,6 +486,9 @@ MMSTATUS(){
fi fi
echo echo
else
fi fi
fi fi