info "Backing up current Nextcloud directory to '${GREEN}${backup_file}${NORMAL}' ..."
+ if [[ "${SIMULATE}" ]] ; then
+ return
+ fi
+
if [[ ! -d "${BACKUP_DIR}" ]] ; then
info "Creating '${CYAN}${BACKUP_DIR}${NORMAL}' ..."
MKDIR -p "${BACKUP_DIR}"
cd
debug "Removing temporary directory '${CYAN}${TEMP_DIR}${NORMAL}' ..."
+ if [[ "${SIMULATE}" ]] ; then
+ return
+ fi
purge -r "${TEMP_DIR}"
}
TEMP_DIR=$( mktemp -d "${TEMP_DIR_PARENT}/nextcloud-unpack-XXXXXXXXXX" )
local archive="${DOWNLOAD_DIR}/${ARTIFACT}"
+ info "Unpacking '${CYAN}${archive}${NORMAL}' into '${CYAN}${TEMP_DIR}${NORMAL}' ..."
+
debug "Activating trap ..."
trap cleanup_tmp_dir INT TERM EXIT ABRT
cd "${TEMP_DIR}"
- info "Unpacking '${GREEN}${archive}${NORMAL}' ..."
+ local cmd="tar xfj \"${archive}\""
if [[ "${VERBOSE}" && "${VERBOSE}" -gt '1' ]] ; then
- tar xfvj "${archive}"
+ cmd="tar xfvj \"${archive}\""
+ fi
+ if [[ "${SIMULATE}" ]] ; then
+ info "Simulate exec: ${cmd}"
else
- tar xfj "${archive}"
+ debug "Exec: ${cmd}"
+ eval ${cmd}
fi
info "Moving '${CYAN}${TEMP_DIR}/nextcloud${NORMAL}' to '${CYAN}${NEXTCLOUD_DIR_NEW}${NORMAL}' ..."
- mv "${TEMP_DIR}/nextcloud" "${NEXTCLOUD_DIR_NEW}"
+ mv_no_verbose "${TEMP_DIR}/nextcloud" "${NEXTCLOUD_DIR_NEW}"
cd
debug "Deactivating trap ..."
info "Adjusting permissions if '${CYAN}${NEXTCLOUD_DIR_NEW}${NORMAL}' ..."
info "Setting ownership to ${WWW_USER}:${WWW_GROUP} ..."
- chown -R "${WWW_USER}:${WWW_GROUP}" .
+ chown_no_verbose --recursive "${WWW_USER}:${WWW_GROUP}" .
info "Setting file mode to '${FILE_PERMS}' ..."
- find ./ -type f -print0 | xargs --null chmod "${FILE_PERMS}"
+ if [[ -z "${SIMULATE}" ]] ; then
+ find ./ -type f -print0 | xargs --null chmod "${FILE_PERMS}"
+ fi
info "Setting dir mode to '${DIR_PERMS}' ..."
- find ./ -type d -print0 | xargs --null chmod "${DIR_PERMS}"
+ if [[ -z "${SIMULATE}" ]] ; then
+ find ./ -type d -print0 | xargs --null chmod "${DIR_PERMS}"
+ fi
}
for app in ${app_sync_list} ; do
if [[ -d "${cur_apps_dir}/${app}" ]] ; then
debug "Syncing app '${CYAN}${app}${NORMAL}' ..."
- rsync -a "${cur_apps_dir}/${app}" "${new_apps_dir}/"
+ if [[ -z "${SIMULATE}" ]] ; then
+ rsync -a "${cur_apps_dir}/${app}" "${new_apps_dir}/"
+ fi
fi
done
occ() {
debug "Executing '${CYAN}php occ $*${NORMAL}' ..."
- (
- cd "${NEXTCLOUD_DIR}"
- sudo -u "${WWW_USER}" php occ "$@"
- )
+ if [[ "${SIMULATE}" ]] ; then
+ info "Simulate executing: sudo -u \"${WWW_USER}\" php occ $*"
+ else
+ debug "Executing: sudo -u \"${WWW_USER}\" php occ $*"
+ (
+ cd "${NEXTCLOUD_DIR}"
+ sudo -u "${WWW_USER}" php occ "$@"
+ )
+ fi
}
}
-#------------------------------------------------------------------------------
-stop_service() {
-
- info "Stopping '${CYAN}${SERVICE_NAME}${NORMAL}' ..."
- systemctl stop "${SERVICE_NAME}"
- if [[ "${VERBOSE}" ]] ; then
- systemctl status "${SERVICE_NAME}" || true
- fi
-
-}
-
#------------------------------------------------------------------------------
switch_nc_dirs() {
}
-#------------------------------------------------------------------------------
-start_service() {
-
- info "Starting '${CYAN}${SERVICE_NAME}${NORMAL}' ..."
- systemctl start "${SERVICE_NAME}"
- if [[ "${VERBOSE}" ]] ; then
- systemctl status "${SERVICE_NAME}" || true
- fi
-
-}
-
#------------------------------------------------------------------------------
release_maintenance() {
sync_apps
set_maintenance
copy_config
- stop_service
+ stop_service "${SERVICE_NAME}"
switch_nc_dirs
upgrade_nc
- start_service
+ start_service "${SERVICE_NAME}"
release_maintenance
}
CYAN=""
NORMAL=""
-VERSION="0.5.0"
+VERSION="0.5.1"
STD_SHORT_OPTIONS="sdvqhV"
STD_LONG_OPTIONS="simulate,debug,verbose,quiet,nocolor,help,version"
}
+#------------------------------------------------------------------------------
+cp_no_verbose() {
+ if [[ "${SIMULATE}" ]] ; then
+ info "Executing: cp $*"
+ return
+ fi
+ debug "Executing: cp $*"
+ cp "$@"
+}
+
#------------------------------------------------------------------------------
MV() {
}
+#------------------------------------------------------------------------------
+mv_no_verbose() {
+ if [[ "${SIMULATE}" ]] ; then
+ info "Executing: mv $*"
+ return
+ fi
+ debug "Executing: mv $*"
+ mv "$@"
+}
+
#------------------------------------------------------------------------------
CHOWN() {
}
+#------------------------------------------------------------------------------
+chown_no_verbose() {
+ if [[ "${SIMULATE}" ]] ; then
+ info "Executing: chown $*"
+ return
+ fi
+ debug "Executing: chown $*"
+ chown "$@"
+}
+
#------------------------------------------------------------------------------
CHMOD() {
}
+#------------------------------------------------------------------------------
+chmod_no_verbose() {
+ if [[ "${SIMULATE}" ]] ; then
+ info "Executing: chmod $*"
+ return
+ fi
+ debug "Executing: chmod $*"
+ chmod "$@"
+}
+
#------------------------------------------------------------------------------
LN() {
}
+#------------------------------------------------------------------------------
+stop_service() {
+
+ local service="$1"
+
+ info "Stopping '${CYAN}${service}${NORMAL}' ..."
+ local cmd="systemctl stop \"${service}\""
+ if [[ "${SIMULATE}" ]] ; then
+ debug "Simulating exec: ${cmd}"
+ else
+ debug "Exec: ${cmd}"
+ eval ${cmd}
+ fi
+
+ if [[ "${VERBOSE}" ]] ; then
+ systemctl status "${service}" || true
+ fi
+
+}
+
+#------------------------------------------------------------------------------
+start_service() {
+
+ local service="$1"
+
+ info "Starting '${CYAN}${service}${NORMAL}' ..."
+ local cmd="systemctl start \"${service}\""
+ if [[ "${SIMULATE}" ]] ; then
+ debug "Simulating exec: ${cmd}"
+ else
+ debug "Exec: ${cmd}"
+ eval ${cmd}
+ fi
+
+ if [[ "${VERBOSE}" ]] ; then
+ systemctl status "${service}" || true
+ fi
+
+}
+
#------------------------------------------------------------------------------
set_locale() {