From 7c0ec375ff26968a1bf208b82d5a69431d6bbc1a Mon Sep 17 00:00:00 2001 From: Evilham Date: Mon, 5 May 2025 20:22:05 +0200 Subject: [PATCH] __single_binary_service: fix oddities when removing a service We were requiring too many arguments --- type/__single_binary_service/man.rst | 16 +++++++--------- type/__single_binary_service/manifest | 10 ++++++++-- type/__single_binary_service/parameter/optional | 1 + type/__single_binary_service/parameter/required | 1 - 4 files changed, 16 insertions(+), 12 deletions(-) delete mode 100644 type/__single_binary_service/parameter/required diff --git a/type/__single_binary_service/man.rst b/type/__single_binary_service/man.rst index 47bcdbd..1f94cd9 100644 --- a/type/__single_binary_service/man.rst +++ b/type/__single_binary_service/man.rst @@ -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:...`. diff --git a/type/__single_binary_service/manifest b/type/__single_binary_service/manifest index 8277603..f46d62e 100755 --- a/type/__single_binary_service/manifest +++ b/type/__single_binary_service/manifest @@ -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 diff --git a/type/__single_binary_service/parameter/optional b/type/__single_binary_service/parameter/optional index b4ada3d..aaed0ac 100644 --- a/type/__single_binary_service/parameter/optional +++ b/type/__single_binary_service/parameter/optional @@ -15,5 +15,6 @@ unpack-extension unpack-args url user-home-dir +version working-directory working-directory-permissions diff --git a/type/__single_binary_service/parameter/required b/type/__single_binary_service/parameter/required deleted file mode 100644 index 088eda4..0000000 --- a/type/__single_binary_service/parameter/required +++ /dev/null @@ -1 +0,0 @@ -version