__single_binary_service: fix oddities when removing a service

We were requiring too many arguments
This commit is contained in:
evilham 2025-05-05 20:22:05 +02:00
commit 7c0ec375ff
Signed by: evilham
GPG key ID: AE3EE30D970886BF
4 changed files with 16 additions and 12 deletions

View file

@ -27,15 +27,6 @@ This type supports services managed by `__runit(7)` when `systemd` is not
the init system being used.
REQUIRED PARAMETERS
-------------------
version
This type will use a thumbstone file with a "version" number to track
whether or not a service must be updated.
This thumbstone file is placed under
`/usr/local/bin/.${__object_id}.cdist.version`.
BOOLEAN PARAMETERS
------------------
unpack
@ -52,6 +43,13 @@ do-not-manage-user
OPTIONAL PARAMETERS
-------------------
version
Required when installing a service.
This type will use a thumbstone file with a "version" number to track
whether or not a service must be updated.
This thumbstone file is placed under
`/usr/local/bin/.${__object_id}.cdist.version`.
checksum
This will be passed verbatim to `__download(7)`.
Use something like `sha256:...`.

View file

@ -87,10 +87,16 @@ fi
SERVICE_DEFINITION="$(cat "${__object}/parameter/service-definition" 2>/dev/null || true)"
CHECKSUM="$(cat "${__object}/parameter/checksum")"
SHOULD_VERSION="$(cat "${__object}/parameter/version")"
SHOULD_VERSION="$(cat "${__object}/parameter/version" 2>/dev/null || true)"
DOWNLOAD_URL="$(cat "${__object}/parameter/url")"
LOCAL_SOURCE="$(cat "${__object}/parameter/local-source")"
if [ -z "${DOWNLOAD_URL}${LOCAL_SOURCE}" ]; then
if [ "${STATE}" = "present" ] && [ -z "${SHOULD_VERSION}" ]; then
cat >&1 <<-EOM
When installing a service, --version must be specified.
EOM
exit 1
fi
if [ "${STATE}" = "present" ] && [ -z "${DOWNLOAD_URL}${LOCAL_SOURCE}" ]; then
cat >&1 <<-EOM
Exactly one of --url or --local-source must be specified.
EOM

View file

@ -15,5 +15,6 @@ unpack-extension
unpack-args
url
user-home-dir
version
working-directory
working-directory-permissions

View file

@ -1 +0,0 @@
version