NEW_VERSION=""
OLD_VERSION=""
-BASEDIR=/var/www
-NEXTCLOUD_DIR_LINK="${BASEDIR}/nextcloud"
-NEW_NEXTCLOUD_DIR="${BASEDIR}/nextcloud-bla"
+WWW_BASE=/var/www
+NEXTCLOUD_DIR_LINK="${WWW_BASE}/nextcloud"
+NEW_NEXTCLOUD_DIR="${WWW_BASE}/nextcloud-bla"
DOWNLOAD_DIR="/root/Downloads"
ARTIFACT="nextcloud-bla.tar.bz2"
MD5_FILE="${ARTIFACT}.md5"
ARTIFACT="nextcloud-${NEW_VERSION}.tar.bz2"
MD5_FILE="${ARTIFACT}.md5"
SHA256_FILE="${ARTIFACT}.sha256"
- NEW_NEXTCLOUD_DIR="${BASEDIR}/nextcloud-${NEW_VERSION}"
+ NEW_NEXTCLOUD_DIR="${WWW_BASE}/nextcloud-${NEW_VERSION}"
check_for_root
adjust_permissions() {
cd "${NEW_NEXTCLOUD_DIR}"
- local verbose_opt=""
- if [[ "${VERBOSE}" == "y" ]] ; then
- verbose_opt=" --verbose"
- fi
info "Adjusting permissions if '${CYAN}${NEW_NEXTCLOUD_DIR}${NORMAL}' ..."
info "Setting ownership to ${WWW_USER}:${WWW_GROUP} ..."
- CHOWN -R "${WWW_USER}:${WWW_GROUP}" .
+ chown -R "${WWW_USER}:${WWW_GROUP}" .
info "Setting file mode to '${FILE_PERMS}' ..."
- find ./ -type f -print0 | xargs --null chmod ${verbose_opt} "${FILE_PERMS}"
+ find ./ -type f -print0 | xargs --null chmod "${FILE_PERMS}"
info "Setting dir mode to '${DIR_PERMS}' ..."
- find ./ -type d -print0 | xargs --null chmod ${verbose_opt} "${DIR_PERMS}"
+ find ./ -type d -print0 | xargs --null chmod "${DIR_PERMS}"
+
+}
+
+#------------------------------------------------------------------------------
+sync_apps() {
+
+ local cur_nc_dir="${WWW_BASE}/nextcloud-${OLD_VERSION}"
+ local cur_apps_dir="${cur_nc_dir}/apps"
+ local new_apps_dir="${NEW_NEXTCLOUD_DIR}/apps"
+ local app=
+
+ TEMP_DIR=$( mktemp -d "${TEMP_DIR_PARENT}/nextcloud-apps-XXXXXXXXXX" )
+ debug "Activating trap ..."
+ trap cleanup_tmp_dir INT TERM EXIT ABRT
+ info "Evaluating apps to sync from '${CYAN}${cur_apps_dir}${NORMAL}' => '${CYAN}${new_apps_dir}${NORMAL}' ..."
+ cd "${TEMP_DIR}"
+ ls -1 "${cur_apps_dir}/" > INSTALLED_APPS.txt
+ ls -1 "${new_apps_dir}/" > DEFAULT_APPS.txt
+
+ local app_sync_list=$( diff --suppress-common-lines -y DEFAULT_APPS.txt INSTALLED_APPS.txt | \
+ sed -e 's/^[[:space:]]*>.//g' )
+
+ debug "Apps to sync:\n${app_sync_list}"
+ for app in ${app_sync_list} ; do
+ debug "Syncing app '${CYAN}${app}${NORMAL}' ..."
+ rsync -a "${cur_apps_dir}/${app}" "${new_apps_dir}/"
+ done
+
+ cd
+
+ debug "Deactivating trap ..."
+ trap - INT TERM EXIT ABRT
+ cleanup_tmp_dir
}
#------------------------------------------------------------------------------
download_release
unpack_archive
adjust_permissions
+ sync_apps
}