diff --git a/conf/update_hostname.conf.sample b/conf/update_hostname.conf.sample index e60f4a8..704d1b6 100644 --- a/conf/update_hostname.conf.sample +++ b/conf/update_hostname.conf.sample @@ -103,3 +103,13 @@ PSQL_PASS= # - defaults to 'localhost' # - PSQL_SERVER= + + +# - WOPI_URL +# - +# - URL to connect ColaboraOnline service +# - +# - Example: +# - WOPI_URL="https://office-cl.oopen.de" +# - +#WOPI_URL="" diff --git a/update_nextcloud.sh b/update_nextcloud.sh index 3d8d02d..fd24fdd 100755 --- a/update_nextcloud.sh +++ b/update_nextcloud.sh @@ -1,7 +1,8 @@ #!/usr/bin/env bash - +script_name="$(basename $(realpath $0))" script_dir="$(dirname $(realpath $0))" + conf_dir="${script_dir}/conf" declare -a unsorted_website_arr+ @@ -18,6 +19,22 @@ backup_date=$(date +%Y-%m-%d-%H%M) clean_up() { + + if [[ -f "$_backup_crontab_file" ]]; then + + echononl "(Re)Install previously saved crontab from '$_backup_crontab_file'.." + + crontab $_backup_crontab_file >> $log_file 2>&1 + + if [[ $? -eq 0 ]]; then + echo_ok + else + echo_failed + error "$(cat $log_file)" + fi + + fi + # Perform program exit housekeeping rm -f $log_file exit $1 @@ -129,6 +146,20 @@ containsElement () { return 1 } +blank_line() { + if $terminal ; then + echo "" + fi +} + + + +# ---------- +# - Jobhandling +# ---------- + +# - Run 'clean_up' for signals SIGHUP SIGINT SIGTERM +# - trap clean_up SIGHUP SIGINT SIGTERM ## - @@ -285,6 +316,24 @@ if [[ "$DATABASE_TYPE" = "postgres" ]]; then fi fi + +# - Determin PHP binary +# - +php_binary="$(realpath "$(which php)")" +if [[ -z "$php_binary" ]]; then + if [[ -x "/usr/local/php/bin/php" ]]; then + php_binary="/usr/local/php/bin/php" + else + fatal "No PHP binary present" + fi +else + if [[ ! -x "$php_binary" ]]; then + fatal "Found PHP binary '$php_binary', but this file is not executable!" + fi +fi + +# - Determin user/group of the webserver +# - httpd_binary="`which httpd`" if [ -z "$httpd_binary" ]; then httpd_binary="$(ps -axu | grep httpd | grep -e "^root" | grep -v grep | awk '{print$11}')" @@ -512,6 +561,7 @@ fi # - Erstelle Web-Verzeichnis für die neue OwnCloud Version # - echononl " Create (new) dir '${WEB_BASE_DIR}/nextcloud-${VERSION}'.." +mkdir "${WEB_BASE_DIR}/nextcloud-${VERSION}" > $log_file 2>&1 if [[ $? -eq 0 ]]; then echo_ok else @@ -522,7 +572,7 @@ mkdir ${WEB_BASE_DIR}/nextcloud-${VERSION} > $log_file 2>&1 # - Kopiere Verzeichnis "config" in das neue Installationsverzeichnis # - -echononl " Copy ols config into '${WEB_BASE_DIR}/nextcloud-${VERSION}'.." +echononl " Copy old config into '${WEB_BASE_DIR}/nextcloud-${VERSION}'.." cp -a ${CURRENT_INSTALL_DIR}/config $INSTALL_DIR/ > $log_file 2>&1 if [[ $? -eq 0 ]]; then echo_ok @@ -665,7 +715,7 @@ fi # - echo "" echo " Update Nextcloud" -su -c"/usr/local/php/bin/php ${WEB_BASE_DIR}/htdocs/occ upgrade" -s /bin/bash $HTTP_USER +su -c"/usr/local/php/bin/php ${WEB_BASE_DIR}/htdocs/occ upgrade" -s /bin/bash $HTTP_USER > $log_file 2>&1 if [[ $? -eq 0 ]]; then echo_ok else @@ -673,6 +723,359 @@ else fatal "$(cat $log_file)" fi + + +# ----- +# - (Re)install/(Re)enable some more nextcloud apps +# ----- + +echo "" +echo "" +echo -e "\033[37m\033[1mi(re)install/(Re)enable some more nextcloud apps..\033[m" +echo "" + + +# - Install and enable nextcloud app 'calendar' +# - +_app="calendar" + +echononl "Install nextcloud app '$_app'.." +sudo -u "$HTTP_USER" "$php_binary" "${INSTALL_DIR}/occ" app:install "$_app" > $log_file 2>&1 +if [[ $? -eq 0 ]]; then + echo_ok +else + echo_failed + error "$(cat $log_file)" + + echononl "continue anyway [yes/no]: " + read OK + OK="$(echo "$OK" | tr '[:upper:]' '[:lower:]')" + while [[ "$OK" != "yes" ]] && [[ "$OK" != "no" ]] ; do + echononl "Wrong entry! - repeat [yes/no]: " + read OK + done + [[ $OK = "yes" ]] || fatal "Interrupted ny user." +fi + +echononl "Eanable nextcloud app '$_app'.." +sudo -u "$HTTP_USER" "$php_binary" "${INSTALL_DIR}/occ" app:enable "$_app" > $log_file 2>&1 +if [[ $? -eq 0 ]]; then + echo_ok +else + echo_failed + error "$(cat $log_file)" + + echononl "continue anyway [yes/no]: " + read OK + OK="$(echo "$OK" | tr '[:upper:]' '[:lower:]')" + while [[ "$OK" != "yes" ]] && [[ "$OK" != "no" ]] ; do + echononl "Wrong entry! - repeat [yes/no]: " + read OK + done + [[ $OK = "yes" ]] || fatal "Interrupted ny user." +fi + + +blank_line + + +# - Install and enable nextcloud app 'contacts' +# - +_app="contacts" + +echononl "Install nextcloud app '$_app'.." +sudo -u "$HTTP_USER" "$php_binary" "${INSTALL_DIR}/occ" app:install "$_app" > $log_file 2>&1 +if [[ $? -eq 0 ]]; then + echo_ok +else + echo_failed + error "$(cat $log_file)" + + echononl "continue anyway [yes/no]: " + read OK + OK="$(echo "$OK" | tr '[:upper:]' '[:lower:]')" + while [[ "$OK" != "yes" ]] && [[ "$OK" != "no" ]] ; do + echononl "Wrong entry! - repeat [yes/no]: " + read OK + done + [[ $OK = "yes" ]] || fatal "Interrupted ny user." +fi + +echononl "Eanable nextcloud app '$_app'.." +sudo -u "$HTTP_USER" "$php_binary" "${INSTALL_DIR}/occ" app:enable "$_app" > $log_file 2>&1 +if [[ $? -eq 0 ]]; then + echo_ok +else + echo_failed + error "$(cat $log_file)" + + echononl "continue anyway [yes/no]: " + read OK + OK="$(echo "$OK" | tr '[:upper:]' '[:lower:]')" + while [[ "$OK" != "yes" ]] && [[ "$OK" != "no" ]] ; do + echononl "Wrong entry! - repeat [yes/no]: " + read OK + done + [[ $OK = "yes" ]] || fatal "Interrupted ny user." +fi + + +blank_line + + +# - Install and enable nextcloud app 'notes' +# - +_app="notes" + +echononl "Install nextcloud app '$_app'.." +sudo -u "$HTTP_USER" "$php_binary" "${INSTALL_DIR}/occ" app:install "$_app" > $log_file 2>&1 +if [[ $? -eq 0 ]]; then + echo_ok +else + echo_failed + error "$(cat $log_file)" + + echononl "continue anyway [yes/no]: " + read OK + OK="$(echo "$OK" | tr '[:upper:]' '[:lower:]')" + while [[ "$OK" != "yes" ]] && [[ "$OK" != "no" ]] ; do + echononl "Wrong entry! - repeat [yes/no]: " + read OK + done + [[ $OK = "yes" ]] || fatal "Interrupted ny user." +fi + +echononl "Eanable nextcloud app '$_app'.." +sudo -u "$HTTP_USER" "$php_binary" "${INSTALL_DIR}/occ" app:enable "$_app" > $log_file 2>&1 +if [[ $? -eq 0 ]]; then + echo_ok +else + echo_failed + error "$(cat $log_file)" + + echononl "continue anyway [yes/no]: " + read OK + OK="$(echo "$OK" | tr '[:upper:]' '[:lower:]')" + while [[ "$OK" != "yes" ]] && [[ "$OK" != "no" ]] ; do + echononl "Wrong entry! - repeat [yes/no]: " + read OK + done + [[ $OK = "yes" ]] || fatal "Interrupted ny user." +fi + + +blank_line + + +# - Install and enable nextcloud app 'tasks' +# - +_app="tasks" + +echononl "Install nextcloud app '$_app'.." +sudo -u "$HTTP_USER" "$php_binary" "${INSTALL_DIR}/occ" app:install "$_app" > $log_file 2>&1 + +if [[ $? -eq 0 ]]; then + echo_ok +else + echo_failed + error "$(cat $log_file)" + + echononl "continue anyway [yes/no]: " + read OK + OK="$(echo "$OK" | tr '[:upper:]' '[:lower:]')" + while [[ "$OK" != "yes" ]] && [[ "$OK" != "no" ]] ; do + echononl "Wrong entry! - repeat [yes/no]: " + read OK + done + [[ $OK = "yes" ]] || fatal "Interrupted ny user." +fi + +echononl "Eanable nextcloud app '$_app'.." +sudo -u "$HTTP_USER" "$php_binary" "${INSTALL_DIR}/occ" app:enable "$_app" > $log_file 2>&1 +if [[ $? -eq 0 ]]; then + echo_ok +else + echo_failed + error "$(cat $log_file)" + + echononl "continue anyway [yes/no]: " + read OK + OK="$(echo "$OK" | tr '[:upper:]' '[:lower:]')" + while [[ "$OK" != "yes" ]] && [[ "$OK" != "no" ]] ; do + echononl "Wrong entry! - repeat [yes/no]: " + read OK + done + [[ $OK = "yes" ]] || fatal "Interrupted ny user." +fi + + +blank_line + + +# - Install and enable nextcloud app 'richdocuments' +# - +_app="richdocuments" + +echononl "Install nextcloud app '$_app'.." +sudo -u "$HTTP_USER" "$php_binary" "${INSTALL_DIR}/occ" app:install "$_app" > $log_file 2>&1 +if [[ $? -eq 0 ]]; then + echo_ok +else + echo_failed + error "$(cat $log_file)" + + echononl "continue anyway [yes/no]: " + read OK + OK="$(echo "$OK" | tr '[:upper:]' '[:lower:]')" + while [[ "$OK" != "yes" ]] && [[ "$OK" != "no" ]] ; do + echononl "Wrong entry! - repeat [yes/no]: " + read OK + done + [[ $OK = "yes" ]] || fatal "Interrupted ny user." +fi + +echononl "Eanable nextcloud app '$_app'.." +sudo -u "$HTTP_USER" "$php_binary" "${INSTALL_DIR}/occ" app:enable "$_app" > $log_file 2>&1 +if [[ $? -eq 0 ]]; then + echo_ok +else + echo_failed + error "$(cat $log_file)" + + echononl "continue anyway [yes/no]: " + read OK + OK="$(echo "$OK" | tr '[:upper:]' '[:lower:]')" + while [[ "$OK" != "yes" ]] && [[ "$OK" != "no" ]] ; do + echononl "Wrong entry! - repeat [yes/no]: " + read OK + done + [[ $OK = "yes" ]] || fatal "Interrupted ny user." +fi + + +echononl "Configure nextcloud app '$_app'.." +if [[ -z "$WOPI_URL" ]] ; then + echo_skipped + error "No Wopi URL given (variable 'WOPI_URL')." +else + sudo -u "$HTTP_USER" "$php_binary" "${INSTALL_DIR}/occ" config:app:set richdocuments wopi_url --value="$WOPI_URL" >> $log_file 2>&1 + if [[ $? -eq 0 ]]; then + echo_ok + else + echo_failed + error "$(cat $log_file)" + + echononl "continue anyway [yes/no]: " + read OK + OK="$(echo "$OK" | tr '[:upper:]' '[:lower:]')" + while [[ "$OK" != "yes" ]] && [[ "$OK" != "no" ]] ; do + echononl "Wrong entry! - repeat [yes/no]: " + read OK + done + [[ $OK = "yes" ]] || fatal "Interrupted ny user." + fi +fi + + +blank_line + + +# - Install and enable nextcloud app 'bruteforcesettings' +# - +_app="bruteforcesettings" + +echononl "Install nextcloud app '$_app'.." +sudo -u "$HTTP_USER" "$php_binary" "${INSTALL_DIR}/occ" app:install "$_app" > $log_file 2>&1 +if [[ $? -eq 0 ]]; then + echo_ok +else + echo_failed + error "$(cat $log_file)" + + echononl "continue anyway [yes/no]: " + read OK + OK="$(echo "$OK" | tr '[:upper:]' '[:lower:]')" + while [[ "$OK" != "yes" ]] && [[ "$OK" != "no" ]] ; do + echononl "Wrong entry! - repeat [yes/no]: " + read OK + done + [[ $OK = "yes" ]] || fatal "Interrupted ny user." +fi + +echononl "Eanable nextcloud app '$_app'.." +sudo -u "$HTTP_USER" "$php_binary" "${INSTALL_DIR}/occ" app:enable "$_app" > $log_file 2>&1 + +if [[ $? -eq 0 ]]; then + echo_ok +else + echo_failed + error "$(cat $log_file)" + + echononl "continue anyway [yes/no]: " + read OK + OK="$(echo "$OK" | tr '[:upper:]' '[:lower:]')" + while [[ "$OK" != "yes" ]] && [[ "$OK" != "no" ]] ; do + echononl "Wrong entry! - repeat [yes/no]: " + read OK + done + [[ $OK = "yes" ]] || fatal "Interrupted ny user." +fi + + +# - Install and enable nextcloud app 'announcementcenter' +# - +_app="announcementcenter" + +echononl "Install nextcloud app '$_app'.." +sudo -u "$HTTP_USER" "$php_binary" "${INSTALL_DIR}/occ" app:install "$_app" > $log_file 2>&1 +if [[ $? -eq 0 ]]; then + echo_ok +else + echo_failed + error "$(cat $log_file)" + + echononl "continue anyway [yes/no]: " + read OK + OK="$(echo "$OK" | tr '[:upper:]' '[:lower:]')" + while [[ "$OK" != "yes" ]] && [[ "$OK" != "no" ]] ; do + echononl "Wrong entry! - repeat [yes/no]: " + read OK + done + [[ $OK = "yes" ]] || fatal "Interrupted ny user." +fi + +echononl "Eanable nextcloud app '$_app'.." +sudo -u "$HTTP_USER" "$php_binary" "${INSTALL_DIR}/occ" app:enable "$_app" > $log_file 2>&1 + +if [[ $? -eq 0 ]]; then + echo_ok +else + echo_failed + error "$(cat $log_file)" + + echononl "continue anyway [yes/no]: " + read OK + OK="$(echo "$OK" | tr '[:upper:]' '[:lower:]')" + while [[ "$OK" != "yes" ]] && [[ "$OK" != "no" ]] ; do + echononl "Wrong entry! - repeat [yes/no]: " + read OK + done + [[ $OK = "yes" ]] || fatal "Interrupted ny user." +fi + + + + + + +# ----- +# - Doing some post-update tasks +# ----- + +echo "" +echo "" +echo -e "\033[37m\033[1mDoing some post-update tasks..\033[m" + echo "" echononl " Restart PHP engine.." if [[ "$PHP_ENGINE" = "FPM" ]]; then @@ -765,16 +1168,6 @@ else fi fi - -echononl " Install previously saved crontab from '$_backup_crontab_file'.." -crontab $_backup_crontab_file > $log_file 2>&1 -if [[ $? -eq 0 ]]; then - echo_ok -else - echo_failed - error "$(cat $log_file)" -fi - clean_up 0