Compare commits

..

27 Commits

Author SHA1 Message Date
793b1b1e1c update_nextcloud.sh: use realpath for data dirctory. 2025-06-20 22:05:33 +02:00
b6fd1ab6a3 add-new-account.sh: supprt blank sign in account name. 2025-05-02 18:24:48 +02:00
d60a7d5937 update_nextcloud.sh: restart notify_push service if present.. 2025-04-22 17:40:21 +02:00
9346c73f39 A realy smal change on script output. 2025-04-20 02:11:27 +02:00
23edc5828c Add script 'add-new-account.sh'. 2025-04-20 02:07:01 +02:00
73f2f79324 snippets/get-cloud-instance-to-update.sh: a really smal change - remove a blank sign.. 2025-03-30 18:24:15 +02:00
78a10d9169 Add script 'remove-old-nc-installations.sh'. 2025-03-30 18:23:24 +02:00
9893bd4371 restore_nextcloud.sh: some changes in error handling. 2025-03-29 03:06:33 +01:00
00cce38bf1 Add script 'correct-cloud-database-row-format.sh'. 2025-03-28 01:55:32 +01:00
4abff5e4fa update_nextcloud.sh: run 'Migrating the mimetypes' job after update. 2024-10-19 01:43:03 +02:00
6882e48d80 Add 'script occ_migrate_mimetipes.sh'. 2024-08-25 00:35:22 +02:00
ab1256f14b update_nextcloud.sh: some changes in script output. 2024-03-31 03:01:42 +02:00
a9fb3067df update_nextcloud.sh: start the cronjon manually only on demand. 2023-12-23 02:28:46 +01:00
b5a0204dec Some minor changes on script output. 2023-12-18 01:50:28 +01:00
ebdccd5c44 occ_maintenance.sh: some minor changes to the script output. 2023-08-05 00:42:42 +02:00
588eb68502 fix error determin configuration file. 2023-08-04 01:39:40 +02:00
2f8d771420 Merge branch 'master' of https://git.oopen.de/script/nextcloud 2023-08-04 01:28:53 +02:00
bea755c670 occ_maintenance.sh: fix error determin configuration file. 2023-08-04 01:28:23 +02:00
2c37b04ddf Some post installations on update and restore scripts. 2023-08-03 10:43:06 +02:00
d84294cf0b Add snippet 'get-path-of-php-command.sh' and change concerning code.. 2023-08-03 00:11:02 +02:00
1df7bb124b forgot script 'add_user_to_group.sh'.. 2023-08-02 23:19:58 +02:00
14f062908f Rename snippet 'get-php-major-version' to 'get-php-major-version.sh'.. 2023-08-02 23:17:45 +02:00
588cf5ca2e Rename snippet 'get-cloud-instance-to-update' to 'get-cloud-instance-to-update.sh'.. 2023-08-02 23:16:00 +02:00
17eaf8e278 Add snippet 'get-webservice-environment.sh' and change related code.. 2023-08-02 23:05:19 +02:00
a335d51975 rename 'check_encryption_scan_legacy-format' to 'check_encryption_scan_legacy-format.sh'. 2023-08-02 14:25:09 +02:00
08a9bc984d add snippet 'get-cloud-instance-to-update'.. 2023-08-02 14:23:46 +02:00
f244232347 Move snippet snippet-get-php-major-version into snippet dir and also rename it to 'get-php-major-version'. 2023-08-02 13:13:13 +02:00
25 changed files with 2943 additions and 2510 deletions

745
add-new-account.sh Executable file
View File

@ -0,0 +1,745 @@
#!/usr/bin/env bash
CUR_IFS=$IFS
script_name="$(basename $(realpath $0))"
script_dir="$(dirname $(realpath $0))"
conf_dir="${script_dir}/conf"
snippet_dir="${script_dir}/snippets"
declare -a unsorted_website_arr
declare -a website_arr
declare -a unsorted_account_arr
declare -a account_arr
declare -a unsorted_group_arr
declare -a group_arr
log_file="$(mktemp)"
backup_date=$(date +%Y-%m-%d-%H%M)
# =============
# --- Some functions
# =============
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
blank_line
exit $1
}
is_number() {
return $(test ! -z "${1##*[!0-9]*}" > /dev/null 2>&1);
# - also possible
# -
#[[ ! -z "${1##*[!0-9]*}" ]] && return 0 || return 1
#return $([[ ! -z "${1##*[!0-9]*}" ]])
}
echononl(){
echo X\\c > /tmp/shprompt$$
if [ `wc -c /tmp/shprompt$$ | awk '{print $1}'` -eq 1 ]; then
echo -e -n "$*\\c" 1>&2
else
echo -e -n "$*" 1>&2
fi
rm /tmp/shprompt$$
}
echo_done() {
if $terminal ; then
echo -e "\033[75G[ \033[32mdone\033[m ]"
else
echo " [ done ]"
fi
}
echo_ok() {
if $terminal ; then
echo -e "\033[75G[ \033[32mok\033[m ]"
else
echo " [ ok ]"
fi
}
echo_warning() {
if $terminal ; then
echo -e "\033[75G[ \033[33m\033[1mwarn\033[m ]"
else
echo " [ warning ]"
fi
}
echo_failed(){
if $terminal ; then
echo -e "\033[75G[ \033[1;31mfailed\033[m ]"
else
echo ' [ failed! ]'
fi
}
echo_skipped() {
if $terminal ; then
echo -e "\033[75G[ \033[37mskipped\033[m ]"
else
echo " [ skipped ]"
fi
}
fatal (){
echo ""
echo ""
if $terminal ; then
echo -e "\t[ \033[31m\033[1mFatal\033[m ]: \033[37m\033[1m$*\033[m"
echo ""
echo -e "\t\033[31m\033[1m Script will be interrupted..\033[m\033[m"
else
echo "fatal: $*"
echo "Script will be interrupted.."
fi
clean_up 1
}
error(){
echo ""
if $terminal ; then
echo -e "\t[ \033[31m\033[1mFehler\033[m ]: $*"
else
echo "Error: $*"
fi
echo ""
}
warn (){
echo ""
if $terminal ; then
echo -e "\t[ \033[33m\033[1mWarning\033[m ]: $*"
else
echo "Warning: $*"
fi
echo ""
}
info (){
echo ""
if $terminal ; then
echo -e "\t[ \033[32m\033[1mInfo\033[m ]: $*"
else
echo "Info: $*"
fi
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// /}"
}
# - Remove leading/trailling whitespaces
# -
trim() {
local var="$*"
var="${var#"${var%%[![:space:]]*}"}" # remove leading whitespace characters
var="${var%"${var##*[![:space:]]}"}" # remove trailing whitespace characters
echo -n "$var"
}
## - 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
return 1
}
random_char() {
local chars="$1"
echo -n "${chars:RANDOM%${#chars}:1}"
}
# Funktion zur Generierung eines zufälligen Strings mit den angegebenen Anforderungen
generate_random_string() {
local length="$1"
# Überprüfen, ob die Länge größer als 8 ist
if [[ "$length" -le 8 ]]; then
echo "Fehler: Die Länge muss größer als 8 Zeichen sein."
return 1
fi
# Zeichenmengen
# not allowed: 0ODl18B
local lower="abcdefghijkmnopqrstuvwxyz"
#local upper="ABCDEFGHIJKLMNOPQRSTUVWXYZ"
local upper="ACEFGHIJKLMNPQRSTUVWXYZ"
#local digits="0123456789"
local digits="2345679"
#local special="!@#$%^&*()_+-=[]{}|;:,.<>?/"
local special="__+---///...."
# Generiere mindestens ein Zeichen aus jeder Kategorie
local random_string=$(random_char "$lower")
random_string+=$(random_char "$upper")
random_string+=$(random_char "$digits")
random_string+=$(random_char "$special")
random_string+=$(random_char "$special")
# Fülle den Rest der Zeichenkette mit zufälligen Zeichen aus allen Kategorien
local all_chars="$lower$upper$digits$special"
for (( i=${#random_string}; i<length; i++ )); do
random_string+=$(random_char "$all_chars")
done
# Mische die Zeichenkette, um die Reihenfolge der Zeichen zufällig zu machen
random_string=$(echo "$random_string" | fold -w1 | shuf | tr -d '\n')
# Ausgabe des generierten Strings
echo "$random_string"
}
validate_email() {
local email=$1
local pattern="^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$"
if [[ $email =~ $pattern ]]; then
return 0 # Erfolg - E-Mail ist gültig
else
return 1 # Fehler - E-Mail ist ungültig
fi
}
blank_line() {
if $terminal ; then
echo ""
fi
}
# ----------
# - Jobhandling
# ----------
# - Run 'clean_up' for signals SIGHUP SIGINT SIGTERM
# -
trap clean_up SIGHUP SIGINT SIGTERM
## -
while IFS='' read -r -d '' _conf_file ; do
source $_conf_file
if [[ -n "$WEBSITE" ]] ; then
unsorted_website_arr+=("${WEBSITE}:$_conf_file")
fi
WEBSITE=""
done < <(find "${conf_dir}" -maxdepth 1 -type f -name "*.conf" -print0)
if [[ ${#unsorted_website_arr} -eq 0 ]]; then
fatal "No configuration files found in '${script_dir}/conf' or no website configured!"
fi
# - Sort array
# -
IFS=$'\n' website_arr=($(sort <<<"${unsorted_website_arr[*]}"))
# - Reset IFS
# -
IFS=$CUR_IFS
# =============
# --- Some
# =============
# - Support systemd ?
# -
if [[ "X$(which systemd)" = "X" ]]; then
SYSTEMD_EXISTS=false
else
SYSTEMD_EXISTS=true
fi
# - Running in a terminal?
# -
if [[ -t 1 ]] ; then
terminal=true
else
terminal=false
fi
#clear
echo ""
echo -e "\033[32m-----\033[m"
echo -e "Add a new User to NC - \033[1mIts possible to assign existing group(s)\033[m"
echo -e "\033[32m-----\033[m"
# Which cloud instance (website) would you like to update
#
source ${snippet_dir}/get-cloud-instance-to-update.sh
# - Reset IFS
# -
IFS=$CUR_IFS
echo ""
echononl " Include Configuration file.."
if [[ ! -f $conf_file ]]; then
echo_failed
fatal "Missing configuration file '$conf_file'"
else
source $conf_file
echo_ok
fi
echo ""
# =============
# --- Some checks
# =============
DEFAULT_SRC_BASE_DIR="/usr/local/src/nextcloud"
DEFAULT_HTTP_USER="www-data"
DEFAULT_HTTP_GROUP="www-data"
DEFAULT_PHP_ENGINE="FPM"
if [[ -z ${WEBSITE} ]] ; then
fatal "No website given (parameter 'WEBSITE')"
fi
DEFAULT_WEB_BASE_DIR="/var/www/$WEBSITE"
[[ -n "$WEB_BASE_DIR" ]] || WEB_BASE_DIR=$DEFAULT_WEB_BASE_DIR
if [[ ! -d ${WEB_BASE_DIR} ]] ; then
fatal "Web base directory not found (parameter 'WEB_BASE_DIR')"
fi
[[ -n "$PHP_ENGINE" ]] || PHP_ENGINE=$DEFAULT_PHP_ENGINE
if [[ "$DATABASE_TYPE" != "postgres" ]] && [[ "$DATABASE_TYPE" != "mysql" ]]; then
fatal "Wrong or missing database type (parameter 'DATABASE_TYPE')"
fi
if [[ -z "$DATABASE_NAME" ]]; then
fatal "Missing database name (parameter 'DATABASE_NAME')"
fi
if [[ "$DATABASE_TYPE" = "mysql" ]] && [[ -z "$MYSQL_CREDENTIALS" ]]; then
fatal "No Database Credentials for MySQL given (parameter 'MYSQL_CREDENTIALS')"
fi
if [[ "$DATABASE_TYPE" = "postgres" ]]; then
if [[ -z "$PSQL_USER" ]] || [[ -z "$PSQL_PASS" ]]; then
fatal "No Database Credentials for PostgreSQL given (parameters: 'PSQL_USER' 'PSQL_PASS'"
fi
fi
NGINX_IS_ENABLED=false
APACHE2_IS_ENABLED=false
# Get Webservice environment as IS_HTTPD_RUNNING, HTTP_USER, HTTP_GROUP..
#
source ${snippet_dir}/get-webservice-environment.sh
# Check PHP Version
#
source ${snippet_dir}/get-php-major-version.sh
# Get full qualified PHP command
#
source ${snippet_dir}/get-path-of-php-command.sh
CURRENT_INSTALL_DIR=`realpath ${WEB_BASE_DIR}/nextcloud`
CURRENT_DATA_DIR=`realpath ${WEB_BASE_DIR}/data`
CURRENT_VERSION=`basename $CURRENT_INSTALL_DIR | cut -d"-" -f2`
blank_line
echononl " Get list of current accounts.."
# Methode 1: mapfile (empfohlen)
#
mapfile -t unsorted_account_arr < <(su -c "${PHP_BIN} ${WEB_BASE_DIR}/htdocs/occ user:list" -s /bin/bash $HTTP_USER 2> ${log_file} | awk -F'[:[:space:]]+' '{print $3}' 2>> ${log_file} )
# Oder Methode 2: while-Schleife
#
#while IFS= read -r line; do
# unsorted_account_arr+=("$(echo "$line" | awk -F'[:[:space:]]+' '{print $3}' 2>> ${log_file})")
#done <<< "$(su -c "${PHP_BIN} ${WEB_BASE_DIR}/htdocs/occ user:list" -s /bin/bash $HTTP_USER 2> ${log_file})"
if [[ $? -gt 0 ]] || [[ -s "${log_file}" ]] ; then
echo_failed
error "$(cat $log_file)\n"
else
echo_ok
fi
echononl " Get list of current groups.."
mapfile -t unsorted_group_arr < <(su -c "${PHP_BIN} ${WEB_BASE_DIR}/htdocs/occ group:list" -s /bin/bash $HTTP_USER 2> ${log_file} | awk '/^\s*-\s[^:]+:$/{gsub(/^\s*-\s|:$/, ""); print}' 2>> ${log_file} )
#su -c "${PHP_BIN} ${WEB_BASE_DIR}/htdocs/occ user:list" -s /bin/bash $HTTP_USER | \
# | awk -F'[:[:space:]]+' '{print $3}'
echo ""
echo ""
echo -e "\033[32m-----\033[m"
echo ""
echo -e " Which \033[1muser\033[m would you like to add?"
echo ""
NEW_ACCOUNT=
while [[ -z "$(trim ${NEW_ACCOUNT})" ]] ; do
echononl " New NC accoun name: "
read NEW_ACCOUNT
if containsElement "${NEW_ACCOUNT}" "${unsorted_account_arr[@]}" ; then
echo -e "\n\t\033[33m\033[1mAccount \033[m\033[1m${NEW_ACCOUNT}\033[33m already exists! \033[m- Try again\n"
NEW_ACCOUNT=""
#echononl " New NC accoun name: "
continue
fi
if [[ -z "$(trim ${NEW_ACCOUNT})" ]] ; then
echo -e "\n\t\033[33m\033[1mAccount name must be given.\033[m\n"
fi
done
echo ""
echo ""
echo -e "\033[32m-----\033[m"
echo ""
echo -e " Enter the display name for the account \033[1m${NEW_ACCOUNT}\033[m"
echo ""
echo -e " Type \033[33mNone\033[m to not assign a display name"
echo ""
DISPLAY_NAME=
while [[ -z "$(trim ${DISPLAY_NAME})" ]] ; do
echononl " Display name for he account \033[1m${DISPLAY_NAME}\033[m: "
read DISPLAY_NAME
if [[ "${DISPLAY_NAME,,}" = "none" ]] ; then
DISPLAY_NAME=""
break
fi
if [[ -z "$(trim ${DISPLAY_NAME})" ]] ; then
echo -e "\n\t\033[33m\033[1mEntry must not be empty. Type \033[m\033[1mNone\033[33m for not assigning a display name.\033[m\n"
fi
done
blank_line
blank_line
echo -e " Present groups on NC Cloud instance \033[1m${WEBSITE}\033[m\n"
echo -en "\033[33m"
printf " %s\n" "${unsorted_group_arr[@]}"
echo -en "\033[m"
blank_line
echo ""
echo ""
echo -e "\033[32m-----\033[m"
echo ""
echo -e " Which groups should the new account belong to?"
echo ""
echo " - enter a list separated by spaces"
echo -e " - or type \033[33mNone\033[m to not assign the account to any group"
echo ""
ASSIGNED_GROUPS=
while [[ -z "$(trim ${ASSIGNED_GROUPS})" ]] ; do
echononl " Groups to which the new account should belong: "
read ASSIGNED_GROUPS
if [[ "${ASSIGNED_GROUPS,,}" = "none" ]] ; then
ASSIGNED_GROUPS=""
break
fi
if [[ -z "$(trim ${ASSIGNED_GROUPS})" ]] ; then
echo -e "\n\t\033[33m\033[1mEntry must not be empty. Type \033[m\033[1mNone\033[33m for not assigning a group.\033[m\n"
continue
fi
IFS=' ' read -ra assigned_groups_arr <<< "${ASSIGNED_GROUPS}"
for _group in "${assigned_groups_arr[@]}" ; do
if ! containsElement "${_group}" "${unsorted_group_arr[@]}" ; then
echo -e "\n\t\033[33m\033[1m No group \033[m\033[1m${_group}\033[33m present!\033[m - Try again..\n"
ASSIGNED_GROUPS=""
break
fi
done
# - Sort array
# -
IFS=$'\n' assigned_groups_arr=($(sort <<<"${assigned_groups_arr[*]}"))
done
echo ""
echo ""
echo -e "\033[32m-----\033[m"
echo ""
echo -e " Enter a password for the new account \033[1m${NEW_ACCOUNT}\033[m"
echo ""
echo " Some random genaerated Passwords:"
echo ""
for ((i=0; i<=9; i++)); do
echo -en " $i: "
echo -e "\033[33m$(generate_random_string 12)\033[m"
done
echo ""
_PW1="X"
_PW2="Y"
while [ "$_PW1" != "$_PW2" ]
do
echononl "Password: "
#read -s _PW1
read _PW1
echo
if [ "X$_PW1" = "X" ]; then
echo -e "\n\t\033[33m\033[1mA password is required!\033[m\n"
continue
fi
echononl "Repeat the password: "
#read -s _PW2
read _PW2
echo
if [ "$_PW1" != "$_PW2" ];then
echo -e "\n\t\033[33m\033[1mpassword entries are NOT identical!\033[m\n"
else
PASSWORD=$_PW1
fi
done
regex_email="^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$"
echo ""
echo ""
echo -e "\033[32m-----\033[m"
echo ""
echo -e " Enter an e-mail address for the new account \033[1m${NEW_ACCOUNT}\033[m"
echo ""
echo -e " Type \033[33mNone\033[m to not assign an e-mail address"
echo ""
E_MAIL=
while [[ -z "$(trim ${E_MAIL})" ]] ; do
echononl " E-Mail address for the new account \033[1m${E_MAIL}\033[m: "
read E_MAIL
if [[ "${E_MAIL,,}" = "none" ]] ; then
E_MAIL=""
break
fi
if [[ ! "${E_MAIL,,}" =~ ${regex_email} ]]; then
echo -e "\n\t\033[m\033[1m${E_MAIL}\033[33m is not a valid e-mail address\033[m - Try again..\n"
E_MAIL=""
continue
fi
if [[ -z "$(trim ${E_MAIL})" ]] ; then
echo -e "\n\t\033[33m\033[1mEntry must not be empty. Type \033[m\033[1mNone\033[33m for not assigning an e-mail address.\033[m\n"
fi
done
echo ""
echo ""
echo ""
echo -e "\033[1;32mStarting Script for \033[1;37m${WEBSITE}\033[m"
echo ""
echo -e " Cloud instance to be changed.........: ${WEBSITE}"
echo ""
echo -e " Current version of nextcloud.........: $CURRENT_VERSION"
echo ""
echo ""
echo -e " New Account..........................: ${NEW_ACCOUNT}"
if [[ -z "${DISPLAY_NAME}" ]] ; then
echo -e " Display Name.........................: \033[33mNone\033[m"
else
echo -e " Display Name.........................: ${DISPLAY_NAME}"
fi
if [[ -z "${E_MAIL}" ]] ; then
echo -e " E-Mail Address.......................: \033[33mNone\033[m"
else
echo -e " E-Mail Address.......................: ${E_MAIL}"
fi
echo ""
echo -e " Password.............................: ${PASSWORD}"
echo ""
if [[ -z "${ASSIGNED_GROUPS}" ]] ; then
echo -e " Group(s) assigned to the new account.: \033[33mNone\033[m"
else
declare -i index=0
for _group in "${assigned_groups_arr[@]}" ; do
if [[ ${index} -lt 1 ]] ; then
echo -e " Group(s) assigned to the new account.: \033[33m${_group}\033[m"
else
echo -e " \033[33m${_group}\033[m"
fi
(( index++ ))
done
fi
echo ""
echo ""
echo -e " Web base directory...................: $WEB_BASE_DIR"
echo ""
echo -e " Webserver user.......................: $HTTP_USER"
echo -e " Webserver group......................: $HTTP_GROUP"
echo ""
echo -e " PHP version..........................: $PHP_VERSION"
echo -e " PHP Engine...........................: $PHP_ENGINE"
echo ""
echo -e " PHP command..........................: $PHP_BIN"
echo ""
echo -e " Databse name.........................: $DATABASE_NAME"
echo -e " Database type........................: $DATABASE_TYPE"
echo ""
if [[ "$DATABASE_TYPE" = "mysql" ]] ; then
echo -e " Mysql Credentials....................: $MYSQL_CREDENTIALS"
fi
echo ""
echo ""
echo -n " Type upper case 'YES' to continue executing with this parameters: "
read OK
if [[ "$OK" = "YES" ]] ; then
echo ""
echo ""
echo -e "\033[1;32mGoing to create new account \033[1;37m${NEW_ACCOUNT}\033[1;32m on \033[1;37m${WEBSITE}\033[m"
echo ""
else
fatal "Abort by user request - Answer as not 'YES'"
fi
# -----
# - Main part of the script
# -----
echo ""
echo ""
echo -e "\033[37m\033[1mMain part of the script\033[m"
echo ""
occ_arg_string="user:add --password-from-env"
echononl " Create Parametwer String.."
[[ -n "${DISPLAY_NAME}" ]] && occ_arg_string="${occ_arg_string} --display-name='${DISPLAY_NAME}'"
if [[ ${#assigned_groups_arr[@]} -gt 0 ]] ; then
for _group in "${assigned_groups_arr[@]}" ; do
occ_arg_string="${occ_arg_string} --group='${_group}'"
done
fi
[[ -n "${E_MAIL}" ]] && occ_arg_string="${occ_arg_string} --email=${E_MAIL}"
occ_arg_string="${occ_arg_string} '${NEW_ACCOUNT}'"
echo_done
# - Create new account
# -
echononl " Create new account \033[1;37m${NEW_ACCOUNT}\033[m on \033[1;37m${WEBSITE} \033[m"..""
su -c "OC_PASS='${PASSWORD}' ${PHP_BIN} ${WEB_BASE_DIR}/htdocs/occ ${occ_arg_string}" -s /bin/bash ${HTTP_USER} \
> $log_file 2>&1
if [[ $? -eq 0 ]]; then
echo_ok
blank_line
echo -e "\033[37m\033[1mCommand output was:\033[m"
blank_line
cat ${log_file}
blank_line
echo -e "Password set to '${PASSWORD}'"
else
echo_failed
blank_line
echo ""
echo -e "\033[37m\033[1mCommandline was:\033[m"
echo -e "
su -c \"OC_PASS='${PASSWORD}' ${PHP_BIN} ${WEB_BASE_DIR}/htdocs/occ ${occ_arg_string}\" -s /bin/bash ${HTTP_USER}
"
blank_line
error "\n\n$(cat $log_file)"
fi
blank_line
clean_up 0

View File

@ -6,6 +6,7 @@ script_name="$(basename $(realpath $0))"
script_dir="$(dirname $(realpath $0))"
conf_dir="${script_dir}/conf"
snippet_dir="${script_dir}/snippets"
declare -a unsorted_website_arr
declare -a website_arr
@ -216,34 +217,9 @@ echo -e "\033[32m-----\033[m"
echo "Add missing columns"
echo -e "\033[32m-----\033[m"
WEBSITE=
_OK=false
echo ""
echo "Which site would you like to update?"
echo ""
declare -i i=0
for _site in ${website_arr[@]} ; do
IFS=':' read -a _arr <<< ${_site}
echo " [$i] ${_arr[0]}"
((i++))
done
echo
echononl " Eingabe: "
while ! $_OK ; do
read _IN
if is_number "$_IN" && [[ -n ${website_arr[$_IN]} ]]; then
IFS=':' read -a _arr <<< ${website_arr[$_IN]}
conf_file=${_arr[1]}
DEFAULT_WEBSITE="${_arr[0]}"
_OK=true
else
echo ""
echo -e "\tFalsche Eingabe !"
echo ""
echononl " Eingabe: "
fi
done
# Which cloud instance (website) would you like to update
#
source ${snippet_dir}/get-cloud-instance-to-update.sh
# - Reset IFS
@ -309,107 +285,18 @@ fi
NGINX_IS_ENABLED=false
APACHE2_IS_ENABLED=false
# Check if NGINX webserver is ctive
# Get Webservice environment as IS_HTTPD_RUNNING, HTTP_USER, HTTP_GROUP..
#
if $(systemctl -q is-enabled nginx 2> /dev/null) ; then
NGINX_IS_ENABLED=true
# - Determin user of the webserver
# -
nginx_binary="$(which nginx)"
if [[ -z "$nginx_binary" ]] ; then
nginx_binary="$(ps -axu | grep -E "nginx:.*master" | grep -v grep | grep -o -E "\S+/nginx")"
if [[ -z "$nginx_binary" ]] ; then
if [[ -x "/usr/local/nginx/bin/nginx" ]]; then
nginx_binary="/usr/local/nginx/bin/nginx"
elif [[ -x "/usr/local/nginx/sbin/nginx" ]]; then
nginx_binary="/usr/local/nginx/sbin/nginx"
fi
fi
fi
if [[ -x "$nginx_binary" ]] ; then
_HTTP_USER="$($nginx_binary -T 2> /dev/null | grep -E "^\s*user\s+\S+;" | grep -o -E "\S+;$" | sed -e 's/;$//')"
fi
# - Is webserver running ?
# -
PID=$(ps aux | grep "$(realpath $nginx_binary)" | grep -e "^root" | grep -v grep | awk '{print$2}')
if [[ "X${PID}X" = "XX" ]] ;then
IS_HTTPD_RUNNING=false
else
IS_HTTPD_RUNNING=true
fi
elif $(systemctl -q is-enabled apache2 2> /dev/null) ; then
APACHE2_IS_ENABLED=true
# - Determin user 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}')"
if [ -z "$httpd_binary" ]; then
if [ -x "/usr/local/apache2/bin/httpd" ]; then
httpd_binary="/usr/local/apache2/bin/httpd"
fi
fi
fi
if [ -x "$httpd_binary" ];then
# - Determin websever user
# -
_HTTP_USER="`$httpd_binary -t -D DUMP_RUN_CFG | grep -i -e "^User" | awk '{print$2}' | cut -d\"=\" -f2 | tr -d '"'`"
_HTTP_GROUP="`$httpd_binary -t -D DUMP_RUN_CFG | grep -i -e "^Group" | awk '{print$2}' | cut -d\"=\" -f2 | tr -d '"'`"
# - Is webserver running ?
# -
PID=$(ps aux | grep "$(realpath $httpd_binary)" | grep -e "^root" | grep -v grep | awk '{print$2}')
if [[ "X${PID}X" = "XX" ]] ;then
IS_HTTPD_RUNNING=false
else
IS_HTTPD_RUNNING=true
fi
fi
else
error "Neither \033[1mapache2\033[m nor \033[1mnginx\033[m is enabled on this machine"
echononl "continue anyway [yes/no]: "
read OK
OK="$(echo "$OK" | tr '[:upper:]' '[:lower:]')"
while [[ "$OK" != "yes" ]] && [[ "$OK" != "no" ]] ; do
echononl "Wrong entry! - repeat [yes/nno]: "
read OK
done
[[ $OK = "yes" ]] || fatal "Interrupted by user"
fi
if [[ -n "$_HTTP_USER" ]] ; then
if [[ -n "$HTTP_USER" ]] && [[ "$_HTTP_USER" != "$HTTP_USER" ]]; then
warn "The script has determined \033[1;37m${_HTTP_USER}\033[m as Webservers user. This\n value differs from the value given in your configuration file, \n which is \033[1;37m${HTTP_USER}\033[m and takes precedence."
else
HTTP_USER=$_HTTP_USER
fi
else
[[ -n "$HTTP_USER" ]] || HTTP_USER=$DEFAULT_HTTP_USER
fi
if [[ -n "$_HTTP_GROUP" ]] ; then
if [[ -n "$HTTP_GROUP" ]] && [[ "$_HTTP_GROUP" != "$HTTP_GROUP" ]]; then
warn "The script has determined \033[1;37m${_HTTP_GROUP}\033[m as Webservers group. This\n value differs from the value given in your configuration file, \n which is \033[1;37m${HTTP_GROUP}\033[m and takes precedence."
else
HTTP_GROUP=$_HTTP_GROUP
fi
else
[[ -n "$HTTP_GROUP" ]] || HTTP_GROUP=$DEFAULT_HTTP_GROUP
fi
source ${snippet_dir}/get-webservice-environment.sh
# Check PHP Version
#
source ${script_dir}/snippet-get-php-major-version
source ${snippet_dir}/get-php-major-version.sh
# Get full qualified PHP command
#
source ${snippet_dir}/get-path-of-php-command.sh
CURRENT_INSTALL_DIR="$(realpath ${WEB_BASE_DIR}/nextcloud)"
@ -429,6 +316,8 @@ echo -e " Webserver group......................: $HTTP_GROUP"
echo ""
echo -e " PHP version..........................: $PHP_VERSION"
echo -e " PHP Engine...........................: $PHP_ENGINE"
echo ""
echo -e " PHP Command..........................: $PHP_BIN"
echo ""
echo -n " Type upper case 'YES' to continue executing with this parameters: "
@ -634,7 +523,7 @@ echo ""
# - Add missing columns
# -
echononl " Add missing columns .."
su -c "/usr/local/php/bin/php ${WEB_BASE_DIR}/htdocs/occ db:add-missing-columns" -s /bin/bash $HTTP_USER > $log_file 2>&1
su -c "${PHP_BIN} ${WEB_BASE_DIR}/htdocs/occ db:add-missing-columns" -s /bin/bash $HTTP_USER > $log_file 2>&1
if [[ $? -eq 0 ]]; then
echo_ok
else

View File

@ -6,6 +6,7 @@ script_name="$(basename $(realpath $0))"
script_dir="$(dirname $(realpath $0))"
conf_dir="${script_dir}/conf"
snippet_dir="${script_dir}/snippets"
declare -a unsorted_website_arr
declare -a website_arr
@ -216,34 +217,9 @@ echo -e "\033[32m-----\033[m"
echo "Create missing indices"
echo -e "\033[32m-----\033[m"
WEBSITE=
_OK=false
echo ""
echo "Which site would you like to update?"
echo ""
declare -i i=0
for _site in ${website_arr[@]} ; do
IFS=':' read -a _arr <<< ${_site}
echo " [$i] ${_arr[0]}"
((i++))
done
echo
echononl " Eingabe: "
while ! $_OK ; do
read _IN
if is_number "$_IN" && [[ -n ${website_arr[$_IN]} ]]; then
IFS=':' read -a _arr <<< ${website_arr[$_IN]}
conf_file=${_arr[1]}
DEFAULT_WEBSITE="${_arr[0]}"
_OK=true
else
echo ""
echo -e "\tFalsche Eingabe !"
echo ""
echononl " Eingabe: "
fi
done
# Which cloud instance (website) would you like to update
#
source ${snippet_dir}/get-cloud-instance-to-update.sh
# - Reset IFS
@ -306,110 +282,24 @@ if [[ "$DATABASE_TYPE" = "postgres" ]]; then
fi
fi
NGINX_IS_ENABLED=false
APACHE2_IS_ENABLED=false
# Check if NGINX webserver is ctive
# Get Webservice environment as IS_HTTPD_RUNNING, HTTP_USER, HTTP_GROUP..
#
if $(systemctl -q is-enabled nginx 2> /dev/null) ; then
source ${snippet_dir}/get-webservice-environment.sh
NGINX_IS_ENABLED=true
# - Determin user of the webserver
# -
nginx_binary="$(which nginx)"
if [[ -z "$nginx_binary" ]] ; then
nginx_binary="$(ps -axu | grep -E "nginx:.*master" | grep -v grep | grep -o -E "\S+/nginx")"
if [[ -z "$nginx_binary" ]] ; then
if [[ -x "/usr/local/nginx/bin/nginx" ]]; then
nginx_binary="/usr/local/nginx/bin/nginx"
elif [[ -x "/usr/local/nginx/sbin/nginx" ]]; then
nginx_binary="/usr/local/nginx/sbin/nginx"
fi
fi
fi
if [[ -x "$nginx_binary" ]] ; then
_HTTP_USER="$($nginx_binary -T 2> /dev/null | grep -E "^\s*user\s+\S+;" | grep -o -E "\S+;$" | sed -e 's/;$//')"
fi
# - Is webserver running ?
# -
PID=$(ps aux | grep "$(realpath $nginx_binary)" | grep -e "^root" | grep -v grep | awk '{print$2}')
if [[ "X${PID}X" = "XX" ]] ;then
IS_HTTPD_RUNNING=false
else
IS_HTTPD_RUNNING=true
fi
elif $(systemctl -q is-enabled apache2 2> /dev/null) ; then
APACHE2_IS_ENABLED=true
# - Determin user 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}')"
if [ -z "$httpd_binary" ]; then
if [ -x "/usr/local/apache2/bin/httpd" ]; then
httpd_binary="/usr/local/apache2/bin/httpd"
fi
fi
fi
if [ -x "$httpd_binary" ];then
# - Determin websever user
# -
_HTTP_USER="`$httpd_binary -t -D DUMP_RUN_CFG | grep -i -e "^User" | awk '{print$2}' | cut -d\"=\" -f2 | tr -d '"'`"
_HTTP_GROUP="`$httpd_binary -t -D DUMP_RUN_CFG | grep -i -e "^Group" | awk '{print$2}' | cut -d\"=\" -f2 | tr -d '"'`"
# - Is webserver running ?
# -
PID=$(ps aux | grep "$(realpath $httpd_binary)" | grep -e "^root" | grep -v grep | awk '{print$2}')
if [[ "X${PID}X" = "XX" ]] ;then
IS_HTTPD_RUNNING=false
else
IS_HTTPD_RUNNING=true
fi
fi
else
error "Neither \033[1mapache2\033[m nor \033[1mnginx\033[m is enabled on this machine"
echononl "continue anyway [yes/no]: "
read OK
OK="$(echo "$OK" | tr '[:upper:]' '[:lower:]')"
while [[ "$OK" != "yes" ]] && [[ "$OK" != "no" ]] ; do
echononl "Wrong entry! - repeat [yes/nno]: "
read OK
done
[[ $OK = "yes" ]] || fatal "Interrupted by user"
fi
if [[ -n "$_HTTP_USER" ]] ; then
if [[ -n "$HTTP_USER" ]] && [[ "$_HTTP_USER" != "$HTTP_USER" ]]; then
warn "The script has determined \033[1;37m${_HTTP_USER}\033[m as Webservers user. This\n value differs from the value given in your configuration file, \n which is \033[1;37m${HTTP_USER}\033[m and takes precedence."
else
HTTP_USER=$_HTTP_USER
fi
else
[[ -n "$HTTP_USER" ]] || HTTP_USER=$DEFAULT_HTTP_USER
fi
if [[ -n "$_HTTP_GROUP" ]] ; then
if [[ -n "$HTTP_GROUP" ]] && [[ "$_HTTP_GROUP" != "$HTTP_GROUP" ]]; then
warn "The script has determined \033[1;37m${_HTTP_GROUP}\033[m as Webservers group. This\n value differs from the value given in your configuration file, \n which is \033[1;37m${HTTP_GROUP}\033[m and takes precedence."
else
HTTP_GROUP=$_HTTP_GROUP
fi
else
[[ -n "$HTTP_GROUP" ]] || HTTP_GROUP=$DEFAULT_HTTP_GROUP
fi
# Check PHP Version
#
source ${script_dir}/snippet-get-php-major-version
source ${snippet_dir}/get-php-major-version.sh
# Get full qualified PHP command
#
source ${snippet_dir}/get-path-of-php-command.sh
CURRENT_INSTALL_DIR="$(realpath ${WEB_BASE_DIR}/nextcloud)"
CURRENT_VERSION="$(basename $CURRENT_INSTALL_DIR | cut -d"-" -f2)"
@ -428,6 +318,8 @@ echo -e " Webserver group......................: $HTTP_GROUP"
echo ""
echo -e " PHP version..........................: $PHP_VERSION"
echo -e " PHP Engine...........................: $PHP_ENGINE"
echo ""
echo -e " PHP Command..........................: $PHP_BIN"
echo ""
echo -n " Type upper case 'YES' to continue executing with this parameters: "
@ -633,7 +525,7 @@ echo ""
# - Create missing indices
# -
echononl " Add missing indices .."
su -c "/usr/local/php/bin/php ${WEB_BASE_DIR}/htdocs/occ db:add-missing-indices" -s /bin/bash $HTTP_USER > $log_file 2>&1
su -c "${PHP_BIN} ${WEB_BASE_DIR}/htdocs/occ db:add-missing-indices" -s /bin/bash $HTTP_USER > $log_file 2>&1
if [[ $? -eq 0 ]]; then
echo_ok
else

View File

@ -6,6 +6,7 @@ script_name="$(basename $(realpath $0))"
script_dir="$(dirname $(realpath $0))"
conf_dir="${script_dir}/conf"
snippet_dir="${script_dir}/snippets"
declare -a unsorted_website_arr
declare -a website_arr
@ -216,34 +217,9 @@ echo -e "\033[32m-----\033[m"
echo "Create missing indices"
echo -e "\033[32m-----\033[m"
WEBSITE=
_OK=false
echo ""
echo "Which site would you like to update?"
echo ""
declare -i i=0
for _site in ${website_arr[@]} ; do
IFS=':' read -a _arr <<< ${_site}
echo " [$i] ${_arr[0]}"
((i++))
done
echo
echononl " Eingabe: "
while ! $_OK ; do
read _IN
if is_number "$_IN" && [[ -n ${website_arr[$_IN]} ]]; then
IFS=':' read -a _arr <<< ${website_arr[$_IN]}
conf_file=${_arr[1]}
DEFAULT_WEBSITE="${_arr[0]}"
_OK=true
else
echo ""
echo -e "\tFalsche Eingabe !"
echo ""
echononl " Eingabe: "
fi
done
# Which cloud instance (website) would you like to update
#
source ${snippet_dir}/get-cloud-instance-to-update.sh
# - Reset IFS
@ -309,107 +285,18 @@ fi
NGINX_IS_ENABLED=false
APACHE2_IS_ENABLED=false
# Check if NGINX webserver is ctive
# Get Webservice environment as IS_HTTPD_RUNNING, HTTP_USER, HTTP_GROUP..
#
if $(systemctl -q is-enabled nginx 2> /dev/null) ; then
NGINX_IS_ENABLED=true
# - Determin user of the webserver
# -
nginx_binary="$(which nginx)"
if [[ -z "$nginx_binary" ]] ; then
nginx_binary="$(ps -axu | grep -E "nginx:.*master" | grep -v grep | grep -o -E "\S+/nginx")"
if [[ -z "$nginx_binary" ]] ; then
if [[ -x "/usr/local/nginx/bin/nginx" ]]; then
nginx_binary="/usr/local/nginx/bin/nginx"
elif [[ -x "/usr/local/nginx/sbin/nginx" ]]; then
nginx_binary="/usr/local/nginx/sbin/nginx"
fi
fi
fi
if [[ -x "$nginx_binary" ]] ; then
_HTTP_USER="$($nginx_binary -T 2> /dev/null | grep -E "^\s*user\s+\S+;" | grep -o -E "\S+;$" | sed -e 's/;$//')"
fi
# - Is webserver running ?
# -
PID=$(ps aux | grep "$(realpath $nginx_binary)" | grep -e "^root" | grep -v grep | awk '{print$2}')
if [[ "X${PID}X" = "XX" ]] ;then
IS_HTTPD_RUNNING=false
else
IS_HTTPD_RUNNING=true
fi
elif $(systemctl -q is-enabled apache2 2> /dev/null) ; then
APACHE2_IS_ENABLED=true
# - Determin user 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}')"
if [ -z "$httpd_binary" ]; then
if [ -x "/usr/local/apache2/bin/httpd" ]; then
httpd_binary="/usr/local/apache2/bin/httpd"
fi
fi
fi
if [ -x "$httpd_binary" ];then
# - Determin websever user
# -
_HTTP_USER="`$httpd_binary -t -D DUMP_RUN_CFG | grep -i -e "^User" | awk '{print$2}' | cut -d\"=\" -f2 | tr -d '"'`"
_HTTP_GROUP="`$httpd_binary -t -D DUMP_RUN_CFG | grep -i -e "^Group" | awk '{print$2}' | cut -d\"=\" -f2 | tr -d '"'`"
# - Is webserver running ?
# -
PID=$(ps aux | grep "$(realpath $httpd_binary)" | grep -e "^root" | grep -v grep | awk '{print$2}')
if [[ "X${PID}X" = "XX" ]] ;then
IS_HTTPD_RUNNING=false
else
IS_HTTPD_RUNNING=true
fi
fi
else
error "Neither \033[1mapache2\033[m nor \033[1mnginx\033[m is enabled on this machine"
echononl "continue anyway [yes/no]: "
read OK
OK="$(echo "$OK" | tr '[:upper:]' '[:lower:]')"
while [[ "$OK" != "yes" ]] && [[ "$OK" != "no" ]] ; do
echononl "Wrong entry! - repeat [yes/nno]: "
read OK
done
[[ $OK = "yes" ]] || fatal "Interrupted by user"
fi
if [[ -n "$_HTTP_USER" ]] ; then
if [[ -n "$HTTP_USER" ]] && [[ "$_HTTP_USER" != "$HTTP_USER" ]]; then
warn "The script has determined \033[1;37m${_HTTP_USER}\033[m as Webservers user. This\n value differs from the value given in your configuration file, \n which is \033[1;37m${HTTP_USER}\033[m and takes precedence."
else
HTTP_USER=$_HTTP_USER
fi
else
[[ -n "$HTTP_USER" ]] || HTTP_USER=$DEFAULT_HTTP_USER
fi
if [[ -n "$_HTTP_GROUP" ]] ; then
if [[ -n "$HTTP_GROUP" ]] && [[ "$_HTTP_GROUP" != "$HTTP_GROUP" ]]; then
warn "The script has determined \033[1;37m${_HTTP_GROUP}\033[m as Webservers group. This\n value differs from the value given in your configuration file, \n which is \033[1;37m${HTTP_GROUP}\033[m and takes precedence."
else
HTTP_GROUP=$_HTTP_GROUP
fi
else
[[ -n "$HTTP_GROUP" ]] || HTTP_GROUP=$DEFAULT_HTTP_GROUP
fi
source ${snippet_dir}/get-webservice-environment.sh
# Check PHP Version
#
source ${script_dir}/snippet-get-php-major-version
source ${snippet_dir}/get-php-major-version.sh
# Get full qualified PHP command
#
source ${snippet_dir}/get-path-of-php-command.sh
CURRENT_INSTALL_DIR="$(realpath ${WEB_BASE_DIR}/nextcloud)"
@ -429,6 +316,8 @@ echo -e " Webserver group......................: $HTTP_GROUP"
echo ""
echo -e " PHP version..........................: $PHP_VERSION"
echo -e " PHP Engine...........................: $PHP_ENGINE"
echo ""
echo -e " PHP Command..........................: $PHP_BIN"
echo ""
echo -n " Type upper case 'YES' to continue executing with this parameters: "
@ -631,10 +520,10 @@ echo -e "\033[37m\033[1mMain part of the script\033[m"
echo ""
# - Create missing indices
# - Add missing primary keys ..
# -
echononl " Add missing primary keys .."
su -c "/usr/local/php/bin/php ${WEB_BASE_DIR}/htdocs/occ db:add-missing-primary-keys" -s /bin/bash $HTTP_USER > $log_file 2>&1
su -c "${PHP_BIN} ${WEB_BASE_DIR}/htdocs/occ db:add-missing-primary-keys" -s /bin/bash $HTTP_USER > $log_file 2>&1
if [[ $? -eq 0 ]]; then
echo_ok
else

View File

@ -6,6 +6,7 @@ script_name="$(basename $(realpath $0))"
script_dir="$(dirname $(realpath $0))"
conf_dir="${script_dir}/conf"
snippet_dir="${script_dir}/snippets"
declare -a unsorted_website_arr
declare -a website_arr
@ -254,34 +255,9 @@ echo -e "\033[32m-----\033[m"
echo -e "Add User to Group - \033[1mBoth, User and Group has to exist\033[m"
echo -e "\033[32m-----\033[m"
WEBSITE=
_OK=false
echo ""
echo "Cloud instance that you want to change?"
echo ""
declare -i i=0
for _site in ${website_arr[@]} ; do
IFS=':' read -a _arr <<< ${_site}
echo " [$i] ${_arr[0]}"
((i++))
done
echo
echononl " Eingabe: "
while ! $_OK ; do
read _IN
if is_number "$_IN" && [[ -n ${website_arr[$_IN]} ]]; then
IFS=':' read -a _arr <<< ${website_arr[$_IN]}
conf_file=${_arr[1]}
DEFAULT_WEBSITE="${_arr[0]}"
_OK=true
else
echo ""
echo -e "\tFalsche Eingabe !"
echo ""
echononl " Eingabe: "
fi
done
# Which cloud instance (website) would you like to update
#
source ${snippet_dir}/get-cloud-instance-to-update.sh
# - Reset IFS
@ -344,110 +320,23 @@ if [[ "$DATABASE_TYPE" = "postgres" ]]; then
fi
fi
NGINX_IS_ENABLED=false
APACHE2_IS_ENABLED=false
# Check if NGINX webserver is ctive
# Get Webservice environment as IS_HTTPD_RUNNING, HTTP_USER, HTTP_GROUP..
#
if $(systemctl -q is-enabled nginx 2> /dev/null) ; then
source ${snippet_dir}/get-webservice-environment.sh
NGINX_IS_ENABLED=true
# - Determin user of the webserver
# -
nginx_binary="$(which nginx)"
if [[ -z "$nginx_binary" ]] ; then
nginx_binary="$(ps -axu | grep -E "nginx:.*master" | grep -v grep | grep -o -E "\S+/nginx")"
if [[ -z "$nginx_binary" ]] ; then
if [[ -x "/usr/local/nginx/bin/nginx" ]]; then
nginx_binary="/usr/local/nginx/bin/nginx"
elif [[ -x "/usr/local/nginx/sbin/nginx" ]]; then
nginx_binary="/usr/local/nginx/sbin/nginx"
fi
fi
fi
if [[ -x "$nginx_binary" ]] ; then
_HTTP_USER="$($nginx_binary -T 2> /dev/null | grep -E "^\s*user\s+\S+;" | grep -o -E "\S+;$" | sed -e 's/;$//')"
fi
# - Is webserver running ?
# -
PID=$(ps aux | grep "$(realpath $nginx_binary)" | grep -e "^root" | grep -v grep | awk '{print$2}')
if [[ "X${PID}X" = "XX" ]] ;then
IS_HTTPD_RUNNING=false
else
IS_HTTPD_RUNNING=true
fi
elif $(systemctl -q is-enabled apache2 2> /dev/null) ; then
APACHE2_IS_ENABLED=true
# - Determin user 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}')"
if [ -z "$httpd_binary" ]; then
if [ -x "/usr/local/apache2/bin/httpd" ]; then
httpd_binary="/usr/local/apache2/bin/httpd"
fi
fi
fi
if [ -x "$httpd_binary" ];then
# - Determin websever user
# -
_HTTP_USER="`$httpd_binary -t -D DUMP_RUN_CFG | grep -i -e "^User" | awk '{print$2}' | cut -d\"=\" -f2 | tr -d '"'`"
_HTTP_GROUP="`$httpd_binary -t -D DUMP_RUN_CFG | grep -i -e "^Group" | awk '{print$2}' | cut -d\"=\" -f2 | tr -d '"'`"
# - Is webserver running ?
# -
PID=$(ps aux | grep "$(realpath $httpd_binary)" | grep -e "^root" | grep -v grep | awk '{print$2}')
if [[ "X${PID}X" = "XX" ]] ;then
IS_HTTPD_RUNNING=false
else
IS_HTTPD_RUNNING=true
fi
fi
else
error "Neither \033[1mapache2\033[m nor \033[1mnginx\033[m is enabled on this machine"
echononl "continue anyway [yes/no]: "
read OK
OK="$(echo "$OK" | tr '[:upper:]' '[:lower:]')"
while [[ "$OK" != "yes" ]] && [[ "$OK" != "no" ]] ; do
echononl "Wrong entry! - repeat [yes/nno]: "
read OK
done
[[ $OK = "yes" ]] || fatal "Interrupted by user"
fi
if [[ -n "$_HTTP_USER" ]] ; then
if [[ -n "$HTTP_USER" ]] && [[ "$_HTTP_USER" != "$HTTP_USER" ]]; then
warn "The script has determined \033[1;37m${_HTTP_USER}\033[m as Webservers user. This\n value differs from the value given in your configuration file, \n which is \033[1;37m${HTTP_USER}\033[m and takes precedence."
else
HTTP_USER=$_HTTP_USER
fi
else
[[ -n "$HTTP_USER" ]] || HTTP_USER=$DEFAULT_HTTP_USER
fi
if [[ -n "$_HTTP_GROUP" ]] ; then
if [[ -n "$HTTP_GROUP" ]] && [[ "$_HTTP_GROUP" != "$HTTP_GROUP" ]]; then
warn "The script has determined \033[1;37m${_HTTP_GROUP}\033[m as Webservers group. This\n value differs from the value given in your configuration file, \n which is \033[1;37m${HTTP_GROUP}\033[m and takes precedence."
else
HTTP_GROUP=$_HTTP_GROUP
fi
else
[[ -n "$HTTP_GROUP" ]] || HTTP_GROUP=$DEFAULT_HTTP_GROUP
fi
# Check PHP Version
#
source ${script_dir}/snippet-get-php-major-version
source ${snippet_dir}/get-php-major-version.sh
# Get full qualified PHP command
#
source ${snippet_dir}/get-path-of-php-command.sh
CURRENT_INSTALL_DIR=`realpath ${WEB_BASE_DIR}/nextcloud`
CURRENT_DATA_DIR=`realpath ${WEB_BASE_DIR}/data`
@ -507,6 +396,8 @@ echo ""
echo -e " PHP version..........................: $PHP_VERSION"
echo -e " PHP Engine...........................: $PHP_ENGINE"
echo ""
echo -e " PHP Command..........................: $PHP_BIN"
echo ""
echo -e " Databse name.........................: $DATABASE_NAME"
echo -e " Database type........................: $DATABASE_TYPE"
echo ""
@ -545,7 +436,7 @@ echo ""
# -
echononl " Add user \033[37m\033[1m$USER\033[m to group \033[37m\033[1m$GROUP\033[m .."
su -c "/usr/local/php/bin/php ${WEB_BASE_DIR}/htdocs/occ group:adduser '$GROUP' '$USER'" -s /bin/bash $HTTP_USER > $log_file 2>&1
su -c "${PHP_BIN} ${WEB_BASE_DIR}/htdocs/occ group:adduser '$GROUP' '$USER'" -s /bin/bash $HTTP_USER > $log_file 2>&1
if [[ $? -eq 0 ]]; then
echo_ok
else
@ -553,7 +444,7 @@ else
blank_line
echo ""
echo -e "\033[37m\033[1mcommandline was:\033[m"
echo "su -c \"/usr/local/php/bin/php ${WEB_BASE_DIR}/htdocs/occ group:adduser '$GROUP' '$USER'\" -s /bin/bash $HTTP_USER"
echo "su -c \"${PHP_BIN} ${WEB_BASE_DIR}/htdocs/occ group:adduser '$GROUP' '$USER'\" -s /bin/bash $HTTP_USER"
blank_line
warn "Despite errors, it is possible that the user \033[37m\033[1m$USER\033[m was added to the group \033[37m\033[1m$GROUP\033[m"
fatal "$(cat $log_file)"

View File

@ -6,6 +6,7 @@ script_name="$(basename $(realpath $0))"
script_dir="$(dirname $(realpath $0))"
conf_dir="${script_dir}/conf"
snippet_dir="${script_dir}/snippets"
declare -a unsorted_website_arr
declare -a website_arr
@ -225,33 +226,9 @@ echo "Create missing indices"
echo -e "\033[32m-----\033[m"
WEBSITE=
_OK=false
echo ""
echo "Which site would you like to update?"
echo ""
declare -i i=0
for _site in ${website_arr[@]} ; do
IFS=':' read -a _arr <<< ${_site}
echo " [$i] ${_arr[0]}"
((i++))
done
echo
echononl " Eingabe: "
while ! $_OK ; do
read _IN
if is_number "$_IN" && [[ -n ${website_arr[$_IN]} ]]; then
IFS=':' read -a _arr <<< ${website_arr[$_IN]}
conf_file=${_arr[1]}
DEFAULT_WEBSITE="${_arr[0]}"
_OK=true
else
echo ""
echo -e "\tFalsche Eingabe !"
echo ""
echononl " Eingabe: "
fi
done
# Which cloud instance (website) would you like to update
#
source ${snippet_dir}/get-cloud-instance-to-update.sh
# - Reset IFS
@ -316,192 +293,24 @@ if [[ "$DATABASE_TYPE" = "postgres" ]]; then
fi
fi
NGINX_IS_ENABLED=false
APACHE2_IS_ENABLED=false
# Check if NGINX webserver is ctive
# Get Webservice environment as IS_HTTPD_RUNNING, HTTP_USER, HTTP_GROUP..
#
if $(systemctl -q is-enabled nginx 2> /dev/null) ; then
source ${snippet_dir}/get-webservice-environment.sh
NGINX_IS_ENABLED=true
# - Determin user of the webserver
# -
nginx_binary="$(which nginx)"
if [[ -z "$nginx_binary" ]] ; then
nginx_binary="$(ps -axu | grep -E "nginx:.*master" | grep -v grep | grep -o -E "\S+/nginx")"
if [[ -z "$nginx_binary" ]] ; then
if [[ -x "/usr/local/nginx/bin/nginx" ]]; then
nginx_binary="/usr/local/nginx/bin/nginx"
elif [[ -x "/usr/local/nginx/sbin/nginx" ]]; then
nginx_binary="/usr/local/nginx/sbin/nginx"
fi
fi
fi
if [[ -x "$nginx_binary" ]] ; then
_HTTP_USER="$($nginx_binary -T 2> /dev/null | grep -E "^\s*user\s+\S+;" | grep -o -E "\S+;$" | sed -e 's/;$//')"
fi
# - Is webserver running ?
# -
PID=$(ps aux | grep "$(realpath $nginx_binary)" | grep -e "^root" | grep -v grep | awk '{print$2}')
if [[ "X${PID}X" = "XX" ]] ;then
IS_HTTPD_RUNNING=false
else
IS_HTTPD_RUNNING=true
fi
elif $(systemctl -q is-enabled apache2 2> /dev/null) ; then
APACHE2_IS_ENABLED=true
# - Determin user 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}')"
if [ -z "$httpd_binary" ]; then
if [ -x "/usr/local/apache2/bin/httpd" ]; then
httpd_binary="/usr/local/apache2/bin/httpd"
fi
fi
fi
if [ -x "$httpd_binary" ];then
# - Determin websever user
# -
_HTTP_USER="`$httpd_binary -t -D DUMP_RUN_CFG | grep -i -e "^User" | awk '{print$2}' | cut -d\"=\" -f2 | tr -d '"'`"
_HTTP_GROUP="`$httpd_binary -t -D DUMP_RUN_CFG | grep -i -e "^Group" | awk '{print$2}' | cut -d\"=\" -f2 | tr -d '"'`"
# - Is webserver running ?
# -
PID=$(ps aux | grep "$(realpath $httpd_binary)" | grep -e "^root" | grep -v grep | awk '{print$2}')
if [[ "X${PID}X" = "XX" ]] ;then
IS_HTTPD_RUNNING=false
else
IS_HTTPD_RUNNING=true
fi
fi
else
error "Neither \033[1mapache2\033[m nor \033[1mnginx\033[m is enabled on this machine"
echononl "continue anyway [yes/no]: "
read OK
OK="$(echo "$OK" | tr '[:upper:]' '[:lower:]')"
while [[ "$OK" != "yes" ]] && [[ "$OK" != "no" ]] ; do
echononl "Wrong entry! - repeat [yes/nno]: "
read OK
done
[[ $OK = "yes" ]] || fatal "Interrupted by user"
fi
if [[ -n "$_HTTP_USER" ]] ; then
if [[ -n "$HTTP_USER" ]] && [[ "$_HTTP_USER" != "$HTTP_USER" ]]; then
warn "The script has determined \033[1;37m${_HTTP_USER}\033[m as Webservers user. This\n value differs from the value given in your configuration file, \n which is \033[1;37m${HTTP_USER}\033[m and takes precedence."
else
HTTP_USER=$_HTTP_USER
fi
else
[[ -n "$HTTP_USER" ]] || HTTP_USER=$DEFAULT_HTTP_USER
fi
if [[ -n "$_HTTP_GROUP" ]] ; then
if [[ -n "$HTTP_GROUP" ]] && [[ "$_HTTP_GROUP" != "$HTTP_GROUP" ]]; then
warn "The script has determined \033[1;37m${_HTTP_GROUP}\033[m as Webservers group. This\n value differs from the value given in your configuration file, \n which is \033[1;37m${HTTP_GROUP}\033[m and takes precedence."
else
HTTP_GROUP=$_HTTP_GROUP
fi
else
[[ -n "$HTTP_GROUP" ]] || HTTP_GROUP=$DEFAULT_HTTP_GROUP
fi
# Check PHP Version
#
if [[ "$PHP_ENGINE" = "FPM" ]] ; then
if [[ -z "$PHP_VERSION" ]] ; then
if [[ -z "$VHOST_CONFIG_FILE" ]] ; then
if $NGINX_IS_ENABLED ; then
source ${snippet_dir}/get-php-major-version.sh
if [[ -f "/etc/nginx/sites-enabled/${WEBSITE}.conf" ]] ; then
VHOST_CONFIG_FILE="$(realpath "/etc/nginx/sites-enabled/${WEBSITE}.conf")"
fi
elif $APACHE2_IS_ENABLED ; then
# Get full qualified PHP command
#
source ${snippet_dir}/get-path-of-php-command.sh
if [[ -f "/usr/local/apache2/conf/vhosts/${WEBSITE}.conf.php-fpm" ]] ; then
VHOST_CONFIG_FILE="/usr/local/apache2/conf/vhosts/${WEBSITE}.conf.php-fpm"
elif [[ -f "/usr/local/apache2/conf/vhosts/${WEBSITE}.conf" ]] ; then
VHOST_CONFIG_FILE="/usr/local/apache2/conf/vhosts/${WEBSITE}.conf"
elif [[ -f "/etc/apache2/sites-enabled/${WEBSITE}.conf" ]] ; then
VHOST_CONFIG_FILE="/etc/apache2/sites-enabled/${WEBSITE}.conf"
fi
fi
fi
if [[ -n "$VHOST_CONFIG_FILE" ]] ; then
PHP_VERSION="$(grep -o -E "^[^#]*php-?[[:digit:]]{1,2}\.[[:digit:]]{1}-fpm" $VHOST_CONFIG_FILE \
| grep -o -E "[[:digit:]]{1,2}\.[[:digit:]]{1}")"
fi
if [[ -z "$PHP_VERSION" ]] ; then
if $NGINX_IS_ENABLED ; then
upstream_handler="$(grep -o -E "^[^#]*fastcgi_pass\s+[^;]+" ${VHOST_CONFIG_FILE} | awk '{print$2}' )"
for _file in $(ls /etc/nginx/conf.d/) ; do
_rp_file="$(realpath "/etc/nginx/conf.d/${_file}")"
if $(grep -q -E "\s+${upstream_handler}\s*" ${_rp_file} 2> /dev/null) ; then
PHP_VERSION="$(grep -o -E "^[^#]*php-?[[:digit:]]{1,2}\.[[:digit:]]{1}-fpm" ${_rp_file} \
| grep -o -E "[[:digit:]]{1,2}\.[[:digit:]]{1}")"
break
fi
done
fi
if [[ -z "$PHP_VERSION" ]] ; then
warn "Cannot determin the PHP version\! Enter it manually"
main_version_regex="^[[:digit:]]{1,2}\.[[:digit:]]{1}$"
echo ""
echo -e "\033[32m--\033[m"
echo ""
echo "Enter the PHP main version, e.g. 7.4 or 8.2 .."
echo ""
echo ""
PHP_VERSION=
while [ "X$PHP_VERSION" = "X" ]
do
echononl " PHP main version: "
read PHP_VERSION
if [ "X$PHP_VERSION" = "X" ]; then
echo ""
echo -e "\033[33m\033[1mInput is required !!\033[m"
echo ""
fi
if [[ ! $PHP_VERSION =~ $main_version_regex ]] ; then
echo ""
echo -e "\033[33m\033[1mWrong entry (${PHP_VERSION}) for main PHP version !!\033[m"
echo ""
PHP_VERSION=
fi
done
fi
fi
fi
fi
if [[ -x "/usr/local/php-${PHP_VERSION}/bin/php" ]] ; then
PHP_BIN="/usr/local/php-${PHP_VERSION}/bin/php"
elif [[ -x "$(realpath /usr/local/php/bin/php)" ]]; then
PHP_BIN="/usr/local/php/bin/php"
else
PHP_BIN="$(which php)"
fi
if [[ ! -x "$PHP_BIN" ]]; then
fatal "No PHP binary found!"

View File

@ -6,6 +6,7 @@ script_name="$(basename $(realpath $0))"
script_dir="$(dirname $(realpath $0))"
conf_dir="${script_dir}/conf"
snippet_dir="${script_dir}/snippets"
declare -a unsorted_website_arr
declare -a website_arr
@ -225,32 +226,9 @@ echo -e "Add User to Group - \033[1mBoth, User and Group has to exist\033[m"
echo -e "\033[32m-----\033[m"
WEBSITE=
_OK=false
echo ""
echo "Cloud instance that you want to change?"
echo ""
declare -i i=0
for _site in ${website_arr[@]} ; do
IFS=':' read -a _arr <<< ${_site}
echo " [$i] ${_arr[0]}"
((i++))
done
echo
echononl " Eingabe: "
while ! $_OK ; do
read _IN
if is_number "$_IN" && [[ -n ${website_arr[$_IN]} ]]; then
IFS=':' read -a _arr <<< ${website_arr[$_IN]}
conf_file=${_arr[1]}
_OK=true
else
echo ""
echo -e "\tFalsche Eingabe !"
echo ""
echononl " Eingabe: "
fi
done
# Which cloud instance (website) would you like to update
#
source ${snippet_dir}/get-cloud-instance-to-update.sh
# - Reset IFS
@ -316,192 +294,24 @@ if [[ "$DATABASE_TYPE" = "postgres" ]]; then
fi
fi
NGINX_IS_ENABLED=false
APACHE2_IS_ENABLED=false
# Check if NGINX webserver is ctive
# Get Webservice environment as IS_HTTPD_RUNNING, HTTP_USER, HTTP_GROUP..
#
if $(systemctl -q is-enabled nginx 2> /dev/null) ; then
source ${snippet_dir}/get-webservice-environment.sh
NGINX_IS_ENABLED=true
# - Determin user of the webserver
# -
nginx_binary="$(which nginx)"
if [[ -z "$nginx_binary" ]] ; then
nginx_binary="$(ps -axu | grep -E "nginx:.*master" | grep -v grep | grep -o -E "\S+/nginx")"
if [[ -z "$nginx_binary" ]] ; then
if [[ -x "/usr/local/nginx/bin/nginx" ]]; then
nginx_binary="/usr/local/nginx/bin/nginx"
elif [[ -x "/usr/local/nginx/sbin/nginx" ]]; then
nginx_binary="/usr/local/nginx/sbin/nginx"
fi
fi
fi
if [[ -x "$nginx_binary" ]] ; then
_HTTP_USER="$($nginx_binary -T 2> /dev/null | grep -E "^\s*user\s+\S+;" | grep -o -E "\S+;$" | sed -e 's/;$//')"
fi
# - Is webserver running ?
# -
PID=$(ps aux | grep "$(realpath $nginx_binary)" | grep -e "^root" | grep -v grep | awk '{print$2}')
if [[ "X${PID}X" = "XX" ]] ;then
IS_HTTPD_RUNNING=false
else
IS_HTTPD_RUNNING=true
fi
elif $(systemctl -q is-enabled apache2 2> /dev/null) ; then
APACHE2_IS_ENABLED=true
# - Determin user 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}')"
if [ -z "$httpd_binary" ]; then
if [ -x "/usr/local/apache2/bin/httpd" ]; then
httpd_binary="/usr/local/apache2/bin/httpd"
fi
fi
fi
if [ -x "$httpd_binary" ];then
# - Determin websever user
# -
_HTTP_USER="`$httpd_binary -t -D DUMP_RUN_CFG | grep -i -e "^User" | awk '{print$2}' | cut -d\"=\" -f2 | tr -d '"'`"
_HTTP_GROUP="`$httpd_binary -t -D DUMP_RUN_CFG | grep -i -e "^Group" | awk '{print$2}' | cut -d\"=\" -f2 | tr -d '"'`"
# - Is webserver running ?
# -
PID=$(ps aux | grep "$(realpath $httpd_binary)" | grep -e "^root" | grep -v grep | awk '{print$2}')
if [[ "X${PID}X" = "XX" ]] ;then
IS_HTTPD_RUNNING=false
else
IS_HTTPD_RUNNING=true
fi
fi
else
error "Neither \033[1mapache2\033[m nor \033[1mnginx\033[m is enabled on this machine"
echononl "continue anyway [yes/no]: "
read OK
OK="$(echo "$OK" | tr '[:upper:]' '[:lower:]')"
while [[ "$OK" != "yes" ]] && [[ "$OK" != "no" ]] ; do
echononl "Wrong entry! - repeat [yes/nno]: "
read OK
done
[[ $OK = "yes" ]] || fatal "Interrupted by user"
fi
if [[ -n "$_HTTP_USER" ]] ; then
if [[ -n "$HTTP_USER" ]] && [[ "$_HTTP_USER" != "$HTTP_USER" ]]; then
warn "The script has determined \033[1;37m${_HTTP_USER}\033[m as Webservers user. This\n value differs from the value given in your configuration file, \n which is \033[1;37m${HTTP_USER}\033[m and takes precedence."
else
HTTP_USER=$_HTTP_USER
fi
else
[[ -n "$HTTP_USER" ]] || HTTP_USER=$DEFAULT_HTTP_USER
fi
if [[ -n "$_HTTP_GROUP" ]] ; then
if [[ -n "$HTTP_GROUP" ]] && [[ "$_HTTP_GROUP" != "$HTTP_GROUP" ]]; then
warn "The script has determined \033[1;37m${_HTTP_GROUP}\033[m as Webservers group. This\n value differs from the value given in your configuration file, \n which is \033[1;37m${HTTP_GROUP}\033[m and takes precedence."
else
HTTP_GROUP=$_HTTP_GROUP
fi
else
[[ -n "$HTTP_GROUP" ]] || HTTP_GROUP=$DEFAULT_HTTP_GROUP
fi
# Check PHP Version
#
if [[ "$PHP_ENGINE" = "FPM" ]] ; then
if [[ -z "$PHP_VERSION" ]] ; then
if [[ -z "$VHOST_CONFIG_FILE" ]] ; then
if $NGINX_IS_ENABLED ; then
source ${snippet_dir}/get-php-major-version.sh
if [[ -f "/etc/nginx/sites-enabled/${WEBSITE}.conf" ]] ; then
VHOST_CONFIG_FILE="$(realpath "/etc/nginx/sites-enabled/${WEBSITE}.conf")"
fi
elif $APACHE2_IS_ENABLED ; then
# Get full qualified PHP command
#
source ${snippet_dir}/get-path-of-php-command.sh
if [[ -f "/usr/local/apache2/conf/vhosts/${WEBSITE}.conf.php-fpm" ]] ; then
VHOST_CONFIG_FILE="/usr/local/apache2/conf/vhosts/${WEBSITE}.conf.php-fpm"
elif [[ -f "/usr/local/apache2/conf/vhosts/${WEBSITE}.conf" ]] ; then
VHOST_CONFIG_FILE="/usr/local/apache2/conf/vhosts/${WEBSITE}.conf"
elif [[ -f "/etc/apache2/sites-enabled/${WEBSITE}.conf" ]] ; then
VHOST_CONFIG_FILE="/etc/apache2/sites-enabled/${WEBSITE}.conf"
fi
fi
fi
if [[ -n "$VHOST_CONFIG_FILE" ]] ; then
PHP_VERSION="$(grep -o -E "^[^#]*php-?[[:digit:]]{1,2}\.[[:digit:]]{1}-fpm" $VHOST_CONFIG_FILE \
| grep -o -E "[[:digit:]]{1,2}\.[[:digit:]]{1}")"
fi
if [[ -z "$PHP_VERSION" ]] ; then
if $NGINX_IS_ENABLED ; then
upstream_handler="$(grep -o -E "^[^#]*fastcgi_pass\s+[^;]+" ${VHOST_CONFIG_FILE} | awk '{print$2}' )"
for _file in $(ls /etc/nginx/conf.d/) ; do
_rp_file="$(realpath "/etc/nginx/conf.d/${_file}")"
if $(grep -q -E "\s+${upstream_handler}\s*" ${_rp_file} 2> /dev/null) ; then
PHP_VERSION="$(grep -o -E "^[^#]*php-?[[:digit:]]{1,2}\.[[:digit:]]{1}-fpm" ${_rp_file} \
| grep -o -E "[[:digit:]]{1,2}\.[[:digit:]]{1}")"
break
fi
done
fi
if [[ -z "$PHP_VERSION" ]] ; then
warn "Cannot determin the PHP version\! Enter it manually"
main_version_regex="^[[:digit:]]{1,2}\.[[:digit:]]{1}$"
echo ""
echo -e "\033[32m--\033[m"
echo ""
echo "Enter the PHP main version, e.g. 7.4 or 8.2 .."
echo ""
echo ""
PHP_VERSION=
while [ "X$PHP_VERSION" = "X" ]
do
echononl " PHP main version: "
read PHP_VERSION
if [ "X$PHP_VERSION" = "X" ]; then
echo ""
echo -e "\033[33m\033[1mInput is required !!\033[m"
echo ""
fi
if [[ ! $PHP_VERSION =~ $main_version_regex ]] ; then
echo ""
echo -e "\033[33m\033[1mWrong entry (${PHP_VERSION}) for main PHP version !!\033[m"
echo ""
PHP_VERSION=
fi
done
fi
fi
fi
fi
if [[ -x "/usr/local/php-${PHP_VERSION}/bin/php" ]] ; then
PHP_BIN="/usr/local/php-${PHP_VERSION}/bin/php"
elif [[ -x "$(realpath /usr/local/php/bin/php)" ]]; then
PHP_BIN="/usr/local/php/bin/php"
else
PHP_BIN="$(which php)"
fi
if [[ ! -x "$PHP_BIN" ]]; then
fatal "No PHP binary found!"
@ -567,7 +377,7 @@ echo ""
# -
echononl " Check, if we can disable legacy encryption - Checking for old files.."
su -c "/usr/local/php/bin/php ${WEB_BASE_DIR}/htdocs/occ encryption:scan:legacy-format" -s /bin/bash $HTTP_USER > $log_file 2>&1
su -c "${PHP_BIN} ${WEB_BASE_DIR}/htdocs/occ encryption:scan:legacy-format" -s /bin/bash $HTTP_USER > $log_file 2>&1
if [[ $? -eq 0 ]]; then
echo_ok
info "Output of command \033[37m\033[1mocc encryption:scan:legacy-format\033[m was:\n\n$(cat $log_file)"
@ -576,7 +386,7 @@ else
blank_line
echo ""
echo -e "\033[37m\033[1mcommandline was:\033[m"
echo "su -c \"/usr/local/php/bin/php ${WEB_BASE_DIR}/htdocs/occ encryption:scan:legacy-format\" -s /bin/bash $HTTP_USER"
echo "su -c \"${PHP_BIN} ${WEB_BASE_DIR}/htdocs/occ encryption:scan:legacy-format\" -s /bin/bash $HTTP_USER"
error "Output of command \033[37m\033[1mocc encryption:scan:legacy-format\033[m was:\n\n$(cat $log_file)"
fi

View File

@ -6,6 +6,7 @@ script_name="$(basename $(realpath $0))"
script_dir="$(dirname $(realpath $0))"
conf_dir="${script_dir}/conf"
snippet_dir="${script_dir}/snippets"
declare -a unsorted_website_arr
declare -a website_arr
@ -225,33 +226,9 @@ echo "Create missing indices"
echo -e "\033[32m-----\033[m"
WEBSITE=
_OK=false
echo ""
echo "Which site would you like to update?"
echo ""
declare -i i=0
for _site in ${website_arr[@]} ; do
IFS=':' read -a _arr <<< ${_site}
echo " [$i] ${_arr[0]}"
((i++))
done
echo
echononl " Eingabe: "
while ! $_OK ; do
read _IN
if is_number "$_IN" && [[ -n ${website_arr[$_IN]} ]]; then
IFS=':' read -a _arr <<< ${website_arr[$_IN]}
conf_file=${_arr[1]}
DEFAULT_WEBSITE="${_arr[0]}"
_OK=true
else
echo ""
echo -e "\tFalsche Eingabe !"
echo ""
echononl " Eingabe: "
fi
done
# Which cloud instance (website) would you like to update
#
source ${snippet_dir}/get-cloud-instance-to-update.sh
# - Reset IFS
@ -316,192 +293,24 @@ if [[ "$DATABASE_TYPE" = "postgres" ]]; then
fi
fi
NGINX_IS_ENABLED=false
APACHE2_IS_ENABLED=false
# Check if NGINX webserver is ctive
# Get Webservice environment as IS_HTTPD_RUNNING, HTTP_USER, HTTP_GROUP..
#
if $(systemctl -q is-enabled nginx 2> /dev/null) ; then
source ${snippet_dir}/get-webservice-environment.sh
NGINX_IS_ENABLED=true
# - Determin user of the webserver
# -
nginx_binary="$(which nginx)"
if [[ -z "$nginx_binary" ]] ; then
nginx_binary="$(ps -axu | grep -E "nginx:.*master" | grep -v grep | grep -o -E "\S+/nginx")"
if [[ -z "$nginx_binary" ]] ; then
if [[ -x "/usr/local/nginx/bin/nginx" ]]; then
nginx_binary="/usr/local/nginx/bin/nginx"
elif [[ -x "/usr/local/nginx/sbin/nginx" ]]; then
nginx_binary="/usr/local/nginx/sbin/nginx"
fi
fi
fi
if [[ -x "$nginx_binary" ]] ; then
_HTTP_USER="$($nginx_binary -T 2> /dev/null | grep -E "^\s*user\s+\S+;" | grep -o -E "\S+;$" | sed -e 's/;$//')"
fi
# - Is webserver running ?
# -
PID=$(ps aux | grep "$(realpath $nginx_binary)" | grep -e "^root" | grep -v grep | awk '{print$2}')
if [[ "X${PID}X" = "XX" ]] ;then
IS_HTTPD_RUNNING=false
else
IS_HTTPD_RUNNING=true
fi
elif $(systemctl -q is-enabled apache2 2> /dev/null) ; then
APACHE2_IS_ENABLED=true
# - Determin user 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}')"
if [ -z "$httpd_binary" ]; then
if [ -x "/usr/local/apache2/bin/httpd" ]; then
httpd_binary="/usr/local/apache2/bin/httpd"
fi
fi
fi
if [ -x "$httpd_binary" ];then
# - Determin websever user
# -
_HTTP_USER="`$httpd_binary -t -D DUMP_RUN_CFG | grep -i -e "^User" | awk '{print$2}' | cut -d\"=\" -f2 | tr -d '"'`"
_HTTP_GROUP="`$httpd_binary -t -D DUMP_RUN_CFG | grep -i -e "^Group" | awk '{print$2}' | cut -d\"=\" -f2 | tr -d '"'`"
# - Is webserver running ?
# -
PID=$(ps aux | grep "$(realpath $httpd_binary)" | grep -e "^root" | grep -v grep | awk '{print$2}')
if [[ "X${PID}X" = "XX" ]] ;then
IS_HTTPD_RUNNING=false
else
IS_HTTPD_RUNNING=true
fi
fi
else
error "Neither \033[1mapache2\033[m nor \033[1mnginx\033[m is enabled on this machine"
echononl "continue anyway [yes/no]: "
read OK
OK="$(echo "$OK" | tr '[:upper:]' '[:lower:]')"
while [[ "$OK" != "yes" ]] && [[ "$OK" != "no" ]] ; do
echononl "Wrong entry! - repeat [yes/nno]: "
read OK
done
[[ $OK = "yes" ]] || fatal "Interrupted by user"
fi
if [[ -n "$_HTTP_USER" ]] ; then
if [[ -n "$HTTP_USER" ]] && [[ "$_HTTP_USER" != "$HTTP_USER" ]]; then
warn "The script has determined \033[1;37m${_HTTP_USER}\033[m as Webservers user. This\n value differs from the value given in your configuration file, \n which is \033[1;37m${HTTP_USER}\033[m and takes precedence."
else
HTTP_USER=$_HTTP_USER
fi
else
[[ -n "$HTTP_USER" ]] || HTTP_USER=$DEFAULT_HTTP_USER
fi
if [[ -n "$_HTTP_GROUP" ]] ; then
if [[ -n "$HTTP_GROUP" ]] && [[ "$_HTTP_GROUP" != "$HTTP_GROUP" ]]; then
warn "The script has determined \033[1;37m${_HTTP_GROUP}\033[m as Webservers group. This\n value differs from the value given in your configuration file, \n which is \033[1;37m${HTTP_GROUP}\033[m and takes precedence."
else
HTTP_GROUP=$_HTTP_GROUP
fi
else
[[ -n "$HTTP_GROUP" ]] || HTTP_GROUP=$DEFAULT_HTTP_GROUP
fi
# Check PHP Version
#
if [[ "$PHP_ENGINE" = "FPM" ]] ; then
if [[ -z "$PHP_VERSION" ]] ; then
if [[ -z "$VHOST_CONFIG_FILE" ]] ; then
if $NGINX_IS_ENABLED ; then
source ${snippet_dir}/get-php-major-version.sh
if [[ -f "/etc/nginx/sites-enabled/${WEBSITE}.conf" ]] ; then
VHOST_CONFIG_FILE="$(realpath "/etc/nginx/sites-enabled/${WEBSITE}.conf")"
fi
elif $APACHE2_IS_ENABLED ; then
# Get full qualified PHP command
#
source ${snippet_dir}/get-path-of-php-command.sh
if [[ -f "/usr/local/apache2/conf/vhosts/${WEBSITE}.conf.php-fpm" ]] ; then
VHOST_CONFIG_FILE="/usr/local/apache2/conf/vhosts/${WEBSITE}.conf.php-fpm"
elif [[ -f "/usr/local/apache2/conf/vhosts/${WEBSITE}.conf" ]] ; then
VHOST_CONFIG_FILE="/usr/local/apache2/conf/vhosts/${WEBSITE}.conf"
elif [[ -f "/etc/apache2/sites-enabled/${WEBSITE}.conf" ]] ; then
VHOST_CONFIG_FILE="/etc/apache2/sites-enabled/${WEBSITE}.conf"
fi
fi
fi
if [[ -n "$VHOST_CONFIG_FILE" ]] ; then
PHP_VERSION="$(grep -o -E "^[^#]*php-?[[:digit:]]{1,2}\.[[:digit:]]{1}-fpm" $VHOST_CONFIG_FILE \
| grep -o -E "[[:digit:]]{1,2}\.[[:digit:]]{1}")"
fi
if [[ -z "$PHP_VERSION" ]] ; then
if $NGINX_IS_ENABLED ; then
upstream_handler="$(grep -o -E "^[^#]*fastcgi_pass\s+[^;]+" ${VHOST_CONFIG_FILE} | awk '{print$2}' )"
for _file in $(ls /etc/nginx/conf.d/) ; do
_rp_file="$(realpath "/etc/nginx/conf.d/${_file}")"
if $(grep -q -E "\s+${upstream_handler}\s*" ${_rp_file} 2> /dev/null) ; then
PHP_VERSION="$(grep -o -E "^[^#]*php-?[[:digit:]]{1,2}\.[[:digit:]]{1}-fpm" ${_rp_file} \
| grep -o -E "[[:digit:]]{1,2}\.[[:digit:]]{1}")"
break
fi
done
fi
if [[ -z "$PHP_VERSION" ]] ; then
warn "Cannot determin the PHP version\! Enter it manually"
main_version_regex="^[[:digit:]]{1,2}\.[[:digit:]]{1}$"
echo ""
echo -e "\033[32m--\033[m"
echo ""
echo "Enter the PHP main version, e.g. 7.4 or 8.2 .."
echo ""
echo ""
PHP_VERSION=
while [ "X$PHP_VERSION" = "X" ]
do
echononl " PHP main version: "
read PHP_VERSION
if [ "X$PHP_VERSION" = "X" ]; then
echo ""
echo -e "\033[33m\033[1mInput is required !!\033[m"
echo ""
fi
if [[ ! $PHP_VERSION =~ $main_version_regex ]] ; then
echo ""
echo -e "\033[33m\033[1mWrong entry (${PHP_VERSION}) for main PHP version !!\033[m"
echo ""
PHP_VERSION=
fi
done
fi
fi
fi
fi
if [[ -x "/usr/local/php-${PHP_VERSION}/bin/php" ]] ; then
PHP_BIN="/usr/local/php-${PHP_VERSION}/bin/php"
elif [[ -x "$(realpath /usr/local/php/bin/php)" ]]; then
PHP_BIN="/usr/local/php/bin/php"
else
PHP_BIN="$(which php)"
fi
if [[ ! -x "$PHP_BIN" ]]; then
fatal "No PHP binary found!"

View File

@ -0,0 +1,14 @@
#"/usr/bin/env bash
read -p "Enter Database Name: " DB_NAME
echo
mysql -e "
SELECT CONCAT('ALTER TABLE \`', TABLE_NAME, '\` ROW_FORMAT=DYNAMIC;')
FROM INFORMATION_SCHEMA.TABLES
WHERE TABLE_SCHEMA = '$DB_NAME'
AND ENGINE = 'InnoDB';
" -B -N | while read -r sql; do
mysql -e "$sql" "$DB_NAME"
done

View File

@ -4,6 +4,7 @@ script_name="$(basename $(realpath $0))"
script_dir="$(dirname $(realpath $0))"
conf_dir="${script_dir}/conf"
snippet_dir="${script_dir}/snippets"
declare -a unsorted_website_arr
declare -a website_arr
@ -132,13 +133,11 @@ error(){
}
warn (){
echo ""
if $terminal ; then
echo ""
echo -e " [ \033[33m\033[1mWarning\033[m ]: $*"
else
echo " [ Warning ]: $*"
echo ""
fi
echo ""
}
info (){
@ -173,6 +172,14 @@ blank_line() {
}
# - Running in a terminal?
# -
if [[ -t 1 ]] ; then
terminal=true
else
terminal=false
fi
# ----------
# - Jobhandling
@ -196,16 +203,68 @@ while getopts hs: opt ; do
done
if [[ -z "$WEBSITE" ]] ; then
fatal "No website ios given on commandline - Missing Parameter '-s <website>'"
while IFS='' read -r -d '' _conf_file ; do
source $_conf_file
if [[ -n "$WEBSITE" ]] ; then
unsorted_website_arr+=("${WEBSITE}:$_conf_file")
fi
WEBSITE=""
done < <(find "${conf_dir}" -maxdepth 1 -type f -name "*.conf" -print0)
# - Sort array
# -
IFS=$'\n' website_arr=($(sort <<<"${unsorted_website_arr[*]}"))
# Which cloud instance (website) would you like to update
#
source ${snippet_dir}/get-cloud-instance-to-update.sh
else
while IFS='' read -r -d '' _conf_file ; do
if $(grep -E -q "WEBSITE=\"?${WEBSITE}\"?" ${_conf_file} 2> /dev/null) ; then
conf_file="${_conf_file}"
break
fi
done < <(find "${conf_dir}" -maxdepth 1 -type f -name "*.conf" -print0)
# conf_file="${conf_dir}/${WEBSITE}.conf"
fi
WEB_BASE_DIR="/var/www/${WEBSITE}"
# - Reset IFS
# -
IFS=$CUR_IFS
DEFAULT_SRC_BASE_DIR="/usr/local/src/nextcloud"
DEFAULT_HTTP_USER="www-data"
DEFAULT_HTTP_GROUP="www-data"
DEFAULT_PHP_ENGINE='FPM'
echo ""
echononl " Include Configuration file '$(basename "${conf_file}")'.."
if [[ ! -f $conf_file ]]; then
echo_failed
fatal "Missing configuration file '$conf_file'."
else
source $conf_file
echo_ok
fi
echo ""
DEFAULT_WEB_BASE_DIR="/var/www/${WEBSITE}"
[[ -n "$WEB_BASE_DIR" ]] || WEB_BASE_DIR=$DEFAULT_WEB_BASE_DIR
if [[ ! -d ${WEB_BASE_DIR} ]] ; then
fatal "Web base directory '$WEB_BASE_DIR' not found!"
fi
DATA_DIR="$(realpath ${WEB_BASE_DIR}/data)"
[[ -n "$PHP_ENGINE" ]] || PHP_ENGINE=$DEFAULT_PHP_ENGINE
INSTALL_DIR="$(realpath ${WEB_BASE_DIR}/nextcloud)"
CURRENT_VERSION="$(basename $INSTALL_DIR | cut -d"-" -f2)"
@ -222,14 +281,6 @@ else
SYSTEMD_EXISTS=true
fi
# - Running in a terminal?
# -
if [[ -t 1 ]] ; then
terminal=true
else
terminal=false
fi
#clear
if $terminal ; then
@ -249,112 +300,24 @@ fi
DEFAULT_HTTP_USER="www-data"
DEFAULT_HTTP_GROUP="www-data"
NGINX_IS_ENABLED=false
APACHE2_IS_ENABLED=false
# Check if NGINX webserver is ctive
# Get Webservice environment as IS_HTTPD_RUNNING, HTTP_USER, HTTP_GROUP..
#
if $(systemctl -q is-enabled nginx 2> /dev/null) ; then
NGINX_IS_ENABLED=true
# - Determin user of the webserver
# -
nginx_binary="$(which nginx)"
if [[ -z "$nginx_binary" ]] ; then
nginx_binary="$(ps -axu | grep -E "nginx:.*master" | grep -v grep | grep -o -E "\S+/nginx")"
if [[ -z "$nginx_binary" ]] ; then
if [[ -x "/usr/local/nginx/bin/nginx" ]]; then
nginx_binary="/usr/local/nginx/bin/nginx"
elif [[ -x "/usr/local/nginx/sbin/nginx" ]]; then
nginx_binary="/usr/local/nginx/sbin/nginx"
fi
fi
fi
if [[ -x "$nginx_binary" ]] ; then
_HTTP_USER="$($nginx_binary -T 2> /dev/null | grep -E "^\s*user\s+\S+;" | grep -o -E "\S+;$" | sed -e 's/;$//')"
fi
# - Is webserver running ?
# -
PID=$(ps aux | grep "$(realpath $nginx_binary)" | grep -e "^root" | grep -v grep | awk '{print$2}')
if [[ "X${PID}X" = "XX" ]] ;then
IS_HTTPD_RUNNING=false
else
IS_HTTPD_RUNNING=true
fi
source ${snippet_dir}/get-webservice-environment.sh
elif $(systemctl -q is-enabled apache2 2> /dev/null) ; then
# Check PHP Version
#
source ${snippet_dir}/get-php-major-version.sh
APACHE2_IS_ENABLED=true
# - Determin user 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}')"
if [ -z "$httpd_binary" ]; then
if [ -x "/usr/local/apache2/bin/httpd" ]; then
httpd_binary="/usr/local/apache2/bin/httpd"
fi
fi
fi
if [ -x "$httpd_binary" ];then
# Get full qualified PHP command
#
source ${snippet_dir}/get-path-of-php-command.sh
# - Determin websever user
# -
_HTTP_USER="`$httpd_binary -t -D DUMP_RUN_CFG | grep -i -e "^User" | awk '{print$2}' | cut -d\"=\" -f2 | tr -d '"'`"
_HTTP_GROUP="`$httpd_binary -t -D DUMP_RUN_CFG | grep -i -e "^Group" | awk '{print$2}' | cut -d\"=\" -f2 | tr -d '"'`"
# - Is webserver running ?
# -
PID=$(ps aux | grep "$(realpath $httpd_binary)" | grep -e "^root" | grep -v grep | awk '{print$2}')
if [[ "X${PID}X" = "XX" ]] ;then
IS_HTTPD_RUNNING=false
else
IS_HTTPD_RUNNING=true
fi
fi
else
error "Neither \033[1mapache2\033[m nor \033[1mnginx\033[m is enabled on this machine"
echononl "continue anyway [yes/no]: "
read OK
OK="$(echo "$OK" | tr '[:upper:]' '[:lower:]')"
while [[ "$OK" != "yes" ]] && [[ "$OK" != "no" ]] ; do
echononl "Wrong entry! - repeat [yes/nno]: "
read OK
done
[[ $OK = "yes" ]] || fatal "Interrupted by user"
fi
if [[ -n "$_HTTP_USER" ]] ; then
if [[ -n "$HTTP_USER" ]] && [[ "$_HTTP_USER" != "$HTTP_USER" ]]; then
warn "The script has determined \033[1;37m${_HTTP_USER}\033[m as Webservers user. This\n value differs from the value given in your configuration file, \n which is \033[1;37m${HTTP_USER}\033[m and takes precedence."
else
HTTP_USER=$_HTTP_USER
fi
else
[[ -n "$HTTP_USER" ]] || HTTP_USER=$DEFAULT_HTTP_USER
fi
if [[ -n "$_HTTP_GROUP" ]] ; then
if [[ -n "$HTTP_GROUP" ]] && [[ "$_HTTP_GROUP" != "$HTTP_GROUP" ]]; then
warn "The script has determined \033[1;37m${_HTTP_GROUP}\033[m as Webservers group. This\n value differs from the value given in your configuration file, \n which is \033[1;37m${HTTP_GROUP}\033[m and takes precedence."
else
HTTP_GROUP=$_HTTP_GROUP
fi
else
[[ -n "$HTTP_GROUP" ]] || HTTP_GROUP=$DEFAULT_HTTP_GROUP
fi
if [[ -x "$(realpath /usr/local/php/bin/php)" ]]; then
PHP_BIN="/usr/local/php/bin/php"
else
PHP_BIN="$(which php)"
fi
if [[ ! -x "$PHP_BIN" ]]; then
fatal "No PHP binary found!"

View File

@ -6,6 +6,7 @@ script_name="$(basename $(realpath $0))"
script_dir="$(dirname $(realpath $0))"
conf_dir="${script_dir}/conf"
snippet_dir="${script_dir}/snippets"
declare -a unsorted_website_arr
declare -a website_arr
@ -139,13 +140,11 @@ error(){
}
warn (){
echo ""
if $terminal ; then
echo ""
echo -e " [ \033[33m\033[1mWarning\033[m ]: $*"
else
echo " [ Warning ]: $*"
echo ""
fi
echo ""
}
info (){
@ -180,6 +179,14 @@ blank_line() {
}
# - Running in a terminal?
# -
if [[ -t 1 ]] ; then
terminal=true
else
terminal=false
fi
# ----------
# - Jobhandling
@ -216,38 +223,19 @@ if [[ -z "$WEBSITE" ]] ; then
# -
IFS=$'\n' website_arr=($(sort <<<"${unsorted_website_arr[*]}"))
WEBSITE=
_OK=false
echo ""
echo "Which site would you like to update?"
echo ""
declare -i i=0
for _site in ${website_arr[@]} ; do
IFS=':' read -a _arr <<< ${_site}
echo " [$i] ${_arr[0]}"
((i++))
done
echo
echononl " Eingabe: "
while ! $_OK ; do
read _IN
if is_number "$_IN" && [[ -n ${website_arr[$_IN]} ]]; then
IFS=':' read -a _arr <<< ${website_arr[$_IN]}
conf_file=${_arr[1]}
_WEBSITE="${_arr[0]}"
_OK=true
else
echo ""
echo -e "\tFalsche Eingabe !"
echo ""
echononl " Eingabe: "
# Which cloud instance (website) would you like to update
#
source ${snippet_dir}/get-cloud-instance-to-update.sh
else
while IFS='' read -r -d '' _conf_file ; do
if $(grep -E -q "WEBSITE=\"?${WEBSITE}\"?" ${_conf_file} 2> /dev/null) ; then
conf_file="${_conf_file}"
break
fi
done
done < <(find "${conf_dir}" -maxdepth 1 -type f -name "*.conf" -print0)
# conf_file="${conf_dir}/${WEBSITE}.conf"
WEBSITE="$_WEBSITE"
#fatal "No website ios given on commandline - Missing Parameter '-s <website>'"
fi
@ -255,14 +243,33 @@ fi
# -
IFS=$CUR_IFS
DEFAULT_SRC_BASE_DIR="/usr/local/src/nextcloud"
DEFAULT_HTTP_USER="www-data"
DEFAULT_HTTP_GROUP="www-data"
DEFAULT_PHP_ENGINE='FPM'
WEB_BASE_DIR="/var/www/${WEBSITE}"
echo ""
echononl " Include Configuration file '$(basename "${conf_file}")'.."
if [[ ! -f $conf_file ]]; then
echo_failed
fatal "Missing configuration file '$conf_file'."
else
source $conf_file
echo_ok
fi
echo ""
DEFAULT_WEB_BASE_DIR="/var/www/${WEBSITE}"
[[ -n "$WEB_BASE_DIR" ]] || WEB_BASE_DIR=$DEFAULT_WEB_BASE_DIR
if [[ ! -d ${WEB_BASE_DIR} ]] ; then
fatal "Web base directory '$WEB_BASE_DIR' not found!"
fi
DATA_DIR="$(realpath ${WEB_BASE_DIR}/data)"
[[ -n "$PHP_ENGINE" ]] || PHP_ENGINE=$DEFAULT_PHP_ENGINE
INSTALL_DIR="$(realpath ${WEB_BASE_DIR}/nextcloud)"
CURRENT_VERSION="$(basename $INSTALL_DIR | cut -d"-" -f2)"
@ -279,14 +286,6 @@ else
SYSTEMD_EXISTS=true
fi
# - Running in a terminal?
# -
if [[ -t 1 ]] ; then
terminal=true
else
terminal=false
fi
#clear
if $terminal ; then
@ -306,112 +305,24 @@ fi
DEFAULT_HTTP_USER="www-data"
DEFAULT_HTTP_GROUP="www-data"
NGINX_IS_ENABLED=false
APACHE2_IS_ENABLED=false
# Check if NGINX webserver is ctive
# Get Webservice environment as IS_HTTPD_RUNNING, HTTP_USER, HTTP_GROUP..
#
if $(systemctl -q is-enabled nginx 2> /dev/null) ; then
NGINX_IS_ENABLED=true
# - Determin user of the webserver
# -
nginx_binary="$(which nginx)"
if [[ -z "$nginx_binary" ]] ; then
nginx_binary="$(ps -axu | grep -E "nginx:.*master" | grep -v grep | grep -o -E "\S+/nginx")"
if [[ -z "$nginx_binary" ]] ; then
if [[ -x "/usr/local/nginx/bin/nginx" ]]; then
nginx_binary="/usr/local/nginx/bin/nginx"
elif [[ -x "/usr/local/nginx/sbin/nginx" ]]; then
nginx_binary="/usr/local/nginx/sbin/nginx"
fi
fi
fi
if [[ -x "$nginx_binary" ]] ; then
_HTTP_USER="$($nginx_binary -T 2> /dev/null | grep -E "^\s*user\s+\S+;" | grep -o -E "\S+;$" | sed -e 's/;$//')"
fi
# - Is webserver running ?
# -
PID=$(ps aux | grep "$(realpath $nginx_binary)" | grep -e "^root" | grep -v grep | awk '{print$2}')
if [[ "X${PID}X" = "XX" ]] ;then
IS_HTTPD_RUNNING=false
else
IS_HTTPD_RUNNING=true
fi
source ${snippet_dir}/get-webservice-environment.sh
elif $(systemctl -q is-enabled apache2 2> /dev/null) ; then
# Check PHP Version
#
source ${snippet_dir}/get-php-major-version.sh
APACHE2_IS_ENABLED=true
# - Determin user 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}')"
if [ -z "$httpd_binary" ]; then
if [ -x "/usr/local/apache2/bin/httpd" ]; then
httpd_binary="/usr/local/apache2/bin/httpd"
fi
fi
fi
if [ -x "$httpd_binary" ];then
# Get full qualified PHP command
#
source ${snippet_dir}/get-path-of-php-command.sh
# - Determin websever user
# -
_HTTP_USER="`$httpd_binary -t -D DUMP_RUN_CFG | grep -i -e "^User" | awk '{print$2}' | cut -d\"=\" -f2 | tr -d '"'`"
_HTTP_GROUP="`$httpd_binary -t -D DUMP_RUN_CFG | grep -i -e "^Group" | awk '{print$2}' | cut -d\"=\" -f2 | tr -d '"'`"
# - Is webserver running ?
# -
PID=$(ps aux | grep "$(realpath $httpd_binary)" | grep -e "^root" | grep -v grep | awk '{print$2}')
if [[ "X${PID}X" = "XX" ]] ;then
IS_HTTPD_RUNNING=false
else
IS_HTTPD_RUNNING=true
fi
fi
else
error "Neither \033[1mapache2\033[m nor \033[1mnginx\033[m is enabled on this machine"
echononl "continue anyway [yes/no]: "
read OK
OK="$(echo "$OK" | tr '[:upper:]' '[:lower:]')"
while [[ "$OK" != "yes" ]] && [[ "$OK" != "no" ]] ; do
echononl "Wrong entry! - repeat [yes/nno]: "
read OK
done
[[ $OK = "yes" ]] || fatal "Interrupted by user"
fi
if [[ -n "$_HTTP_USER" ]] ; then
if [[ -n "$HTTP_USER" ]] && [[ "$_HTTP_USER" != "$HTTP_USER" ]]; then
warn "The script has determined \033[1;37m${_HTTP_USER}\033[m as Webservers user. This\n value differs from the value given in your configuration file, \n which is \033[1;37m${HTTP_USER}\033[m and takes precedence."
else
HTTP_USER=$_HTTP_USER
fi
else
[[ -n "$HTTP_USER" ]] || HTTP_USER=$DEFAULT_HTTP_USER
fi
if [[ -n "$_HTTP_GROUP" ]] ; then
if [[ -n "$HTTP_GROUP" ]] && [[ "$_HTTP_GROUP" != "$HTTP_GROUP" ]]; then
warn "The script has determined \033[1;37m${_HTTP_GROUP}\033[m as Webservers group. This\n value differs from the value given in your configuration file, \n which is \033[1;37m${HTTP_GROUP}\033[m and takes precedence."
else
HTTP_GROUP=$_HTTP_GROUP
fi
else
[[ -n "$HTTP_GROUP" ]] || HTTP_GROUP=$DEFAULT_HTTP_GROUP
fi
if [[ -x "$(realpath /usr/local/php/bin/php)" ]]; then
PHP_BIN="/usr/local/php/bin/php"
else
PHP_BIN="$(which php)"
fi
if [[ ! -x "$PHP_BIN" ]]; then
fatal "No PHP binary found!"

View File

@ -6,6 +6,7 @@ script_name="$(basename $(realpath $0))"
script_dir="$(dirname $(realpath $0))"
conf_dir="${script_dir}/conf"
snippet_dir="${script_dir}/snippets"
declare -a unsorted_website_arr
declare -a website_arr
@ -138,13 +139,11 @@ error(){
}
warn (){
echo ""
if $terminal ; then
echo ""
echo -e " [ \033[33m\033[1mWarning\033[m ]: $*"
else
echo " [ Warning ]: $*"
echo ""
fi
echo ""
}
info (){
@ -180,6 +179,14 @@ blank_line() {
# - Running in a terminal?
# -
if [[ -t 1 ]] ; then
terminal=true
else
terminal=false
fi
# ----------
# - Jobhandling
# ----------
@ -215,37 +222,21 @@ if [[ -z "$WEBSITE" ]] ; then
# -
IFS=$'\n' website_arr=($(sort <<<"${unsorted_website_arr[*]}"))
WEBSITE=
_OK=false
echo ""
echo "Which site would you like to update?"
echo ""
declare -i i=0
for _site in ${website_arr[@]} ; do
IFS=':' read -a _arr <<< ${_site}
echo " [$i] ${_arr[0]}"
((i++))
done
echo
echononl " Eingabe: "
while ! $_OK ; do
read _IN
if is_number "$_IN" && [[ -n ${website_arr[$_IN]} ]]; then
IFS=':' read -a _arr <<< ${website_arr[$_IN]}
conf_file=${_arr[1]}
_WEBSITE="${_arr[0]}"
_OK=true
else
echo ""
echo -e "\tFalsche Eingabe !"
echo ""
echononl " Eingabe: "
# Which cloud instance (website) would you like to update
#
source ${snippet_dir}/get-cloud-instance-to-update.sh
else
while IFS='' read -r -d '' _conf_file ; do
if $(grep -E -q "WEBSITE=\"?${WEBSITE}\"?" ${_conf_file} 2> /dev/null) ; then
conf_file="${_conf_file}"
break
fi
done
done < <(find "${conf_dir}" -maxdepth 1 -type f -name "*.conf" -print0)
WEBSITE="$_WEBSITE"
# conf_file="${conf_dir}/${WEBSITE}.conf"
#fatal "No website ios given on commandline - Missing Parameter '-s <website>'"
fi
@ -253,13 +244,32 @@ fi
# -
IFS=$CUR_IFS
WEB_BASE_DIR="/var/www/${WEBSITE}"
DEFAULT_SRC_BASE_DIR="/usr/local/src/nextcloud"
DEFAULT_HTTP_USER="www-data"
DEFAULT_HTTP_GROUP="www-data"
DEFAULT_PHP_ENGINE='FPM'
blank_line
echononl " Include Configuration file '$(basename "${conf_file}")'.."
if [[ ! -f $conf_file ]]; then
echo_skipped
fatal "Missing configuration file '$conf_file'."
else
source $conf_file
echo_ok
fi
DEFAULT_WEB_BASE_DIR="/var/www/${WEBSITE}"
[[ -n "$WEB_BASE_DIR" ]] || WEB_BASE_DIR=$DEFAULT_WEB_BASE_DIR
if [[ ! -d ${WEB_BASE_DIR} ]] ; then
fatal "Web base directory '$WEB_BASE_DIR' not found!"
fi
DATA_DIR="$(realpath ${WEB_BASE_DIR}/data)"
[[ -n "$PHP_ENGINE" ]] || PHP_ENGINE=$DEFAULT_PHP_ENGINE
INSTALL_DIR="$(realpath ${WEB_BASE_DIR}/nextcloud)"
CURRENT_VERSION="$(basename $INSTALL_DIR | cut -d"-" -f2)"
@ -276,19 +286,9 @@ else
SYSTEMD_EXISTS=true
fi
# - Running in a terminal?
# -
if [[ -t 1 ]] ; then
terminal=true
else
terminal=false
fi
#clear
if $terminal ; then
echo ""
echo ""
echo ""
echo -e "\033[32m-----\033[m"
echo -e "Trigger a set of occ comands on system \033[1m${WEB_BASE_DIR}\033[m"
@ -309,112 +309,24 @@ fi
DEFAULT_HTTP_USER="www-data"
DEFAULT_HTTP_GROUP="www-data"
NGINX_IS_ENABLED=false
APACHE2_IS_ENABLED=false
# Check if NGINX webserver is ctive
# Get Webservice environment as IS_HTTPD_RUNNING, HTTP_USER, HTTP_GROUP..
#
if $(systemctl -q is-enabled nginx 2> /dev/null) ; then
NGINX_IS_ENABLED=true
# - Determin user of the webserver
# -
nginx_binary="$(which nginx)"
if [[ -z "$nginx_binary" ]] ; then
nginx_binary="$(ps -axu | grep -E "nginx:.*master" | grep -v grep | grep -o -E "\S+/nginx")"
if [[ -z "$nginx_binary" ]] ; then
if [[ -x "/usr/local/nginx/bin/nginx" ]]; then
nginx_binary="/usr/local/nginx/bin/nginx"
elif [[ -x "/usr/local/nginx/sbin/nginx" ]]; then
nginx_binary="/usr/local/nginx/sbin/nginx"
fi
fi
fi
if [[ -x "$nginx_binary" ]] ; then
_HTTP_USER="$($nginx_binary -T 2> /dev/null | grep -E "^\s*user\s+\S+;" | grep -o -E "\S+;$" | sed -e 's/;$//')"
fi
# - Is webserver running ?
# -
PID=$(ps aux | grep "$(realpath $nginx_binary)" | grep -e "^root" | grep -v grep | awk '{print$2}')
if [[ "X${PID}X" = "XX" ]] ;then
IS_HTTPD_RUNNING=false
else
IS_HTTPD_RUNNING=true
fi
source ${snippet_dir}/get-webservice-environment.sh
elif $(systemctl -q is-enabled apache2 2> /dev/null) ; then
# Check PHP Version
#
source ${snippet_dir}/get-php-major-version.sh
APACHE2_IS_ENABLED=true
# - Determin user 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}')"
if [ -z "$httpd_binary" ]; then
if [ -x "/usr/local/apache2/bin/httpd" ]; then
httpd_binary="/usr/local/apache2/bin/httpd"
fi
fi
fi
if [ -x "$httpd_binary" ];then
# Get full qualified PHP command
#
source ${snippet_dir}/get-path-of-php-command.sh
# - Determin websever user
# -
_HTTP_USER="`$httpd_binary -t -D DUMP_RUN_CFG | grep -i -e "^User" | awk '{print$2}' | cut -d\"=\" -f2 | tr -d '"'`"
_HTTP_GROUP="`$httpd_binary -t -D DUMP_RUN_CFG | grep -i -e "^Group" | awk '{print$2}' | cut -d\"=\" -f2 | tr -d '"'`"
# - Is webserver running ?
# -
PID=$(ps aux | grep "$(realpath $httpd_binary)" | grep -e "^root" | grep -v grep | awk '{print$2}')
if [[ "X${PID}X" = "XX" ]] ;then
IS_HTTPD_RUNNING=false
else
IS_HTTPD_RUNNING=true
fi
fi
else
error "Neither \033[1mapache2\033[m nor \033[1mnginx\033[m is enabled on this machine"
echononl "continue anyway [yes/no]: "
read OK
OK="$(echo "$OK" | tr '[:upper:]' '[:lower:]')"
while [[ "$OK" != "yes" ]] && [[ "$OK" != "no" ]] ; do
echononl "Wrong entry! - repeat [yes/nno]: "
read OK
done
[[ $OK = "yes" ]] || fatal "Interrupted by user"
fi
if [[ -n "$_HTTP_USER" ]] ; then
if [[ -n "$HTTP_USER" ]] && [[ "$_HTTP_USER" != "$HTTP_USER" ]]; then
warn "The script has determined \033[1;37m${_HTTP_USER}\033[m as Webservers user. This\n value differs from the value given in your configuration file, \n which is \033[1;37m${HTTP_USER}\033[m and takes precedence."
else
HTTP_USER=$_HTTP_USER
fi
else
[[ -n "$HTTP_USER" ]] || HTTP_USER=$DEFAULT_HTTP_USER
fi
if [[ -n "$_HTTP_GROUP" ]] ; then
if [[ -n "$HTTP_GROUP" ]] && [[ "$_HTTP_GROUP" != "$HTTP_GROUP" ]]; then
warn "The script has determined \033[1;37m${_HTTP_GROUP}\033[m as Webservers group. This\n value differs from the value given in your configuration file, \n which is \033[1;37m${HTTP_GROUP}\033[m and takes precedence."
else
HTTP_GROUP=$_HTTP_GROUP
fi
else
[[ -n "$HTTP_GROUP" ]] || HTTP_GROUP=$DEFAULT_HTTP_GROUP
fi
if [[ -x "$(realpath /usr/local/php/bin/php)" ]]; then
PHP_BIN="/usr/local/php/bin/php"
else
PHP_BIN="$(which php)"
fi
if [[ ! -x "$PHP_BIN" ]]; then
fatal "No PHP binary found!"

View File

@ -6,6 +6,7 @@ script_name="$(basename $(realpath $0))"
script_dir="$(dirname $(realpath $0))"
conf_dir="${script_dir}/conf"
snippet_dir="${script_dir}/snippets"
declare -a unsorted_website_arr
declare -a website_arr
@ -138,13 +139,11 @@ error(){
}
warn (){
echo ""
if $terminal ; then
echo ""
echo -e " [ \033[33m\033[1mWarning\033[m ]: $*"
else
echo " [ Warning ]: $*"
echo ""
fi
echo ""
}
info (){
@ -179,6 +178,14 @@ blank_line() {
}
# - Running in a terminal?
# -
if [[ -t 1 ]] ; then
terminal=true
else
terminal=false
fi
# ----------
# - Jobhandling
@ -215,37 +222,20 @@ if [[ -z "$WEBSITE" ]] ; then
# -
IFS=$'\n' website_arr=($(sort <<<"${unsorted_website_arr[*]}"))
WEBSITE=
_OK=false
echo ""
echo "Which site would you like to update?"
echo ""
declare -i i=0
for _site in ${website_arr[@]} ; do
IFS=':' read -a _arr <<< ${_site}
echo " [$i] ${_arr[0]}"
((i++))
done
echo
echononl " Eingabe: "
while ! $_OK ; do
read _IN
if is_number "$_IN" && [[ -n ${website_arr[$_IN]} ]]; then
IFS=':' read -a _arr <<< ${website_arr[$_IN]}
conf_file=${_arr[1]}
_WEBSITE="${_arr[0]}"
_OK=true
else
echo ""
echo -e "\tFalsche Eingabe !"
echo ""
echononl " Eingabe: "
# Which cloud instance (website) would you like to update
#
source ${snippet_dir}/get-cloud-instance-to-update.sh
else
while IFS='' read -r -d '' _conf_file ; do
if $(grep -E -q "WEBSITE=\"?${WEBSITE}\"?" ${_conf_file} 2> /dev/null) ; then
conf_file="${_conf_file}"
break
fi
done
done < <(find "${conf_dir}" -maxdepth 1 -type f -name "*.conf" -print0)
WEBSITE="$_WEBSITE"
# conf_file="${conf_dir}/${WEBSITE}.conf"
#fatal "No website ios given on commandline - Missing Parameter '-s <website>'"
fi
@ -253,13 +243,33 @@ fi
# -
IFS=$CUR_IFS
WEB_BASE_DIR="/var/www/${WEBSITE}"
DEFAULT_SRC_BASE_DIR="/usr/local/src/nextcloud"
DEFAULT_HTTP_USER="www-data"
DEFAULT_HTTP_GROUP="www-data"
DEFAULT_PHP_ENGINE='FPM'
echo ""
echononl " Include Configuration file '$(basename "${conf_file}")'.."
if [[ ! -f $conf_file ]]; then
echo_failed
fatal "Missing configuration file '$conf_file'."
else
source $conf_file
echo_ok
fi
echo ""
DEFAULT_WEB_BASE_DIR="/var/www/${WEBSITE}"
[[ -n "$WEB_BASE_DIR" ]] || WEB_BASE_DIR=$DEFAULT_WEB_BASE_DIR
if [[ ! -d ${WEB_BASE_DIR} ]] ; then
fatal "Web base directory '$WEB_BASE_DIR' not found!"
fi
DATA_DIR="$(realpath ${WEB_BASE_DIR}/data)"
[[ -n "$PHP_ENGINE" ]] || PHP_ENGINE=$DEFAULT_PHP_ENGINE
INSTALL_DIR="$(realpath ${WEB_BASE_DIR}/nextcloud)"
CURRENT_VERSION="$(basename $INSTALL_DIR | cut -d"-" -f2)"
@ -276,14 +286,6 @@ else
SYSTEMD_EXISTS=true
fi
# - Running in a terminal?
# -
if [[ -t 1 ]] ; then
terminal=true
else
terminal=false
fi
#clear
if $terminal ; then
@ -309,112 +311,24 @@ fi
DEFAULT_HTTP_USER="www-data"
DEFAULT_HTTP_GROUP="www-data"
NGINX_IS_ENABLED=false
APACHE2_IS_ENABLED=false
# Check if NGINX webserver is ctive
# Get Webservice environment as IS_HTTPD_RUNNING, HTTP_USER, HTTP_GROUP..
#
if $(systemctl -q is-enabled nginx 2> /dev/null) ; then
NGINX_IS_ENABLED=true
# - Determin user of the webserver
# -
nginx_binary="$(which nginx)"
if [[ -z "$nginx_binary" ]] ; then
nginx_binary="$(ps -axu | grep -E "nginx:.*master" | grep -v grep | grep -o -E "\S+/nginx")"
if [[ -z "$nginx_binary" ]] ; then
if [[ -x "/usr/local/nginx/bin/nginx" ]]; then
nginx_binary="/usr/local/nginx/bin/nginx"
elif [[ -x "/usr/local/nginx/sbin/nginx" ]]; then
nginx_binary="/usr/local/nginx/sbin/nginx"
fi
fi
fi
if [[ -x "$nginx_binary" ]] ; then
_HTTP_USER="$($nginx_binary -T 2> /dev/null | grep -E "^\s*user\s+\S+;" | grep -o -E "\S+;$" | sed -e 's/;$//')"
fi
# - Is webserver running ?
# -
PID=$(ps aux | grep "$(realpath $nginx_binary)" | grep -e "^root" | grep -v grep | awk '{print$2}')
if [[ "X${PID}X" = "XX" ]] ;then
IS_HTTPD_RUNNING=false
else
IS_HTTPD_RUNNING=true
fi
source ${snippet_dir}/get-webservice-environment.sh
elif $(systemctl -q is-enabled apache2 2> /dev/null) ; then
# Check PHP Version
#
source ${snippet_dir}/get-php-major-version.sh
APACHE2_IS_ENABLED=true
# - Determin user 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}')"
if [ -z "$httpd_binary" ]; then
if [ -x "/usr/local/apache2/bin/httpd" ]; then
httpd_binary="/usr/local/apache2/bin/httpd"
fi
fi
fi
if [ -x "$httpd_binary" ];then
# Get full qualified PHP command
#
source ${snippet_dir}/get-path-of-php-command.sh
# - Determin websever user
# -
_HTTP_USER="`$httpd_binary -t -D DUMP_RUN_CFG | grep -i -e "^User" | awk '{print$2}' | cut -d\"=\" -f2 | tr -d '"'`"
_HTTP_GROUP="`$httpd_binary -t -D DUMP_RUN_CFG | grep -i -e "^Group" | awk '{print$2}' | cut -d\"=\" -f2 | tr -d '"'`"
# - Is webserver running ?
# -
PID=$(ps aux | grep "$(realpath $httpd_binary)" | grep -e "^root" | grep -v grep | awk '{print$2}')
if [[ "X${PID}X" = "XX" ]] ;then
IS_HTTPD_RUNNING=false
else
IS_HTTPD_RUNNING=true
fi
fi
else
error "Neither \033[1mapache2\033[m nor \033[1mnginx\033[m is enabled on this machine"
echononl "continue anyway [yes/no]: "
read OK
OK="$(echo "$OK" | tr '[:upper:]' '[:lower:]')"
while [[ "$OK" != "yes" ]] && [[ "$OK" != "no" ]] ; do
echononl "Wrong entry! - repeat [yes/nno]: "
read OK
done
[[ $OK = "yes" ]] || fatal "Interrupted by user"
fi
if [[ -n "$_HTTP_USER" ]] ; then
if [[ -n "$HTTP_USER" ]] && [[ "$_HTTP_USER" != "$HTTP_USER" ]]; then
warn "The script has determined \033[1;37m${_HTTP_USER}\033[m as Webservers user. This\n value differs from the value given in your configuration file, \n which is \033[1;37m${HTTP_USER}\033[m and takes precedence."
else
HTTP_USER=$_HTTP_USER
fi
else
[[ -n "$HTTP_USER" ]] || HTTP_USER=$DEFAULT_HTTP_USER
fi
if [[ -n "$_HTTP_GROUP" ]] ; then
if [[ -n "$HTTP_GROUP" ]] && [[ "$_HTTP_GROUP" != "$HTTP_GROUP" ]]; then
warn "The script has determined \033[1;37m${_HTTP_GROUP}\033[m as Webservers group. This\n value differs from the value given in your configuration file, \n which is \033[1;37m${HTTP_GROUP}\033[m and takes precedence."
else
HTTP_GROUP=$_HTTP_GROUP
fi
else
[[ -n "$HTTP_GROUP" ]] || HTTP_GROUP=$DEFAULT_HTTP_GROUP
fi
if [[ -x "$(realpath /usr/local/php/bin/php)" ]]; then
PHP_BIN="/usr/local/php/bin/php"
else
PHP_BIN="$(which php)"
fi
if [[ ! -x "$PHP_BIN" ]]; then
fatal "No PHP binary found!"

730
occ_migrate_mimetipes.sh Executable file
View File

@ -0,0 +1,730 @@
#!/usr/bin/env bash
CUR_IFS=$IFS
script_name="$(basename $(realpath $0))"
script_dir="$(dirname $(realpath $0))"
conf_dir="${script_dir}/conf"
snippet_dir="${script_dir}/snippets"
declare -a unsorted_website_arr
declare -a website_arr
log_file="$(mktemp)"
backup_date=$(date +%Y-%m-%d-%H%M)
# =============
# --- Some functions
# =============
clean_up() {
if [[ -f "$_backup_crontab_file" ]]; then
echononl " (Re)Install previously saved crontab .."
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
blank_line
exit $1
}
is_number() {
return $(test ! -z "${1##*[!0-9]*}" > /dev/null 2>&1);
# - also possible
# -
#[[ ! -z "${1##*[!0-9]*}" ]] && return 0 || return 1
#return $([[ ! -z "${1##*[!0-9]*}" ]])
}
echononl(){
echo X\\c > /tmp/shprompt$$
if [ `wc -c /tmp/shprompt$$ | awk '{print $1}'` -eq 1 ]; then
echo -e -n "$*\\c" 1>&2
else
echo -e -n "$*" 1>&2
fi
rm /tmp/shprompt$$
}
echo_done() {
if $terminal ; then
echo -e "\033[75G[ \033[32mdone\033[m ]"
else
echo " [ done ]"
fi
}
echo_ok() {
if $terminal ; then
echo -e "\033[75G[ \033[32mok\033[m ]"
else
echo " [ ok ]"
fi
}
echo_warning() {
if $terminal ; then
echo -e "\033[75G[ \033[33m\033[1mwarn\033[m ]"
else
echo " [ warning ]"
fi
}
echo_failed(){
if $terminal ; then
echo -e "\033[75G[ \033[1;31mfailed\033[m ]"
else
echo ' [ failed! ]'
fi
}
echo_skipped() {
if $terminal ; then
echo -e "\033[75G[ \033[37mskipped\033[m ]"
else
echo " [ skipped ]"
fi
}
fatal (){
echo ""
echo ""
if $terminal ; then
echo -e "\t[ \033[31m\033[1mFatal\033[m ]: \033[37m\033[1m$*\033[m"
echo ""
echo -e "\t\033[31m\033[1m Script will be interrupted..\033[m\033[m"
else
echo "fatal: $*"
echo "Script will be interrupted.."
fi
clean_up 1
}
error(){
echo ""
if $terminal ; then
echo -e "\t[ \033[31m\033[1mFehler\033[m ]: $*"
else
echo "Error: $*"
fi
echo ""
}
warn (){
echo ""
if $terminal ; then
echo -e "\t[ \033[33m\033[1mWarning\033[m ]: $*"
else
echo "Warning: $*"
fi
echo ""
}
info (){
echo ""
if $terminal ; then
echo -e "\t[ \033[32m\033[1mInfo\033[m ]: $*"
else
echo "Info: $*"
fi
echo ""
}
## - 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
return 1
}
blank_line() {
if $terminal ; then
echo ""
fi
}
# ----------
# - Jobhandling
# ----------
# - Run 'clean_up' for signals SIGHUP SIGINT SIGTERM
# -
trap clean_up SIGHUP SIGINT SIGTERM
## -
while IFS='' read -r -d '' _conf_file ; do
source $_conf_file
if [[ -n "$WEBSITE" ]] ; then
unsorted_website_arr+=("${WEBSITE}:$_conf_file")
fi
WEBSITE=""
done < <(find "${conf_dir}" -maxdepth 1 -type f -name "*.conf" -print0)
#done < <(find "${conf_dir}" -maxdepth 1 -type f -name "create_missing_indices_*.conf" -print0)
#if [[ ${#unsorted_website_arr} -eq 0 ]]; then
# fatal "No configuration files found in '${script_dir}/conf' or no website configured!"
#fi
# - Sort array
# -
IFS=$'\n' website_arr=($(sort <<<"${unsorted_website_arr[*]}"))
# - Reset IFS
# -
IFS=$CUR_IFS
# =============
# --- Some
# =============
# - Support systemd ?
# -
if [[ "X$(which systemd)" = "X" ]]; then
SYSTEMD_EXISTS=false
else
SYSTEMD_EXISTS=true
fi
# - Running in a terminal?
# -
if [[ -t 1 ]] ; then
terminal=true
else
terminal=false
fi
clear
echo ""
echo -e "\033[32m-----\033[m"
echo "Add missing columns"
echo -e "\033[32m-----\033[m"
# Which cloud instance (website) would you like to update
#
source ${snippet_dir}/get-cloud-instance-to-update.sh
# - Reset IFS
# -
IFS=$CUR_IFS
echo ""
echononl " Include Configuration file.."
if [[ ! -f $conf_file ]]; then
echo_failed
fatal "Missing configuration file '$conf_file'."
else
source $conf_file
echo_ok
fi
echo ""
# =============
# --- Some checks
# =============
DEFAULT_SRC_BASE_DIR="/usr/local/src/nextcloud"
DEFAULT_HTTP_USER="www-data"
DEFAULT_HTTP_GROUP="www-data"
DEFAULT_PHP_ENGINE="FPM"
if [[ -z ${WEBSITE} ]] ; then
WEBSITE="$DEFAULT_WEBSITE"
fi
DEFAULT_WEB_BASE_DIR="/var/www/$WEBSITE"
[[ -n "$WEB_BASE_DIR" ]] || WEB_BASE_DIR=$DEFAULT_WEB_BASE_DIR
if [[ ! -d ${WEB_BASE_DIR} ]] ; then
fatal "Web base directory not found (parameter 'WEB_BASE_DIR')"
fi
[[ -n "$PHP_ENGINE" ]] || PHP_ENGINE=$DEFAULT_PHP_ENGINE
if [[ "$DATABASE_TYPE" != "postgres" ]] && [[ "$DATABASE_TYPE" != "mysql" ]]; then
fatal "Wrong or missing database type (parameter 'DATABASE_TYPE')"
fi
if [[ -z "$DATABASE_NAME" ]]; then
fatal "Missing database name (parameter 'DATABASE_NAME')"
fi
if [[ "$DATABASE_TYPE" = "mysql" ]] && [[ -z "$MYSQL_CREDENTIALS" ]]; then
fatal "No Database Credentials for MySQL given (parameter 'MYSQL_CREDENTIALS')"
fi
if [[ "$DATABASE_TYPE" = "postgres" ]]; then
if [[ -z "$PSQL_USER" ]] || [[ -z "$PSQL_PASS" ]]; then
fatal "No Database Credentials for PostgreSQL given (parameters: 'PSQL_USER' 'PSQL_PASS'"
fi
fi
NGINX_IS_ENABLED=false
APACHE2_IS_ENABLED=false
# Get Webservice environment as IS_HTTPD_RUNNING, HTTP_USER, HTTP_GROUP..
#
source ${snippet_dir}/get-webservice-environment.sh
# Check PHP Version
#
source ${snippet_dir}/get-php-major-version.sh
# Get full qualified PHP command
#
source ${snippet_dir}/get-path-of-php-command.sh
CURRENT_INSTALL_DIR="$(realpath ${WEB_BASE_DIR}/nextcloud)"
CURRENT_VERSION="$(basename $CURRENT_INSTALL_DIR | cut -d"-" -f2)"
echo ""
echo -e "\033[1;32mStarting Script $script_name for \033[1;37m${WEBSITE}\033[m"
echo ""
echo -e " Website to update....................: $WEBSITE"
echo ""
echo -e " Nextcloud version....................: $CURRENT_VERSION"
echo ""
echo -e " Web base directory...................: $WEB_BASE_DIR"
echo ""
echo -e " Webserver user.......................: $HTTP_USER"
echo -e " Webserver group......................: $HTTP_GROUP"
echo ""
echo -e " PHP version..........................: $PHP_VERSION"
echo -e " PHP Engine...........................: $PHP_ENGINE"
echo ""
echo -e " PHP Command..........................: $PHP_BIN"
echo ""
echo -n " Type upper case 'YES' to continue executing with this parameters: "
read OK
if [[ "$OK" = "YES" ]] ; then
echo ""
echo ""
echo -e "\033[1;32mGoing to update Nextcloud on \033[1;37m$WEBSITE \033[m"
echo ""
else
fatal "Abort by user request - Answer as not 'YES'"
fi
echo ""
# -----
# - Do some pre-update tasks..
# -----
echo ""
echo ""
echo -e "\033[37m\033[1mDo some pre-update tasks..\033[m"
echo ""
# - Deaktiviere Cronjobs
# -
_backup_crontab_file=/tmp/crontab_root.${backup_date}
echononl " Backup Crontab to '$_backup_crontab_file'"
crontab -l > $_backup_crontab_file 2> $log_file
if [[ $? -eq 0 ]]; then
echo_ok
else
echo_failed
fatal "$(cat $log_file)"
fi
echononl " Remove crontab for root.."
crontab -r > $log_file 2>&1
if [[ $? -eq 0 ]]; then
echo_ok
else
echo_failed
fatal "$(cat $log_file)"
fi
# - Stop Apache Webserver
# -
echo ""
echononl " Stop Apache Webserver.."
if $APACHE2_IS_ENABLED ; then
if $IS_HTTPD_RUNNING ; then
if $SYSTEMD_EXISTS ; then
systemctl stop apache2
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
else
/etc/init.d/apache2 stop
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
fi
else
echo_skipped
fi
else
echo_skipped
fi
# - Stop Nginx Webservice
# -
echo ""
echononl " Stop Nginx Webserver.."
if $NGINX_IS_ENABLED ; then
if $IS_HTTPD_RUNNING ; then
if $SYSTEMD_EXISTS ; then
systemctl stop nginx
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
else
/etc/init.d/nginx stop
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
fi
else
echo_skipped
fi
fi
echo ""
# - Backup Database
# -
echononl " Backup MySQL database '$DATABASE_NAME'.."
if [[ "$DATABASE_TYPE" = 'mysql' ]]; then
mysqldump $MYSQL_CREDENTIALS --max_allowed_packet=128M --single-transaction $DATABASE_NAME > \
${WEB_BASE_DIR}/${DATABASE_NAME}-v${CURRENT_VERSION}.${backup_date}.sql 2> $log_file
if [[ $? -eq 0 ]]; then
echo_ok
else
echo_failed
blank_line
echo -e "\t[ \033[33m\033[1mCommand\033[m ]: \033[37m\033[1mmysqldump $MYSQL_CREDENTIALS \\
\t --max_allowed_packet=128M --single-transaction $DATABASE_NAME > \\
\t ${WEB_BASE_DIR}/${DATABASE_NAME}-v${PRIOR_VERSION}.${backup_date}.sql\033[m"
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 "Abbruch durch User"
blank_line
fi
elif [[ "$DATABASE_TYPE" = 'postgres' ]]; then
PGPASSWORD=$PSQL_PASS \
pg_dump $DATABASE_NAME -h $PSQL_SERVER -U $PSQL_USER \
-f ${WEB_BASE_DIR}/${DATABASE_NAME}-v${CURRENT_VERSION}.${backup_date}.sql 2> $log_file
if [[ $? -eq 0 ]]; then
echo_ok
else
echo_failed
fatal "$(cat $log_file)"
fi
fi
echo
# -----
# - Main part of the script
# -----
echo ""
echo ""
echo -e "\033[37m\033[1mMain part of the script\033[m"
echo ""
# - Add missing columns
# -
echononl " Migrating the mimetypes .."
su -c "${PHP_BIN} ${WEB_BASE_DIR}/htdocs/occ maintenance:repair --include-expensive" -s /bin/bash $HTTP_USER > $log_file 2>&1
if [[ $? -eq 0 ]]; then
echo_ok
else
echo_failed
fatal "$(cat $log_file)"
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
if $SYSTEMD_EXISTS ; then
systemctl restart php-${PHP_VERSION}-fpm > $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
else
/etc/init.d/php-${PHP_VERSION}-fpm restart > $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
fi
else
echo_skipped
fi
# - Start Apache Webserver
# -
echo ""
echononl " Start Apache Webserver.."
if $APACHE2_IS_ENABLED ; then
if $IS_HTTPD_RUNNING ; then
if $SYSTEMD_EXISTS ; then
systemctl start apache2 > $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
else
/etc/init.d/apache2 start > $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
fi
else
echo_skipped
warn "The webserver was not running, so it will be keept down!"
fi
else
echo_skipped
fi
# - Start NGINX Webservise
# -
echo ""
echononl " Start Nginx Webserver.."
if $NGINX_IS_ENABLED ; then
if $IS_HTTPD_RUNNING ; then
if $SYSTEMD_EXISTS ; then
systemctl start nginx > $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
else
/etc/init.d/nginx start > $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
fi
else
echo_skipped
warn "The NGINX is not configured as active - so nothing to do."
fi
else
echo_skipped
fi
_redis_cli_bin="$(which redis-cli)"
if [[ -z "$_redis_cli_bin" ]]; then
if [[ -x "/usr/local/bin/redis-cli" ]]; then
_redis_cli_bin="/usr/local/bin/redis-cli"
fi
fi
echononl " Flush redis cache.."
if [[ -x "$_redis_cli_bin" ]]; then
$_redis_cli_bin flushall > $log_file 2>&1
if [[ $? -eq 0 ]]; then
echo_ok
else
echo_failed
error "$(cat $log_file)"
fi
else
echo_skipped
fi
echononl " Restart redis server.."
if $SYSTEMD_EXISTS ; then
systemctl restart redis-server > $log_file 2>&1
if [[ $? -eq 0 ]]; then
echo_ok
else
echo_failed
error "$(cat $log_file)"
fi
else
/etc/init.d/redis-server restart > $log_file 2>&1
if [[ $? -eq 0 ]]; then
echo_ok
else
echo_failed
error "$(cat $log_file)"
fi
fi
blank_line
clean_up 0

View File

@ -6,6 +6,7 @@ script_name="$(basename $(realpath $0))"
script_dir="$(dirname $(realpath $0))"
conf_dir="${script_dir}/conf"
snippet_dir="${script_dir}/snippets"
declare -a unsorted_website_arr
declare -a website_arr
@ -138,13 +139,11 @@ error(){
}
warn (){
echo ""
if $terminal ; then
echo ""
echo -e " [ \033[33m\033[1mWarning\033[m ]: $*"
else
echo " [ Warning ]: $*"
echo ""
fi
echo ""
}
info (){
@ -179,6 +178,14 @@ blank_line() {
}
# - Running in a terminal?
# -
if [[ -t 1 ]] ; then
terminal=true
else
terminal=false
fi
# ----------
# - Jobhandling
@ -215,37 +222,22 @@ if [[ -z "$WEBSITE" ]] ; then
# -
IFS=$'\n' website_arr=($(sort <<<"${unsorted_website_arr[*]}"))
WEBSITE=
_OK=false
echo ""
echo "Which site would you like to update?"
echo ""
declare -i i=0
for _site in ${website_arr[@]} ; do
IFS=':' read -a _arr <<< ${_site}
echo " [$i] ${_arr[0]}"
((i++))
done
echo
echononl " Eingabe: "
while ! $_OK ; do
read _IN
if is_number "$_IN" && [[ -n ${website_arr[$_IN]} ]]; then
IFS=':' read -a _arr <<< ${website_arr[$_IN]}
conf_file=${_arr[1]}
_WEBSITE="${_arr[0]}"
_OK=true
else
echo ""
echo -e "\tFalsche Eingabe !"
echo ""
echononl " Eingabe: "
# Which cloud instance (website) would you like to update
#
source ${snippet_dir}/get-cloud-instance-to-update.sh
else
while IFS='' read -r -d '' _conf_file ; do
if $(grep -E -q "WEBSITE=\"?${WEBSITE}\"?" ${_conf_file} 2> /dev/null) ; then
conf_file="${_conf_file}"
break
fi
done
done < <(find "${conf_dir}" -maxdepth 1 -type f -name "*.conf" -print0)
WEBSITE="$_WEBSITE"
# conf_file="${conf_dir}/${WEBSITE}.conf"
#fatal "No website ios given on commandline - Missing Parameter '-s <website>'"
fi
@ -253,13 +245,33 @@ fi
# -
IFS=$CUR_IFS
WEB_BASE_DIR="/var/www/${WEBSITE}"
DEFAULT_SRC_BASE_DIR="/usr/local/src/nextcloud"
DEFAULT_HTTP_USER="www-data"
DEFAULT_HTTP_GROUP="www-data"
DEFAULT_PHP_ENGINE='FPM'
echo ""
echononl " Include Configuration file.. '$(basename "${conf_file}")'"
if [[ ! -f $conf_file ]]; then
echo_failed
fatal "Missing configuration file '$conf_file'."
else
source $conf_file
echo_ok
fi
echo ""
DEFAULT_WEB_BASE_DIR="/var/www/${WEBSITE}"
[[ -n "$WEB_BASE_DIR" ]] || WEB_BASE_DIR=$DEFAULT_WEB_BASE_DIR
if [[ ! -d ${WEB_BASE_DIR} ]] ; then
fatal "Web base directory '$WEB_BASE_DIR' not found!"
fi
DATA_DIR="$(realpath ${WEB_BASE_DIR}/data)"
[[ -n "$PHP_ENGINE" ]] || PHP_ENGINE=$DEFAULT_PHP_ENGINE
INSTALL_DIR="$(realpath ${WEB_BASE_DIR}/nextcloud)"
CURRENT_VERSION="$(basename $INSTALL_DIR | cut -d"-" -f2)"
@ -276,14 +288,6 @@ else
SYSTEMD_EXISTS=true
fi
# - Running in a terminal?
# -
if [[ -t 1 ]] ; then
terminal=true
else
terminal=false
fi
#clear
if $terminal ; then
@ -312,109 +316,20 @@ DEFAULT_HTTP_GROUP="www-data"
NGINX_IS_ENABLED=false
APACHE2_IS_ENABLED=false
# Check if NGINX webserver is ctive
# Get Webservice environment as IS_HTTPD_RUNNING, HTTP_USER, HTTP_GROUP..
#
if $(systemctl -q is-enabled nginx 2> /dev/null) ; then
NGINX_IS_ENABLED=true
# - Determin user of the webserver
# -
nginx_binary="$(which nginx)"
if [[ -z "$nginx_binary" ]] ; then
nginx_binary="$(ps -axu | grep -E "nginx:.*master" | grep -v grep | grep -o -E "\S+/nginx")"
if [[ -z "$nginx_binary" ]] ; then
if [[ -x "/usr/local/nginx/bin/nginx" ]]; then
nginx_binary="/usr/local/nginx/bin/nginx"
elif [[ -x "/usr/local/nginx/sbin/nginx" ]]; then
nginx_binary="/usr/local/nginx/sbin/nginx"
fi
fi
fi
if [[ -x "$nginx_binary" ]] ; then
_HTTP_USER="$($nginx_binary -T 2> /dev/null | grep -E "^\s*user\s+\S+;" | grep -o -E "\S+;$" | sed -e 's/;$//')"
fi
# - Is webserver running ?
# -
PID=$(ps aux | grep "$(realpath $nginx_binary)" | grep -e "^root" | grep -v grep | awk '{print$2}')
if [[ "X${PID}X" = "XX" ]] ;then
IS_HTTPD_RUNNING=false
else
IS_HTTPD_RUNNING=true
fi
source ${snippet_dir}/get-webservice-environment.sh
elif $(systemctl -q is-enabled apache2 2> /dev/null) ; then
# Check PHP Version
#
source ${snippet_dir}/get-php-major-version.sh
APACHE2_IS_ENABLED=true
# - Determin user 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}')"
if [ -z "$httpd_binary" ]; then
if [ -x "/usr/local/apache2/bin/httpd" ]; then
httpd_binary="/usr/local/apache2/bin/httpd"
fi
fi
fi
if [ -x "$httpd_binary" ];then
# Get full qualified PHP command
#
source ${snippet_dir}/get-path-of-php-command.sh
# - Determin websever user
# -
_HTTP_USER="`$httpd_binary -t -D DUMP_RUN_CFG | grep -i -e "^User" | awk '{print$2}' | cut -d\"=\" -f2 | tr -d '"'`"
_HTTP_GROUP="`$httpd_binary -t -D DUMP_RUN_CFG | grep -i -e "^Group" | awk '{print$2}' | cut -d\"=\" -f2 | tr -d '"'`"
# - Is webserver running ?
# -
PID=$(ps aux | grep "$(realpath $httpd_binary)" | grep -e "^root" | grep -v grep | awk '{print$2}')
if [[ "X${PID}X" = "XX" ]] ;then
IS_HTTPD_RUNNING=false
else
IS_HTTPD_RUNNING=true
fi
fi
else
error "Neither \033[1mapache2\033[m nor \033[1mnginx\033[m is enabled on this machine"
echononl "continue anyway [yes/no]: "
read OK
OK="$(echo "$OK" | tr '[:upper:]' '[:lower:]')"
while [[ "$OK" != "yes" ]] && [[ "$OK" != "no" ]] ; do
echononl "Wrong entry! - repeat [yes/nno]: "
read OK
done
[[ $OK = "yes" ]] || fatal "Interrupted by user"
fi
if [[ -n "$_HTTP_USER" ]] ; then
if [[ -n "$HTTP_USER" ]] && [[ "$_HTTP_USER" != "$HTTP_USER" ]]; then
warn "The script has determined \033[1;37m${_HTTP_USER}\033[m as Webservers user. This\n value differs from the value given in your configuration file, \n which is \033[1;37m${HTTP_USER}\033[m and takes precedence."
else
HTTP_USER=$_HTTP_USER
fi
else
[[ -n "$HTTP_USER" ]] || HTTP_USER=$DEFAULT_HTTP_USER
fi
if [[ -n "$_HTTP_GROUP" ]] ; then
if [[ -n "$HTTP_GROUP" ]] && [[ "$_HTTP_GROUP" != "$HTTP_GROUP" ]]; then
warn "The script has determined \033[1;37m${_HTTP_GROUP}\033[m as Webservers group. This\n value differs from the value given in your configuration file, \n which is \033[1;37m${HTTP_GROUP}\033[m and takes precedence."
else
HTTP_GROUP=$_HTTP_GROUP
fi
else
[[ -n "$HTTP_GROUP" ]] || HTTP_GROUP=$DEFAULT_HTTP_GROUP
fi
if [[ -x "$(realpath /usr/local/php/bin/php)" ]]; then
PHP_BIN="/usr/local/php/bin/php"
else
PHP_BIN="$(which php)"
fi
if [[ ! -x "$PHP_BIN" ]]; then
fatal "No PHP binary found!"

453
remove-old-nc-installations.sh Executable file
View File

@ -0,0 +1,453 @@
#!/usr/bin/env bash
CUR_IFS="$IFS"
script_name="$(basename $(realpath $0))"
script_dir="$(dirname $(realpath $0))"
conf_dir="${script_dir}/conf"
snippet_dir="${script_dir}/snippets"
declare -a unsorted_website_arr
declare -a website_arr
log_file="$(mktemp)"
backup_date=$(date +%Y-%m-%d-%H%M)
# =============
# --- Some functions
# =============
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
blank_line
exit $1
}
is_number() {
return $(test ! -z "${1##*[!0-9]*}" > /dev/null 2>&1);
# - also possible
# -
#[[ ! -z "${1##*[!0-9]*}" ]] && return 0 || return 1
#return $([[ ! -z "${1##*[!0-9]*}" ]])
}
echononl(){
echo X\\c > /tmp/shprompt$$
if [ `wc -c /tmp/shprompt$$ | awk '{print $1}'` -eq 1 ]; then
echo -e -n "$*\\c" 1>&2
else
echo -e -n "$*" 1>&2
fi
rm /tmp/shprompt$$
}
echo_done() {
if $terminal ; then
echo -e "\033[75G[ \033[32mdone\033[m ]"
else
echo " [ done ]"
fi
}
echo_ok() {
if $terminal ; then
echo -e "\033[75G[ \033[32mok\033[m ]"
else
echo " [ ok ]"
fi
}
echo_warning() {
if $terminal ; then
echo -e "\033[75G[ \033[33m\033[1mwarn\033[m ]"
else
echo " [ warning ]"
fi
}
echo_failed(){
if $terminal ; then
echo -e "\033[75G[ \033[1;31mfailed\033[m ]"
else
echo ' [ failed! ]'
fi
}
echo_skipped() {
if $terminal ; then
echo -e "\033[75G[ \033[37mskipped\033[m ]"
else
echo " [ skipped ]"
fi
}
echo_wait(){
if $terminal ; then
echo -en "\033[75G[ \033[5m\033[1m..\033[m ]"
fi
}
fatal (){
echo ""
echo ""
if $terminal ; then
echo -e "\t[ \033[31m\033[1mFatal\033[m ]: \033[37m\033[1m$*\033[m"
echo ""
echo -e "\t\033[31m\033[1m Script will be interrupted..\033[m\033[m"
else
echo "fatal: $*"
echo "Script will be interrupted.."
fi
clean_up 1
}
error(){
echo ""
if $terminal ; then
echo -e "\t[ \033[31m\033[1mFehler\033[m ]: $*"
else
echo "Error: $*"
fi
echo ""
}
warn (){
echo ""
if $terminal ; then
echo -e "\t[ \033[33m\033[1mWarning\033[m ]: $*"
else
echo "Warning: $*"
fi
echo ""
}
info (){
echo ""
if $terminal ; then
echo -e "\t[ \033[32m\033[1mInfo\033[m ]: $*"
else
echo "Info: $*"
fi
echo ""
}
## - 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
return 1
}
blank_line() {
if $terminal ; then
echo ""
fi
}
# ----------
# - Jobhandling
# ----------
# - Run 'clean_up' for signals SIGHUP SIGINT SIGTERM
# -
trap clean_up SIGHUP SIGINT SIGTERM
## -
while IFS='' read -r -d '' _conf_file ; do
source $_conf_file
if [[ -n "$WEBSITE" ]] ; then
unsorted_website_arr+=("${WEBSITE}:$_conf_file")
fi
WEBSITE=""
done < <(find "${conf_dir}" -maxdepth 1 -type f -name "*.conf" -print0)
if [[ ${#unsorted_website_arr} -eq 0 ]]; then
fatal "No configuration files found in '${script_dir}/conf' or no website configured!"
fi
# - Sort array
# -
IFS=$'\n' website_arr=($(sort <<<"${unsorted_website_arr[*]}"))
# - Reset IFS
# -
IFS=$CUR_IFS
# =============
# --- Some
# =============
# - Support systemd ?
# -
if [[ "X$(which systemd)" = "X" ]]; then
SYSTEMD_EXISTS=false
else
SYSTEMD_EXISTS=true
fi
# - Running in a terminal?
# -
if [[ -t 1 ]] ; then
terminal=true
else
terminal=false
fi
#clear
echo ""
echo -e "\033[32m-----\033[m"
echo "Clean up NC Installation"
echo -e "\033[32m-----\033[m"
# Which cloud instance (website) would you like to update
#
source ${snippet_dir}/get-cloud-instance-to-update.sh
# - Reset IFS
# -
IFS=$CUR_IFS
echo ""
echononl " Include Configuration file.."
if [[ ! -f $conf_file ]]; then
echo_failed
fatal "Missing configuration file '$conf_file'"
else
source $conf_file
echo_ok
fi
echo ""
# =============
# --- Some checks
# =============
DEFAULT_HTTP_USER="www-data"
DEFAULT_HTTP_USER="www-data"
if [[ -z ${WEBSITE} ]] ; then
fatal "No website given (parameter 'WEBSITE')"
fi
DEFAULT_WEB_BASE_DIR="/var/www/$WEBSITE"
DEFAULT_PHP_ENGINE="FPM"
[[ -n "$WEB_BASE_DIR" ]] || WEB_BASE_DIR=$DEFAULT_WEB_BASE_DIR
if [[ ! -d ${WEB_BASE_DIR} ]] ; then
fatal "Web base directory not found (parameter 'WEB_BASE_DIR')"
fi
[[ -n "$PHP_ENGINE" ]] || PHP_ENGINE=$DEFAULT_PHP_ENGINE
if [[ "$DATABASE_TYPE" != "postgres" ]] && [[ "$DATABASE_TYPE" != "mysql" ]]; then
fatal "Wrong or missing database type (parameter 'DATABASE_TYPE')"
fi
if [[ -z "$DATABASE_NAME" ]]; then
fatal "Missing database name (parameter 'DATABASE_NAME')"
fi
if [[ "$DATABASE_TYPE" = "mysql" ]] && [[ -z "$MYSQL_CREDENTIALS" ]]; then
fatal "No Database Credentials for MySQL given (parameter 'MYSQL_CREDENTIALS')"
fi
if [[ "$DATABASE_TYPE" = "postgres" ]]; then
if [[ -z "$PSQL_USER" ]] || [[ -z "$PSQL_PASS" ]]; then
fatal "No Database Credentials for PostgreSQL given (parameters: 'PSQL_USER' 'PSQL_PASS'"
fi
fi
NGINX_IS_ENABLED=false
APACHE2_IS_ENABLED=false
# Get Webservice environment as IS_HTTPD_RUNNING, HTTP_USER, HTTP_GROUP..
#
source ${snippet_dir}/get-webservice-environment.sh
# Check PHP Version
#
source ${snippet_dir}/get-php-major-version.sh
# Get full qualified PHP command
#
source ${snippet_dir}/get-path-of-php-command.sh
# - Get available backup versions
# -
for _dir in $(ls -d ${WEB_BASE_DIR}/nextcloud-*) ; do
if [[ "$(basename "$_dir")" =~ ^nextcloud-[0-9]{1,2}\.[0-9]{1,2}\.[0-9]{1,2}\.[0-9]{4} ]]; then
_version="$(echo "$_dir"| grep -o -E "[0-9]{1,2}\.[0-9]{1,2}\.[0-9]{1,2}")"
_backup_date="$(echo "$_dir"| grep -o -E "[0-9]{4}-[0-9]{2}-[0-9]{2}-[0-9]{4}")"
if [[ -d "${WEB_BASE_DIR}/nextcloud-${_version}.${_backup_date}" ]] \
&& [[ -d "${WEB_BASE_DIR}/data-${_version}.${_backup_date}" ]] \
&& [[ -f "${WEB_BASE_DIR}/${DATABASE_NAME}-v${_version}.${_backup_date}.sql" ]]; then
nextcloud_version_arr+=("$(basename "${_dir}"):${_version}:${_backup_date}")
fi
fi
done
if [[ ${#nextcloud_version_arr[@]} -lt 1 ]] ; then
info "No old version present!"
clean_up 0
fi
echo ""
echo ""
echo -e "\033[37m\033[1mGoing to delete the folowing old NC installations:..\033[m"
echo ""
for _backup_version in ${nextcloud_version_arr[@]} ; do
IFS=':' read -a _arr <<< ${_backup_version}
echo " [$i] Version ${_arr[1]} from ${_arr[2]}"
((i++))
done
echo ""
echo -en "\t\033[33mType upper case 'YES' to continue with deleting ALL old NC installations\033[m: "
read OK
if [[ "$OK" = "YES" ]] ; then
echo ""
echo ""
echo ""
echo -e "\033[1;32mGoing to delete ALL old NC installations including data directories on \033[1;37m$WEBSITE \033[m"
else
fatal "Abort by user request - Answer as not 'YES'"
fi
for _backup_version in ${nextcloud_version_arr[@]} ; do
IFS=':' read -a _arr <<< ${_backup_version}
echo ""
echo ""
echo -e "\033[37m\033[1mGoing to delete the NC Version ${_arr[1]} saved on ${_arr[2]}..\033[m"
echo ""
echononl " Delete SQL file '${DATABASE_NAME}-v${_arr[1]}.${_arr[2]}.sql'"
if [[ -f "${WEB_BASE_DIR}/${DATABASE_NAME}-v${_arr[1]}.${_arr[2]}.sql" ]]; then
rm -f "${WEB_BASE_DIR}/${DATABASE_NAME}-v${_arr[1]}.${_arr[2]}.sql" > ${log_file} 2>&1
if [[ $? -eq 0 ]]; then
echo_ok
else
echo_failed
error "\n\n$(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 "Abbruch durch User"
blank_line
fi
else
echo_skipped
warn "SQL file '${DATABASE_NAME}-v${_arr[1]}.${_arr[2]}.sql' not found!"
fi
echononl " Delete data directory 'data-${_arr[1]}.${_arr[2]}'"
if [[ -d "${WEB_BASE_DIR}/data-${_arr[1]}.${_arr[2]}" ]]; then
rm -rf "${WEB_BASE_DIR}/data-${_arr[1]}.${_arr[2]}" > ${log_file} 2>&1
echo_wait
if [[ $? -eq 0 ]]; then
echo_ok
else
echo_failed
error "\n\n$(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 "Abbruch durch User"
blank_line
fi
else
echo_skipped
warn "Data directory '${WEB_BASE_DIR}/data-${_arr[1]}.${_arr[2]}' not found!"
fi
echononl " Delete NC install directory 'nextcloud-${_arr[1]}.${_arr[2]}'"
if [[ -d "${WEB_BASE_DIR}/nextcloud-${_arr[1]}.${_arr[2]}" ]]; then
rm -rf "${WEB_BASE_DIR}/nextcloud-${_arr[1]}.${_arr[2]}" > ${log_file} 2>&1
echo_wait
if [[ $? -eq 0 ]]; then
echo_ok
else
echo_failed
error "\n\n$(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 "Abbruch durch User"
blank_line
fi
else
echo_skipped
warn "NC install directory directory '${WEB_BASE_DIR}/nextcloud-${_arr[1]}.${_arr[2]}' not found!"
fi
done
clean_up 0

View File

@ -6,6 +6,7 @@ script_name="$(basename $(realpath $0))"
script_dir="$(dirname $(realpath $0))"
conf_dir="${script_dir}/conf"
snippet_dir="${script_dir}/snippets"
declare -a unsorted_website_arr
declare -a website_arr
@ -255,33 +256,9 @@ echo -e "Remove User from Group - \033[1mBoth, User and Group has to exist\033[m
echo -e "\033[32m-----\033[m"
WEBSITE=
_OK=false
echo ""
echo "Cloud instance that you want to change?"
echo ""
declare -i i=0
for _site in ${website_arr[@]} ; do
IFS=':' read -a _arr <<< ${_site}
echo " [$i] ${_arr[0]}"
((i++))
done
echo
echononl " Eingabe: "
while ! $_OK ; do
read _IN
if is_number "$_IN" && [[ -n ${website_arr[$_IN]} ]]; then
IFS=':' read -a _arr <<< ${website_arr[$_IN]}
conf_file=${_arr[1]}
DEFAULT_WEBSITE="${_arr[0]}"
_OK=true
else
echo ""
echo -e "\tFalsche Eingabe !"
echo ""
echononl " Eingabe: "
fi
done
# Which cloud instance (website) would you like to update
#
source ${snippet_dir}/get-cloud-instance-to-update.sh
# - Reset IFS
@ -344,110 +321,24 @@ if [[ "$DATABASE_TYPE" = "postgres" ]]; then
fi
fi
NGINX_IS_ENABLED=false
APACHE2_IS_ENABLED=false
# Check if NGINX webserver is ctive
# Get Webservice environment as IS_HTTPD_RUNNING, HTTP_USER, HTTP_GROUP..
#
if $(systemctl -q is-enabled nginx 2> /dev/null) ; then
source ${snippet_dir}/get-webservice-environment.sh
NGINX_IS_ENABLED=true
# - Determin user of the webserver
# -
nginx_binary="$(which nginx)"
if [[ -z "$nginx_binary" ]] ; then
nginx_binary="$(ps -axu | grep -E "nginx:.*master" | grep -v grep | grep -o -E "\S+/nginx")"
if [[ -z "$nginx_binary" ]] ; then
if [[ -x "/usr/local/nginx/bin/nginx" ]]; then
nginx_binary="/usr/local/nginx/bin/nginx"
elif [[ -x "/usr/local/nginx/sbin/nginx" ]]; then
nginx_binary="/usr/local/nginx/sbin/nginx"
fi
fi
fi
if [[ -x "$nginx_binary" ]] ; then
_HTTP_USER="$($nginx_binary -T 2> /dev/null | grep -E "^\s*user\s+\S+;" | grep -o -E "\S+;$" | sed -e 's/;$//')"
fi
# - Is webserver running ?
# -
PID=$(ps aux | grep "$(realpath $nginx_binary)" | grep -e "^root" | grep -v grep | awk '{print$2}')
if [[ "X${PID}X" = "XX" ]] ;then
IS_HTTPD_RUNNING=false
else
IS_HTTPD_RUNNING=true
fi
elif $(systemctl -q is-enabled apache2 2> /dev/null) ; then
APACHE2_IS_ENABLED=true
# - Determin user 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}')"
if [ -z "$httpd_binary" ]; then
if [ -x "/usr/local/apache2/bin/httpd" ]; then
httpd_binary="/usr/local/apache2/bin/httpd"
fi
fi
fi
if [ -x "$httpd_binary" ];then
# - Determin websever user
# -
_HTTP_USER="`$httpd_binary -t -D DUMP_RUN_CFG | grep -i -e "^User" | awk '{print$2}' | cut -d\"=\" -f2 | tr -d '"'`"
_HTTP_GROUP="`$httpd_binary -t -D DUMP_RUN_CFG | grep -i -e "^Group" | awk '{print$2}' | cut -d\"=\" -f2 | tr -d '"'`"
# - Is webserver running ?
# -
PID=$(ps aux | grep "$(realpath $httpd_binary)" | grep -e "^root" | grep -v grep | awk '{print$2}')
if [[ "X${PID}X" = "XX" ]] ;then
IS_HTTPD_RUNNING=false
else
IS_HTTPD_RUNNING=true
fi
fi
else
error "Neither \033[1mapache2\033[m nor \033[1mnginx\033[m is enabled on this machine"
echononl "continue anyway [yes/no]: "
read OK
OK="$(echo "$OK" | tr '[:upper:]' '[:lower:]')"
while [[ "$OK" != "yes" ]] && [[ "$OK" != "no" ]] ; do
echononl "Wrong entry! - repeat [yes/nno]: "
read OK
done
[[ $OK = "yes" ]] || fatal "Interrupted by user"
fi
if [[ -n "$_HTTP_USER" ]] ; then
if [[ -n "$HTTP_USER" ]] && [[ "$_HTTP_USER" != "$HTTP_USER" ]]; then
warn "The script has determined \033[1;37m${_HTTP_USER}\033[m as Webservers user. This\n value differs from the value given in your configuration file, \n which is \033[1;37m${HTTP_USER}\033[m and takes precedence."
else
HTTP_USER=$_HTTP_USER
fi
else
[[ -n "$HTTP_USER" ]] || HTTP_USER=$DEFAULT_HTTP_USER
fi
if [[ -n "$_HTTP_GROUP" ]] ; then
if [[ -n "$HTTP_GROUP" ]] && [[ "$_HTTP_GROUP" != "$HTTP_GROUP" ]]; then
warn "The script has determined \033[1;37m${_HTTP_GROUP}\033[m as Webservers group. This\n value differs from the value given in your configuration file, \n which is \033[1;37m${HTTP_GROUP}\033[m and takes precedence."
else
HTTP_GROUP=$_HTTP_GROUP
fi
else
[[ -n "$HTTP_GROUP" ]] || HTTP_GROUP=$DEFAULT_HTTP_GROUP
fi
# Check PHP Version
#
source ${script_dir}/snippet-get-php-major-version
source ${snippet_dir}/get-php-major-version.sh
# Get full qualified PHP command
#
source ${snippet_dir}/get-path-of-php-command.sh
CURRENT_INSTALL_DIR=`realpath ${WEB_BASE_DIR}/nextcloud`
CURRENT_DATA_DIR=`realpath ${WEB_BASE_DIR}/data`
@ -507,6 +398,8 @@ echo ""
echo -e " PHP version..........................: $PHP_VERSION"
echo -e " PHP Engine...........................: $PHP_ENGINE"
echo ""
echo -e " PHP command..........................: $PHP_BIN"
echo ""
echo -e " Databse name.........................: $DATABASE_NAME"
echo -e " Database type........................: $DATABASE_TYPE"
echo ""
@ -545,7 +438,7 @@ echo ""
# -
echononl " Remove user \033[37m\033[1m$USER\033[m from group \033[37m\033[1m$GROUP\033[m .."
su -c "/usr/local/php/bin/php ${WEB_BASE_DIR}/htdocs/occ group:removeuser '$GROUP' '$USER'" -s /bin/bash $HTTP_USER > $log_file 2>&1
su -c "${PHP_BIN} ${WEB_BASE_DIR}/htdocs/occ group:removeuser '$GROUP' '$USER'" -s /bin/bash $HTTP_USER > $log_file 2>&1
if [[ $? -eq 0 ]]; then
echo_ok
else
@ -553,7 +446,7 @@ else
blank_line
echo ""
echo -e "\033[37m\033[1mcommandline was:\033[m"
echo -e "su -c \"/usr/local/php/bin/php ${WEB_BASE_DIR}/htdocs/occ group:removeuser '$GROUP' '$USER'\" -s /bin/bash $HTTP_USER"
echo -e "su -c \"${PHP_BIN} ${WEB_BASE_DIR}/htdocs/occ group:removeuser '$GROUP' '$USER'\" -s /bin/bash $HTTP_USER"
blank_line
warn "Despite errors, it is possible that the user \033[37m\033[1m$USER\033[m was removed from the group \033[37m\033[1m$GROUP\033[m"
fatal "$(cat $log_file)"

View File

@ -6,6 +6,7 @@ script_name="$(basename $(realpath $0))"
script_dir="$(dirname $(realpath $0))"
conf_dir="${script_dir}/conf"
snippet_dir="${script_dir}/snippets"
declare -a unsorted_website_arr
declare -a website_arr
@ -213,37 +214,13 @@ clear
echo ""
echo -e "\033[32m-----\033[m"
echo "Create missing indices"
echo "Replace favicon icon"
echo -e "\033[32m-----\033[m"
WEBSITE=
_OK=false
echo ""
echo "Which site would you like to update?"
echo ""
declare -i i=0
for _site in ${website_arr[@]} ; do
IFS=':' read -a _arr <<< ${_site}
echo " [$i] ${_arr[0]}"
((i++))
done
echo
echononl " Eingabe: "
while ! $_OK ; do
read _IN
if is_number "$_IN" && [[ -n ${website_arr[$_IN]} ]]; then
IFS=':' read -a _arr <<< ${website_arr[$_IN]}
conf_file=${_arr[1]}
DEFAULT_WEBSITE="${_arr[0]}"
_OK=true
else
echo ""
echo -e "\tFalsche Eingabe !"
echo ""
echononl " Eingabe: "
fi
done
# Which cloud instance (website) would you like to update
#
source ${snippet_dir}/get-cloud-instance-to-update.sh
# - Reset IFS
@ -277,10 +254,6 @@ DEFAULT_HTTP_GROUP="www-data"
DEFAULT_PHP_ENGINE="FPM"
if [[ -z ${WEBSITE} ]] ; then
WEBSITE="$DEFAULT_WEBSITE"
fi
DEFAULT_WEB_BASE_DIR="/var/www/$WEBSITE"
[[ -n "$WEB_BASE_DIR" ]] || WEB_BASE_DIR=$DEFAULT_WEB_BASE_DIR
@ -309,110 +282,28 @@ if [[ "$DATABASE_TYPE" = "postgres" ]]; then
fi
fi
NGINX_IS_ENABLED=false
APACHE2_IS_ENABLED=false
# Check if NGINX webserver is ctive
# Get Webservice environment as IS_HTTPD_RUNNING, HTTP_USER, HTTP_GROUP..
#
if $(systemctl -q is-enabled nginx 2> /dev/null) ; then
source ${snippet_dir}/get-webservice-environment.sh
NGINX_IS_ENABLED=true
# - Determin user of the webserver
# -
nginx_binary="$(which nginx)"
if [[ -z "$nginx_binary" ]] ; then
nginx_binary="$(ps -axu | grep -E "nginx:.*master" | grep -v grep | grep -o -E "\S+/nginx")"
if [[ -z "$nginx_binary" ]] ; then
if [[ -x "/usr/local/nginx/bin/nginx" ]]; then
nginx_binary="/usr/local/nginx/bin/nginx"
elif [[ -x "/usr/local/nginx/sbin/nginx" ]]; then
nginx_binary="/usr/local/nginx/sbin/nginx"
fi
fi
fi
if [[ -x "$nginx_binary" ]] ; then
_HTTP_USER="$($nginx_binary -T 2> /dev/null | grep -E "^\s*user\s+\S+;" | grep -o -E "\S+;$" | sed -e 's/;$//')"
fi
# - Is webserver running ?
# -
PID=$(ps aux | grep "$(realpath $nginx_binary)" | grep -e "^root" | grep -v grep | awk '{print$2}')
if [[ "X${PID}X" = "XX" ]] ;then
IS_HTTPD_RUNNING=false
else
IS_HTTPD_RUNNING=true
fi
elif $(systemctl -q is-enabled apache2 2> /dev/null) ; then
APACHE2_IS_ENABLED=true
# - Determin user 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}')"
if [ -z "$httpd_binary" ]; then
if [ -x "/usr/local/apache2/bin/httpd" ]; then
httpd_binary="/usr/local/apache2/bin/httpd"
fi
fi
fi
if [ -x "$httpd_binary" ];then
# - Determin websever user
# -
_HTTP_USER="`$httpd_binary -t -D DUMP_RUN_CFG | grep -i -e "^User" | awk '{print$2}' | cut -d\"=\" -f2 | tr -d '"'`"
_HTTP_GROUP="`$httpd_binary -t -D DUMP_RUN_CFG | grep -i -e "^Group" | awk '{print$2}' | cut -d\"=\" -f2 | tr -d '"'`"
# - Is webserver running ?
# -
PID=$(ps aux | grep "$(realpath $httpd_binary)" | grep -e "^root" | grep -v grep | awk '{print$2}')
if [[ "X${PID}X" = "XX" ]] ;then
IS_HTTPD_RUNNING=false
else
IS_HTTPD_RUNNING=true
fi
fi
else
error "Neither \033[1mapache2\033[m nor \033[1mnginx\033[m is enabled on this machine"
echononl "continue anyway [yes/no]: "
read OK
OK="$(echo "$OK" | tr '[:upper:]' '[:lower:]')"
while [[ "$OK" != "yes" ]] && [[ "$OK" != "no" ]] ; do
echononl "Wrong entry! - repeat [yes/nno]: "
read OK
done
[[ $OK = "yes" ]] || fatal "Interrupted by user"
fi
if [[ -n "$_HTTP_USER" ]] ; then
if [[ -n "$HTTP_USER" ]] && [[ "$_HTTP_USER" != "$HTTP_USER" ]]; then
warn "The script has determined \033[1;37m${_HTTP_USER}\033[m as Webservers user. This\n value differs from the value given in your configuration file, \n which is \033[1;37m${HTTP_USER}\033[m and takes precedence."
else
HTTP_USER=$_HTTP_USER
fi
else
[[ -n "$HTTP_USER" ]] || HTTP_USER=$DEFAULT_HTTP_USER
fi
if [[ -n "$_HTTP_GROUP" ]] ; then
if [[ -n "$HTTP_GROUP" ]] && [[ "$_HTTP_GROUP" != "$HTTP_GROUP" ]]; then
warn "The script has determined \033[1;37m${_HTTP_GROUP}\033[m as Webservers group. This\n value differs from the value given in your configuration file, \n which is \033[1;37m${HTTP_GROUP}\033[m and takes precedence."
else
HTTP_GROUP=$_HTTP_GROUP
fi
else
[[ -n "$HTTP_GROUP" ]] || HTTP_GROUP=$DEFAULT_HTTP_GROUP
fi
# Check PHP Version
#
source ${script_dir}/snippet-get-php-major-version
source ${snippet_dir}/get-php-major-version.sh
# Get full qualified PHP command
#
source ${snippet_dir}/get-path-of-php-command.sh
if [[ ! -x "$PHP_BIN" ]]; then
fatal "No PHP binary found!"
fi
echo ""
echo -e " \033[32m--\033[m"
@ -466,6 +357,8 @@ echo -e " Webserver group......................: $HTTP_GROUP"
echo ""
echo -e " PHP version..........................: $PHP_VERSION"
echo -e " PHP Engine...........................: $PHP_ENGINE"
echo ""
echo -e " PHP Command..........................: $PHP_BIN"
echo ""
echo -n " Type upper case 'YES' to continue executing with this parameters: "
@ -495,7 +388,7 @@ echo ""
# - Create missing indices
# -
echononl " Replace Favicon Icon with \033[1m$(basename ${CUSTOM_FAVICON_PATH})\033[m .."
su -c "/usr/local/php/bin/php ${WEB_BASE_DIR}/htdocs/occ theming:config favicon ${CUSTOM_FAVICON_PATH}" \
su -c "${PHP_BIN} ${WEB_BASE_DIR}/htdocs/occ theming:config favicon ${CUSTOM_FAVICON_PATH}" \
-s /bin/bash $HTTP_USER > $log_file 2>&1
if [[ $? -eq 0 ]]; then
echo_ok

View File

@ -6,6 +6,7 @@ script_name="$(basename $(realpath $0))"
script_dir="$(dirname $(realpath $0))"
conf_dir="${script_dir}/conf"
snippet_dir="${script_dir}/snippets"
declare -a unsorted_website_arr
declare -a website_arr
@ -217,33 +218,19 @@ echo "Create missing indices"
echo -e "\033[32m-----\033[m"
WEBSITE=
_OK=false
echo ""
echo "Which site would you like to update?"
echo ""
declare -i i=0
for _site in ${website_arr[@]} ; do
IFS=':' read -a _arr <<< ${_site}
echo " [$i] ${_arr[0]}"
((i++))
done
echo
echononl " Eingabe: "
while ! $_OK ; do
read _IN
if is_number "$_IN" && [[ -n ${website_arr[$_IN]} ]]; then
IFS=':' read -a _arr <<< ${website_arr[$_IN]}
conf_file=${_arr[1]}
DEFAULT_WEBSITE="${_arr[0]}"
_OK=true
else
echo ""
echo -e "\tFalsche Eingabe !"
echo ""
echononl " Eingabe: "
fi
done
# Which cloud instance (website) would you like to update
#
source ${snippet_dir}/get-cloud-instance-to-update.sh
# Check PHP Version
#
source ${snippet_dir}/get-php-major-version.sh
# Get full qualified PHP command
#
source ${snippet_dir}/get-path-of-php-command.sh
# - Reset IFS
@ -277,10 +264,6 @@ DEFAULT_HTTP_GROUP="www-data"
DEFAULT_PHP_ENGINE="FPM"
if [[ -z ${WEBSITE} ]] ; then
WEBSITE="$DEFAULT_WEBSITE"
fi
DEFAULT_WEB_BASE_DIR="/var/www/$WEBSITE"
[[ -n "$WEB_BASE_DIR" ]] || WEB_BASE_DIR=$DEFAULT_WEB_BASE_DIR
@ -309,110 +292,23 @@ if [[ "$DATABASE_TYPE" = "postgres" ]]; then
fi
fi
NGINX_IS_ENABLED=false
APACHE2_IS_ENABLED=false
# Check if NGINX webserver is ctive
# Get Webservice environment as IS_HTTPD_RUNNING, HTTP_USER, HTTP_GROUP..
#
if $(systemctl -q is-enabled nginx 2> /dev/null) ; then
source ${snippet_dir}/get-webservice-environment.sh
NGINX_IS_ENABLED=true
# - Determin user of the webserver
# -
nginx_binary="$(which nginx)"
if [[ -z "$nginx_binary" ]] ; then
nginx_binary="$(ps -axu | grep -E "nginx:.*master" | grep -v grep | grep -o -E "\S+/nginx")"
if [[ -z "$nginx_binary" ]] ; then
if [[ -x "/usr/local/nginx/bin/nginx" ]]; then
nginx_binary="/usr/local/nginx/bin/nginx"
elif [[ -x "/usr/local/nginx/sbin/nginx" ]]; then
nginx_binary="/usr/local/nginx/sbin/nginx"
fi
fi
fi
if [[ -x "$nginx_binary" ]] ; then
_HTTP_USER="$($nginx_binary -T 2> /dev/null | grep -E "^\s*user\s+\S+;" | grep -o -E "\S+;$" | sed -e 's/;$//')"
fi
# - Is webserver running ?
# -
PID=$(ps aux | grep "$(realpath $nginx_binary)" | grep -e "^root" | grep -v grep | awk '{print$2}')
if [[ "X${PID}X" = "XX" ]] ;then
IS_HTTPD_RUNNING=false
else
IS_HTTPD_RUNNING=true
fi
elif $(systemctl -q is-enabled apache2 2> /dev/null) ; then
APACHE2_IS_ENABLED=true
# - Determin user 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}')"
if [ -z "$httpd_binary" ]; then
if [ -x "/usr/local/apache2/bin/httpd" ]; then
httpd_binary="/usr/local/apache2/bin/httpd"
fi
fi
fi
if [ -x "$httpd_binary" ];then
# - Determin websever user
# -
_HTTP_USER="`$httpd_binary -t -D DUMP_RUN_CFG | grep -i -e "^User" | awk '{print$2}' | cut -d\"=\" -f2 | tr -d '"'`"
_HTTP_GROUP="`$httpd_binary -t -D DUMP_RUN_CFG | grep -i -e "^Group" | awk '{print$2}' | cut -d\"=\" -f2 | tr -d '"'`"
# - Is webserver running ?
# -
PID=$(ps aux | grep "$(realpath $httpd_binary)" | grep -e "^root" | grep -v grep | awk '{print$2}')
if [[ "X${PID}X" = "XX" ]] ;then
IS_HTTPD_RUNNING=false
else
IS_HTTPD_RUNNING=true
fi
fi
else
error "Neither \033[1mapache2\033[m nor \033[1mnginx\033[m is enabled on this machine"
echononl "continue anyway [yes/no]: "
read OK
OK="$(echo "$OK" | tr '[:upper:]' '[:lower:]')"
while [[ "$OK" != "yes" ]] && [[ "$OK" != "no" ]] ; do
echononl "Wrong entry! - repeat [yes/nno]: "
read OK
done
[[ $OK = "yes" ]] || fatal "Interrupted by user"
fi
if [[ -n "$_HTTP_USER" ]] ; then
if [[ -n "$HTTP_USER" ]] && [[ "$_HTTP_USER" != "$HTTP_USER" ]]; then
warn "The script has determined \033[1;37m${_HTTP_USER}\033[m as Webservers user. This\n value differs from the value given in your configuration file, \n which is \033[1;37m${HTTP_USER}\033[m and takes precedence."
else
HTTP_USER=$_HTTP_USER
fi
else
[[ -n "$HTTP_USER" ]] || HTTP_USER=$DEFAULT_HTTP_USER
fi
if [[ -n "$_HTTP_GROUP" ]] ; then
if [[ -n "$HTTP_GROUP" ]] && [[ "$_HTTP_GROUP" != "$HTTP_GROUP" ]]; then
warn "The script has determined \033[1;37m${_HTTP_GROUP}\033[m as Webservers group. This\n value differs from the value given in your configuration file, \n which is \033[1;37m${HTTP_GROUP}\033[m and takes precedence."
else
HTTP_GROUP=$_HTTP_GROUP
fi
else
[[ -n "$HTTP_GROUP" ]] || HTTP_GROUP=$DEFAULT_HTTP_GROUP
fi
# Check PHP Version
#
source ${script_dir}/snippet-get-php-major-version
source ${snippet_dir}/get-php-major-version.sh
# Get full qualified PHP command
#
source ${snippet_dir}/get-path-of-php-command.sh
echo ""
@ -467,6 +363,8 @@ echo -e " Webserver group......................: $HTTP_GROUP"
echo ""
echo -e " PHP version..........................: $PHP_VERSION"
echo -e " PHP Engine...........................: $PHP_ENGINE"
echo ""
echo -e " PHP Command..........................: $PHP_BIN"
echo ""
echo -n " Type upper case 'YES' to continue executing with this parameters: "
@ -496,7 +394,7 @@ echo ""
# - Create missing indices
# -
echononl " Replace Logo with \033[1m$(basename ${CUSTOM_LOGO_PATH})\033[m .."
su -c "/usr/local/php/bin/php ${WEB_BASE_DIR}/htdocs/occ theming:config logo ${CUSTOM_LOGO_PATH}" \
su -c "${PHP_BIN} ${WEB_BASE_DIR}/htdocs/occ theming:config logo ${CUSTOM_LOGO_PATH}" \
-s /bin/bash $HTTP_USER > $log_file 2>&1
if [[ $? -eq 0 ]]; then
echo_ok

View File

@ -6,6 +6,7 @@ script_name="$(basename $(realpath $0))"
script_dir="$(dirname $(realpath $0))"
conf_dir="${script_dir}/conf"
snippet_dir="${script_dir}/snippets"
declare -a unsorted_website_arr
declare -a website_arr
@ -99,7 +100,7 @@ echo_skipped() {
}
echo_wait(){
if $terminal ; then
echo -en "\033[75G[ \033[5m\033[1m...\033[m ]"
echo -en "\033[75G[ \033[5m\033[1m..\033[m ]"
fi
}
fatal (){
@ -222,32 +223,9 @@ echo "Update Nextcloud"
echo -e "\033[32m-----\033[m"
WEBSITE=
_OK=false
echo ""
echo "Which site would you like to restore?"
echo ""
declare -i i=0
for _site in ${website_arr[@]} ; do
IFS=':' read -a _arr <<< ${_site}
echo " [$i] ${_arr[0]}"
((i++))
done
echo
echononl " Eingabe: "
while ! $_OK ; do
read _IN
if is_number "$_IN" && [[ -n ${website_arr[$_IN]} ]]; then
IFS=':' read -a _arr <<< ${website_arr[$_IN]}
conf_file=${_arr[1]}
_OK=true
else
echo ""
echo -e "\tFalsche Eingabe !"
echo ""
echononl " Eingabe: "
fi
done
# Which cloud instance (website) would you like to update
#
source ${snippet_dir}/get-cloud-instance-to-update.sh
# - Reset IFS
@ -309,149 +287,23 @@ if [[ "$DATABASE_TYPE" = "postgres" ]]; then
fi
fi
NGINX_IS_ENABLED=false
APACHE2_IS_ENABLED=false
# Check if NGINX webserver is ctive
# Get Webservice environment as IS_HTTPD_RUNNING, HTTP_USER, HTTP_GROUP..
#
if $(systemctl -q is-enabled nginx 2> /dev/null) ; then
NGINX_IS_ENABLED=true
# - Determin user of the webserver
# -
nginx_binary="$(which nginx)"
if [[ -z "$nginx_binary" ]] ; then
nginx_binary="$(ps -axu | grep -E "nginx:.*master" | grep -v grep | grep -o -E "\S+/nginx")"
if [[ -z "$nginx_binary" ]] ; then
if [[ -x "/usr/local/nginx/bin/nginx" ]]; then
nginx_binary="/usr/local/nginx/bin/nginx"
elif [[ -x "/usr/local/nginx/sbin/nginx" ]]; then
nginx_binary="/usr/local/nginx/sbin/nginx"
fi
fi
fi
if [[ -x "$nginx_binary" ]] ; then
_HTTP_USER="$($nginx_binary -T 2> /dev/null | grep -E "^\s*user\s+\S+;" | grep -o -E "\S+;$" | sed -e 's/;$//')"
fi
# - Is webserver running ?
# -
PID=$(ps aux | grep "$(realpath $nginx_binary)" | grep -e "^root" | grep -v grep | awk '{print$2}')
if [[ "X${PID}X" = "XX" ]] ;then
IS_HTTPD_RUNNING=false
else
IS_HTTPD_RUNNING=true
fi
elif $(systemctl -q is-enabled apache2 2> /dev/null) ; then
APACHE2_IS_ENABLED=true
# - Determin user 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}')"
if [ -z "$httpd_binary" ]; then
if [ -x "/usr/local/apache2/bin/httpd" ]; then
httpd_binary="/usr/local/apache2/bin/httpd"
fi
fi
fi
if [ -x "$httpd_binary" ];then
# - Determin websever user
# -
_HTTP_USER="`$httpd_binary -t -D DUMP_RUN_CFG | grep -i -e "^User" | awk '{print$2}' | cut -d\"=\" -f2 | tr -d '"'`"
# - Is webserver running ?
# -
PID=$(ps aux | grep "$(realpath $httpd_binary)" | grep -e "^root" | grep -v grep | awk '{print$2}')
if [[ "X${PID}X" = "XX" ]] ;then
IS_HTTPD_RUNNING=false
else
IS_HTTPD_RUNNING=true
fi
fi
else
error "Neither \033[1mapache2\033[m nor \033[1mnginx\033[m is enabled on this machine"
echononl "continue anyway [yes/no]: "
read OK
OK="$(echo "$OK" | tr '[:upper:]' '[:lower:]')"
while [[ "$OK" != "yes" ]] && [[ "$OK" != "no" ]] ; do
echononl "Wrong entry! - repeat [yes/nno]: "
read OK
done
[[ $OK = "yes" ]] || fatal "Interrupted by user"
fi
if [[ -n "$_HTTP_USER" ]] ; then
if [[ -n "$HTTP_USER" ]] && [[ "$_HTTP_USER" != "$HTTP_USER" ]]; then
warn "The script has determined \033[1;37m${_HTTP_USER}\033[m as Webservers user. This\n value differs from the value given in your configuration file, \n which is \033[1;37m${HTTP_USER}\033[m and takes precedence."
else
HTTP_USER=$_HTTP_USER
fi
else
[[ -n "$HTTP_USER" ]] || HTTP_USER=$DEFAULT_HTTP_USER
fi
source ${snippet_dir}/get-webservice-environment.sh
# Check PHP Version
#
if [[ "$PHP_ENGINE" = "FPM" ]] ; then
if [[ -z "$PHP_VERSION" ]] ; then
if [[ -z "$VHOST_CONFIG_FILE" ]] ; then
if $NGINX_IS_ENABLED ; then
if [[ -f "/etc/nginx/sites-enabled/${WEBSITE}.conf" ]] ; then
VHOST_CONFIG_FILE=""
fi
elif $APACHE2_IS_ENABLED ; then
if [[ -f "/usr/local/apache2/conf/vhosts/${WEBSITE}.conf.php-fpm" ]] ; then
VHOST_CONFIG_FILE="/usr/local/apache2/conf/vhosts/${WEBSITE}.conf.php-fpm"
elif [[ -f "/usr/local/apache2/conf/vhosts/${WEBSITE}.conf" ]] ; then
VHOST_CONFIG_FILE="/usr/local/apache2/conf/vhosts/${WEBSITE}.conf"
elif [[ -f "/etc/apache2/sites-enabled/${WEBSITE}.conf" ]] ; then
VHOST_CONFIG_FILE="/etc/apache2/sites-enabled/${WEBSITE}.conf"
fi
fi
fi
PHP_VERSION="$(grep -o -E "php-?.{1}\..{1}-fpm" $VHOST_CONFIG_FILE | grep -o -E ".{1}\..{1}")"
if [[ -z "$PHP_VERSION" ]] ; then
fatal "PHP Version must be givven if running PHP-FPM engine (parameter 'PHP_VERSION')"
fi
fi
fi
source ${snippet_dir}/get-php-major-version.sh
# - Determin PHP binary
# -
if [[ -x "/usr/local/php-${PHP_VERSION}/bin/php" ]] ; then
php_binary="/usr/local/php-${PHP_VERSION}/bin/php"
else
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
fi
# Get full qualified PHP command
#
source ${snippet_dir}/get-path-of-php-command.sh
@ -503,7 +355,7 @@ read _IN
done
CURRENT_INSTALL_DIR=`realpath ${WEB_BASE_DIR}/nextcloud`
CURRENT_VERSION="$(sudo -u $HTTP_USER $php_binary ${WEB_BASE_DIR}/htdocs/occ --version | cut -d' ' -f2)"
CURRENT_VERSION="$(sudo -u $HTTP_USER ${PHP_BIN} ${WEB_BASE_DIR}/htdocs/occ --version | cut -d' ' -f2)"
DATA_DIR=${WEB_BASE_DIR}/data
@ -521,7 +373,8 @@ echo -e " Webserver user.......................: $HTTP_USER"
echo ""
echo -e " PHP version..........................: $PHP_VERSION"
echo -e " PHP Engine...........................: $PHP_ENGINE"
echo -e " PHP binary...........................: $php_binary"
echo ""
echo -e " PHP Command..........................: $PHP_BIN"
echo ""
echo -e " Version to rstore....................: $RESTORE_VERSION"
echo -e " Backup date was......................: $DATE_RESTORE_VERSION"
@ -762,7 +615,7 @@ if [[ "$DATABASE_TYPE" = 'mysql' ]]; then
if $_failed ; then
echo_failed
error "$(cat $log_file)"
error "\n\n$(cat $log_file)"
if [[ ${#_tables_not_deleted[@]} -gt 0 ]] ; then
echo ""
@ -772,9 +625,21 @@ if [[ "$DATABASE_TYPE" = 'mysql' ]]; then
done
echo ""
fi
else
echo_ok
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 "Abbruch durch User"
blank_line
else
echo_ok
fi
fi
@ -874,7 +739,7 @@ fi
# - Restore Database
# -
echononl " Restore Database - \033[5m\033[1mmay take a long time\033[m"
echononl " Restore Database \033[5m\033[1mmay take a long time\033[m"
echo_wait
if [[ "$DATABASE_TYPE" = 'mysql' ]]; then
mysql $MYSQL_CREDENTIALS $DATABASE_NAME < \
@ -931,8 +796,90 @@ fi
echo ""
echo ""
echo -e "\033[37m\033[1mDoing some post-script tasks..\033[m"
echo ""
# - Add missing columns
# -
echononl " Add missing columns .."
su -c "${PHP_BIN} ${WEB_BASE_DIR}/htdocs/occ db:add-missing-columns" -s /bin/bash $HTTP_USER > $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
# - Create missing indices
# -
echononl " Add missing indices .."
su -c "${PHP_BIN} ${WEB_BASE_DIR}/htdocs/occ db:add-missing-indices" -s /bin/bash $HTTP_USER > $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
# - Add missing primary keys ..
# -
echononl " Add missing primary keys .."
su -c "${PHP_BIN} ${WEB_BASE_DIR}/htdocs/occ db:add-missing-primary-keys" -s /bin/bash $HTTP_USER > $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 " Run cronjob manually.."
su -c "${PHP_BIN} ${WEB_BASE_DIR}/htdocs/cron.php" -s /bin/bash $HTTP_USER > $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
blank_line
echononl " Restart PHP engine.."
if [[ "$PHP_ENGINE" = "FPM" ]]; then
if $SYSTEMD_EXISTS ; then

View File

@ -0,0 +1,36 @@
WEBSITE=
_OK=false
declare -i i=0
if [[ ${#website_arr[@]} -eq 1 ]] ; then
IFS=':' read -a _arr <<< ${website_arr[0]}
conf_file=${_arr[1]}
WEBSITE=${_arr[0]}
echo ""
echo -e "Update site \033[1m${_arr[0]}"
echo ""
else
echo ""
echo "Which site would you like to update?"
echo ""
for _site in ${website_arr[@]} ; do
IFS=':' read -a _arr <<< ${_site}
echo " [$i] ${_arr[0]}"
((i++))
done
echo
echononl " Eingabe: "
while ! $_OK ; do
read _IN
if is_number "$_IN" && [[ -n ${website_arr[$_IN]} ]]; then
IFS=':' read -a _arr <<< ${website_arr[$_IN]}
conf_file=${_arr[1]}
WEBSITE=${_arr[0]}
_OK=true
else
echo ""
echo -e "\tFalsche Eingabe !"
echo ""
echononl " Eingabe: "
fi
done
fi

View File

@ -0,0 +1,7 @@
if [[ -x "/usr/local/php-${PHP_VERSION}/bin/php" ]] ; then
PHP_BIN="/usr/local/php-${PHP_VERSION}/bin/php"
elif [[ -x "$(realpath /usr/local/php/bin/php)" ]]; then
PHP_BIN="/usr/local/php/bin/php"
else
PHP_BIN="$(which php)"
fi

View File

View File

@ -0,0 +1,97 @@
if $(systemctl -q is-enabled nginx 2> /dev/null) ; then
NGINX_IS_ENABLED=true
# - Determin user of the webserver
# -
nginx_binary="$(which nginx)"
if [[ -z "$nginx_binary" ]] ; then
nginx_binary="$(ps -axu | grep -E "nginx:.*master" | grep -v grep | grep -o -E "\S+/nginx")"
if [[ -z "$nginx_binary" ]] ; then
if [[ -x "/usr/local/nginx/bin/nginx" ]]; then
nginx_binary="/usr/local/nginx/bin/nginx"
elif [[ -x "/usr/local/nginx/sbin/nginx" ]]; then
nginx_binary="/usr/local/nginx/sbin/nginx"
fi
fi
fi
if [[ -x "$nginx_binary" ]] ; then
_HTTP_USER="$($nginx_binary -T 2> /dev/null | grep -E "^\s*user\s+\S+;" | grep -o -E "\S+;$" | sed -e 's/;$//')"
fi
# - Is webserver running ?
# -
PID=$(ps aux | grep "$(realpath $nginx_binary)" | grep -e "^root" | grep -v grep | awk '{print$2}')
if [[ "X${PID}X" = "XX" ]] ;then
IS_HTTPD_RUNNING=false
else
IS_HTTPD_RUNNING=true
fi
elif $(systemctl -q is-enabled apache2 2> /dev/null) ; then
APACHE2_IS_ENABLED=true
# - Determin user 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}')"
if [ -z "$httpd_binary" ]; then
if [ -x "/usr/local/apache2/bin/httpd" ]; then
httpd_binary="/usr/local/apache2/bin/httpd"
fi
fi
fi
if [ -x "$httpd_binary" ];then
# - Determin websever user
# -
_HTTP_USER="`$httpd_binary -t -D DUMP_RUN_CFG | grep -i -e "^User" | awk '{print$2}' | cut -d\"=\" -f2 | tr -d '"'`"
_HTTP_GROUP="`$httpd_binary -t -D DUMP_RUN_CFG | grep -i -e "^Group" | awk '{print$2}' | cut -d\"=\" -f2 | tr -d '"'`"
# - Is webserver running ?
# -
PID=$(ps aux | grep "$(realpath $httpd_binary)" | grep -e "^root" | grep -v grep | awk '{print$2}')
if [[ "X${PID}X" = "XX" ]] ;then
IS_HTTPD_RUNNING=false
else
IS_HTTPD_RUNNING=true
fi
fi
else
error "Neither \033[1mapache2\033[m nor \033[1mnginx\033[m is enabled on this machine"
echononl "continue anyway [yes/no]: "
read OK
OK="$(echo "$OK" | tr '[:upper:]' '[:lower:]')"
while [[ "$OK" != "yes" ]] && [[ "$OK" != "no" ]] ; do
echononl "Wrong entry! - repeat [yes/nno]: "
read OK
done
[[ $OK = "yes" ]] || fatal "Interrupted by user"
fi
if [[ -n "$_HTTP_USER" ]] ; then
if [[ -n "$HTTP_USER" ]] && [[ "$_HTTP_USER" != "$HTTP_USER" ]]; then
warn "The script has determined \033[1;37m${_HTTP_USER}\033[m as Webservers user. This\n value differs from the value given in your configuration file, \n which is \033[1;37m${HTTP_USER}\033[m and takes precedence."
else
HTTP_USER=$_HTTP_USER
fi
else
[[ -n "$HTTP_USER" ]] || HTTP_USER=$DEFAULT_HTTP_USER
fi
if [[ -n "$_HTTP_GROUP" ]] ; then
if [[ -n "$HTTP_GROUP" ]] && [[ "$_HTTP_GROUP" != "$HTTP_GROUP" ]]; then
warn "The script has determined \033[1;37m${_HTTP_GROUP}\033[m as Webservers group. This\n value differs from the value given in your configuration file, \n which is \033[1;37m${HTTP_GROUP}\033[m and takes precedence."
else
HTTP_GROUP=$_HTTP_GROUP
fi
else
[[ -n "$HTTP_GROUP" ]] || HTTP_GROUP=$HTTP_USER
fi

View File

@ -6,6 +6,7 @@ script_name="$(basename $(realpath $0))"
script_dir="$(dirname $(realpath $0))"
conf_dir="${script_dir}/conf"
snippet_dir="${script_dir}/snippets"
declare -a unsorted_website_arr
declare -a website_arr
@ -98,6 +99,12 @@ echo_skipped() {
echo " [ skipped ]"
fi
}
echo_wait(){
if $terminal ; then
echo -en "\033[75G[ \033[5m\033[1m..\033[m ]"
fi
}
fatal (){
echo ""
echo ""
@ -246,32 +253,14 @@ echo "Update Nextcloud"
echo -e "\033[32m-----\033[m"
WEBSITE=
_OK=false
echo ""
echo "Which site would you like to update?"
echo ""
declare -i i=0
for _site in ${website_arr[@]} ; do
IFS=':' read -a _arr <<< ${_site}
echo " [$i] ${_arr[0]}"
((i++))
done
echo
echononl " Eingabe: "
while ! $_OK ; do
read _IN
if is_number "$_IN" && [[ -n ${website_arr[$_IN]} ]]; then
IFS=':' read -a _arr <<< ${website_arr[$_IN]}
conf_file=${_arr[1]}
_OK=true
else
echo ""
echo -e "\tFalsche Eingabe !"
echo ""
echononl " Eingabe: "
fi
done
# Which cloud instance (website) would you like to update
#
source ${snippet_dir}/get-cloud-instance-to-update.sh
# Get full qualified PHP command
#
source ${snippet_dir}/get-path-of-php-command.sh
# - Reset IFS
@ -394,147 +383,34 @@ if [[ "$DATABASE_TYPE" = "postgres" ]]; then
fi
fi
NGINX_IS_ENABLED=false
APACHE2_IS_ENABLED=false
# Check if NGINX webserver is ctive
# Get Webservice environment as IS_HTTPD_RUNNING, HTTP_USER, HTTP_GROUP..
#
if $(systemctl -q is-enabled nginx 2> /dev/null) ; then
NGINX_IS_ENABLED=true
# - Determin user of the webserver
# -
nginx_binary="$(which nginx)"
if [[ -z "$nginx_binary" ]] ; then
nginx_binary="$(ps -axu | grep -E "nginx:.*master" | grep -v grep | grep -o -E "\S+/nginx")"
if [[ -z "$nginx_binary" ]] ; then
if [[ -x "/usr/local/nginx/bin/nginx" ]]; then
nginx_binary="/usr/local/nginx/bin/nginx"
elif [[ -x "/usr/local/nginx/sbin/nginx" ]]; then
nginx_binary="/usr/local/nginx/sbin/nginx"
fi
fi
fi
if [[ -x "$nginx_binary" ]] ; then
_HTTP_USER="$($nginx_binary -T 2> /dev/null | grep -E "^\s*user\s+\S+;" | grep -o -E "\S+;$" | sed -e 's/;$//')"
fi
# - Is webserver running ?
# -
PID=$(ps aux | grep "$(realpath $nginx_binary)" | grep -e "^root" | grep -v grep | awk '{print$2}')
if [[ "X${PID}X" = "XX" ]] ;then
IS_HTTPD_RUNNING=false
else
IS_HTTPD_RUNNING=true
fi
elif $(systemctl -q is-enabled apache2 2> /dev/null) ; then
APACHE2_IS_ENABLED=true
# - Determin user 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}')"
if [ -z "$httpd_binary" ]; then
if [ -x "/usr/local/apache2/bin/httpd" ]; then
httpd_binary="/usr/local/apache2/bin/httpd"
fi
fi
fi
if [ -x "$httpd_binary" ];then
# - Determin websever user
# -
_HTTP_USER="`$httpd_binary -t -D DUMP_RUN_CFG | grep -i -e "^User" | awk '{print$2}' | cut -d\"=\" -f2 | tr -d '"'`"
_HTTP_GROUP="`$httpd_binary -t -D DUMP_RUN_CFG | grep -i -e "^Group" | awk '{print$2}' | cut -d\"=\" -f2 | tr -d '"'`"
# - Is webserver running ?
# -
PID=$(ps aux | grep "$(realpath $httpd_binary)" | grep -e "^root" | grep -v grep | awk '{print$2}')
if [[ "X${PID}X" = "XX" ]] ;then
IS_HTTPD_RUNNING=false
else
IS_HTTPD_RUNNING=true
fi
fi
else
error "Neither \033[1mapache2\033[m nor \033[1mnginx\033[m is enabled on this machine"
echononl "continue anyway [yes/no]: "
read OK
OK="$(echo "$OK" | tr '[:upper:]' '[:lower:]')"
while [[ "$OK" != "yes" ]] && [[ "$OK" != "no" ]] ; do
echononl "Wrong entry! - repeat [yes/nno]: "
read OK
done
[[ $OK = "yes" ]] || fatal "Interrupted by user"
fi
if [[ -n "$_HTTP_USER" ]] ; then
if [[ -n "$HTTP_USER" ]] && [[ "$_HTTP_USER" != "$HTTP_USER" ]]; then
warn "The script has determined \033[1;37m${_HTTP_USER}\033[m as Webservers user. This\n value differs from the value given in your configuration file, \n which is \033[1;37m${HTTP_USER}\033[m and takes precedence."
else
HTTP_USER=$_HTTP_USER
fi
else
[[ -n "$HTTP_USER" ]] || HTTP_USER=$DEFAULT_HTTP_USER
fi
if [[ -n "$_HTTP_GROUP" ]] ; then
if [[ -n "$HTTP_GROUP" ]] && [[ "$_HTTP_GROUP" != "$HTTP_GROUP" ]]; then
warn "The script has determined \033[1;37m${_HTTP_GROUP}\033[m as Webservers group. This\n value differs from the value given in your configuration file, \n which is \033[1;37m${HTTP_GROUP}\033[m and takes precedence."
else
HTTP_GROUP=$_HTTP_GROUP
fi
else
[[ -n "$HTTP_GROUP" ]] || HTTP_GROUP=$HTTP_USER
fi
source ${snippet_dir}/get-webservice-environment.sh
# Check PHP Version
#
source ${script_dir}/snippet-get-php-major-version
source ${snippet_dir}/get-php-major-version.sh
# - Determin PHP binary
# -
if [[ -x "/usr/local/php-${PHP_VERSION}/bin/php" ]] ; then
php_binary="/usr/local/php-${PHP_VERSION}/bin/php"
else
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
fi
# Get full qualified PHP command
#
source ${snippet_dir}/get-path-of-php-command.sh
# ---
INSTALL_DIR="${WEB_BASE_DIR}/nextcloud-${VERSION}"
CURRENT_INSTALL_DIR="$(realpath ${WEB_BASE_DIR}/nextcloud)"
#PRIOR_VERSION="$(basename $CURRENT_INSTALL_DIR | cut -d"-" -f2)"
PRIOR_VERSION="$(sudo -u $HTTP_USER /usr/local/php/bin/php ${WEB_BASE_DIR}/htdocs/occ --version | cut -d' ' -f2)"
PRIOR_VERSION="$(sudo -u $HTTP_USER ${PHP_BIN} ${WEB_BASE_DIR}/htdocs/occ --version | cut -d' ' -f2)"
#DATA_DIR=${WEB_BASE_DIR}/data-${VERSION}
#CURRENT_DATA_DIR="$(realpath ${WEB_BASE_DIR}/data-$PRIOR_VERSION)"
DATA_DIR=${WEB_BASE_DIR}/data
OLD_DATA_DIR=${WEB_BASE_DIR}/data-${PRIOR_VERSION}
DATA_DIR="$(realpath "${WEB_BASE_DIR}/data")"
OLD_DATA_DIR="$(dirname "${DATA_DIR}")/data-${PRIOR_VERSION}.${backup_date}"
@ -569,7 +445,8 @@ echo -e " Webserver user.......................: $HTTP_USER"
echo ""
echo -e " PHP version..........................: $PHP_VERSION"
echo -e " PHP Engine...........................: $PHP_ENGINE"
echo -e " PHP binary...........................: $php_binary"
echo ""
echo -e " PHP Command..........................: $PHP_BIN"
echo ""
echo -e " Databse name.........................: $DATABASE_NAME"
echo -e " Database type........................: $DATABASE_TYPE"
@ -787,7 +664,7 @@ if $NGINX_IS_ENABLED ; then
fi
fi
echo ""
blank_line
# - Backup Database
# -
@ -826,11 +703,18 @@ elif [[ "$DATABASE_TYPE" = 'postgres' ]]; then
echo_ok
else
echo_failed
fatal "$(cat $log_file)"
fi
fi
error "$(cat $log_file)"
echo
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
# - Backup old installation directory
@ -842,8 +726,19 @@ if [[ $? -eq 0 ]]; then
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
blank_line
# - Remove symlink from old installation directory
# -
@ -853,7 +748,16 @@ if [[ $? -eq 0 ]]; then
echo_ok
else
echo_failed
fatal "$(cat $log_file)"
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
@ -885,7 +789,16 @@ if [[ $? -eq 0 ]]; then
echo_ok
else
echo_failed
fatal "$(cat $log_file)"
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
# - Kopiere Verzeichnis "config" in das neue Installationsverzeichnis
@ -941,13 +854,22 @@ fi
# - Backup Daten Verzeichnis (hardlinks - harte Dateiverweise)
# -
echononl " Copy (hardlink) data directory to '${OLD_DATA_DIR}.$backup_date'.."
cp -al "${DATA_DIR}" "${OLD_DATA_DIR}.${backup_date}" > $log_file 2>&1
echononl " Copy (hardlink) data directory to '${OLD_DATA_DIR}'.."
cp -al "${DATA_DIR}" "${OLD_DATA_DIR}" > $log_file 2>&1
if [[ $? -eq 0 ]]; then
echo_ok
else
echo_failed
fatal "$(cat $log_file)"
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
@ -959,7 +881,16 @@ if [[ $? -eq 0 ]]; then
echo_ok
else
echo_failed
fatal "$(cat $log_file)"
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
# - Set Permissions on new data directory
@ -970,7 +901,16 @@ if [[ $? -eq 0 ]]; then
echo_ok
else
echo_failed
fatal "$(cat $log_file)"
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
@ -983,20 +923,66 @@ if [[ $? -eq 0 ]]; then
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
blank_line
# - Update Nextcloud
# -
echo ""
echo " Update Nextcloud"
su -c"/usr/local/php/bin/php ${WEB_BASE_DIR}/htdocs/occ upgrade" -s /bin/bash $HTTP_USER
echo -e " Update Nextcloud\n"
su -c"${PHP_BIN} ${WEB_BASE_DIR}/htdocs/occ upgrade" -s /bin/bash $HTTP_USER
echo ""
if [[ $? -eq 0 ]]; then
info "Updating nextcloud core was successfully.."
else
fatal "$(cat $log_file)"
error "Updating nextcloud core failed!"
echo -e " Command was:"
echo -e " \033[33msu -c\"${PHP_BIN} ${WEB_BASE_DIR}/htdocs/occ upgrade\" -s /bin/bash $HTTP_USER\033[m"
echo ""
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
# Set maintenace mode to 'off'.. !!
#
blank_line
echononl " Set maintenace mode to 'off'.."
su -c "${PHP_BIN} ${WEB_BASE_DIR}/htdocs/occ maintenance:mode --off" -s /bin/bash $HTTP_USER > $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
blank_line
## -----
@ -1014,7 +1000,7 @@ fi
#_app="calendar"
#
#echononl "Install nextcloud app '$_app'.."
#sudo -u "$HTTP_USER" "$php_binary" "${INSTALL_DIR}/occ" app:install "$_app" > $log_file 2>&1
#sudo -u "$HTTP_USER" "${PHP_BIN}" "${INSTALL_DIR}/occ" app:install "$_app" > $log_file 2>&1
#if [[ $? -eq 0 ]]; then
# echo_ok
#else
@ -1037,7 +1023,7 @@ fi
#fi
#
#echononl "Eanable nextcloud app '$_app'.."
#sudo -u "$HTTP_USER" "$php_binary" "${INSTALL_DIR}/occ" app:enable "$_app" > $log_file 2>&1
#sudo -u "$HTTP_USER" "${PHP_BIN}" "${INSTALL_DIR}/occ" app:enable "$_app" > $log_file 2>&1
#if [[ $? -eq 0 ]]; then
# echo_ok
#else
@ -1063,7 +1049,7 @@ fi
#_app="contacts"
#
#echononl "Install nextcloud app '$_app'.."
#sudo -u "$HTTP_USER" "$php_binary" "${INSTALL_DIR}/occ" app:install "$_app" > $log_file 2>&1
#sudo -u "$HTTP_USER" "${PHP_BIN}" "${INSTALL_DIR}/occ" app:install "$_app" > $log_file 2>&1
#if [[ $? -eq 0 ]]; then
# echo_ok
#else
@ -1086,7 +1072,7 @@ fi
#fi
#
#echononl "Enable nextcloud app '$_app'.."
#sudo -u "$HTTP_USER" "$php_binary" "${INSTALL_DIR}/occ" app:enable "$_app" > $log_file 2>&1
#sudo -u "$HTTP_USER" "${PHP_BIN}" "${INSTALL_DIR}/occ" app:enable "$_app" > $log_file 2>&1
#if [[ $? -eq 0 ]]; then
# echo_ok
#else
@ -1112,7 +1098,7 @@ fi
#_app="notes"
#
#echononl "Install nextcloud app '$_app'.."
#sudo -u "$HTTP_USER" "$php_binary" "${INSTALL_DIR}/occ" app:install "$_app" > $log_file 2>&1
#sudo -u "$HTTP_USER" "${PHP_BIN}" "${INSTALL_DIR}/occ" app:install "$_app" > $log_file 2>&1
#if [[ $? -eq 0 ]]; then
# echo_ok
#else
@ -1135,7 +1121,7 @@ fi
#fi
#
#echononl "Eanable nextcloud app '$_app'.."
#sudo -u "$HTTP_USER" "$php_binary" "${INSTALL_DIR}/occ" app:enable "$_app" > $log_file 2>&1
#sudo -u "$HTTP_USER" "${PHP_BIN}" "${INSTALL_DIR}/occ" app:enable "$_app" > $log_file 2>&1
#if [[ $? -eq 0 ]]; then
# echo_ok
#else
@ -1161,7 +1147,7 @@ fi
#_app="tasks"
#
#echononl "Install nextcloud app '$_app'.."
#sudo -u "$HTTP_USER" "$php_binary" "${INSTALL_DIR}/occ" app:install "$_app" > $log_file 2>&1
#sudo -u "$HTTP_USER" "${PHP_BIN}" "${INSTALL_DIR}/occ" app:install "$_app" > $log_file 2>&1
#
#if [[ $? -eq 0 ]]; then
# echo_ok
@ -1185,7 +1171,7 @@ fi
#fi
#
#echononl "Eanable nextcloud app '$_app'.."
#sudo -u "$HTTP_USER" "$php_binary" "${INSTALL_DIR}/occ" app:enable "$_app" > $log_file 2>&1
#sudo -u "$HTTP_USER" "${PHP_BIN}" "${INSTALL_DIR}/occ" app:enable "$_app" > $log_file 2>&1
#if [[ $? -eq 0 ]]; then
# echo_ok
#else
@ -1213,7 +1199,7 @@ fi
# _app="richdocuments"
#
# echononl "Install nextcloud app '$_app'.."
# sudo -u "$HTTP_USER" "$php_binary" "${INSTALL_DIR}/occ" app:install "$_app" > $log_file 2>&1
# sudo -u "$HTTP_USER" "${PHP_BIN}" "${INSTALL_DIR}/occ" app:install "$_app" > $log_file 2>&1
# if [[ $? -eq 0 ]]; then
# echo_ok
# else
@ -1236,7 +1222,7 @@ fi
# fi
#
# echononl "Eanable nextcloud app '$_app'.."
# sudo -u "$HTTP_USER" "$php_binary" "${INSTALL_DIR}/occ" app:enable "$_app" > $log_file 2>&1
# sudo -u "$HTTP_USER" "${PHP_BIN}" "${INSTALL_DIR}/occ" app:enable "$_app" > $log_file 2>&1
# if [[ $? -eq 0 ]]; then
# echo_ok
# else
@ -1259,7 +1245,7 @@ fi
# 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
# sudo -u "$HTTP_USER" "${PHP_BIN}" "${INSTALL_DIR}/occ" config:app:set richdocuments wopi_url --value="$WOPI_URL" >> $log_file 2>&1
# if [[ $? -eq 0 ]]; then
# echo_ok
# else
@ -1287,7 +1273,7 @@ fi
#_app="bruteforcesettings"
#
#echononl "Install nextcloud app '$_app'.."
#sudo -u "$HTTP_USER" "$php_binary" "${INSTALL_DIR}/occ" app:install "$_app" > $log_file 2>&1
#sudo -u "$HTTP_USER" "${PHP_BIN}" "${INSTALL_DIR}/occ" app:install "$_app" > $log_file 2>&1
#if [[ $? -eq 0 ]]; then
# echo_ok
#else
@ -1310,7 +1296,7 @@ fi
#fi
#
#echononl "Eanable nextcloud app '$_app'.."
#sudo -u "$HTTP_USER" "$php_binary" "${INSTALL_DIR}/occ" app:enable "$_app" > $log_file 2>&1
#sudo -u "$HTTP_USER" "${PHP_BIN}" "${INSTALL_DIR}/occ" app:enable "$_app" > $log_file 2>&1
#
#if [[ $? -eq 0 ]]; then
# echo_ok
@ -1334,7 +1320,7 @@ fi
#_app="announcementcenter"
#
#echononl "Install nextcloud app '$_app'.."
#sudo -u "$HTTP_USER" "$php_binary" "${INSTALL_DIR}/occ" app:install "$_app" > $log_file 2>&1
#sudo -u "$HTTP_USER" "${PHP_BIN}" "${INSTALL_DIR}/occ" app:install "$_app" > $log_file 2>&1
#if [[ $? -eq 0 ]]; then
# echo_ok
#else
@ -1357,7 +1343,7 @@ fi
#fi
#
#echononl "Eanable nextcloud app '$_app'.."
#sudo -u "$HTTP_USER" "$php_binary" "${INSTALL_DIR}/occ" app:enable "$_app" > $log_file 2>&1
#sudo -u "$HTTP_USER" "${PHP_BIN}" "${INSTALL_DIR}/occ" app:enable "$_app" > $log_file 2>&1
#
#if [[ $? -eq 0 ]]; then
# echo_ok
@ -1383,8 +1369,126 @@ fi
echo ""
echo ""
echo -e "\033[37m\033[1mDoing some post-update tasks..\033[m"
echo ""
# - Add missing columns
# -
echononl " Add missing columns .."
su -c "${PHP_BIN} ${WEB_BASE_DIR}/htdocs/occ db:add-missing-columns" -s /bin/bash $HTTP_USER > $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
# - Create missing indices
# -
echononl " Add missing indices .."
su -c "${PHP_BIN} ${WEB_BASE_DIR}/htdocs/occ db:add-missing-indices" -s /bin/bash $HTTP_USER > $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
# - Add missing primary keys ..
# -
echononl " Add missing primary keys .."
su -c "${PHP_BIN} ${WEB_BASE_DIR}/htdocs/occ db:add-missing-primary-keys" -s /bin/bash $HTTP_USER > $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 " Migrating the mimetypes .."
su -c "${PHP_BIN} ${WEB_BASE_DIR}/htdocs/occ maintenance:repair --include-expensive" -s /bin/bash $HTTP_USER > $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
#echo ""
#echo " Would you like to run the cronjob manually - it may take a realy long time! "
#echo ""
#echononl " Run cronjob manually [yes/no]: "
#read OK
#OK="$(echo "$OK" | tr '[:upper:]' '[:lower:]')"
#while [[ "$OK" != "yes" ]] && [[ "$OK" != "no" ]] ; do
# echononl "Wrong entry! - repeat [yes/no]: "
# read OK
# OK="$(echo "$OK" | tr '[:upper:]' '[:lower:]')"
#done
#if [[ $OK = "yes" ]] ; then
#
# echononl " Run cronjob manually.. (can take a very long time)"
# echo_wait
# su -c "${PHP_BIN} ${WEB_BASE_DIR}/htdocs/cron.php" -s /bin/bash $HTTP_USER > $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
#fi
blank_line
echononl " Restart PHP engine.."
if [[ "$PHP_ENGINE" = "FPM" ]]; then
if $SYSTEMD_EXISTS ; then
@ -1569,6 +1673,18 @@ else
fi
fi
echononl " Restart notify_push service .."
if $(systemctl list-units --full -all | grep -Fq "notify_push") ; then
systemctl restart notify_push > $log_file 2>&1
if [[ $? -eq 0 ]]; then
echo_ok
else
echo_failed
error "\n\n$(cat $log_file)"
fi
fi
blank_line
clean_up 0