From ec2bccea4bd66f18ac314cf070eb5ee3845d6aa4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rn-Michael=20Miehe?= Date: Fri, 31 Oct 2025 00:54:40 +0100 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20add=20nextcloud=20desktop=20launche?= =?UTF-8?q?r?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- bin/.icon/nextcloud.svg | 3 +++ bin/.inc/common | 18 ++++++++++++++ bin/nextcloud-appimage-launch | 45 +++++++++++++++++++++++++++++++++++ bin/system-update | 13 +++++----- 4 files changed, 72 insertions(+), 7 deletions(-) create mode 100644 bin/.icon/nextcloud.svg create mode 100644 bin/.inc/common create mode 100755 bin/nextcloud-appimage-launch diff --git a/bin/.icon/nextcloud.svg b/bin/.icon/nextcloud.svg new file mode 100644 index 0000000..cc0cdb6 --- /dev/null +++ b/bin/.icon/nextcloud.svg @@ -0,0 +1,3 @@ + + +image/svg+xml \ No newline at end of file diff --git a/bin/.inc/common b/bin/.inc/common new file mode 100644 index 0000000..e2281b9 --- /dev/null +++ b/bin/.inc/common @@ -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 +} diff --git a/bin/nextcloud-appimage-launch b/bin/nextcloud-appimage-launch new file mode 100755 index 0000000..37ce432 --- /dev/null +++ b/bin/nextcloud-appimage-launch @@ -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 "${@}" diff --git a/bin/system-update b/bin/system-update index 9afbc24..413ad74 100755 --- a/bin/system-update +++ b/bin/system-update @@ -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