cdist-contrib/type/__runit_service/manifest
evilham 2038244ec4 [__runit*] Add support for Debian/Devuan
Apparently these types were only supporting FreeBSD, this brings in support for
Debian and Devuan by taking advantage of
https://packages.debian.org/bullseye/runit-run
2021-10-30 10:40:01 +02:00

51 lines
1 KiB
Bash
Executable file

#!/bin/sh -e
os="$(cat "${__global}/explorer/os")"
case "${os}" in
debian|devuan)
svdir="/etc/service"
;;
*bsd)
svdir="/var/service"
;;
*)
echo "Your OS '${OS}' is currently not supported." >&2
exit 1
;;
esac
sv="${__object_id}"
state="$(cat "${__object}/parameter/state")"
run_file="${svdir}/${sv}/run"
source="$(cat "$__object/parameter/source")"
if [ "$source" = "-" ]; then
source="$__object/stdin"
fi
# Create this service's directory
__directory --state "${state}" "${svdir}/${sv}"
export require="__directory${svdir}/${sv}"
if [ "${state}" != "present" ]; then
# We are done here, the service gets removed
exit
fi
if [ -f "${__object}/parameter/log" ]; then
# Setup logger if requested
__directory --parents "${svdir}/${sv}/log/main"
export require="${require} __directory${svdir}/${sv}/log/main"
__file "${svdir}/${sv}/log/run" \
--state "${state}" \
--mode 0755 \
--source "-" <<EOF
#!/bin/sh
exec svlogd -tt ./main
EOF
fi
# Setup run file
__file --state "${state}" --mode 0755 --source "${source}" "${run_file}"