Update mm-scripts.sh
This commit is contained in:
248
mm-scripts.sh
248
mm-scripts.sh
@@ -827,144 +827,150 @@ VPNSPEEDTEST(){
|
|||||||
}
|
}
|
||||||
|
|
||||||
UPDATESERVICE(){
|
UPDATESERVICE(){
|
||||||
if [ "${1}" == "all" ]; then
|
if [ "${1}" == "service" ]; then
|
||||||
for usrvc in "${UPDATE_SERVICES[@]}"; do
|
if [ "${2}" == "all" ]; then
|
||||||
[ "${MM_UPDATE_REPO[${usrvc}]}" != "" ] && UPDATESERVICE ${usrvc} ${2}
|
for usrvc in "${UPDATE_SERVICES[@]}"; do
|
||||||
done
|
[ "${MM_UPDATE_REPO[${usrvc}]}" != "" ] && UPDATESERVICE service ${usrvc} ${3}
|
||||||
|
done
|
||||||
|
|
||||||
elif [ "${1}" != "" ]; then
|
elif [ "${2}" != "" ]; then
|
||||||
usrvc=${1}
|
usrvc=${2}
|
||||||
echo "${usrvc} Update" > ${TMPFOLDER}/mm.update.stop
|
echo "${usrvc} Update" > ${TMPFOLDER}/mm.update.stop
|
||||||
echo "$(date) - Updating Service (${usrvc}) : Starting" >> $logfile
|
echo "$(date) - Updating Service (${usrvc}) : Starting" >> $logfile
|
||||||
echo
|
echo
|
||||||
echo -e "${idsCL[Green]}Updating ${usrvc^} Service${idsCL[Default]}"
|
echo -e "${idsCL[Green]}Updating ${usrvc^} Service${idsCL[Default]}"
|
||||||
DIVIDER . lightGreen
|
DIVIDER . lightGreen
|
||||||
if [ "${usrvc}" == "organizr" ]; then
|
if [ "${usrvc}" == "organizr" ]; then
|
||||||
msg="Checking for update"; c=0; spc=''; spc1=$((${cw_spc}-${#msg})); until [ $c = ${spc1} ]; do spc="${spc} "; c=`expr $c + 1`; done
|
msg="Checking for update"; 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]}"
|
|
||||||
|
|
||||||
cd /var/www/media.scity.us/html >/dev/null 2>&1
|
|
||||||
if [ "`git log --pretty=%H ...refs/heads/v2-master^ | head -n 1`" != "`git ls-remote origin -h refs/heads/v2-master |cut -f1`" ] || [ "${2}" == "-f" ]; then
|
|
||||||
[ "${2}" == "-f" ] && echo -e "${idsCL[LightCyan]}Update Not Needed, forcing anyway${idsCL[Default]}" || echo -e "${idsCL[Green]}Update Available${idsCL[Default]}"
|
|
||||||
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]}"
|
echo -en "${idsCL[White]}${msg}${spc} : ${idsCL[Default]}"
|
||||||
/usr/bin/git stash >/dev/null 2>&1
|
|
||||||
/usr/bin/git pull >/dev/null 2>&1
|
|
||||||
/bin/chown -Rf www-data:www-data /var/www/media.scity.us/html
|
|
||||||
echo -e "${idsCL[Green]}Done${idsCL[Default]}"
|
|
||||||
|
|
||||||
msg="Restarting NGINX"; 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 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 Available${idsCL[Default]}"
|
|
||||||
echo "$(date) - Updating Service (${usrvc}) : Update Not Needed" >> $logfile
|
|
||||||
fi
|
|
||||||
|
|
||||||
else
|
cd /var/www/media.scity.us/html >/dev/null 2>&1
|
||||||
if [[ " ${UPDATE_SERVICES[*]} " =~ " ${usrvc} " ]]; then
|
if [ "`git log --pretty=%H ...refs/heads/v2-master^ | head -n 1`" != "`git ls-remote origin -h refs/heads/v2-master |cut -f1`" ] || [ "${3}" == "-f" ]; then
|
||||||
if [ "${MM_UPDATE_REPO[${usrvc}]}" != "" ] && [ "${MM_UPDATE_REPO[${usrvc}]}" != "systemd" ]; then
|
[ "${3}" == "-f" ] && echo -e "${idsCL[LightCyan]}Update Not Needed, forcing anyway${idsCL[Default]}" || echo -e "${idsCL[Green]}Update Available${idsCL[Default]}"
|
||||||
|
msg="Updating service"; c=0; spc=''; spc1=$((${cw_spc}-${#msg})); until [ $c = ${spc1} ]; do spc="${spc} "; c=`expr $c + 1`; done
|
||||||
msg="Checking for update"; 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]}"
|
echo -en "${idsCL[White]}${msg}${spc} : ${idsCL[Default]}"
|
||||||
|
/usr/bin/git stash >/dev/null 2>&1
|
||||||
if [[ $BETA_SERVICES == *${usrvc}* ]]; then
|
/usr/bin/git pull >/dev/null 2>&1
|
||||||
latest_release_url=`curl -s https://api.github.com/repos/${MM_UPDATE_REPO[${usrvc}]}/${usrvc}/releases | jq -r '.[0].assets[].browser_download_url' | grep "${MM_UPDATE_REPO_GREP[${usrvc}]}" | cut -d '"' -f 4 | grep -i 'https://'`
|
/bin/chown -Rf www-data:www-data /var/www/media.scity.us/html
|
||||||
echo "$(date) - Updating Service (${usrvc}) : BETA UPDATEURL = ${latest_release_url}" >> $logfile
|
echo -e "${idsCL[Green]}Done${idsCL[Default]}"
|
||||||
beta="BETA "
|
|
||||||
else
|
msg="Restarting NGINX"; c=0; spc=''; spc1=$((${cw_spc}-${#msg})); until [ $c = ${spc1} ]; do spc="${spc} "; c=`expr $c + 1`; done
|
||||||
latest_release_url=`curl -s https://api.github.com/repos/${MM_UPDATE_REPO[${usrvc}]}/${usrvc}/releases/latest | jq -r '.assets[].browser_download_url' | grep "${MM_UPDATE_REPO_GREP[${usrvc}]}" | cut -d '"' -f 4 | grep -i 'https://'`
|
echo -en "${idsCL[White]}${msg}${spc} : ${idsCL[Default]}"
|
||||||
echo "$(date) - Updating Service (${usrvc}) : UPDATEURL = ${latest_release_url}" >> $logfile
|
/bin/systemctl restart nginx >/dev/null 2>&1
|
||||||
beta=""
|
echo -e "${idsCL[Green]}Done${idsCL[Default]}"
|
||||||
fi
|
echo "$(date) - Updating Service (${usrvc}) : Completed" >> $logfile
|
||||||
latest_ver=`echo ${latest_release_url} | cut -d/ -f8`
|
else
|
||||||
cver=${usrvc}_VER
|
echo -e "${idsCL[LightCyan]}Update Not Available${idsCL[Default]}"
|
||||||
|
echo "$(date) - Updating Service (${usrvc}) : Update Not Needed" >> $logfile
|
||||||
if [ "${!cver}" != "${latest_ver}" ] || [ "${2}" == "-f" ]; then
|
fi
|
||||||
[ "${2}" == "-f" ] && echo -e "${idsCL[LightCyan]}Update Not Needed, forcing anyway${idsCL[Default]}" || echo -e "${idsCL[Green]}Update Available${idsCL[Default]}"
|
|
||||||
# rm -f ${MMFOLDER}/logs/update.${usrvc}
|
else
|
||||||
touch ${MMFOLDER}/logs/update.${usrvc}
|
if [[ " ${UPDATE_SERVICES[*]} " =~ " ${usrvc} " ]]; then
|
||||||
|
if [ "${MM_UPDATE_REPO[${usrvc}]}" != "" ] && [ "${MM_UPDATE_REPO[${usrvc}]}" != "systemd" ]; then
|
||||||
SERVICEBACKUP ${usrvc}
|
|
||||||
|
msg="Checking for update"; c=0; spc=''; spc1=$((${cw_spc}-${#msg})); until [ $c = ${spc1} ]; do spc="${spc} "; c=`expr $c + 1`; done
|
||||||
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]}"
|
echo -en "${idsCL[White]}${msg}${spc} : ${idsCL[Default]}"
|
||||||
|
|
||||||
|
if [[ $BETA_SERVICES == *${usrvc}* ]]; then
|
||||||
|
latest_release_url=`curl -s https://api.github.com/repos/${MM_UPDATE_REPO[${usrvc}]}/${usrvc}/releases | jq -r '.[0].assets[].browser_download_url' | grep "${MM_UPDATE_REPO_GREP[${usrvc}]}" | cut -d '"' -f 4 | grep -i 'https://'`
|
||||||
|
echo "$(date) - Updating Service (${usrvc}) : BETA UPDATEURL = ${latest_release_url}" >> $logfile
|
||||||
|
beta="BETA "
|
||||||
|
else
|
||||||
|
latest_release_url=`curl -s https://api.github.com/repos/${MM_UPDATE_REPO[${usrvc}]}/${usrvc}/releases/latest | jq -r '.assets[].browser_download_url' | grep "${MM_UPDATE_REPO_GREP[${usrvc}]}" | cut -d '"' -f 4 | grep -i 'https://'`
|
||||||
|
echo "$(date) - Updating Service (${usrvc}) : UPDATEURL = ${latest_release_url}" >> $logfile
|
||||||
|
beta=""
|
||||||
|
fi
|
||||||
|
latest_ver=`echo ${latest_release_url} | cut -d/ -f8`
|
||||||
|
cver=${usrvc}_VER
|
||||||
|
|
||||||
|
if [ "${!cver}" != "${latest_ver}" ] || [ "${3}" == "-f" ]; then
|
||||||
|
[ "${3}" == "-f" ] && echo -e "${idsCL[LightCyan]}Update Not Needed, forcing anyway${idsCL[Default]}" || echo -e "${idsCL[Green]}Update Available${idsCL[Default]}"
|
||||||
|
# rm -f ${MMFOLDER}/logs/update.${usrvc}
|
||||||
|
touch ${MMFOLDER}/logs/update.${usrvc}
|
||||||
|
|
||||||
|
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]}"
|
||||||
|
|
||||||
if curl --output /dev/null --silent --head --fail $latest_release_url; then
|
if curl --output /dev/null --silent --head --fail $latest_release_url; then
|
||||||
wget -qO ${tmpfile} $latest_release_url >> ${MMFOLDER}/logs/update.${usrvc}
|
wget -qO ${tmpfile} $latest_release_url >> ${MMFOLDER}/logs/update.${usrvc}
|
||||||
if [[ ( $? -eq 0 ) && ( -f ${tmpfile} ) ]]; then
|
if [[ ( $? -eq 0 ) && ( -f ${tmpfile} ) ]]; then
|
||||||
if [ "${usrvc}" != "bazarr" ]; then
|
if [ "${usrvc}" != "bazarr" ]; then
|
||||||
rm -Rf /opt/${usrvc^} >> ${MMFOLDER}/logs/update.${usrvc}
|
rm -Rf /opt/${usrvc^} >> ${MMFOLDER}/logs/update.${usrvc}
|
||||||
mkdir /opt/${usrvc^} >> ${MMFOLDER}/logs/update.${usrvc}
|
mkdir /opt/${usrvc^} >> ${MMFOLDER}/logs/update.${usrvc}
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ "${usrvc}" == "ombi" ]; then
|
if [ "${usrvc}" == "ombi" ]; then
|
||||||
/bin/tar xfP ${tmpfile} -C /opt/${usrvc^} >> ${MMFOLDER}/logs/update.${usrvc}
|
/bin/tar xfP ${tmpfile} -C /opt/${usrvc^} >> ${MMFOLDER}/logs/update.${usrvc}
|
||||||
elif [ "${usrvc}" == "bazarr" ]; then
|
elif [ "${usrvc}" == "bazarr" ]; then
|
||||||
/usr/bin/unzip -oqq ${tmpfile} -d /opt/${usrvc^}
|
/usr/bin/unzip -oqq ${tmpfile} -d /opt/${usrvc^}
|
||||||
else
|
else
|
||||||
/bin/tar xfP ${tmpfile} -C /opt >> ${MMFOLDER}/logs/update.${usrvc}
|
/bin/tar xfP ${tmpfile} -C /opt >> ${MMFOLDER}/logs/update.${usrvc}
|
||||||
|
fi
|
||||||
|
chown -R user:users /opt/${usrvc^} >> ${MMFOLDER}/logs/update.${usrvc}
|
||||||
fi
|
fi
|
||||||
chown -R user:users /opt/${usrvc^} >> ${MMFOLDER}/logs/update.${usrvc}
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
rm -f ${tmpfile} &>/dev/null
|
||||||
|
echo -e "${idsCL[Green]}Done${idsCL[Default]}"
|
||||||
|
|
||||||
|
[ ! -f ${TMPFOLDER}/vers.info ] && touch ${TMPFOLDER}/vers.info
|
||||||
|
/bin/sed -i /${usrvc}/d ${TMPFOLDER}/vers.info
|
||||||
|
echo "${usrvc}_VER=\"${latest_ver}\"" >> ${TMPFOLDER}/vers.info
|
||||||
|
|
||||||
|
SERVICEBACKUPSTART ${usrvc}
|
||||||
|
|
||||||
|
echo "$(date) - Updating Service (${usrvc}) : Completed" >> $logfile
|
||||||
|
echo -e "${idsCL[Green]}${usrvc^} Service has been updated${idsCL[Default]}"
|
||||||
|
|
||||||
|
else
|
||||||
|
echo -e "${idsCL[LightCyan]}Update Not Available${idsCL[Default]}"
|
||||||
|
echo "$(date) - Updating Service (${usrvc}) : Update Not Needed" >> $logfile
|
||||||
fi
|
fi
|
||||||
|
|
||||||
rm -f ${tmpfile} &>/dev/null
|
elif [ "${MM_UPDATE_REPO[${usrvc}]}" == "systemd" ]; then
|
||||||
echo -e "${idsCL[Green]}Done${idsCL[Default]}"
|
msg="Checking for update"; c=0; spc=''; spc1=$((${cw_spc}-${#msg})); until [ $c = ${spc1} ]; do spc="${spc} "; c=`expr $c + 1`; done
|
||||||
|
|
||||||
[ ! -f ${TMPFOLDER}/vers.info ] && touch ${TMPFOLDER}/vers.info
|
|
||||||
/bin/sed -i /${usrvc}/d ${TMPFOLDER}/vers.info
|
|
||||||
echo "${usrvc}_VER=\"${latest_ver}\"" >> ${TMPFOLDER}/vers.info
|
|
||||||
|
|
||||||
SERVICEBACKUPSTART ${usrvc}
|
|
||||||
|
|
||||||
echo "$(date) - Updating Service (${usrvc}) : Completed" >> $logfile
|
|
||||||
echo -e "${idsCL[Green]}${usrvc^} Service has been updated${idsCL[Default]}"
|
|
||||||
|
|
||||||
else
|
|
||||||
echo -e "${idsCL[LightCyan]}Update Not Available${idsCL[Default]}"
|
|
||||||
echo "$(date) - Updating Service (${usrvc}) : Update Not Needed" >> $logfile
|
|
||||||
fi
|
|
||||||
|
|
||||||
elif [ "${MM_UPDATE_REPO[${usrvc}]}" == "systemd" ]; then
|
|
||||||
msg="Checking for update"; 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]}"
|
|
||||||
[ "${usrvc}" == "qbittorrent" ] && ausrvc="qbittorrent-nox" || ausrvc=${usrvc}
|
|
||||||
|
|
||||||
if [ "$(apt-get -s upgrade | grep ${ausrvc})" != "" ] || [ "${2}" == "-f" ]; then
|
|
||||||
echo -e "${idsCL[Green]}Update Available${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]}"
|
echo -en "${idsCL[White]}${msg}${spc} : ${idsCL[Default]}"
|
||||||
/usr/bin/apt install ${ausrvc} -y >/dev/null 2>&1
|
[ "${usrvc}" == "qbittorrent" ] && ausrvc="qbittorrent-nox" || ausrvc=${usrvc}
|
||||||
echo -e "${idsCL[Green]}Done${idsCL[Default]}"
|
|
||||||
echo "$(date) - Updating Service (${usrvc}) : Completed" >> $logfile
|
|
||||||
|
|
||||||
SERVICEBACKUPSTART ${usrvc}
|
|
||||||
|
|
||||||
else
|
|
||||||
echo -e "${idsCL[LightCyan]}Update Not Available${idsCL[Default]}"
|
|
||||||
echo "$(date) - Updating Service (${usrvc}) : Update not needed" >> $logfile
|
|
||||||
fi
|
|
||||||
|
|
||||||
fi
|
if [ "$(apt-get -s upgrade | grep ${ausrvc})" != "" ] || [ "${2}" == "-f" ]; then
|
||||||
|
echo -e "${idsCL[Green]}Update Available${idsCL[Default]}"
|
||||||
else
|
SERVICEBACKUP ${usrvc}
|
||||||
echo -e "${idsCL[Red]}Not currently available to update${idsCL[Default]}"
|
|
||||||
|
|
||||||
|
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 ${ausrvc} -y >/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 Available${idsCL[Default]}"
|
||||||
|
echo "$(date) - Updating Service (${usrvc}) : Update not needed" >> $logfile
|
||||||
|
fi
|
||||||
|
|
||||||
|
fi
|
||||||
|
|
||||||
|
else
|
||||||
|
echo -e "${idsCL[Red]}Not currently available to update${idsCL[Default]}"
|
||||||
|
|
||||||
|
fi
|
||||||
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
else
|
||||||
|
echo -e "${idsCL[Red]}No service selected for update${idsCL[Default]}"
|
||||||
fi
|
fi
|
||||||
|
rm -f ${TMPFOLDER}/mm.update.stop
|
||||||
|
|
||||||
|
elif [ "${1}" == "list" ]; then
|
||||||
|
SHOWSRVCUPDATES
|
||||||
|
|
||||||
else
|
|
||||||
echo -e "${idsCL[Red]}No service selected for update${idsCL[Default]}"
|
|
||||||
fi
|
fi
|
||||||
rm -f ${TMPFOLDER}/mm.update.stop
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1348,7 +1354,7 @@ MMSETUP(){
|
|||||||
read -n 1 choice
|
read -n 1 choice
|
||||||
case "$choice" in
|
case "$choice" in
|
||||||
[Yy]) for usrvc in "${UPDATE_SERVICES[@]}"; do
|
[Yy]) for usrvc in "${UPDATE_SERVICES[@]}"; do
|
||||||
[ "${MM_UPDATE_REPO[${usrvc}]}" != "" ] && UPDATESERVICE ${usrvc}
|
[ "${MM_UPDATE_REPO[${usrvc}]}" != "" ] && UPDATESERVICE service ${usrvc}
|
||||||
done;;
|
done;;
|
||||||
* ) tmp='';;
|
* ) tmp='';;
|
||||||
esac
|
esac
|
||||||
@@ -1482,7 +1488,7 @@ if [ ! -f ${TMPFOLDER}/mm.update.stop ]; then
|
|||||||
MMSTATUS ${2}
|
MMSTATUS ${2}
|
||||||
;;
|
;;
|
||||||
|
|
||||||
update);;
|
update) UPDATESERVICE ${2} ${3};;
|
||||||
update-list) SHOWSRVCUPDATES;;
|
update-list) SHOWSRVCUPDATES;;
|
||||||
update-service) UPDATESERVICE ${2} ${3};;
|
update-service) UPDATESERVICE ${2} ${3};;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user