diff --git a/mm-scripts.sh b/mm-scripts.sh index 7d0d437..c4b0e9b 100755 --- a/mm-scripts.sh +++ b/mm-scripts.sh @@ -5,17 +5,13 @@ action="$1" VERBOSE=true -if [ -f /opt/idssys/settings/mediamanager.conf ]; then - mv /opt/idssys/settings/mediamanager.conf ${MMFOLDER}/settings.conf -fi - source /opt/idssys/defaults/colors.inc source /opt/idssys/defaults/default.inc source /opt/idssys/mediamanager/settings.conf source /opt/idssys/mediamanager/defaults.inc [ -f ${MMFOLDER}/realwanip ] && source ${MMFOLDER}/realwanip [ -f ${MMFOLDER}/vers.info ] && source ${MMFOLDER}/vers.info - +[ "${GITBRANCH}" != "" ] && GBRANCH="${GITBRANCH}" || GBRANCH="master" if [ "${2}" == "q" ]; then unset idsCL idsBG idsST @@ -59,8 +55,9 @@ MMCRONCHECK(){ echo "$(date) - Updated All Services" >> $logfile fi elif [ $(date +%H)$(date +%M) -ge 0300 ] && [ $(date +%H)$(date +%M) -lt 0305 ] ; then - if [ $(expr `date +%s` - $(stat -c %Y ${MMFOLDER}/.git/index)) -gt 600 ]; then + if [ $(expr `date +%s` - $(stat -c %Y ${MMFOLDER}/.git/ORIG_HEAD)) -gt 600 ] && [ "`git -C /opt/idssys/nodemgmt log --pretty=%H ...refs/heads/${GBRANCH}^ | head -n 1`" != "`git -C /opt/idssys/nodemgmt ls-remote origin -h refs/heads/${GBRANCH} |cut -f1`" ]; then /usr/local/bin/mm update q >/dev/null 2>&1 + source /opt/idssys/mediamanager/defaults.inc echo "$(date) - Updated MM Scripts to v${VERS}" >> $logfile fi fi @@ -848,11 +845,11 @@ UPDATESERVICE(){ echo -en "${idsCL[White]}${msg}${spc} : ${idsCL[Default]}" /bin/systemctl restart nginx >/dev/null 2>&1 echo -e "${idsCL[Green]}Done${idsCL[Default]}" + echo "$(date) - Updating Service (${usrvc}) : Completed" >> $logfile else echo -e " ${idsCL[LightCyan]} Update Not Needed ${idsCL[Default]}" + echo "$(date) - Updating Service (${usrvc}) : Update Not Needed" >> $logfile fi - - echo "$(date) - Updated Organizr" >> $logfile else if [[ " ${UPDATE_SERVICES[*]} " =~ " ${usrvc} " ]]; then @@ -954,7 +951,7 @@ UPDATESERVICE(){ else echo -e "${idsCL[LightCyan]} Update Not Needed ${idsCL[Default]}" - + echo "$(date) - Updating Service (${usrvc}) : Update Not Needed" >> $logfile fi elif [ "${MM_UPDATE_REPO[${usrvc}]}" == "systemd" ]; then @@ -969,10 +966,11 @@ UPDATESERVICE(){ /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 else echo -e "${idsCL[LightCyan]}Update Not Needed${idsCL[Default]}" - + echo "$(date) - Updating Service (${usrvc}) : Update not needed" >> $logfile fi fi diff --git a/run.sh b/run.sh index c682b24..0a660cb 100755 --- a/run.sh +++ b/run.sh @@ -4,6 +4,9 @@ source /opt/idssys/defaults/colors.inc source /opt/idssys/defaults/default.inc source /opt/idssys/mediamanager/defaults.inc +source ${MMFOLDER}/settings.conf +[ "${GITBRANCH}" != "" ] && GBRANCH="${GITBRANCH}" || GBRANCH="master" + if [ "${2}" == "q" ]; then unset idsCL idsBG idsST @@ -13,12 +16,6 @@ if [ "${2}" == "q" ]; then [ "${1}" == "update" ] && echo -e "\n\n$(date) - Starting log #############################\n" >> ${outputlogfile} fi -if [ -f /opt/idssys/settings/mediamanager.conf ]; then - source /opt/idssys/settings/mediamanager.conf -else - source ${MMFOLDER}/settings.conf -fi - if ([ "${1}" == "check" ] && [ "$(date +%M)" == "15" ]) || [ "${1}" == "" ]; then MMUPDATECHECK fi @@ -47,23 +44,22 @@ if [ "${1}" == "update" ] || [ "${1}" == "setup" ]; then fi cd ${MMFOLDER} - [ "${GITBRANCH}" != "" ] && gb="${GITBRANCH}" || gb="master" - if [ "`git log --pretty=%H ...refs/heads/${gb}^ | head -n 1`" != "`git ls-remote origin -h refs/heads/${gb} |cut -f1`" ]; then + if [ "`git log --pretty=%H ...refs/heads/${GBRANCH}^ | head -n 1`" != "`git ls-remote origin -h refs/heads/${GBRANCH} |cut -f1`" ]; then if [ "${2}" != "q" ]; then echo -en "\e[1A"; echo -e "\e[0K\r ${idsCL[LightCyan]}Installing mediamanager updates...${idsCL[Default]}" else echo -e "${idsCL[LightCyan]}Installing mediamanager updates...${idsCL[Default]}" fi - git fetch origin ${gb} >/dev/null 2>&1 - git reset --hard origin/${gb} >/dev/null 2>&1 + git fetch origin ${GBRANCH} >/dev/null 2>&1 + git reset --hard origin/${GBRANCH} >/dev/null 2>&1 git reflog expire --expire=now --all >/dev/null 2>&1 git repack -ad >/dev/null 2>&1 git prune >/dev/null 2>&1 git pull >/dev/null 2>&1 git submodule update --remote >/dev/null 2>&1 /bin/chmod +x ${MMFOLDER}/mm-scripts.sh 2>&1 - source /opt/idssys/mediamanager/defaults.inc + source ${MMFOLDER}/defaults.inc if [ "${2}" != "q" ]; then echo -en "\e[1A"; echo -e "\e[0K\r ${idsCL[Green]}Update to v${VERS} complete${idsCL[Default]}"