You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

82 lines
2.1 KiB

#!/bin/bash
# Author: Tealk
# Repo: https://codeberg.org/Tealk/shell-administration-script
# shellcheck disable=SC2034
title="Update"
error=false
printf " %b %s..." "${INFO}" "${title}"
if [ "${PROGNAME}" = "NextCloud" ]; then
chmod 770 "${FULLPATH}"/occ
sleep 3
# shellcheck disable=SC2024
if ! sudo -u "${WEBUSER}" "${PHP}" "${FULLPATH}"/occ upgrade --no-interaction >>"$FULLPATH"/upgrade.log 2>&1; then
reason="can't upgrade"
error=true
ERROR
fi
if [ "${INSTALLAPP}" = "true" ]; then
for IAPP in "${APPINSTALL[@]}"; do
if ! sudo -u "${WEBUSER}" "${PHP}" "${FULLPATH}"/occ app:install "${IAPP}" >/dev/null 2>&1; then
reason="can't install app $IAPP"
ERROR
fi
echo "${IAPP}" was successfully installed
done
for EAPP in "${APPENABLE[@]}"; do
if ! sudo -u "${WEBUSER}" "${PHP}" "${FULLPATH}"/occ app:enable "${EAPP}" >/dev/null 2>&1; then
reason="can't enable app ${EAPP}"
ERROR
fi
echo "${IAPP}" was successfully enabled
done
for DAPP in "${APPDISABLE[@]}"; do
if ! sudo -u "${WEBUSER}" "${PHP}" "${FULLPATH}"/occ app:disable "${DAPP}" >/dev/null 2>&1; then
reason="can't disable app ${DAPP}"
ERROR
fi
echo "${IAPP}" was successfully disabled
done
if ! sudo -u "${WEBUSER}" "${PHP}" "${FULLPATH}"/occ app:update --all >/dev/null 2>&1; then
reason="can't update apps"
ERROR
fi
fi
fi
if [ "${PROGNAME}" = "MediaWiki" ]; then
# shellcheck disable=SC2024
if ! sudo -u "${WEBUSER}" "${PHP}" "${FULLPATH}"/maintenance/update.php >>"$FULLPATH"/upgrade.log 2>&1; then
reason="can't upgrade"
error=true
ERROR
fi
fi
if [ "${PROGNAME}" = "writefreely" ]; then
# shellcheck disable=SC2024
if ! "${FULLPATH}"/writefreely db migrate >>"$FULLPATH"/upgrade.log 2>&1; then
reason="can't migrate db"
error=true
ERROR
fi
if [[ "yes" == $(ASKYN "Generate a new encryption key?") ]]; then
if ! "${FULLPATH}"/writefreely keys generate >/dev/null 2>&1; then
reason="can't generate keys"
error=true
ERROR
fi
fi
fi
if [ ! ${error} ]; then
printf "%b %b %s\\n" "${OVER}" "${TICK}" "${title}"
fi