diff options
Diffstat (limited to 'bin/nextcloud-pharupdate')
-rwxr-xr-x | bin/nextcloud-pharupdate | 97 |
1 files changed, 97 insertions, 0 deletions
diff --git a/bin/nextcloud-pharupdate b/bin/nextcloud-pharupdate new file mode 100755 index 0000000..b05404d --- /dev/null +++ b/bin/nextcloud-pharupdate @@ -0,0 +1,97 @@ +#!/usr/bin/env bash + +# This will not be maintained anymore. It's an older script entirely relying +# on updater.phar - and I'm not happy with the latter, so I've integrated this +# into my conf file construct, also for cutover to the new scripts, and then +# be abandoned once production can 100% rely on the new scripts. + +# shellcheck disable=SC1091 +source /etc/lirion/nextcloud.conf || exit 1 + +COREUP=0 +APPSUP=0 +NCSTATUS=0 +UPDCHECK=0 +[ -n "$COLUMNS" ] && MYCOLS="$COLUMNS" +[ -z "$MYCOLS" ] && MYCOLS="$(tput cols 2>/dev/null)" +[ -z "$MYCOLS" ] && MYCOLS="32" +function dashprint { + printf "\\033[;1m" + for (( i=0; i<MYCOLS; ++i ));do + printf "-" + done + printf "\\033[0m\\n" +} +function hayulp { + printf "USAGE: %b [-a] [-c] [-s] [-u]\\n" "$(basename "$0")" + ( + printf -- "-a:;Update all apps\\n" + printf -- "-c:;Update the Nextcloud core\\n" + printf -- "-s:;Status including version\\n" + printf -- "-u:;Status including update check\\n" + printf -- "-h:;This help text\\n" + )|column -ts \; +} +while getopts :cahsu SHOPT;do + # shellcheck disable=SC2220 + case "$SHOPT" in + c) COREUP=1;; + a) APPSUP=1;; + s) NCSTATUS=1;; + u) UPDCHECK=1;; + h)hayulp;exit 0;; + esac +done +if [ "$COREUP" -eq 1 ] || [ "$APPSUP" -eq 1 ];then + sudo stat -tL "${NCAPPLDIR}" >/dev/null 2>&1 || exit 101 +fi +if [ "$NCSTATUS" -eq 1 ];then + sudo -u "${NCUSER}" "$NCPHPBIN" "${NCAPPLDIR}/occ" status + MYRET="$?" + [ "$MYRET" -ne 0 ] && exit "$MYRET" + if [ "$UPDCHECK" -eq 1 ];then + sudo -u "${NCUSER}" "$NCPHPBIN" "${NCAPPLDIR}/occ" update:check + fi + if [ "$COREUP" -eq 1 ] || [ "$APPSUP" -eq 1 ];then + printf "\\nYou selected the status action, not proceeding with updates.\\n" + exit 255 + fi + exit "$MYRET" +fi +if [ "$UPDCHECK" -eq 1 ];then + sudo -u "${NCUSER}" "$NCPHPBIN" "${NCAPPLDIR}/occ" update:check +fi +if [ "$COREUP" -eq 1 ];then + dashprint + printf "\\033[1mupdater/updater.phar\\033[0m\\n" + sudo -u "${NCUSER}" "$NCPHPBIN" "${NCAPPLDIR}/updater/updater.phar" || exit 1 + dashprint +fi +if [ "$APPSUP" -eq 1 ];then + printf "\\033[1mocc app:update --all\\033[0m\\n" + sudo -u "${NCUSER}" "$NCPHPBIN" "${NCAPPLDIR}/occ" app:update --all || exit 2 + # NC 29+: Now there's a message if no updates could be found. Commenting out the following: + # printf "\\033[96mDone.\\033[0m\\n" + dashprint +fi +if [ "$COREUP" -eq 1 ] || [ "$APPSUP" -eq 1 ];then + printf "\\033[1mocc db:add-missing-primary-keys\\033[0m\\n" + sudo -u "${NCUSER}" "$NCPHPBIN" "${NCAPPLDIR}/occ" db:add-missing-primary-keys || exit 3 + dashprint + printf "\\033[1mocc db:add-missing-columns\\033[0m\\n" + sudo -u "${NCUSER}" "$NCPHPBIN" "${NCAPPLDIR}/occ" db:add-missing-columns || exit 4 + printf "\\033[1m-------------------------------\\033[0m\\n" + printf "\\033[1mocc db:add-missing-indices\\033[0m\\n" + sudo -u "${NCUSER}" "$NCPHPBIN" "${NCAPPLDIR}/occ" db:add-missing-indices || exit 5 + printf "\\033[96mDone.\\033[0m\\n" + dashprint + printf "\\033[1mcron.php\\033[0m\\n" + sudo -u "${NCUSER}" "$NCPHPBIN" -f "${NCAPPLDIR}/cron.php" || exit 6 + printf "\\033[96mDone.\\033[0m\\n" + dashprint +fi +if [ "$COREUP" -eq 0 ] && [ "$APPSUP" -eq 0 ] && [ "$NCSTATUS" -eq 0 ] && [ "$UPDCHECK" -eq 0 ];then + hayulp + printf "\\nNo option specified.\\n" >&2 + exit 101 +fi |