From dacdb0c4c3c2fdbdf85eadd08ec0b2183d5611cb Mon Sep 17 00:00:00 2001 From: David Schroeder Date: Tue, 2 May 2023 20:16:54 -0500 Subject: [PATCH] update --- defaults.inc | 7 ++++- mm-scripts.sh | 74 ++++++++++++++++++++++++++++----------------------- 2 files changed, 46 insertions(+), 35 deletions(-) diff --git a/defaults.inc b/defaults.inc index 2d1fac6..bb83c2f 100755 --- a/defaults.inc +++ b/defaults.inc @@ -1,6 +1,6 @@ #!/usr/bin/env bash -VERS='3.8.206-04292023' +VERS='3.8.208-04292023' MMFOLDER="/opt/idssys/mediamanager" MMSRV=$(/sbin/ip -o -4 addr list eth0 | awk '{print $4}' | cut -d/ -f1) @@ -20,6 +20,7 @@ logfile=${MMFOLDER}/logs/logfile outputlogfile=${MMFOLDER}/logs/outputs.check.log [ ! -f ${logfile} ] && touch $logfile [ ! -f ${outputlogfile} ] && touch $outputlogfile +[ ! -d /opt/Backups ] && mkdir /opt/Backups declare -A MM_SERVICES MM_SERVICES['openvpn']='OpenVPN (TorGuard VPN Tunnel)' @@ -56,6 +57,10 @@ MM_SERVICE_CFG['lidarr']='/home/user/.config/Lidarr' MM_SERVICE_CFG['jackett']='/home/user/.config/Jackett' MM_SERVICE_CFG['bazarr']='' +declare -A MM_SERVICE_APP +MM_SERVICE_CFG['sonarr']='/usr/lib/sonarr/bin' +MM_SERVICE_CFG['snap.tautulli.tautulli']='/snap/tautulli/current' + declare -A MM_UPDATE_REPO #MM_UPDATE_REPO['ombi']='Ombi-app' MM_UPDATE_REPO['ombi']='systemd' diff --git a/mm-scripts.sh b/mm-scripts.sh index 5af0ae7..30f4417 100755 --- a/mm-scripts.sh +++ b/mm-scripts.sh @@ -876,26 +876,12 @@ UPDATESERVICE(){ if [ "${!cver}" != "${latest_ver}" ] || [ "${2}" == "force" ]; then [ "${2}" == "force" ] && echo -e "${idsCL[LightCyan]} Update Not Needed, but forcing anyway${idsCL[Default]}" || echo -e "${idsCL[Green]}Done${idsCL[Default]}" + # rm -f ${MMFOLDER}/logs/update.${usrvc} + touch ${MMFOLDER}/logs/update.${usrvc} - tmpfile=/tmp/${usrvc}-update.tar.gz - bak=/opt/Backups/${usrvc}.opt.tgz - bakcfg=/opt/Backups/${usrvc}.cfg.tgz - - msg="Stopping service and preparing"; c=0; spc=''; spc1=$((${cw_spc}-${#msg})); until [ $c = ${spc1} ]; do spc="${spc} "; c=`expr $c + 1`; done - echo -en "${idsCL[White]}${msg}${spc} : ${idsCL[Default]}" - - rm -f ${MMFOLDER}/logs/update.${usrvc} - touch ${MMFOLDER}/logs/update.${usrvc} - - /bin/systemctl stop ${usrvc} >> ${MMFOLDER}/logs/update.${usrvc} - [ "${usrvc}" == "radarr" ] && [[ " ${SERVICES_CHECK[*]} " =~ " radarr3d " ]] && /bin/systemctl stop radarr3d >> ${MMFOLDER}/logs/update.${usrvc} - - [[ -f ${bak} ]] && rm -f "${bak}" &>/dev/null - [[ -f ${tmpfile} ]] && rm -f "${tmpfile}" &>/dev/null - [ ! -d /opt/Backups ] && mkdir /opt/Backups - echo -e "${idsCL[Green]}Done${idsCL[Default]}" - - msg="Downloading and updating" + SERVICEBACKUP ${usrvc} + + msg="Updating Service" c=0; spc=''; spc1=$((${cw_spc}-${#msg})) until [ $c = ${spc1} ]; do spc="${spc} "; c=`expr $c + 1`; done echo -en "${idsCL[White]}${msg}${spc} : ${idsCL[Default]}" @@ -907,8 +893,6 @@ UPDATESERVICE(){ rm -Rf /opt/${usrvc^} >> ${MMFOLDER}/logs/update.${usrvc} mkdir /opt/${usrvc^} >> ${MMFOLDER}/logs/update.${usrvc} fi - /bin/tar -cpPf $bak /opt/${usrvc^} >> ${MMFOLDER}/logs/update.${usrvc} - [ "${MM_SERVICE_CFG[${usrvc}]}" != "" ] && [ -d ${MM_SERVICE_CFG[${usrvc}]} ] && /bin/tar -cpPf $bakcfg ${MM_SERVICE_CFG[${usrvc}]} >> ${MMFOLDER}/logs/update.${usrvc} if [ "${usrvc}" == "ombi" ]; then /bin/tar xfP ${tmpfile} -C /opt/${usrvc^} >> ${MMFOLDER}/logs/update.${usrvc} @@ -928,18 +912,7 @@ UPDATESERVICE(){ /bin/sed -i /${usrvc}/d ${MMFOLDER}/vers.info echo "${usrvc}_VER=\"${latest_ver}\"" >> ${MMFOLDER}/vers.info - msg="Starting service back up"; c=0; spc=''; spc1=$((${cw_spc}-${#msg})); until [ $c = ${spc1} ]; do spc="${spc} "; c=`expr $c + 1`; done - echo -en "${idsCL[White]}${msg}${spc} : ${idsCL[Default]}" - - OUT=$(ip link | grep "$VPN_INTERFACE") >/dev/null 2>&1 - if [[ " ${SERVICES_CHECK[*]} " =~ " ${usrvc} " ]] && [ ! -f ${MMFOLDER}/mm.noservices ] && [ ! `find /opt/idssys/mediamanager/ -name 'mm.plexmount.fail*'` ]; then - /bin/systemctl disable ${usrvc} >> ${MMFOLDER}/logs/update.${usrvc} - /bin/systemctl start ${usrvc} >> ${MMFOLDER}/logs/update.${usrvc} - [ "${usrvc}" == "radarr" ] && [[ " ${SERVICES_CHECK[*]} " =~ " radarr3d " ]] && /bin/systemctl start radarr3d >> ${MMFOLDER}/logs/update.${usrvc} - echo -e "${idsCL[Green]}Done${idsCL[Default]}" - else - echo -e "${idsCL[LightCyan]}Skipping${idsCL[Default]}" - fi + SERVICEBACKUPSTART ${usrvc} echo "$(date) - Updating Service (${usrvc}) : Completed" >> $logfile echo -e "${idsCL[Green]}${usrvc^} Service has been updated${idsCL[Default]}" @@ -955,13 +928,16 @@ UPDATESERVICE(){ if [ "$(apt-get -s upgrade | grep ${usrvc})" != "" ] || [ "${2}" == "force" ]; then echo -e "${idsCL[Green]}Done${idsCL[Default]}" + SERVICEBACKUP ${usrvc} + msg="Updating service"; c=0; spc=''; spc1=$((${cw_spc}-${#msg})); until [ $c = ${spc1} ]; do spc="${spc} "; c=`expr $c + 1`; done echo -en "${idsCL[White]}${msg}${spc} : ${idsCL[Default]}" /usr/bin/apt install ${usrvc} >/dev/null 2>&1 - /bin/systemctl disable ${usrvc} >/dev/null 2>&1 echo -e "${idsCL[Green]}Done${idsCL[Default]}" echo "$(date) - Updating Service (${usrvc}) : Completed" >> $logfile + SERVICEBACKUPSTART ${usrvc} + else echo -e "${idsCL[LightCyan]}Update Not Needed${idsCL[Default]}" echo "$(date) - Updating Service (${usrvc}) : Update not needed" >> $logfile @@ -983,6 +959,36 @@ UPDATESERVICE(){ } +SERVICEBACKUP(){ + usrvc=${1} + msg="Stopping Service and Backing Up"; c=0; spc=''; spc1=$((${cw_spc}-${#msg})); until [ $c = ${spc1} ]; do spc="${spc} "; c=`expr $c + 1`; done + echo -en "${idsCL[White]}${msg}${spc} : ${idsCL[Default]}" + /bin/systemctl stop ${usrvc} >> ${MMFOLDER}/logs/update.${usrvc} + [ "${usrvc}" == "radarr" ] && /bin/systemctl stop radarr3d >> ${MMFOLDER}/logs/update.${usrvc} + tmpfile=/tmp/${usrvc}-update.tar.gz + bak=/opt/Backups/${usrvc}.opt.tgz + bakcfg=/opt/Backups/${usrvc}.cfg.tgz + [[ -f ${bak} ]] && rm -f "${bak}" &>/dev/null + [[ -f ${tmpfile} ]] && rm -f "${tmpfile}" &>/dev/null + [ "${MM_SERVICE_APP[$usrvc]}" != "" ] && bkfldr=${MM_SERVICE_APP[$usrvc]} || bkfldr=/opt/${usrvc^} + /bin/tar -cpPf $bak ${bkfldr} >> ${MMFOLDER}/logs/update.${usrvc} + [ "${MM_SERVICE_CFG[${usrvc}]}" != "" ] && [ -d ${MM_SERVICE_CFG[${usrvc}]} ] && /bin/tar -cpPf $bakcfg ${MM_SERVICE_CFG[${usrvc}]} >> ${MMFOLDER}/logs/update.${usrvc} + echo -e "${idsCL[Green]}Done${idsCL[Default]}" +} +SERVICEBACKUPSTART(){ + msg="Starting service back up"; c=0; spc=''; spc1=$((${cw_spc}-${#msg})); until [ $c = ${spc1} ]; do spc="${spc} "; c=`expr $c + 1`; done + echo -en "${idsCL[White]}${msg}${spc} : ${idsCL[Default]}" + OUT=$(ip link | grep "$VPN_INTERFACE") >/dev/null 2>&1 + if [[ " ${SERVICES_CHECK[*]} " =~ " ${usrvc} " ]] && [ ! -f ${MMFOLDER}/mm.noservices ] && [ ! `find /opt/idssys/mediamanager/ -name 'mm.plexmount.fail*'` ]; then + /bin/systemctl disable ${usrvc} >> ${MMFOLDER}/logs/update.${usrvc} + /bin/systemctl start ${usrvc} >> ${MMFOLDER}/logs/update.${usrvc} + [ "${usrvc}" == "radarr" ] && [[ " ${SERVICES_CHECK[*]} " =~ " radarr3d " ]] && /bin/systemctl start radarr3d >> ${MMFOLDER}/logs/update.${usrvc} + echo -e "${idsCL[Green]}Done${idsCL[Default]}" + else + echo -e "${idsCL[LightCyan]}Skipping${idsCL[Default]}" + fi +} + SHOWSRVCUPDATES(){ echo -e "${idsCL[LightCyan]}Latest Update URLs Available${idsCL[Default]}" DIVIDER . lightGreen