From d5cde8c230b70751f258f0a09f3b3e5b4988d32a Mon Sep 17 00:00:00 2001 From: Christoph Date: Thu, 14 Feb 2019 04:29:18 +0100 Subject: [PATCH] Add support for installation of Redis and ColaboraOnline Service. --- install_nextcloud.sh | 1359 ++++++++++++++++++++++++++++++++++-------- 1 file changed, 1095 insertions(+), 264 deletions(-) diff --git a/install_nextcloud.sh b/install_nextcloud.sh index 19f79a2..c43a132 100755 --- a/install_nextcloud.sh +++ b/install_nextcloud.sh @@ -144,8 +144,37 @@ info (){ echo "" } -## - Check if a given array (parameter 2) contains a given string (parameter 1) -## - +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 () { local e for e in "${@:2}"; do [[ "$e" == "$1" ]] && return 0; done @@ -217,6 +246,8 @@ clear # - Give your default values here # - +DEFAULT_SSL_CERT_GROUP="$(stat -c "%G" /etc/ssl/private/ssl-cert-snakeoil.key)" + DEFAULT_SRC_BASE_DIR="$working_dir" DEFAULT_ADMIN_USER="admin" DEFAULT_WEB_DIRS_ROOT="/var/www" @@ -242,6 +273,11 @@ fi [[ -z "$ADMIN_USER" ]] && ADMIN_USER="$DEFAULT_ADMIN_USER" +[[ -z "$SSL_CERT_GROUP" ]] && SSL_CERT_GROUP="$DEFAULT_SSL_CERT_GROUP" + +DEFAULT_IPV4_CO="$(ip a | grep " inet " | grep "scope global" | awk '{print$2}' | cut -d'/' -f1 | head -1 2> /dev/null)" +DEFAULT_IPV6_CO="$(ip a | grep " inet6 " | grep "scope global" | awk '{print$2}' | cut -d'/' -f1 | head -1 2> /dev/null)" + # ========== @@ -435,9 +471,7 @@ if [[ "$PHP_ENGINE" = "FPM" ]] ; then echo "" echo " Insert PHP (Main) Version." echo "" - echo " Examples:" - echo " 7.1" - echo " 7.3" + echo " Examples: 7.2 or 7.3" echo "" PHP_VERSION= @@ -580,6 +614,168 @@ else fi +# - Install redis-service? +# - +INSTALL_REDIS_SERVICE=false +REDIS_SERVICE_INSTALLED=false +declare -a dpkg_pkg_redis=() +check_package="redis-server" +if ! $(dpkg -l "$check_package" 2> /devnull | grep -q -E "^ii\s+${check_package}\s+" 2>/dev/null) ; then + echo "" + echo -e " \033[32m--\033[m" + echo "" + echo " redis service seems not to be installed." + echo "" + echo "" + + echononl "Install redis service [yes/no]: " + read OK + while [[ "${OK,,}" != "yes" ]] && [[ "${OK,,}" != "no" ]] ; do + echononl "Wrong entry! - repeat [yes/no]: " + read OK + done + + if [[ ${OK,,} = "yes" ]] ; then + INSTALL_REDIS_SERVICE=true + dpkg_pkg_redis+=("redis-server") + dpkg_pkg_redis+=("redis-tools") + else + INSTALL_REDIS_SERVICE=false + fi +else + REDIS_SERVICE_INSTALLED=true +fi + + +# - Install ColaboraOnline? +# - +INSTALL_COLABORA_SERVICE=false +COLABORA_SERVICE_INSTALLED=false + +# - 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 + echo "" + echo " ColaboraOnline service seems not to be installed." + echo "" + echo "" + + echononl "Install ColaboraOnline service [yes/no]: " + read OK + while [[ "${OK,,}" != "yes" ]] && [[ "${OK,,}" != "no" ]] ; do + echononl "Wrong entry! - repeat [yes/no]: " + read OK + done + + if [[ ${OK,,} = "yes" ]] ; then + INSTALL_COLABORA_SERVICE=true + dpkg_pkg_colabora_online+=("loolwsd") + dpkg_pkg_colabora_online+=("code-brand") + else + INSTALL_COLABORA_SERVICE=false + fi + else + COLABORA_SERVICE_INSTALLED=true + fi +fi + + +# - More information is needed if ColaboraOnline service is to be installed +# - +if $INSTALL_COLABORA_SERVICE || $COLABORA_SERVICE_INSTALLED ; then + + echo "" + echo -e " \033[32m--\033[m" + echo "" + echo " Insert hostname for ColaboraOnline Service.." + echo "" + echo "" + HOSTNAME_CO= + echononl "\033[1mHostname for ColaboraOnline Service:\033[m " + read HOSTNAME_CO + + while [[ "X$HOSTNAME_CO" = "X" ]] ; do + echo -e "\n \033[33m\033[1mHostname for ColaboraOnline Service is required!\033[m\n" + echononl "\033[1mHostname for ColaboraOnline Service:\033[m " + read HOSTNAME_CO + done + WOPI_URL="https://$HOSTNAME_CO" + +fi + +if $INSTALL_COLABORA_SERVICE ; then + + if [[ -n "$(dig +short "$HOSTNAME_CO" A)" ]]; then + DEFAULT_IPV4_CO="$(dig +short "$HOSTNAME_CO" A)" + fi + + if [[ -n "$(dig +short "$HOSTNAME_CO" AAAA)" ]]; then + DEFAULT_IPV6_CO="$(dig +short "$HOSTNAME_CO" AAAA)" + fi + + echo "" + echo -e " \033[32m--\033[m" + echo "" + echo " Insert IPv4 address for ColaboraOnline Service.." + echo "" + echo "" + if [[ -n "$DEFAULT_IPV4_CO" ]]; then + echononl "IPv4 address ColaboraOnline Service [${DEFAULT_IPV4_CO}]: " + read IPV4_CO + if [[ "X${IPV4_CO}" = "X" ]]; then + IPV4_CO=$DEFAULT_IPV4_CO + fi + else + echononl "IPv4 address ColaboraOnline Service: " + read IPV4_CO + while [[ "X$IPV4_CO" = "X" ]] ; do + echo -e "\n \033[33m\033[1mIPv4 address ColaboraOnline Service is required!\033[m\n" + echononl "\033[1mIPv4 address ColaboraOnline Service:\033[m " + read IPV4_CO + done + fi + + echo "" + echo -e " \033[32m--\033[m" + echo "" + echo " Insert IPv6 address for ColaboraOnline Service.." + echo "" + echo "" + if [[ -n "$DEFAULT_IPV6_CO" ]]; then + echononl "IPv6 address ColaboraOnline Service [${DEFAULT_IPV6_CO}]: " + read IPV6_CO + if [[ "X${IPV6_CO}" = "X" ]]; then + IPV6_CO=$DEFAULT_IPV6_CO + fi + else + echononl "IPv6 address ColaboraOnline Service: " + read IPV6_CO + while [[ "X$IPV6_CO" = "X" ]] ; do + echo -e "\n \033[33m\033[1mIPv6 address ColaboraOnline Service is required!\033[m\n" + echononl "\033[1mIPv6 address ColaboraOnline Service:\033[m " + read IPV6_CO + done + fi + +fi + + # ---------- # Some checks # ---------- @@ -646,6 +842,28 @@ else [[ -n "$HTTP_GROUP" ]] || HTTP_GROUP=$DEFAULT_HTTP_GROUP fi +# - Determin ServerRoot Directory +# - +apache_base_dir=`$_httpd_binary -t -D DUMP_RUN_CFG | grep ServerRoot | awk '{print$2}' | tr -d '"'` +if [ "`realpath /usr/local/apache2`" = "$apache_base_dir" ]; then + apache_base_dir="/usr/local/apache2" + _apache_base_dir_realpath="`realpath $apache_base_dir`" +elif [ -z "$apache_base_dir" ]; then + if [ -d "`realpath /usr/local/apache2`" ];then + apache_base_dir="/usr/local/apache2" + _apache_base_dir_realpath="`realpath $apache_base_dir`" + fi +else + _apache_base_dir_realpath=$apache_base_dir +fi + +if [[ ! -d "${_apache_base_dir_realpath}/conf/vhosts" ]] ; then + warn "No Apache VHost directory found." + apache_vhost_dir="" +else + apache_vhost_dir="${_apache_base_dir_realpath}/conf/vhosts" +fi + DATA_DIR=${WEB_BASE_DIR}/data-${VERSION} INSTALL_DIR=${WEB_BASE_DIR}/nextcloud-${VERSION} @@ -681,9 +899,18 @@ echo " Database type........................: $DATABASE_TYPE" echo " Database user........................: $DATABASE_USER" echo " Database password....................: $DATABASE_PASS" echo "" -#if [[ "$DATABASE_TYPE" = "mysql" ]] ; then -# echo -e " Mysql Credentials....................: $MYSQL_CREDENTIALS" -#fi +echo -e " Install redis service?...............: \033[33m${INSTALL_REDIS_SERVICE}\033[m" +echo -e " Install ColaboraOnline service.......: \033[33m${INSTALL_COLABORA_SERVICE}\033[m" +if $INSTALL_COLABORA_SERVICE ; then + echo " Hostname ColaboraOnline Service...: $HOSTNAME_CO" + echo " IPv4 ColaboraOnline Service.......: $IPV4_CO" + echo " IPv6 ColaboraOnline Service.......: $IPV6_CO" + echo " Group of os installed certs.......: $SSL_CERT_GROUP" +elif $COLABORA_SERVICE_INSTALLED ; then + echo "" + echo " Hostname ColaboraOnline Service......: $HOSTNAME_CO" +fi +echo "" echo "" echo "" @@ -751,6 +978,17 @@ echo "# - Databse name.........................: $DATABASE_NAME" >> $log_file echo "# - Database type........................: $DATABASE_TYPE" >> $log_file echo "# - Database user........................: $DATABASE_USER" >> $log_file echo "# - Database password....................: $DATABASE_PASS" >> $log_file +echo "# -" >> $log_file +echo "# - Install redis service?...............: $INSTALL_REDIS_SERVICE" >> $log_file +echo "# - Install ColaboraOnline service.......: $INSTALL_COLABORA_SERVICE" >> $log_file +if $INSTALL_COLABORA_SERVICE ; then + echo "# - Hostname ColaboraOnline Service...: $HOSTNAME_CO" >> $log_file + echo "# - IPv4 ColaboraOnline Service.......: $IPV4_CO" >> $log_file + echo "# - IPv6 ColaboraOnline Service.......: $IPV6_CO" >> $log_file + echo "# - Group of os installed certs.......: $SSL_CERT_GROUP" >> $log_file +elif $COLABORA_SERVICE_INSTALLED ; then + echo "# - Hostname ColaboraOnline Service...: $HOSTNAME_CO" >> $log_file +fi echo "" >> $log_file echo "" >> $log_file @@ -771,11 +1009,598 @@ echo "DATABASE_NAME=$DATABASE_NAME" >> $log_file echo "DATABASE_TYPE=$DATABASE_TYPE" >> $log_file echo "DATABASE_USER=$DATABASE_USER" >> $log_file echo "DATABASE_PASS=$DATABASE_PASS" >> $log_file +echo "INSTALL_REDIS_SERVICE=$INSTALL_REDIS_SERVICE" >> $log_file +echo "INSTALL_COLABORA_SERVICE=$INSTALL_COLABORA_SERVICE" >> $log_file +echo "" >> $log_file +echo "HOSTNAME_CO=$HOSTNAME_CO" >> $log_file +echo "IPV4_CO=$IPV4_CO" >> $log_file +echo "IPV6_CO=$IPV6_CO" >> $log_file +echo "SSL_CERT_GROUP=$SSL_CERT_GROUP" >> $log_file echo "" >> $log_file echo "" >> $log_file +# ----- +# - Install redis service +# ----- + +echo "" +echo "" +echo -e "\033[37m\033[1mInstall redis service..\033[m" +echo "" + +echo "" >> $log_file +echo "" >> $log_file +echo "# -----" >> $log_file +echo "# - Install redis service" >> $log_file +echo "# -----" >> $log_file + +if ! $INSTALL_REDIS_SERVICE ; then + if $REDIS_SERVICE_INSTALLED ; then + info "Redis Service is already installed." + else + warn "Redis Service is NOT installed, but also NOT requested for installation!" + fi +else + for _debian_pkg in ${dpkg_pkg_redis[@]} ; do + + echononl "Installing $_debian_pkg .." + if ! dpkg -l $_debian_pkg 2> /dev/null | grep -e "^ii" > /dev/null 2>&1 ; then + echo "" >> $log_file + echo "# - Installing $_debian_pkg" >> $log_file + echo "# -" >> $log_file + echo "DEBIAN_FRONTEND=noninteractive apt-get install -q -y $_debian_pkg" >> $log_file + + DEBIAN_FRONTEND=noninteractive apt-get install -q -y $_debian_pkg >> $log_file 2>&1 + if [ "$?" = 0 ]; then + echo_ok + else + echo_failed + error "For more informations see log output at '$log_file'." + fi + else + echo_skipped + fi + + done + + # - Adjust parameter unixsocket + # - + redis_conf_file="/etc/redis/redis.conf" + echo "" >> $log_file + echo "# - Adjust configuration for 'unixsocket' (file: '$redis_conf_file')" >> $log_file + echo "# -" >> $log_file + echononl "Adjust configuration for 'unixsocket' (file: '$redis_conf_file').." + + if ! $(grep -q -E "^\s*unixsocket\s+" "$redis_conf_file" 2> /dev/null ) ; then + if $(grep -q -E "^\s*#\s*unixsocket\s+" "$redis_conf_file" 2> /dev/null ) ; then + + cat <> $log_file +perl -i.ORIG -n -p -e "s/^(\s*#\s*unixsocket\s+(.*))/\1\nunixsocket \2/g" "$redis_conf_file" +EOF + perl -i.ORIG -n -p -e "s/^(\s*#\s*unixsocket\s+(.*))/\1\nunixsocket \2/g" "$redis_conf_file" >> $log_file 2>&1 + + if [ "$?" = 0 ]; then + echo_ok + else + echo_failed + error "For more informations see log output at '$log_file'." + fi + + else + + cat <> $log_file +cat <> $redis_conf_file + +# Changed by $script_name at $backup_date +# +unixsocket /var/run/redis/redis.sock +EOF +END + cat <> $redis_conf_file + +# Changed by $script_name at $backup_date +# +unixsocket /var/run/redis/redis.sock +EOF + + if [ "$?" = 0 ]; then + echo_ok + else + echo_failed + error "For more informations see log output at '$log_file'." + fi + fi + else + echo_skipped + fi + + + # - Adjust parameter unixsocketperm + # - + _parameter="unixsocketperm" + _value="770" + echo "" >> $log_file + echo "# - Adjust configuration for '${_parameter}' (file: '$redis_conf_file')" >> $log_file + echo "# -" >> $log_file + echononl "Adjust configuration for '${_parameter}' (file: '$redis_conf_file').." + + if ! $(grep -q -E "^\s*${_parameter}\s+" "$redis_conf_file" 2> /dev/null ) ; then + if $(grep -q -E "^\s*#\s*${_parameter}\s+" "$redis_conf_file" 2> /dev/null ) ; then + + cat <> $log_file +perl -i.ORIG -n -p -e "s/^(\s*#\s*${_parameter}\s+.*)/\1\n${_parameter} ${_value}/g" "$redis_conf_file" +EOF + perl -i.ORIG -n -p -e "s/^(\s*#\s*${_parameter}\s+(.*))/\1\n${_parameter} ${_value}/g" "$redis_conf_file" >> $log_file 2>&1 + + if [ "$?" = 0 ]; then + echo_ok + else + echo_failed + error "For more informations see log output at '$log_file'." + fi + + else + + cat <> $log_file +cat <> $redis_conf_file + +# Changed by $script_name at $backup_date +# +${_parameter} 770 +EOF +END + cat <> $redis_conf_file + +# Changed by $script_name at $backup_date +# +${_parameter} 770 +EOF + + if [ "$?" = 0 ]; then + echo_ok + else + echo_failed + error "For more informations see log output at '$log_file'." + fi + fi + else + echo_skipped + fi + + REDIS_SOCKET="$(grep -E "^\s*unixsocket\s+" $redis_conf_file 2> /dev/null | awk '{print$2}' 2> /dev/null)" + REDIS_GROUP="$(stat -c "%G" $REDIS_SOCKET)" + + echo "" >> $log_file + echo "REDIS_SOCKET=$REDIS_SOCKET" >> $log_file + echo "REDIS_GROUP=$REDIS_GROUP" >> $log_file + echo "" >> $log_file + + # - Add webserver user to redis group + # - + echo "" >> $log_file + echo "# - Add webserver user '${HTTP_USER}' to redis group ${REDIS_GROUP}" >> $log_file + echo "# -" >> $log_file + echononl "Add webserver user '${HTTP_USER}' to redis group ${REDIS_GROUP}.." + + if ! $(grep -E "^redis:" /etc/group 2> /dev/null | grep -q "$HTTP_USER" 2> /dev/null) ; then + usermod -a -G "$REDIS_GROUP" "$HTTP_USER" >> $log_file 2>&1 + if [ "$?" = 0 ]; then + echo_ok + else + echo_failed + error "For more informations see log output at '$log_file'." + fi + else + echo_skipped + fi + + REDIS_SERVICE_INSTALLED=true + +fi + + +# ----- +# - Install Install ColaboraOnline Service +# ----- + +echo "" +echo "" +echo -e "\033[37m\033[1mInstall ColaboraOnline Service..\033[m" +echo "" + +echo "" >> $log_file +echo "" >> $log_file +echo "# -----" >> $log_file +echo "# - Install ColaboraOnline Service" >> $log_file +echo "# -----" >> $log_file + +if ! $INSTALL_COLABORA_SERVICE ; then + if $COLABORA_SERVICE_INSTALLED ; then + info "ColaboraOnline Service (loolwsd) is already installed." + else + warn "ColaboraOnline Service is not installed!" + fi +else + + # - Add key for ColaboraOnline Repository + # - + echo "" >> $log_file + echo "# - Add key for ColaboraOnline Repository" >> $log_file + echo "# -" >> $log_file + echononl "Add key for ColaboraOnline Repository.." + + echo "apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 0C54D189F4BA284D" >> $log_file + apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 0C54D189F4BA284D >> $log_file 2>&1 + + if [ "$?" = 0 ]; then + echo_ok + else + echo_failed + error "For more informations see log output at '$log_file'." + fi + + + # - Add Repository ColaboraOnline + # - + echo "" >> $log_file + echo "# - Add debian Repository for ColaboraOnline" >> $log_file + echo "# -" >> $log_file + echononl "Add debian Repository for ColaboraOnline" + + cat <> $log_file +cat < /etc/apt/sources.list.d/collaboraonline.list +deb https://www.collaboraoffice.com/repos/CollaboraOnline/CODE-debian${os_version} ./ +EOF +END + cat < /etc/apt/sources.list.d/collaboraonline.list 2>> $log_file +deb https://www.collaboraoffice.com/repos/CollaboraOnline/CODE-debian${os_version} ./ +EOF + if [ "$?" = 0 ]; then + echo_ok + else + echo_failed + error "For more informations see log output at '$log_file'." + fi + + + # - Update package index files + # - + echo "" >> $log_file + echo "# - Update package index files" >> $log_file + echo "# -" >> $log_file + echononl "Update package index files" + + echo "apt-get update" >> $log_file + apt-get update >> $log_file 2>&1 + + if [ "$?" = 0 ]; then + echo_ok + else + echo_failed + error "For more informations see log output at '$log_file'." + fi + + + # - Install ColaboraOnline packages + # - + for _debian_pkg in ${dpkg_pkg_colabora_online[@]} ; do + + echononl "Installing $_debian_pkg .." + if ! dpkg -l $_debian_pkg 2> /dev/null | grep -e "^ii" > /dev/null 2>&1 ; then + echo "" >> $log_file + echo "# - Installing $_debian_pkg" >> $log_file + echo "# -" >> $log_file + echo "DEBIAN_FRONTEND=noninteractive apt-get install -q -y $_debian_pkg" >> $log_file + + DEBIAN_FRONTEND=noninteractive apt-get install -q -y $_debian_pkg >> $log_file 2>&1 + if [ "$?" = 0 ]; then + echo_ok + else + echo_failed + error "For more informations see log output at '$log_file'." + fi + else + echo_skipped + fi + + done + + LOOLWDS_USER="$(stat -c "%U" /etc/loolwsd/loolwsd.xml)" + echo "" >> $log_file + echo "LOOLWDS_USER=$LOOLWDS_USER" >> $log_file + echo "" >> $log_file + + + # - Add loolwsd user to group 'ssl-cert' + # - + echo "" >> $log_file + echo "# - Add loolwsd user '${LOOLWDS_USER}' to group ${SSL_CERT_GROUP}" >> $log_file + echo "# -" >> $log_file + echononl "Add loolwsd user '${LOOLWDS_USER}' to group ${SSL_CERT_GROUP}.." + + if ! $(grep -E "^${SSL_CERT_GROUP}:" /etc/group 2> /dev/null | grep -q "$LOOLWDS_USER" 2> /dev/null) ; then + usermod -a -G "${SSL_CERT_GROUP}" "$LOOLWDS_USER" >> $log_file 2>&1 + if [ "$?" = 0 ]; then + echo_ok + else + echo_failed + error "For more informations see log output at '$log_file'." + fi + else + echo_skipped + fi + + blank_line + + # - Symlimk Snakeoil Cert '/etc/loolwsd/cert.pem' --> '/etc/ssl/certs/ssl-cert-snakeoil.pem' + # - + _symlink_src="/etc/ssl/certs/ssl-cert-snakeoil.pem" + _symlink_dst="/etc/loolwsd/cert.pem" + echo "" >> $log_file + echo "# - Symlink '${_symlink_dst}' --> ${_symlink_src}" >> $log_file + echo "# -" >> $log_file + echononl "Symlink '${_symlink_dst}' --> ${_symlink_src}" + ln -s "$_symlink_src" "$_symlink_dst" >> $log_file 2>&1 + if [ "$?" = 0 ]; then + echo_ok + else + echo_failed + error "For more informations see log output at '$log_file'." + fi + + # - Symlimk Snakeoil Cert '/etc/loolwsd/ca-chain.cert.pem' --> '/etc/ssl/certs/ssl-cert-snakeoil.pem' + # - + _symlink_src="/etc/ssl/certs/ssl-cert-snakeoil.pem" + _symlink_dst="/etc/loolwsd/ca-chain.cert.pem" + echo "" >> $log_file + echo "# - Symlink '${_symlink_dst}' --> ${_symlink_src}" >> $log_file + echo "# -" >> $log_file + echononl "Symlink '${_symlink_dst}' --> ${_symlink_src}" + ln -s "$_symlink_src" "$_symlink_dst" >> $log_file 2>&1 + if [ "$?" = 0 ]; then + echo_ok + else + echo_failed + error "For more informations see log output at '$log_file'." + fi + + # - Symlimk Snakeoil Cert '/etc/loolwsd/key.pem' --> '/etc/ssl/private/ssl-cert-snakeoil.key' + # - + _symlink_src="/etc/ssl/private/ssl-cert-snakeoil.key" + _symlink_dst="/etc/loolwsd/key.pem" + echo "" >> $log_file + echo "# - Symlink '${_symlink_dst}' --> ${_symlink_src}" >> $log_file + echo "# -" >> $log_file + echononl "Symlink '${_symlink_dst}' --> ${_symlink_src}" + ln -s "$_symlink_src" "$_symlink_dst" >> $log_file 2>&1 + if [ "$?" = 0 ]; then + echo_ok + else + echo_failed + error "For more informations see log output at '$log_file'." + fi + + blank_line + + # - Restart 'loolwsd' service + # - + echo "" >> $log_file + echo "# - Restart 'loolwsd' service" >> $log_file + echo "# -" >> $log_file + echononl "Restart 'loolwsd' service.." + if $systemd_supported ; then + + echo "systemctl start loolwsd" >> $log_file + systemctl restart loolwsd >> $log_file 2>&1 + + if [[ $? -eq 0 ]]; then + echo_ok + else + echo_failed + error "For more informations see log output at '$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 + else + + echo "/etc/init.d/loolwsd start" >> $log_file + /etc/init.d/loolwsd restart>> $log_file 2>&1 + + if [[ $? -eq 0 ]]; then + echo_ok + else + echo_failed + error "For more informations see log output at '$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 + + # - Create Apache2 vhost configuration for ColaboraOnline service + # - + if [[ -e "/var/lib/dehydrated/certs/${HOSTNAME_CO}/fullchain.pem" ]]; then + server_cert="/var/lib/dehydrated/certs/${HOSTNAME_CO}/fullchain.pem" + server_key="/var/lib/dehydrated/certs/${HOSTNAME_CO}/privkey.pem" + else + server_cert="/usr/local/apache2/conf/server-bundle.crt" + server_key="/usr/local/apache2/conf/server.key" + fi + + if [[ -d "$apache_vhost_dir" ]] ; then + + # - Backup apache vhost file if exists + # - + if [[ -f "${apache_vhost_dir}/${HOSTNAME_CO}.conf.static" ]]; then + + echo "" >> $log_file + echo "# - Backup existing file '${apache_vhost_dir}/${HOSTNAME_CO}.conf.static'" >> $log_file + echo "# -" >> $log_file + echononl "Backup existing file '${apache_vhost_dir}/${HOSTNAME_CO}.conf.static'" >> $log_file + + echo "mv \"${apache_vhost_dir}/${HOSTNAME_CO}.conf.static\" \"${apache_vhost_dir}/${HOSTNAME_CO}.conf.static.$backup_date\"" >> $log_file + mv "${apache_vhost_dir}/${HOSTNAME_CO}.conf.static" "${apache_vhost_dir}/${HOSTNAME_CO}.conf.static.$backup_date" >> $log_file 2>&1 + + if [ "$?" = 0 ]; then + echo_ok + else + echo_failed + error "For more informations see log output at '$log_file'." + fi + + fi + + + echo "" >> $log_file + echo "# - Create apache vhost entry for (lokal) ColaboraOnline service" >> $log_file + echo "# -" >> $log_file + echononl "Create apache vhost entry for (lokal) ColaboraOnline service" + + cat< "${apache_vhost_dir}/${HOSTNAME_CO}.conf.static" 2>> $log_file + + + ServerName $HOSTNAME_CO + + Options -Indexes + + # Encoded slashes need to be allowed + AllowEncodedSlashes NoDecode + + # Container uses a unique non-signed certificate + SSLProxyEngine On + SSLProxyVerify None + SSLProxyCheckPeerCN Off + SSLProxyCheckPeerName Off + + # keep the host + ProxyPreserveHost On + + # static html, js, images, etc. served from loolwsd + # loleaflet is the client part of Collabora Online + ProxyPass /loleaflet https://127.0.0.1:9980/loleaflet retry=0 + ProxyPassReverse /loleaflet https://127.0.0.1:9980/loleaflet + + # WOPI discovery URL + ProxyPass /hosting/discovery https://127.0.0.1:9980/hosting/discovery retry=0 + ProxyPassReverse /hosting/discovery https://127.0.0.1:9980/hosting/discovery + + # Capabilities + ProxyPass /hosting/capabilities https://127.0.0.1:9980/hosting/capabilities retry=0 + ProxyPassReverse /hosting/capabilities https://127.0.0.1:9980/hosting/capabilities + + # Main websocket + ProxyPassMatch "/lool/(.*)/ws$" wss://127.0.0.1:9980/lool/\$1/ws nocanon + + # Admin Console websocket + ProxyPass /lool/adminws wss://127.0.0.1:9980/lool/adminws + + # Download as, Fullscreen presentation and Image upload operations + ProxyPass /lool https://127.0.0.1:9980/lool + ProxyPassReverse /lool https://127.0.0.1:9980/lool + + + SSLEngine on + + SSLCertificateFile $server_cert + SSLCertificateKeyFile $server_key + + CustomLog /var/log/apache2/ip_requests.log base_requests + + CustomLog /var/log/apache2/colabora-online-access.log combined + ErrorLog /var/log/apache2/colabora-online-error.log + + +EOF + if [ "$?" = 0 ]; then + echo_ok + else + echo_failed + error "For more informations see log output at '$log_file'." + fi + + + # - Remove symlink for apache vhost file (if exists) + # - + if [[ -h "${apache_vhost_dir}/${HOSTNAME_CO}.conf" ]]; then + + echo "" >> $log_file + echo "# - Remove existing Symlink '${apache_vhost_dir}/${HOSTNAME_CO}.conf'" >> $log_file + echo "# -" >> $log_file + echononl "Remove existing Symlink '${apache_vhost_dir}/${HOSTNAME_CO}.conf'" >> $log_file + + echo "rm -f \"${apache_vhost_dir}/${HOSTNAME_CO}.conf\"" >> $log_file + rm -f "${apache_vhost_dir}/${HOSTNAME_CO}.conf" >> $log_file 2>&1 + + if [ "$?" = 0 ]; then + echo_ok + else + echo_failed + error "For more informations see log output at '$log_file'." + fi + + fi + + + # - Backup apache vhost file if exists + # - + if [[ -f "${apache_vhost_dir}/${HOSTNAME_CO}.conf" ]]; then + + echo "" >> $log_file + echo "# - Backup existing file '${apache_vhost_dir}/${HOSTNAME_CO}.conf'" >> $log_file + echo "# -" >> $log_file + echononl "Backup existing file '${apache_vhost_dir}/${HOSTNAME_CO}.conf'" >> $log_file + + echo "mv \"${apache_vhost_dir}/${HOSTNAME_CO}.conf\" \"${apache_vhost_dir}/${HOSTNAME_CO}.conf.$backup_date\"" >> $log_file + mv "${apache_vhost_dir}/${HOSTNAME_CO}.conf" "${apache_vhost_dir}/${HOSTNAME_CO}.conf.$backup_date" >> $log_file 2>&1 + + if [ "$?" = 0 ]; then + echo_ok + else + echo_failed + error "For more informations see log output at '$log_file'." + fi + + fi + + + # - Symlimk Apache VHost file '${HOSTNAME_CO}.conf' --> '${HOSTNAME_CO}.conf.static' + # - + _symlink_src="${HOSTNAME_CO}.conf.static" + _symlink_dst="${apache_vhost_dir}/${HOSTNAME_CO}.conf" + echo "" >> $log_file + echo "# - Symlink '${_symlink_dst}' --> ${_symlink_src}" >> $log_file + echo "# -" >> $log_file + echononl "Symlink '${_symlink_dst}' --> ${_symlink_src}" + ln -s "$_symlink_src" "$_symlink_dst" >> $log_file 2>&1 + if [ "$?" = 0 ]; then + echo_ok + else + echo_failed + error "For more informations see log output at '$log_file'." + fi + + COLABORA_SERVICE_INSTALLED=true + fi +fi + + # ----- # - Doing some pre-installation tasks # ----- @@ -797,8 +1622,8 @@ echo "# -----" >> $log_file _backup_crontab_file=/tmp/crontab_root.${backup_date} echo "" >> $log_file -echo "# -" >> $log_file echo "# - Backup Crontab to '$_backup_crontab_file'" >> $log_file +echo "# -" >> $log_file echononl "Backup Crontab to '$_backup_crontab_file'" echo "crontab -l > $_backup_crontab_file" >> $log_file @@ -821,8 +1646,8 @@ else fi echo "" >> $log_file -echo "# -" >> $log_file echo "# - Remove crontab for root" >> $log_file +echo "# -" >> $log_file echononl "Remove crontab for root.." echo "crontab -r" >> $log_file @@ -849,8 +1674,8 @@ fi # - Stop Apache Webserver # - echo "" >> $log_file -echo "# -" >> $log_file echo "# - Stop Apache Webserver" >> $log_file +echo "# -" >> $log_file echononl "Stop Apache Webserver.." if $systemd_supported ; then @@ -965,7 +1790,7 @@ if [[ "$DATABASE_TYPE" = "mysql" ]] ; then if $_failed ; then echo_failed - error ""For more informations see log output at '$log_file'."" + error "For more informations see log output at '$log_file'." clean_up 1 else echo_ok @@ -992,7 +1817,7 @@ EOF echo_ok else echo_failed - error ""For more informations see log output at '$log_file'."" + error "For more informations see log output at '$log_file'." clean_up 1 fi @@ -2207,44 +3032,6 @@ else fi -# - Adjust 'memcache.locking' -# - -# - Memory caching backend for file locking -# - -# - Defaults to none -# - -_parameter="memcache.locking" -_value="\\OC\\Memcache\\Redis" -_type="string" -echo "" >> $log_file -echo "# - Adjust configuration parameter '$_parameter'" >> $log_file -echo "# -" >> $log_file -echononl "Adjust configuration parameter '$_parameter'.." - -cat <> $log_file -sudo -u "$HTTP_USER" "$php_binary" "${INSTALL_DIR}/occ" config:system:set "$_parameter" \\ - --value="${_value}" --type="${_type}" -EOF -sudo -u "$HTTP_USER" "$php_binary" "${INSTALL_DIR}/occ" config:system:set "$_parameter" \ - --value="${_value}" --type="${_type}" >> $log_file 2>&1 - -if [[ $? -eq 0 ]]; then - echo_ok -else - echo_failed - error "For more informations see log output at '$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 - - # - Adjust 'memcache.local' # - # - Memory caching backend for locally stored data @@ -2283,159 +3070,209 @@ else fi -# - Adjust 'memcache.distributed' -# - -# - Memory caching backend for locally stored data -# - -# - Defaults to none -# - -_parameter="memcache.distributed" -_value="\\OC\\Memcache\\Redis" -_type="string" -echo "" >> $log_file -echo "# - Adjust configuration parameter '$_parameter'" >> $log_file -echo "# -" >> $log_file -echononl "Adjust configuration parameter '$_parameter'.." +if $REDIS_SERVICE_INSTALLED ; then -cat <> $log_file + # - Adjust 'memcache.locking' + # - + # - Memory caching backend for file locking + # - + # - Defaults to none + # - + _parameter="memcache.locking" + _value="\\OC\\Memcache\\Redis" + _type="string" + echo "" >> $log_file + echo "# - Adjust configuration parameter '$_parameter'" >> $log_file + echo "# -" >> $log_file + echononl "Adjust configuration parameter '$_parameter'.." + + cat <> $log_file sudo -u "$HTTP_USER" "$php_binary" "${INSTALL_DIR}/occ" config:system:set "$_parameter" \\ - --value="${_value}" --type="${_type}" + --value="${_value}" --type="${_type}" EOF -sudo -u "$HTTP_USER" "$php_binary" "${INSTALL_DIR}/occ" config:system:set "$_parameter" \ - --value="${_value}" --type="${_type}" >> $log_file 2>&1 + sudo -u "$HTTP_USER" "$php_binary" "${INSTALL_DIR}/occ" config:system:set "$_parameter" \ + --value="${_value}" --type="${_type}" >> $log_file 2>&1 -if [[ $? -eq 0 ]]; then - echo_ok -else - echo_failed - error "For more informations see log output at '$log_file'." + if [[ $? -eq 0 ]]; then + echo_ok + else + echo_failed + error "For more informations see log output at '$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 "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 -# - Adjust parameter 'redis' 'port' -# - -# - Connection details for redis to use for memory caching -# - -# - Defaults to none -# - -_parameter="redis" -_array_index="port" -_value=0 -_type="integer" -echo "" >> $log_file -echo "# - Adjust configuration parameter '$_parameter' '$_array_index'" >> $log_file -echo "# -" >> $log_file -echononl "Adjust configuration parameter '$_parameter' '$_array_index'.." + # - Adjust 'memcache.distributed' + # - + # - Memory caching backend for locally stored data + # - + # - Defaults to none + # - + _parameter="memcache.distributed" + _value="\\OC\\Memcache\\Redis" + _type="string" + echo "" >> $log_file + echo "# - Adjust configuration parameter '$_parameter'" >> $log_file + echo "# -" >> $log_file + echononl "Adjust configuration parameter '$_parameter'.." -cat <> $log_file + cat <> $log_file +sudo -u "$HTTP_USER" "$php_binary" "${INSTALL_DIR}/occ" config:system:set "$_parameter" \\ + --value="${_value}" --type="${_type}" +EOF + sudo -u "$HTTP_USER" "$php_binary" "${INSTALL_DIR}/occ" config:system:set "$_parameter" \ + --value="${_value}" --type="${_type}" >> $log_file 2>&1 + + if [[ $? -eq 0 ]]; then + echo_ok + else + echo_failed + error "For more informations see log output at '$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 + + + # - Adjust parameter 'redis' 'port' + # - + # - Connection details for redis to use for memory caching + # - + # - Defaults to none + # - + _parameter="redis" + _array_index="port" + _value=0 + _type="integer" + echo "" >> $log_file + echo "# - Adjust configuration parameter '$_parameter' '$_array_index'" >> $log_file + echo "# -" >> $log_file + echononl "Adjust configuration parameter '$_parameter' '$_array_index'.." + + cat <> $log_file sudo -u "$HTTP_USER" "$php_binary" "${INSTALL_DIR}/occ" config:system:set "$_parameter" "$_array_index" \\ - --value="${_value}" --type="${_type}" + --value="${_value}" --type="${_type}" EOF -sudo -u "$HTTP_USER" "$php_binary" "${INSTALL_DIR}/occ" config:system:set "$_parameter" "$_array_index" \ - --value="${_value}" --type="${_type}" >> $log_file 2>&1 + sudo -u "$HTTP_USER" "$php_binary" "${INSTALL_DIR}/occ" config:system:set "$_parameter" "$_array_index" \ + --value="${_value}" --type="${_type}" >> $log_file 2>&1 -if [[ $? -eq 0 ]]; then - echo_ok -else - echo_failed - error "For more informations see log output at '$log_file'." + if [[ $? -eq 0 ]]; then + echo_ok + else + echo_failed + error "For more informations see log output at '$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 "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 -# - Adjust parameter 'redis' 'host' -# - -# - Connection details for redis to use for memory caching -# - -# - Defaults to none -# - -_parameter="redis" -_array_index="host" -_value="/var/run/redis/redis.sock" -_type="string" -echo "" >> $log_file -echo "# - Adjust configuration parameter '$_parameter' '$_array_index'" >> $log_file -echo "# -" >> $log_file -echononl "Adjust configuration parameter '$_parameter' '$_array_index'.." + # - Adjust parameter 'redis' 'host' + # - + # - Connection details for redis to use for memory caching + # - + # - Defaults to none + # - + [[ -z "$redis_conf_file" ]] && redis_conf_file="/etc/redis/redis.conf" + + REDIS_SOCKET="$(grep -E "^\s*unixsocket\s+" $redis_conf_file 2> /dev/null | awk '{print$2}' 2> /dev/null)" -cat <> $log_file + if [[ -z "$REDIS_SOCKET" ]] ; then + warn "Variable 'REDIS_SOCKET' not set or empty.\n\n Set value to \033[1m/var/run/redis/redis.sock\033[m" + fi + + _parameter="redis" + _array_index="host" + _value="$REDIS_SOCKET" + _type="string" + echo "" >> $log_file + echo "# - Adjust configuration parameter '$_parameter' '$_array_index'" >> $log_file + echo "# -" >> $log_file + echononl "Adjust configuration parameter '$_parameter' '$_array_index'.." + + cat <> $log_file sudo -u "$HTTP_USER" "$php_binary" "${INSTALL_DIR}/occ" config:system:set "$_parameter" "$_array_index" \\ - --value="${_value}" --type="${_type}" + --value="${_value}" --type="${_type}" EOF -sudo -u "$HTTP_USER" "$php_binary" "${INSTALL_DIR}/occ" config:system:set "$_parameter" "$_array_index" \ - --value="${_value}" --type="${_type}" >> $log_file 2>&1 + sudo -u "$HTTP_USER" "$php_binary" "${INSTALL_DIR}/occ" config:system:set "$_parameter" "$_array_index" \ + --value="${_value}" --type="${_type}" >> $log_file 2>&1 -if [[ $? -eq 0 ]]; then - echo_ok -else - echo_failed - error "For more informations see log output at '$log_file'." + if [[ $? -eq 0 ]]; then + echo_ok + else + echo_failed + error "For more informations see log output at '$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 "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 -# - Adjust parameter 'redis' 'timeout' -# - -# - Connection details for redis to use for memory caching -# - -# - Defaults to none -# - -_parameter="redis" -_array_index="timeout" -_value=0 -_type="integer" -echo "" >> $log_file -echo "# - Adjust configuration parameter '$_parameter' '$_array_index'" >> $log_file -echo "# -" >> $log_file -echononl "Adjust configuration parameter '$_parameter' '$_array_index'.." + # - Adjust parameter 'redis' 'timeout' + # - + # - Connection details for redis to use for memory caching + # - + # - Defaults to none + # - + _parameter="redis" + _array_index="timeout" + _value=0 + _type="integer" + echo "" >> $log_file + echo "# - Adjust configuration parameter '$_parameter' '$_array_index'" >> $log_file + echo "# -" >> $log_file + echononl "Adjust configuration parameter '$_parameter' '$_array_index'.." -cat <> $log_file + cat <> $log_file sudo -u "$HTTP_USER" "$php_binary" "${INSTALL_DIR}/occ" config:system:set "$_parameter" "$_array_index" \\ - --value="${_value}" --type="${_type}" + --value="${_value}" --type="${_type}" EOF -sudo -u "$HTTP_USER" "$php_binary" "${INSTALL_DIR}/occ" config:system:set "$_parameter" "$_array_index" \ - --value="${_value}" --type="${_type}" >> $log_file 2>&1 + sudo -u "$HTTP_USER" "$php_binary" "${INSTALL_DIR}/occ" config:system:set "$_parameter" "$_array_index" \ + --value="${_value}" --type="${_type}" >> $log_file 2>&1 -if [[ $? -eq 0 ]]; then - echo_ok -else - echo_failed - error "For more informations see log output at '$log_file'." + if [[ $? -eq 0 ]]; then + echo_ok + else + echo_failed + error "For more informations see log output at '$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 "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 # if $REDIS_SERVICE_INSTALLED blank_line @@ -2872,7 +3709,7 @@ if [[ $? -eq 0 ]]; then echo_ok else echo_failed - error "For more informations see log output at '$log_file'." + error "For more informations see log output: \"$log_file\"." echononl "continue anyway [yes/no]: " read OK @@ -2887,82 +3724,83 @@ fi blank_line +if $COLABORA_SERVICE_INSTALLED ; then + # - Install and enable nextcloud app 'richdocuments' + # - + _app="richdocuments" + echo "" >> $log_file + echo "# -" >> $log_file + echo "# - Install nextcloud app '$_app'" >> $log_file + echononl "Install nextcloud app '$_app'.." -# - Install and enable nextcloud app 'richdocuments' -# - -_app="richdocuments" -echo "" >> $log_file -echo "# -" >> $log_file -echo "# - Install nextcloud app '$_app'" >> $log_file -echononl "Install nextcloud app '$_app'.." + echo "sudo -u \"$HTTP_USER\" \"$php_binary\" \"${INSTALL_DIR}/occ\" app:install \"$_app\"" >> $log_file + sudo -u "$HTTP_USER" "$php_binary" "${INSTALL_DIR}/occ" app:install "$_app" >> $log_file 2>&1 -echo "sudo -u \"$HTTP_USER\" \"$php_binary\" \"${INSTALL_DIR}/occ\" app:install \"$_app\"" >> $log_file -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 "For more informations see log output at '$log_file'." -if [[ $? -eq 0 ]]; then - echo_ok -else - echo_failed - error "For more informations see log output at '$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 "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 + echo "" >> $log_file + echo "# -" >> $log_file + echo "# - Eanable nextcloud app '$_app'" >> $log_file + echononl "Eanable nextcloud app '$_app'.." -echo "" >> $log_file -echo "# -" >> $log_file -echo "# - Eanable nextcloud app '$_app'" >> $log_file -echononl "Eanable nextcloud app '$_app'.." + echo "sudo -u \"$HTTP_USER\" \"$php_binary\" \"${INSTALL_DIR}/occ\" app:enable \"$_app\"" >> $log_file + sudo -u "$HTTP_USER" "$php_binary" "${INSTALL_DIR}/occ" app:enable "$_app" >> $log_file 2>&1 -echo "sudo -u \"$HTTP_USER\" \"$php_binary\" \"${INSTALL_DIR}/occ\" app:enable \"$_app\"" >> $log_file -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 "For more informations see log output at '$log_file'." -if [[ $? -eq 0 ]]; then - echo_ok -else - echo_failed - error "For more informations see log output at '$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 "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 + echo "" >> $log_file + echo "# -" >> $log_file + echo "# - Configure nextcloud app '$_app'" >> $log_file + echononl "Configure nextcloud app '$_app'.." -echo "" >> $log_file -echo "# -" >> $log_file -echo "# - Configure nextcloud app '$_app'" >> $log_file -echononl "Configure nextcloud app '$_app'.." + echo "sudo -u \"$HTTP_USER\" \"$php_binary\" \"${INSTALL_DIR}/occ\" config:app:set richdocuments wopi_url --value=\"${WOPI_URL}\"" >> $log_file -echo "sudo -u \"$HTTP_USER\" \"$php_binary\" \"${INSTALL_DIR}/occ\" config:app:set richdocuments wopi_url --value=\"https://co-01.oopen.de/\"" >> $log_file + sudo -u "$HTTP_USER" "$php_binary" "${INSTALL_DIR}/occ" config:app:set richdocuments wopi_url --value="${WOPI_URL}" >> $log_file 2>&1 -sudo -u "$HTTP_USER" "$php_binary" "${INSTALL_DIR}/occ" config:app:set richdocuments wopi_url --value="https://co-01.oopen.de/" >> $log_file 2>&1 + if [[ $? -eq 0 ]]; then + echo_ok + else + echo_failed + error "For more informations see log output at '$log_file'." -if [[ $? -eq 0 ]]; then - echo_ok -else - echo_failed - error "For more informations see log output at '$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 "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 # if $COLABORA_SERVICE_INSTALLED blank_line @@ -3207,49 +4045,42 @@ blank_line clean_up 0 -cd $WEB_BASE_DIR +#------------------------------------------------------------------------ ------------------------------------------------------------------------- - -## - Alternativly enable maintenance mode +## - Enable maintenance mode ## - su -c "/usr/local/php/bin/php ${WEB_BASE_DIR}/htdocs/occ maintenance:mode --on" -s /bin/bash $HTTP_USER +## - Disable maintenance mode +## - +su -c "/usr/local/php/bin/php ${WEB_BASE_DIR}/htdocs/occ maintenance:mode --off" -s /bin/bash $HTTP_USER + + ## - Deactivate third party apps ## - -## - for _app in $THIRD_PARTY_APPS ; do -## - #su -c"/usr/local/php/bin/php ${WEB_BASE_DIR}/htdocs/occ app:disable $_app" -s /bin/bash $HTTP_USER -## - su -c"/usr/local/php/bin/php ${WEB_BASE_DIR}/nextcloud/occ app:disable $_app" -s /bin/bash $HTTP_USER -## - done for _app in $THIRD_PARTY_APPS ; do - #su -c"/usr/local/php/bin/php ${WEB_BASE_DIR}/htdocs/occ app:disable $_app" -s /bin/bash $HTTP_USER - su -c"/usr/local/php/bin/php ${WEB_BASE_DIR}/nextcloud/occ app:disable $_app" -s /bin/bash $HTTP_USER + su -c"/usr/local/php/bin/php ${WEB_BASE_DIR}/htdocs/occ app:disable $_app" -s /bin/bash $HTTP_USER done - -## - ## - Enable third party apps -## - ## - -## - for _app in $THIRD_PARTY_APPS ; do -## - su -c"/usr/local/php/bin/php ${WEB_BASE_DIR}/htdocs/occ app:enable $_app" -s /bin/bash $HTTP_USER -## - done +## - Enable third party apps +## - for _app in $THIRD_PARTY_APPS ; do + su -c"/usr/local/php/bin/php ${WEB_BASE_DIR}/htdocs/occ app:install $_app" -s /bin/bash $HTTP_USER su -c"/usr/local/php/bin/php ${WEB_BASE_DIR}/htdocs/occ app:enable $_app" -s /bin/bash $HTTP_USER done ------------------------------------------------------------------------- +#------------------------------------------------------------------------ -https://doc.owncloud.org/server/8.0/admin_manual/maintenance/upgrade.html +# see: https://doc.owncloud.org/server/8.0/admin_manual/maintenance/upgrade.html while IFS= read -r -d '' n; do - #if [[ "$n" == "mb" ]]; then - # continue - #fi + [[ ! -d "${n}/files" ]] && continue su -c "/usr/local/php/bin/php ${WEB_BASE_DIR}/htdocs/console.php files:scan --path `basename $n`" -s /bin/bash $HTTP_USER done < <(find $WEB_BASE_DIR/data/ -mindepth 1 -maxdepth 1 -type d -print0)