From a0f3135c80c8a1ba4c5c1d413eebdb7cdee46602 Mon Sep 17 00:00:00 2001 From: Nathaniel van Diepen Date: Thu, 17 Aug 2023 19:39:22 -0600 Subject: [PATCH] Fix #638 --- package/display/package | 8 +++----- package/draft/package | 7 ++----- package/koreader/package | 12 ++---------- package/oxide/package | 11 ++--------- package/reboot-guard/package | 6 ++---- package/rmfakecloud-proxy/package | 4 ++-- package/rmkit/package | 10 ++++------ package/tailscale-systemd/package | 12 ++---------- package/toltec-base/package | 4 ++-- package/webinterface-wifi/package | 11 ++--------- package/xochitl/package | 6 ++---- scripts/install-lib | 28 ++++++++++++++++++++++++++++ 12 files changed, 53 insertions(+), 66 deletions(-) diff --git a/package/display/package b/package/display/package index 9cb5abf8d..1fd07a475 100644 --- a/package/display/package +++ b/package/display/package @@ -8,7 +8,7 @@ timestamp=2023-04-16T20:53:38Z maintainer="raisjn " license=MIT url="https://github.com/ddvk/remarkable2-framebuffer" -pkgver=1:0.0.31-2 +pkgver=1:0.0.31-3 _release="${pkgver%-*}" _release="v${_release#*:}" _libver=1.0.1 @@ -72,7 +72,7 @@ display() { systemctl restart xochitl fi else - systemctl disable rm2fb --now + disable-unit rm2fb.service echo "Failed to start rm2fb. Keeping it disabled for now." echo "Please check the logs and open an issue:" echo " https://github.com/toltec-dev/toltec/issues/new" @@ -83,9 +83,7 @@ display() { preremove() { if [[ $arch = rm2 ]]; then - if systemctl list-units --full -all | grep -Fq 'rm2fb.service'; then - systemctl disable rm2fb --now - fi + disable-unit rm2fb.service echo -n "make sure " if ! is-enabled xochitl.service; then echo "to re-enable xochitl with 'systemctl enable xochitl --now'" diff --git a/package/draft/package b/package/draft/package index 2234c85f0..aac94f8e6 100644 --- a/package/draft/package +++ b/package/draft/package @@ -5,7 +5,7 @@ pkgnames=(draft) pkgdesc="Launcher which wraps around the standard interface" url=https://github.com/dixonary/draft-reMarkable -pkgver=0.2.0-21 +pkgver=0.2.0-22 timestamp=2020-07-20T10:23Z section="launchers" maintainer="Mattéo Delabre " @@ -60,10 +60,7 @@ configure() { } preremove() { - if systemctl list-units --full -all | grep -Fq "$pkgname.service"; then - echo "Disabling $pkgname" - systemctl disable --now "$pkgname" - fi + disable-unit "$pkgname.service" } postremove() { diff --git a/package/koreader/package b/package/koreader/package index d98e24233..27bf4a2e5 100644 --- a/package/koreader/package +++ b/package/koreader/package @@ -5,7 +5,7 @@ pkgnames=(koreader) pkgdesc="Ebook reader supporting PDF, DjVu, EPUB, FB2 and many more formats" url=https://github.com/koreader/koreader -pkgver=2023.06.1-1 +pkgver=2023.06.1-2 timestamp=2023-07-09T08:17:26Z section="readers" maintainer="raisjn " @@ -62,15 +62,7 @@ MSG } preremove() { - if is-active "$pkgname"; then - echo "Stopping $pkgname" - systemctl stop "$pkgname" - fi - - if is-enabled "$pkgname"; then - echo "Disabling $pkgname" - systemctl disable "$pkgname" - fi + disable-unit "$pkgname.service" } postremove() { diff --git a/package/oxide/package b/package/oxide/package index a9b7a4010..356eb1a01 100644 --- a/package/oxide/package +++ b/package/oxide/package @@ -3,7 +3,7 @@ # SPDX-License-Identifier: MIT pkgnames=(erode fret oxide rot tarnish decay corrupt anxiety liboxide libsentry notify-send) -pkgver=2.5-2 +pkgver=2.5-3 _sentryver=0.5.0 timestamp=2023-01-26T22:52:14Z maintainer="Eeems " @@ -99,14 +99,7 @@ tarnish() { systemctl daemon-reload } preremove() { - if is-active tarnish; then - echo "Stopping tarnish" - systemctl stop tarnish - fi - if is-enabled tarnish; then - echo "Disabling tarnish" - systemctl disable tarnish - fi + disable-unit tarnish.service } postremove() { systemctl daemon-reload diff --git a/package/reboot-guard/package b/package/reboot-guard/package index 61825f748..da4bb6cdb 100644 --- a/package/reboot-guard/package +++ b/package/reboot-guard/package @@ -5,7 +5,7 @@ pkgnames=(reboot-guard) pkgdesc="Block systemd-initiated poweroff/reboot/halt until configurable condition checks pass" url=https://github.com/stephanritscher/reboot-guard -pkgver=1.0.1-6 +pkgver=1.0.1-7 timestamp=2020-05-04T06:16Z section="devel" maintainer="Eeems " @@ -34,9 +34,7 @@ configure() { } preremove() { - if systemctl list-units --full -all | grep -Fq 'rguard.service'; then - systemctl disable --now rguard - fi + disable-unit rguard.service } postremove() { diff --git a/package/rmfakecloud-proxy/package b/package/rmfakecloud-proxy/package index 25b90d9b0..b9f247d55 100644 --- a/package/rmfakecloud-proxy/package +++ b/package/rmfakecloud-proxy/package @@ -7,7 +7,7 @@ pkgdesc="Connect Xochitl to a rmfakecloud server" _url=https://github.com/ddvk/rmfakecloud-proxy url="$_url" _upver=0.0.3 -pkgver="$_upver-3" +pkgver="$_upver-4" timestamp=2022-02-26T22:59Z section="utils" maintainer="Mattéo Delabre " @@ -55,7 +55,7 @@ configure() { install-hosts else uninstall-certificates - systemctl disable --now rmfakecloud-proxy + disable-unit rmfakecloud-proxy.service uninstall-hosts fi diff --git a/package/rmkit/package b/package/rmkit/package index 9c5cda508..4df5f55de 100644 --- a/package/rmkit/package +++ b/package/rmkit/package @@ -53,7 +53,7 @@ dumbskull() { genie() { pkgdesc="Gesture engine that connects commands to gestures" url="https://rmkit.dev/apps/genie" - pkgver=0.1.6-2 + pkgver=0.1.6-3 section="utils" package() { @@ -68,8 +68,7 @@ genie() { } preremove() { - echo "Disabling $pkgname" - systemctl disable --now "$pkgname" + disable-unit "$pkgname.service" } postremove() { @@ -147,7 +146,7 @@ nao() { remux() { pkgdesc="Launcher that supports multi-tasking applications" url="https://rmkit.dev/apps/remux" - pkgver=0.2.4-1 + pkgver=0.2.4-2 section="launchers" package() { @@ -167,8 +166,7 @@ remux() { } preremove() { - echo "Disabling $pkgname" - systemctl disable --now "$pkgname" + disable-unit "$pkgname.service" } postremove() { diff --git a/package/tailscale-systemd/package b/package/tailscale-systemd/package index 4e7fe832a..e8a7836f4 100644 --- a/package/tailscale-systemd/package +++ b/package/tailscale-systemd/package @@ -5,7 +5,7 @@ pkgnames=(tailscale-systemd) pkgdesc="SystemD configuration for tailscale" url=https://tailscale.com -pkgver=0.0.0-1 +pkgver=0.0.0-2 section="utils" timestamp=2023-07-12T00:00Z maintainer="Kai " @@ -30,15 +30,7 @@ configure() { } preremove() { - if is-active tailscaled; then - echo "Stopping tailscaled" - systemctl stop tailscaled - fi - - if is-enabled tailscaled; then - echo "Disabling tailscaled" - systemctl disable tailscaled - fi + disable-unit "tailscaled.service" } postremove() { diff --git a/package/toltec-base/package b/package/toltec-base/package index 87dd4aa26..8e88c399f 100644 --- a/package/toltec-base/package +++ b/package/toltec-base/package @@ -6,7 +6,7 @@ archs=(rm1 rm2) pkgnames=(toltec-base) pkgdesc="Metapackage defining the base set of packages in a Toltec install" url=https://toltec-dev.org/ -pkgver=1.2-2 +pkgver=1.2-3 timestamp=2023-05-08T19:31Z section="utils" maintainer="Eeems " @@ -31,7 +31,7 @@ configure() { /opt/etc/profile if is-enabled "update-engine.service"; then echo "Disabling automatic update" - systemctl disable --now update-engine + disable-unit update-engine.service fi if [[ "$arch" == "rm1" ]] && ! is-masked sys-subsystem-net-devices-usb1.device; then echo "Disabling usb1 network device to avoid long boots" diff --git a/package/webinterface-wifi/package b/package/webinterface-wifi/package index e8bdeaff6..cc8880569 100644 --- a/package/webinterface-wifi/package +++ b/package/webinterface-wifi/package @@ -5,7 +5,7 @@ pkgnames=(webinterface-wifi) pkgdesc="View the web interface if running, over wifi" url="https://github.com/rM-self-serve/webinterface-wifi" -pkgver=1.0.2-1 +pkgver=1.0.2-2 timestamp=2023-02-06T12:23:17Z section="utils" maintainer="rM-self-serve <122753594+rM-self-serve@users.noreply.github.com>" @@ -42,14 +42,7 @@ configure() { } preremove() { - if is-active "$pkgname"; then - echo "Stopping $pkgname" - systemctl stop "$pkgname" - fi - if is-enabled "$pkgname"; then - echo "Disabling $pkgname" - systemctl disable "$pkgname" - fi + disable-unit "$pkgname.service" } postremove() { diff --git a/package/xochitl/package b/package/xochitl/package index 1ebefec09..1a20b3613 100644 --- a/package/xochitl/package +++ b/package/xochitl/package @@ -5,7 +5,7 @@ pkgnames=(xochitl) pkgdesc="Read documents and take notes" url=https://remarkable.com -pkgver=0.0.0-14 +pkgver=0.0.0-15 timestamp=2022-11-07T20:19:57Z section="readers" maintainer="Mattéo Delabre " @@ -83,9 +83,7 @@ configure() { } preremove() { - if is-active manual-sync.service; then - systemctl disable --now manual-sync.service - fi + disable-unit manual-sync.service } postremove() { diff --git a/scripts/install-lib b/scripts/install-lib index cb98421bf..6899464a4 100644 --- a/scripts/install-lib +++ b/scripts/install-lib @@ -174,3 +174,31 @@ remove-bind-mount() { rm "$unit_path" systemctl daemon-reload } + +# Check to see if a systemd unit exists +# +# Arguments: +# +# $1 - Full name of the systemd unit, e.g. "draft.service" +unit-exists() { + [ $(systemctl --quiet list-unit-files "${1}" | grep "${1}" | wc -l) -eq 1 ] +} + +# Stops and disabled a unit +# +# Arguments: +# +# $1 - Full name of the systemd unit, e.g. "draft.service" +disable-unit() { + if ! unit-exists "$1"; then + return + fi + if is-active "$1"; then + echo "Stopping $1" + systemctl stop "$1" + fi + if is-enabled "$1"; then + echo "Disabling $1" + systemctl disable "$1" + fi +}