diff --git a/package/xochitl/manual-sync.service b/package/xochitl/manual-sync@.service similarity index 89% rename from package/xochitl/manual-sync.service rename to package/xochitl/manual-sync@.service index 359f84849..386011a02 100644 --- a/package/xochitl/manual-sync.service +++ b/package/xochitl/manual-sync@.service @@ -6,14 +6,14 @@ Description=reMarkable Document Sync without the xochitl.service dependency After=dbus.socket StartLimitIntervalSec=60 StartLimitBurst=4 -Conflicts=sync.service +Conflicts=%i.service [Service] # Do NOT make this dbus, systemd will kill the service when it should be # running otherwise. Type=simple BusName=no.remarkable.sync -ExecStart=/usr/bin/sync --service +ExecStart=/usr/bin/%i --service Restart=on-failure RestartForceExitStatus=SIGHUP SIGINT SIGTERM SIGPIPE diff --git a/package/xochitl/package b/package/xochitl/package index 07fa0a042..0db662542 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-17 +pkgver=0.0.0-18 timestamp=2022-11-07T20:19:57Z section="readers" maintainer="Mattéo Delabre " @@ -24,7 +24,7 @@ source=( toltec-after-launcher.conf toltec-wrapper.conf env-readme - manual-sync.service + manual-sync@.service ) sha256sums=( SKIP @@ -59,19 +59,30 @@ package() { install -D -m 644 -t "$pkgdir"/etc/systemd/system/remarkable-reboot.service.d \ "$srcdir"/toltec-after-launcher.conf install -D -m 644 -t "$pkgdir"/etc/systemd/system \ - "$srcdir"/manual-sync.service + "$srcdir"/manual-sync@.service } configure() { systemctl daemon-reload - # sync.service interferes with launchers - # we use manual-sync.service instead - if [[ "x$(systemctl is-enabled sync.service)" != "xmasked" ]]; then + # sync.service and rm-sync.service interfere with launchers + # we use manual-sync@.service instead + if [ -f /usr/bin/sync ] && ! is-masked sync.service; then systemctl mask sync.service fi - if ! is-active manual-sync.service; then - systemctl enable --now manual-sync.service + + if [ -f /usr/bin/rm-sync ] && ! is-masked rm-sync.service; then + systemctl mask rm-sync.service + fi + + # manual-sync.service has been changed to manual-sync@.service + # Make sure to disable and stop the old version + disable-unit manual-sync.service + + if [ -f /usr/bin/rm-sync ] && ! is-active manual-sync@rm-sync.service; then + systemctl enable --now manual-sync@rm-sync.service + elif [ -f /usr/bin/sync ] && ! is-active manual-sync@sync.service; then + systemctl enable --now manual-sync@sync.service fi if is-enabled xochitl.service && ! is-enabled launcher.service; then @@ -83,14 +94,18 @@ configure() { } preremove() { - disable-unit manual-sync.service + disable-unit manual-sync@rm-sync.service + disable-unit manual-sync@sync.service } postremove() { systemctl daemon-reload - if [[ "x$(systemctl is-enabled sync.service)" == "xmasked" ]]; then - systemctl unmask sync.service 2> /dev/null + if [ -f /usr/bin/sync ] && is-masked sync.service; then + systemctl unmask sync.service + fi + if [ -f /usr/bin/rm-sync ] && is-masked rm-sync.service; then + systemctl unmask rm-sync.service fi if is-enabled xochitl.service && is-enabled launcher.service; then diff --git a/package/xochitl/xochitl b/package/xochitl/xochitl index f16945fe0..4a2eb95f2 100644 --- a/package/xochitl/xochitl +++ b/package/xochitl/xochitl @@ -9,13 +9,22 @@ for file in /opt/etc/xochitl.env.d/*.env; do source "$file" fi done + # If for some reason, sync.service is no longer masked, re-mask it # The package install should have handled this, but something may # have changed it. if [[ "x$(systemctl is-enabled sync.service)" != "xmasked" ]]; then systemctl mask sync.service fi -if ! systemctl is-active --quiet manual-sync.service; then - systemctl enable --now manual-sync.service + +if [[ "x$(systemctl is-enabled rm-sync.service)" != "xmasked" ]]; then + systemctl mask rm-sync.service fi + +if [ -f /usr/bin/rm-sync ] && ! is-active manual-sync@rm-sync.service; then + systemctl enable --now manual-sync@rm-sync.service +elif [ -f /usr/bin/sync ] && ! is-active manual-sync@sync.service; then + systemctl enable --now manual-sync@sync.service +fi + exec -a /usr/bin/xochitl /usr/bin/xochitl "$@" diff --git a/scripts/install-lib b/scripts/install-lib index ae6cb5066..c151e2c59 100644 --- a/scripts/install-lib +++ b/scripts/install-lib @@ -189,7 +189,7 @@ remove-bind-mount() { # # $1 - Full name of the systemd unit, e.g. "draft.service" unit-exists() { - [ "$(systemctl --quiet list-unit-files "${1}" | /bin/grep -c "${1}" 2> /dev/null || echo "0")" -eq 1 ] + [ "$(systemctl --quiet list-unit-files "${1}" | /bin/grep -c "${1}" 2> /dev/null)" -eq 1 ] } # Stops and disabled a unit