add nextcloud desktop launcher

This commit is contained in:
Jörn-Michael Miehe 2025-10-31 00:54:40 +01:00
parent 93c5d8ca6d
commit ec2bccea4b
4 changed files with 72 additions and 7 deletions

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
View 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
}

45
bin/nextcloud-appimage-launch Executable file
View file

@ -0,0 +1,45 @@
#!/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 -sSv 'https://github.com/nextcloud-releases/desktop/releases/latest' 2>&1 \
| grep '^< location: ' \
| grep -Eo '[[:digit:]]+\.[[:digit:]]+\.[[:digit:]]+' \
| head -n1 \
)"
version_installed="$( \
readlink "${INSTALL_DIR}/current" \
| grep -Eo '[[:digit:]]+\.[[:digit:]]+\.[[:digit:]]+' \
)"
if [ -n "${version_available}" ] && [ "${version_available}" != "${version_installed}" ]; then
echo "new nextcloud version available: ${version_available}"
notify-send \
--app-name "Nextcloud" \
--icon "${THISDIR}/.icon/nextcloud.svg" \
"nextcloud-appimage-launch" \
"new nextcloud version available: ${version_available}"
curl -sSfL \
"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"
else
echo "nextcloud is up to date!"
fi
exec "${INSTALL_DIR}/current" --background "${@}"

View file

@ -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
@ -48,9 +47,9 @@ if has_command snap; then
env LANG=en_US.UTF-8 snap list --all \
| awk '/disabled/{print $1, $3}' \
| while read -r snap_name snap_revision; do
set -x
snap remove "${snap_name}" --revision="${snap_revision}"
set +x
set -x
snap remove "${snap_name}" --revision="${snap_revision}"
set +x
done
set +ex
fi