Update mm-scripts.sh
This commit is contained in:
@@ -240,6 +240,7 @@ PersistentKeepalive = 25" >> /etc/wireguard/${VPN_INTERFACE}.conf
|
||||
fi
|
||||
|
||||
|
||||
echo -en "${idsCL[LightCyan]}Verifying Plex Media is Mounted : ${idsCL[Default]}"
|
||||
### CHECK FOR PLEX MOUNT
|
||||
files=$(shopt -s nullglob dotglob; echo ${PLEX_MOUNT}/*)
|
||||
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` ))
|
||||
if [ ${fd} -gt 3600 ]; then
|
||||
PMFS=true
|
||||
rm -f ${MMFOLDER}/mm.plexmount.fail
|
||||
else
|
||||
PMFS=false
|
||||
fi
|
||||
@@ -265,21 +265,29 @@ PersistentKeepalive = 25" >> /etc/wireguard/${VPN_INTERFACE}.conf
|
||||
|
||||
if [ "${EMAIL_NOTICE}" != "" ] && [ ${PMFS} = true ]; then
|
||||
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
|
||||
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
|
||||
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
|
||||
for srvc in "${SERVICES_CHECK[@]}"; do
|
||||
/bin/systemctl stop ${srvc}
|
||||
done
|
||||
fi
|
||||
else
|
||||
echo -e "${idsCL[Green]}Mounted${idsCL[Default]}"
|
||||
rm -f ${MMFOLDER}/mm.plexmount.fail
|
||||
fi
|
||||
|
||||
[ "${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]}"
|
||||
for srvc in "${SERVICES_CHECK[@]}"; do
|
||||
/bin/systemctl start ${srvc}
|
||||
@@ -287,7 +295,6 @@ PersistentKeepalive = 25" >> /etc/wireguard/${VPN_INTERFACE}.conf
|
||||
echo -e "${idsCL[Green]} done${idsCL[Default]}"
|
||||
else
|
||||
echo -e "${idsCL[LightYellow]}Skipping ${mmsv} Services ${idsCL[Default]}"
|
||||
touch ${MMFOLDER}/mm.noservices
|
||||
fi
|
||||
echo
|
||||
|
||||
@@ -402,13 +409,20 @@ MMSTATUS(){
|
||||
echo -en " ${NM_SERVICES[${srvc}]}$spc: "
|
||||
|
||||
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
|
||||
echo -e "${idsCL[Red]}Not Running${idsCL[Default]}"
|
||||
|
||||
else
|
||||
echo -e "${idsCL[Green]}Running${idsCL[Default]}"
|
||||
|
||||
if [[ ${srvc} == *"vpn"* ]] || [[ ${srvc} == *"wireguard"* ]]; then
|
||||
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)
|
||||
@@ -472,6 +486,9 @@ MMSTATUS(){
|
||||
fi
|
||||
|
||||
echo
|
||||
|
||||
else
|
||||
|
||||
fi
|
||||
fi
|
||||
|
||||
|
||||
Reference in New Issue
Block a user