Compare commits
2 commits
da6a208a4f
...
bce99f4684
| Author | SHA1 | Date | |
|---|---|---|---|
| bce99f4684 | |||
| ec2bccea4b |
4 changed files with 79 additions and 7 deletions
3
bin/.icon/nextcloud.svg
Normal file
3
bin/.icon/nextcloud.svg
Normal file
File diff suppressed because one or more lines are too long
|
After Width: | Height: | Size: 10 KiB |
18
bin/.inc/common
Normal file
18
bin/.inc/common
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
#!/bin/sh
|
||||
|
||||
# check if a command is available
|
||||
has_command() { # $command
|
||||
command -v "${1}" 1>/dev/null 2>/dev/null
|
||||
}
|
||||
|
||||
needs_commands() { # $status $cmd1 $cmd2 ...
|
||||
_nc_status="${1}"
|
||||
shift 1
|
||||
|
||||
for _nc_cmd in "${@}"; do
|
||||
if ! has_command "${_nc_cmd}"; then
|
||||
echo "Command '${_nc_cmd}' not available!" >&2
|
||||
exit "${_nc_status}"
|
||||
fi
|
||||
done
|
||||
}
|
||||
52
bin/nextcloud-appimage-launch
Executable file
52
bin/nextcloud-appimage-launch
Executable file
|
|
@ -0,0 +1,52 @@
|
|||
#!/bin/sh
|
||||
|
||||
INSTALL_DIR="/path/to/nextcloud-client"
|
||||
|
||||
# name: nextcloud-appimage-launch
|
||||
# summary: Downloads and launches the latest Nextcloud (desktop) AppImage
|
||||
# params: none
|
||||
|
||||
THISDIR="$(dirname "$(readlink -f "${0}")")"
|
||||
# shellcheck disable=SC1091
|
||||
. "${THISDIR}/.inc/common"
|
||||
|
||||
needs_commands "curl" "notify-send"
|
||||
|
||||
version_available="$( \
|
||||
curl --silent --verbose --retry-all-errors --retry-delay 3 --retry 5 \
|
||||
'https://github.com/nextcloud-releases/desktop/releases/latest' 2>&1 \
|
||||
| grep '^< location: ' \
|
||||
| grep -Eo '[[:digit:]]+\.[[:digit:]]+\.[[:digit:]]+' \
|
||||
| head -n1 \
|
||||
)"
|
||||
|
||||
if [ -z "${version_available}" ]; then
|
||||
echo "failed checking for nextcloud update" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
version_installed="$( \
|
||||
readlink "${INSTALL_DIR}/current" \
|
||||
| grep -Eo '[[:digit:]]+\.[[:digit:]]+\.[[:digit:]]+' \
|
||||
)"
|
||||
|
||||
if [ "${version_available}" == "${version_installed}" ]; then
|
||||
echo "nextcloud is up to date!" >&2
|
||||
exit 0
|
||||
fi
|
||||
|
||||
echo "new nextcloud version available: ${version_available}" >&2
|
||||
notify-send \
|
||||
--app-name "Nextcloud" \
|
||||
--icon "${THISDIR}/.icon/nextcloud.svg" \
|
||||
"nextcloud-appimage-launch" \
|
||||
"new nextcloud version available: ${version_available}"
|
||||
|
||||
curl --silent --show-error --fail --location \
|
||||
"https://github.com/nextcloud-releases/desktop/releases/download/v${version_available}/Nextcloud-${version_available}-x86_64.AppImage" \
|
||||
--output "${INSTALL_DIR}/Nextcloud-${version_available}-x86_64.AppImage"
|
||||
|
||||
chmod +x "${INSTALL_DIR}/Nextcloud-${version_available}-x86_64.AppImage"
|
||||
ln -sf "./Nextcloud-${version_available}-x86_64.AppImage" "${INSTALL_DIR}/current"
|
||||
|
||||
exec "${INSTALL_DIR}/current" --background "${@}"
|
||||
|
|
@ -6,10 +6,9 @@
|
|||
# - fully POSIX shell compliant
|
||||
# params: none
|
||||
|
||||
# check if a command is available
|
||||
has_command() { # $command
|
||||
command -v "$1" 1>/dev/null 2>/dev/null
|
||||
}
|
||||
THISDIR="$(dirname "$(readlink -f "${0}")")"
|
||||
# shellcheck disable=SC1091
|
||||
. "${THISDIR}/.inc/common"
|
||||
|
||||
# run self as root
|
||||
if [ "$(id -u)" -ne 0 ]; then
|
||||
|
|
|
|||
Loading…
Reference in a new issue