This commit is contained in:
2023-02-25 17:31:38 -06:00
parent b480bf1ceb
commit 00a2463175
3 changed files with 70 additions and 60 deletions

View File

@@ -2,6 +2,7 @@
VERS='2.02232023' VERS='2.02232023'
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)
noheader=' check noup stop ' noheader=' check noup stop '

View File

@@ -6,14 +6,14 @@ action="$1"
VERBOSE=true VERBOSE=true
if [ -f /opt/idssys/settings/mediamanager.conf ]; then if [ -f /opt/idssys/settings/mediamanager.conf ]; then
mv /opt/idssys/settings/mediamanager.conf /opt/idssys/mediamanager/settings.conf mv /opt/idssys/settings/mediamanager.conf ${MMFOLDER}/settings.conf
fi fi
source /opt/idssys/defaults/colors.inc source /opt/idssys/defaults/colors.inc
source /opt/idssys/defaults/default.inc source /opt/idssys/defaults/default.inc
source /opt/idssys/mediamanager/settings.conf source ${MMFOLDER}/settings.conf
source /opt/idssys/mediamanager/defaults.inc source ${MMFOLDER}/defaults.inc
if [ "${action}" != "check" ] && [ "${action}" != "update" ] && [ "${2}" != "noup" ]; then if [ "${action}" != "check" ] && [ "${action}" != "update" ] && [ "${2}" != "noup" ]; then
echo "" echo ""
@@ -21,7 +21,7 @@ if [ "${action}" != "check" ] && [ "${action}" != "update" ] && [ "${2}" != "nou
DIVIDER . lightGreen DIVIDER . lightGreen
fi fi
logfile=/opt/idssys/mediamanager/logfile logfile=${MMFOLDER}/logfile
touch $logfile touch $logfile
@@ -35,13 +35,13 @@ MMSTART(){
if [ "${1}" = "start" ] || [ "${1}" = "restart" ] || [ "${1}" = "" ]; then if [ "${1}" = "start" ] || [ "${1}" = "restart" ] || [ "${1}" = "" ]; then
GOFORSTART=true; GOFORSTART=true;
elif [ "${1}" = "check" ] && [ "$(ip link | grep "wg-torguard")" = "" ] && [ ! -f /opt/idssys/mediamanager/mm.vpn* ]; then elif [ "${1}" = "check" ] && [ "$(ip link | grep "wg-torguard")" = "" ] && [ ! -f ${MMFOLDER}/mm.vpn* ]; then
GOFORSTART=true; GOFORSTART=true;
[ "${EMAIL_NOTICE}" != "" ] && echo "" | mail -s "Starting Media Management Systems" ${EMAIL_NOTICE} [ "${EMAIL_NOTICE}" != "" ] && echo "" | mail -s "Starting Media Management Systems" ${EMAIL_NOTICE}
echo "$(date) - Starting Media Management system - (wireguard not running)" >> $logfile echo "$(date) - Starting Media Management system - (wireguard not running)" >> $logfile
echo -e "${idsCL[LightCyan]}Fresh startup${idsCL[Default]}" echo -e "${idsCL[LightCyan]}Fresh startup${idsCL[Default]}"
elif [ "${1}" = "check" ] && [ "$(ip link | grep "wg-torguard")" = "" ] && [ -f /opt/idssys/mediamanager/mm.vpn* ]; then elif [ "${1}" = "check" ] && [ "$(ip link | grep "wg-torguard")" = "" ] && [ -f ${MMFOLDER}/mm.vpn* ]; then
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]}"
@@ -81,9 +81,9 @@ AllowedIPs = 0.0.0.0/0
Endpoint = ${vpnaddress}:${vpnport} Endpoint = ${vpnaddress}:${vpnport}
PersistentKeepalive = 25" >> /etc/wireguard/wg-torguard.conf PersistentKeepalive = 25" >> /etc/wireguard/wg-torguard.conf
rm -f /opt/idssys/mediamanager/vpninfo.* rm -f ${MMFOLDER}/vpninfo.*
echo -e "$publickey" >> /opt/idssys/mediamanager/vpninfo.publickey echo -e "$publickey" >> ${MMFOLDER}/vpninfo.publickey
echo -e "$vpnaddress" >> /opt/idssys/mediamanager/vpninfo.address echo -e "$vpnaddress" >> ${MMFOLDER}/vpninfo.address
echo -e "${idsCL[Green]} done${idsCL[Default]}" echo -e "${idsCL[Green]} done${idsCL[Default]}"
@@ -103,21 +103,21 @@ PersistentKeepalive = 25" >> /etc/wireguard/wg-torguard.conf
OUT=$(ip link | grep "$VPN_INTERFACE") OUT=$(ip link | grep "$VPN_INTERFACE")
if [ ${#OUT} = 0 ]; then if [ ${#OUT} = 0 ]; then
if [ -f /opt/idssys/mediamanager/mm.vpn.fail ]; then if [ -f ${MMFOLDER}/mm.vpn.fail ]; then
echo -e "${idsCL[Red]} failed, restarting system${idsCL[Default]}" echo -e "${idsCL[Red]} failed, restarting system${idsCL[Default]}"
echo "$(date) - VPN Failure #2 - restarting system" >> $logfile echo "$(date) - VPN Failure #2 - restarting system" >> $logfile
[ "${EMAIL_NOTICE}" != "" ] && echo "2nd Failure, will try and restart the VPN" | mail -s "VPN Failure" ${EMAIL_NOTICE} [ "${EMAIL_NOTICE}" != "" ] && echo "2nd Failure, will try and restart the VPN" | mail -s "VPN Failure" ${EMAIL_NOTICE}
touch /opt/idssys/mediamanager/mm.vpn.fail2 touch ${MMFOLDER}/mm.vpn.fail2
rm -f /opt/idssys/mediamanager/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 30s sleep 30s
rm -f /opt/idssys/mediamanager/mm.stop* rm -f ${MMFOLDER}/mm.stop*
rm -f /opt/idssys/mediamanager/mm.checking rm -f ${MMFOLDER}/mm.checking
[ $VERBOSE = true ] && DEBUGLOGSTOP [ $VERBOSE = true ] && DEBUGLOGSTOP
exit 1 exit 1
elif [ -f /opt/idssys/mediamanager/mm.vpn.fail2 ]; then elif [ -f ${MMFOLDER}/mm.vpn.fail2 ]; then
echo "$(date) - VPN Failure #3 - Shutting down Media Management systems" >> $logfile echo "$(date) - VPN Failure #3 - Shutting down Media Management systems" >> $logfile
[ "${EMAIL_NOTICE}" != "" ] && echo "Final Failure, shutting down system" | mail -s "VPN Failure" ${EMAIL_NOTICE} [ "${EMAIL_NOTICE}" != "" ] && echo "Final Failure, shutting down system" | mail -s "VPN Failure" ${EMAIL_NOTICE}
MMSTOP MMSTOP
@@ -127,13 +127,13 @@ PersistentKeepalive = 25" >> /etc/wireguard/wg-torguard.conf
echo -e "${idsCL[Red]} failed, restarting system${idsCL[Default]}" echo -e "${idsCL[Red]} failed, restarting system${idsCL[Default]}"
echo "$(date) - VPN Failure #1 - restarting system" >> $logfile echo "$(date) - VPN Failure #1 - restarting system" >> $logfile
[ "${EMAIL_NOTICE}" != "" ] && echo "1st Failure, will try and restart the VPN" | mail -s "VPN Failure" ${EMAIL_NOTICE} [ "${EMAIL_NOTICE}" != "" ] && echo "1st Failure, will try and restart the VPN" | mail -s "VPN Failure" ${EMAIL_NOTICE}
touch /opt/idssys/mediamanager/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 30s sleep 30s
rm -f /opt/idssys/mediamanager/mm.stop* rm -f ${MMFOLDER}/mm.stop*
rm -f /opt/idssys/mediamanager/mm.checking rm -f ${MMFOLDER}/mm.checking
[ $VERBOSE = true ] && DEBUGLOGSTOP [ $VERBOSE = true ] && DEBUGLOGSTOP
exit 1 exit 1
fi fi
@@ -154,7 +154,7 @@ PersistentKeepalive = 25" >> /etc/wireguard/wg-torguard.conf
/bin/ip route add default dev wg-torguard /bin/ip route add default dev wg-torguard
/bin/ip route add 0.0.0.0/1 dev wg-torguard /bin/ip route add 0.0.0.0/1 dev wg-torguard
/bin/ip route add 128.0.0.0/1 dev wg-torguard /bin/ip route add 128.0.0.0/1 dev wg-torguard
/bin/ip route add $(cat /opt/idssys/mediamanager/vpninfo.address)/32 via 10.10.0.1 dev eth0 /bin/ip route add $(cat ${MMFOLDER}/vpninfo.address)/32 via 10.10.0.1 dev eth0
echo -e "${idsCL[Green]} done${idsCL[Default]}" echo -e "${idsCL[Green]} done${idsCL[Default]}"
zerogw=$(ip route show | grep 0.0.0.0 | cut -d' ' -f 3) zerogw=$(ip route show | grep 0.0.0.0 | cut -d' ' -f 3)
@@ -173,12 +173,12 @@ PersistentKeepalive = 25" >> /etc/wireguard/wg-torguard.conf
echo -e "${idsCL[Red]}Could not confirm default routes, restarting system!${idsCL[Default]}" echo -e "${idsCL[Red]}Could not confirm default routes, restarting system!${idsCL[Default]}"
echo "$(date) - Could not confirm default routes, restarting system" >> $logfile echo "$(date) - Could not confirm default routes, restarting system" >> $logfile
[ "${EMAIL_NOTICE}" != "" ] && echo "Default route failure, will try and restart the VPN" | mail -s "Network Failure" ${EMAIL_NOTICE} [ "${EMAIL_NOTICE}" != "" ] && echo "Default route failure, will try and restart the VPN" | mail -s "Network Failure" ${EMAIL_NOTICE}
touch /opt/idssys/mediamanager/mm.vpn.fail touch ${MMFOLDER}/mm.vpn.fail
MMSTOP MMSTOP
sleep 2m sleep 2m
"${VPN_START[@]}" >/dev/null 2>&1 & "${VPN_START[@]}" >/dev/null 2>&1 &
sleep 1m sleep 1m
rm -f /opt/idssys/mediamanager/mm.stop* rm -f ${MMFOLDER}/mm.stop*
[ $VERBOSE = true ] && DEBUGLOGSTOP [ $VERBOSE = true ] && DEBUGLOGSTOP
exit 1 exit 1
fi fi
@@ -203,12 +203,12 @@ PersistentKeepalive = 25" >> /etc/wireguard/wg-torguard.conf
echo "$(date) - Cannot get an WAN address, restarting system! scip(${scip}) mmip(${mmip})" >> $logfile echo "$(date) - Cannot get an WAN address, restarting system! scip(${scip}) mmip(${mmip})" >> $logfile
[ $VERBOSE = true ] && echo "$(date) - Default Routes: zerogw(${zerogw}) defaultgw(${defaultgw})" >> $logfile [ $VERBOSE = true ] && echo "$(date) - Default Routes: zerogw(${zerogw}) defaultgw(${defaultgw})" >> $logfile
[ "${EMAIL_NOTICE}" != "" ] && echo "Cannot get an WAN address, will try and restart the VPN" | mail -s "Network Failure" ${EMAIL_NOTICE} [ "${EMAIL_NOTICE}" != "" ] && echo "Cannot get an WAN address, will try and restart the VPN" | mail -s "Network Failure" ${EMAIL_NOTICE}
touch /opt/idssys/mediamanager/mm.vpn.fail touch ${MMFOLDER}/mm.vpn.fail
MMSTOP MMSTOP
sleep 2m sleep 2m
"${VPN_START[@]}" >/dev/null 2>&1 & "${VPN_START[@]}" >/dev/null 2>&1 &
sleep 1m sleep 1m
rm -f /opt/idssys/mediamanager/mm.stop* rm -f ${MMFOLDER}/mm.stop*
[ $VERBOSE = true ] && DEBUGLOGSTOP [ $VERBOSE = true ] && DEBUGLOGSTOP
exit 1 exit 1
fi fi
@@ -223,12 +223,12 @@ PersistentKeepalive = 25" >> /etc/wireguard/wg-torguard.conf
echo "$(date) - Traffic is not routing through VPN, restarting system! scip(${scip}) mmip(${mmip})" >> $logfile echo "$(date) - Traffic is not routing through VPN, restarting system! scip(${scip}) mmip(${mmip})" >> $logfile
[ $VERBOSE = true ] && echo "$(date) - Default Routes: zerogw(${zerogw}) defaultgw(${defaultgw})" >> $logfile [ $VERBOSE = true ] && echo "$(date) - Default Routes: zerogw(${zerogw}) defaultgw(${defaultgw})" >> $logfile
[ "${EMAIL_NOTICE}" != "" ] && echo "Traffic route failure, will try and restart the VPN" | mail -s "Network Failure" ${EMAIL_NOTICE} [ "${EMAIL_NOTICE}" != "" ] && echo "Traffic route failure, will try and restart the VPN" | mail -s "Network Failure" ${EMAIL_NOTICE}
touch /opt/idssys/mediamanager/mm.vpn.fail touch ${MMFOLDER}/mm.vpn.fail
MMSTOP MMSTOP
sleep 2m sleep 2m
"${VPN_START[@]}" >/dev/null 2>&1 & "${VPN_START[@]}" >/dev/null 2>&1 &
sleep 1m sleep 1m
rm -f /opt/idssys/mediamanager/mm.stop* rm -f ${MMFOLDER}/mm.stop*
[ $VERBOSE = true ] && DEBUGLOGSTOP [ $VERBOSE = true ] && DEBUGLOGSTOP
exit 1 exit 1
fi fi
@@ -243,11 +243,11 @@ PersistentKeepalive = 25" >> /etc/wireguard/wg-torguard.conf
files=$(shopt -s nullglob dotglob; echo ${PLEX_MOUNT}/*) files=$(shopt -s nullglob dotglob; echo ${PLEX_MOUNT}/*)
if (( ! ${#files} )); then if (( ! ${#files} )); then
if [ -f /opt/idssys/mediamanager/mm.plexmount.fail ]; then if [ -f ${MMFOLDER}/mm.plexmount.fail ]; then
fd=$(( `date +%s` - `stat -L --format %Y /opt/idssys/mediamanager/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 /opt/idssys/mediamanager/mm.plexmount.fail rm -f ${MMFOLDER}/mm.plexmount.fail
else else
PMFS=false PMFS=false
fi fi
@@ -257,7 +257,7 @@ PersistentKeepalive = 25" >> /etc/wireguard/wg-torguard.conf
if [ "${EMAIL_NOTICE}" != "" ] && [ ${PMFS} = true ]; then if [ "${EMAIL_NOTICE}" != "" ] && [ ${PMFS} = true ]; then
echo "Could not mount the Plex Media Folder" | mail -s "Plex Media Not Mounted" ${EMAIL_NOTICE} echo "Could not mount the Plex Media Folder" | mail -s "Plex Media Not Mounted" ${EMAIL_NOTICE}
touch /opt/idssys/mediamanager/mm.plexmount.fail 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
else else
@@ -281,12 +281,12 @@ PersistentKeepalive = 25" >> /etc/wireguard/wg-torguard.conf
#echo -e "${idsCL[LightCyan]}It may take a couple of minutes before all services fully start${idsCL[Default]}" #echo -e "${idsCL[LightCyan]}It may take a couple of minutes before all services fully start${idsCL[Default]}"
MMSTATUS MMSTATUS
fi fi
if [ -f /opt/idssys/mediamanager/mm.vpn.fail* ]; then if [ -f ${MMFOLDER}/mm.vpn.fail* ]; then
echo "$(date) - VPN issue has been fixed" >> $logfile echo "$(date) - VPN issue has been fixed" >> $logfile
[ "${EMAIL_NOTICE}" != "" ] && echo "VPN issue has been fixed" | mail -s "Services Restored" ${EMAIL_NOTICE} [ "${EMAIL_NOTICE}" != "" ] && echo "VPN issue has been fixed" | mail -s "Services Restored" ${EMAIL_NOTICE}
rm -f /opt/idssys/mediamanager/mm.vpn.fail* rm -f ${MMFOLDER}/mm.vpn.fail*
fi fi
rm -f /opt/idssys/mediamanager/mm.stop* rm -f ${MMFOLDER}/mm.stop*
echo -e "${idsCL[Green]}All systems are go!${idsCL[Default]}" echo -e "${idsCL[Green]}All systems are go!${idsCL[Default]}"
if [ "${1}" = "start" ] || [ "${1}" = "" ]; then if [ "${1}" = "start" ] || [ "${1}" = "" ]; then
echo "$(date) - Media Management systems started" >> $logfile echo "$(date) - Media Management systems started" >> $logfile
@@ -301,14 +301,14 @@ PersistentKeepalive = 25" >> /etc/wireguard/wg-torguard.conf
} }
MMSTOP(){ MMSTOP(){
if [ -f /opt/idssys/mediamanager/mm.stop ]; then if [ -f ${MMFOLDER}/mm.stop ]; then
echo -e "${idsCL[Yellow]}The system is already stopped, will verify anyway...${idsCL[Default]}" echo -e "${idsCL[Yellow]}The system is already stopped, will verify anyway...${idsCL[Default]}"
else else
echo -e "${idsCL[Green]}Stopping System...${idsCL[Default]}" echo -e "${idsCL[Green]}Stopping System...${idsCL[Default]}"
echo echo
fi fi
echo echo
touch /opt/idssys/mediamanager/mm.stop touch ${MMFOLDER}/mm.stop
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
@@ -352,8 +352,8 @@ MMSTOP(){
fi fi
done done
[ "$(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 /opt/idssys/mediamanager/vpninfo.address) [ "$(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)
rm -f /opt/idssys/mediamanager/vpninfo.* rm -f ${MMFOLDER}/vpninfo.*
[ $VERBOSE = true ] && echo "$(date) - Added default route back in" >> $logfile [ $VERBOSE = true ] && echo "$(date) - Added default route back in" >> $logfile
echo -e "${idsCL[Green]} done${idsCL[Default]}" echo -e "${idsCL[Green]} done${idsCL[Default]}"
@@ -414,7 +414,7 @@ MMSTATUS(){
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]}Not correct${idsCL[Default]}"
if [ ! -f /opt/idssys/mediamanager/mm.stop ]; then if [ ! -f ${MMFOLDER}/mm.stop ]; then
echo echo
echo -e "${idsCL[LightCyan]}Restarting system...${idsCL[Default]}" echo -e "${idsCL[LightCyan]}Restarting system...${idsCL[Default]}"
MMSTOP MMSTOP
@@ -447,7 +447,7 @@ MMSTATUS(){
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 Good${idsCL[Default]}"
if [ ! -f /opt/idssys/mediamanager/mm.stop ]; then if [ ! -f ${MMFOLDER}/mm.stop ]; then
echo echo
echo -e "${idsCL[LightCyan]}Restarting system...${idsCL[Default]}" echo -e "${idsCL[LightCyan]}Restarting system...${idsCL[Default]}"
MMSTOP MMSTOP
@@ -468,18 +468,27 @@ MMSTATUS(){
echo echo
} }
if [ ! -f /opt/idssys/mediamanager/mm.update.stop ]; then MMUPDATE(){
if [ -f /opt/idssys/mediamanager/mm.stop ]; then if curl -m 15 -s --head --request GET https://git.schroedercity.com | grep "HTTP/2 200" > /dev/null; then
stoppedsince=`date +%s`-$(stat -c %Y /opt/idssys/mediamanager/mm.stop) cd ${MMFOLDER}
if [ "`git log --pretty=%H ...refs/heads/master^ | head -n 1`" != "`git ls-remote origin -h refs/heads/master |cut -f1`" ]; then
touch /opt
fi
fi
}
if [ ! -f ${MMFOLDER}/mm.update.stop ]; then
if [ -f ${MMFOLDER}/mm.stop ]; then
stoppedsince=`date +%s`-$(stat -c %Y ${MMFOLDER}/mm.stop)
stopmsg="${idsCL[Yellow]}The system has currently been stopped for '$(SHOW_TIME ${stoppedsince})'.\n${idsCL[LightCyan]}(You'll need to run \"mm start\" to start services again)${idsCL[Default]}" stopmsg="${idsCL[Yellow]}The system has currently been stopped for '$(SHOW_TIME ${stoppedsince})'.\n${idsCL[LightCyan]}(You'll need to run \"mm start\" to start services again)${idsCL[Default]}"
fi fi
case $action in case $action in
start | check) start | check)
if [ -f /opt/idssys/mediamanager/mm.stop ] && [ "${action}" = "check" ]; then if [ -f ${MMFOLDER}/mm.stop ] && [ "${action}" = "check" ]; then
if [ -f /opt/idssys/mediamanager/mm.stop.checking ]; then if [ -f ${MMFOLDER}/mm.stop.checking ]; then
checkstopped=`expr $(date +%s) - $(stat -c %Y /opt/idssys/mediamanager/mm.stop.checking)` checkstopped=`expr $(date +%s) - $(stat -c %Y ${MMFOLDER}/mm.stop.checking)`
if [ $checkstopped -gt 1800 ]; then if [ $checkstopped -gt 1800 ]; then
rm -f /opt/idssys/mediamanager/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
/bin/kill $i /bin/kill $i
@@ -496,15 +505,15 @@ if [ ! -f /opt/idssys/mediamanager/mm.update.stop ]; then
exit 1 exit 1
fi fi
fi fi
touch /opt/idssys/mediamanager/mm.stop touch ${MMFOLDER}/mm.stop
[ "${action}" = "check" ] && touch /opt/idssys/mediamanager/mm.stop.checking [ "${action}" = "check" ] && touch ${MMFOLDER}/mm.stop.checking
MMSTART ${action};; MMSTART ${action};;
stop) stop)
MMSTOP;; MMSTOP;;
restart) restart)
if [ -f /opt/idssys/mediamanager/mm.stop ]; then if [ -f ${MMFOLDER}/mm.stop ]; then
echo -e "${stopmsg}" echo -e "${stopmsg}"
echo echo
exit 1 exit 1
@@ -516,7 +525,7 @@ if [ ! -f /opt/idssys/mediamanager/mm.update.stop ]; then
MMSTART ${action};; MMSTART ${action};;
status) status)
if [ -f /opt/idssys/mediamanager/mm.stop ]; then if [ -f ${MMFOLDER}/mm.stop ]; then
echo -e "${stopmsg}" echo -e "${stopmsg}"
echo echo
fi fi

22
run.sh
View File

@@ -8,7 +8,7 @@ source /opt/idssys/mediamanager/defaults.inc
if [ -f /opt/idssys/settings/mediamanager.conf ]; then if [ -f /opt/idssys/settings/mediamanager.conf ]; then
source /opt/idssys/settings/mediamanager.conf source /opt/idssys/settings/mediamanager.conf
else else
source /opt/idssys/mediamanager/settings.conf source ${MMFOLDER}/settings.conf
fi fi
if [ "${1}" == "update" ]; then if [ "${1}" == "update" ]; then
@@ -31,7 +31,7 @@ if [ "${1}" == "update" ]; then
git pull >/dev/null 2>&1 git pull >/dev/null 2>&1
git submodule update --remote >/dev/null 2>&1 git submodule update --remote >/dev/null 2>&1
fi fi
cd /opt/idssys/mediamanager cd ${MMFOLDER}
if [ "`git log --pretty=%H ...refs/heads/master^ | head -n 1`" != "`git ls-remote origin -h refs/heads/master |cut -f1`" ]; then if [ "`git log --pretty=%H ...refs/heads/master^ | head -n 1`" != "`git ls-remote origin -h refs/heads/master |cut -f1`" ]; then
if [ "${2}" != "q" ]; then if [ "${2}" != "q" ]; then
echo -en "\e[1A"; echo -en "\e[1A";
@@ -44,7 +44,7 @@ if [ "${1}" == "update" ]; then
git prune >/dev/null 2>&1 git prune >/dev/null 2>&1
git pull >/dev/null 2>&1 git pull >/dev/null 2>&1
git submodule update --remote >/dev/null 2>&1 git submodule update --remote >/dev/null 2>&1
/bin/chmod +x /opt/idssys/mediamanager/mm-scripts.sh 2>&1 /bin/chmod +x ${MMFOLDER}/mm-scripts.sh 2>&1
if [ "${2}" != "q" ]; then if [ "${2}" != "q" ]; then
echo -en "\e[1A"; echo -en "\e[1A";
echo -e "\e[0K\r ${idsCL[Green]}Updates Completed${idsCL[Default]}" echo -e "\e[0K\r ${idsCL[Green]}Updates Completed${idsCL[Default]}"
@@ -58,20 +58,20 @@ if [ "${1}" == "update" ]; then
fi fi
else else
[ "${1}" == "clear" ] && rm -f /opt/idssys/mediamanager/mm.* [ "${1}" == "clear" ] && rm -f ${MMFOLDER}/mm.*
if [ -f /opt/idssys/mediamanager/mm.checking ]; then if [ -f ${MMFOLDER}/mm.checking ]; then
fd=$(( `date +%s` - `stat -L --format %Y /opt/idssys/mediamanager/mm.checking` )) fd=$(( `date +%s` - `stat -L --format %Y ${MMFOLDER}/mm.checking` ))
if [ ${fd} -gt 900 ]; then if [ ${fd} -gt 900 ]; then
rm -f /opt/idssys/mediamanager/mm.checking rm -f ${MMFOLDER}/mm.checking
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]}"
fi fi
fi fi
if [ ! -f /opt/idssys/mediamanager/mm.checking ]; then if [ ! -f ${MMFOLDER}/mm.checking ]; then
touch /opt/idssys/mediamanager/mm.checking touch ${MMFOLDER}/mm.checking
/opt/idssys/mediamanager/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 /opt/idssys/mediamanager/mm.checking rm -f ${MMFOLDER}/mm.checking
fi fi
fi fi