From 146bcee8383d16f7e3170c11e455ebe9b8dc42c0 Mon Sep 17 00:00:00 2001 From: Christoph Date: Wed, 31 Mar 2021 04:19:19 +0200 Subject: [PATCH] update_nextcloud.sh: add support for nginx webserver. --- update_nextcloud.sh | 176 +++++++++++++++++++++++++++++++------------- 1 file changed, 125 insertions(+), 51 deletions(-) diff --git a/update_nextcloud.sh b/update_nextcloud.sh index bc71531..35d5c4d 100755 --- a/update_nextcloud.sh +++ b/update_nextcloud.sh @@ -5,7 +5,7 @@ script_dir="$(dirname $(realpath $0))" conf_dir="${script_dir}/conf" -declare -a unsorted_website_arr+ +declare -a unsorted_website_arr declare -a website_arr log_file="$(mktemp)" @@ -139,6 +139,35 @@ info (){ echo "" } +detect_os_1 () { + + if $(which lsb_release > /dev/null 2>&1) ; then + + os_dist="$(lsb_release -i | awk '{print tolower($3)}')" + os_version="$(lsb_release -r | awk '{print tolower($2)}')" + os_codename="$(lsb_release -c | awk '{print tolower($2)}')" + + if [[ "$os_dist" = "debian" ]]; then + if $(echo "$os_version" | grep -q '\.') ; then + os_version=$(echo "$os_version" | cut --delimiter='.' -f1) + fi + fi + + elif [[ -e "/etc/os-release" ]]; then + + . /etc/os-release + + os_dist=$ID + os_version=${VERSION_ID} + + fi + + # remove whitespace from os_dist and os_version + os_dist="${os_dist// /}" + os_version="${os_version// /}" + +} + ## - Check if a given array (parameter 2) contains a given string (parameter 1) ## - containsElement () { @@ -255,6 +284,46 @@ do done +# - Detect Detect OS distribution and Version +# - +echo "" +echo -e " \033[32m--\033[m" +echo "" +echononl "Detect OS distribution and Version" +detect_os_1 > /dev/null 2>&1 +if [[ $? -gt 0 ]] ; then + echo_failed +else + echo_ok +fi + +if [[ "${os_dist,,}" = "debian" ]] ; then + + declare -a dpkg_pkg_colabora_online=() + check_package="loolwsd" + if ! $(dpkg -l "$check_package" 2> /devnull | grep -q -E "^ii\s+${check_package}\s+" 2>/dev/null) ; then + + echononl "Install ColaboraOnline App (yes/no) [yes]: " + read OK + while [[ "${OK,,}" != "yes" ]] && [[ "${OK,,}" != "no" ]] ; do + echononl "Wrong entry! - repeat (yes/no) [yes]: " + read OK + [[ -z "${OK,,}" ]] && OK="yes" + done + + if [[ ${OK,,} = "yes" ]] ; then + INSTALL_COLABORA_ONLINE_APP=true + else + INSTALL_COLABORA_ONLINE_APP=false + fi + else + INSTALL_COLABORA_ONLINE_APP=true + fi +fi + + + + echo "" echononl " Include Configuration file.." if [[ ! -f $conf_file ]]; then @@ -441,6 +510,8 @@ echo "" echo -e " Databse name.........................: $DATABASE_NAME" echo -e " Database type........................: $DATABASE_TYPE" echo "" +echo -e " Install ColaboraOnline App...........: $INSTALL_COLABORA_ONLINE_APP" +echo "" if [[ "$DATABASE_TYPE" = "mysql" ]] ; then echo -e " Mysql Credentials....................: $MYSQL_CREDENTIALS" fi @@ -994,18 +1065,39 @@ 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 - if grep -q -E "${_app}\s+already\s+installed" $log_file ; then - echo_skipped - warn "$(cat $log_file)" +if $INSTALL_COLABORA_ONLINE_APP ; then + # - 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 + if grep -q -E "${_app}\s+already\s+installed" $log_file ; then + echo_skipped + warn "$(cat $log_file)" + 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 by user." + fi + 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)" @@ -1019,48 +1111,30 @@ else done [[ $OK = "yes" ]] || fatal "Interrupted by user." fi -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 by 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 "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 by user." - fi + 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 by user." + fi + fi fi