WWW_GROUP="www-data"
FILE_PERMS="0640"
DIR_PERMS="0750"
-
+SERVICE_NAME="apache2.service"
if [[ -f "${LIB_DIR}/functions.rc" ]] ; then
. "${LIB_DIR}/functions.rc"
cd
debug "Removing temporary directory '${CYAN}${TEMP_DIR}${NORMAL}' ..."
- RM -r "${TEMP_DIR}"
+ purge -r "${TEMP_DIR}"
}
cleanup_tmp_dir
}
+#------------------------------------------------------------------------------
+set_maintenance() {
+
+ info "Setting maintenance mode ..."
+ cd "${NEXTCLOUD_DIR_LINK}"
+ sudo -u "${WWW_USER}" php occ maintenance:mode --on
+
+}
+
+#------------------------------------------------------------------------------
+copy_config() {
+
+ local cur_nc_dir="${WWW_BASE}/nextcloud-${OLD_VERSION}"
+ local cur_cfg_file="${cur_nc_dir}/config/config.php"
+ local new_cfg_file="${NEW_NEXTCLOUD_DIR}/config/config.php"
+
+ info "Copying configuration ..."
+ CP "${cur_cfg_file}" "${new_cfg_file}"
+
+}
+
+#------------------------------------------------------------------------------
+stop_service() {
+
+ info "Stopping '${CYAN}${SERVICE_NAME}${NORMAL}' ..."
+ systemctl stop "${SERVICE_NAME}"
+ if [[ "${VERBOSE}" == 'y' ]] ; then
+ systemctl status "${SERVICE_NAME}" || true
+ fi
+
+}
+
+#------------------------------------------------------------------------------
+change_symlinks() {
+
+ info "Setting symlink '${CYAN}${NEXTCLOUD_DIR_LINK}${NORMAL}' -> '${CYAN}nextcloud-${NEW_VERSION}${NORMAL}' ..."
+ cd
+ RM "${NEXTCLOUD_DIR_LINK}"
+ LN "nextcloud-${NEW_VERSION}" "${NEXTCLOUD_DIR_LINK}"
+
+}
+
+#------------------------------------------------------------------------------
+upgrade_nc() {
+
+ echo
+ info "Upgrading Nextcloud ..."
+ cd "${NEXTCLOUD_DIR_LINK}"
+ sudo -u "${WWW_USER}" php occ upgrade
+
+}
+
+#------------------------------------------------------------------------------
+start_service() {
+
+ info "Starting '${CYAN}${SERVICE_NAME}${NORMAL}' ..."
+ systemctl start "${SERVICE_NAME}"
+ if [[ "${VERBOSE}" == 'y' ]] ; then
+ systemctl status "${SERVICE_NAME}" || true
+ fi
+
+}
+
+#------------------------------------------------------------------------------
+release_maintenance() {
+
+ info "Releasing maintenance mode ..."
+ cd "${NEXTCLOUD_DIR_LINK}"
+ sudo -u "${WWW_USER}" php occ maintenance:mode --off
+
+}
+
#------------------------------------------------------------------------------
main() {
unpack_archive
adjust_permissions
sync_apps
+ set_maintenance
+ copy_config
+ stop_service
+ change_symlinks
+ upgrade_nc
+ start_service
+ release_maintenance
}
CYAN=""
NORMAL=""
-VERSION="0.3.4"
+VERSION="0.3.5"
STD_SHORT_OPTIONS="sdvhV"
STD_LONG_OPTIONS="simulate,debug,verbose,nocolor,help,version"
}
+#------------------------------------------------------------------------------
+purge() {
+
+ if [[ "${VERBOSE}" != "y" ]] ; then
+ rm "$@"
+ else
+ rm --verbose "$@"
+ fi
+
+}
+
#------------------------------------------------------------------------------
CP() {
}
+#------------------------------------------------------------------------------
+LN() {
+
+ if [[ "${SIMULATE}" == "y" ]] ; then
+ debug "Simulating: ln $*"
+ return
+ fi
+ if [[ "${VERBOSE}" != "y" ]] ; then
+ ln "$@"
+ else
+ ln --verbose "$@"
+ fi
+
+}
+
#------------------------------------------------------------------------------
set_locale() {