NEXTCLOUD_DIR_OLD="${NEXTCLOUD_DIR}.old"
DOWNLOAD_DIR="/root/Downloads"
ARTIFACT="nextcloud-bla.tar.bz2"
+METADATA="nextcloud-bla.metadata"
MD5_FILE="${ARTIFACT}.md5"
SHA256_FILE="${ARTIFACT}.sha256"
SHA512_FILE="${ARTIFACT}.sha512"
. "${CONF_FILE}"
fi
+DO_BACKUP="y"
+
DESCRIPTION=$( cat <<-EOF
Updates the local Nextcloud installation under '${CYAN}${NEXTCLOUD_DIR}${NORMAL}'.
#------------------------------------------------------------------------------
usage() {
cat <<-EOF
- Usage: ${BASE_NAME} NEXTCLOUD_VERSION [Common Options]
+ Usage: ${BASE_NAME} [-N|--no-backup] NEXTCLOUD_VERSION [Common Options]
${BASE_NAME} [-h|--help]
${BASE_NAME} [-V|--version]
}
+#------------------------------------------------------------------------------
+eval_my_options() {
+
+ debug "Evaluating my options."
+
+ REMAINING_ARGS=()
+ REMAINING_OPTS=()
+
+ if [[ "$#" -gt 0 ]] ; then
+ while true ; do
+ case "$1" in
+ -N|--no-backup)
+ DO_BACKUP=""
+ shift
+ ;;
+ --) shift
+ break
+ ;;
+ *) REMAINING_OPTS+=($1)
+ shift
+ ;;
+ esac
+ done
+ fi
+
+ if [[ "$#" -gt "0" ]] ; then
+ # REMAINING_ARGS=("--")
+ while [[ "$#" -gt "0" ]] ; do
+ REMAINING_ARGS+=($1)
+ shift
+ done
+ fi
+
+}
+
#------------------------------------------------------------------------------
get_options() {
local tmp=
local base_dir=
+ local short_options="${STD_SHORT_OPTIONS}N"
+ local long_options="${STD_LONG_OPTIONS},no-backup"
set +e
- tmp=$( getopt -o ${STD_SHORT_OPTIONS} --long ${STD_LONG_OPTIONS} -n "${BASE_NAME}" -- "$@" )
+ tmp=$( getopt -o "${short_options}" --long "${long_options}" -n "${BASE_NAME}" -- "$@" )
if [[ $? != 0 ]] ; then
echo "" >&2
usage >&2
declare -p REMAINING_ARGS
fi
+ eval_my_options "${REMAINING_OPTS[@]}" -- "${REMAINING_ARGS[@]}"
+ if [[ "${DEBUG}" ]] ; then
+ declare -p REMAINING_OPTS
+ declare -p REMAINING_ARGS
+ fi
+
if [[ "${#REMAINING_OPTS[@]}" -gt 0 ]] ; then
error "Unknown options: ${REMAINING_OPTS[*]}"
echo >&2
NEW_VERSION="${REMAINING_ARGS[1]}"
ARTIFACT="nextcloud-${NEW_VERSION}.tar.bz2"
+ METADATA="nextcloud-${NEW_VERSION}.metadata"
MD5_FILE="${ARTIFACT}.md5"
SHA256_FILE="${ARTIFACT}.sha256"
SHA512_FILE="${ARTIFACT}.sha512"
+ if [[ -z "${DO_BACKUP}" ]] ; then
+ warn "Backup of current Nextcloud directory '${CYAN}${WWW_BASE}/nextcloud${NORMAL}' will not be executed."
+ fi
+
check_for_root
}
cd "${DOWNLOAD_DIR}"
local release_url="${DOWNLOAD_URL_BASE}/${ARTIFACT}"
+ local metadata_url="${DOWNLOAD_URL_BASE}/${METADATA}"
local md5_url="${DOWNLOAD_URL_BASE}/${MD5_FILE}"
local sha256_url="${DOWNLOAD_URL_BASE}/${SHA256_FILE}"
local sha512_url="${DOWNLOAD_URL_BASE}/${SHA512_FILE}"
WGET "${release_url}"
fi
+ if [[ ! -f "${METADATA}" ]] ; then
+ WGET "${metadata_url}"
+ fi
+
if [[ ! -f "${MD5_FILE}" ]] ; then
WGET "${md5_url}"
fi
debug "Verbose level is '${CYAN}${VERBOSE}${NORMAL}'."
get_old_version
- do_backup
+ if [[ "${DO_BACKUP}" ]] ; then
+ do_backup
+ fi
download_release
unpack_archive
adjust_permissions