From b8a1ad0ebd10c9695e8c73aa897aa6995cb61f5f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kamila=20Sou=C4=8Dkov=C3=A1?= Date: Sat, 2 Sep 2017 21:25:17 +0200 Subject: [PATCH] Improve __daemontools on FreeBSD (#567) Improve __daemontools on freebsd --- cdist/conf/type/__daemontools/man.rst | 5 ++++ cdist/conf/type/__daemontools/manifest | 25 ++++++++++++++++--- .../parameter/default/servicedir | 1 + .../type/__daemontools/parameter/optional | 1 + 4 files changed, 28 insertions(+), 4 deletions(-) create mode 100644 cdist/conf/type/__daemontools/parameter/default/servicedir diff --git a/cdist/conf/type/__daemontools/man.rst b/cdist/conf/type/__daemontools/man.rst index a8e81e54..bc1b4d33 100644 --- a/cdist/conf/type/__daemontools/man.rst +++ b/cdist/conf/type/__daemontools/man.rst @@ -21,11 +21,16 @@ OPTIONAL PARAMETERS from-package Package to install. Must be compatible with the original daemontools. Example: daemontools-encore. Default: daemontools. +servicedir + Directory to scan for services. Default: `/service` + + BOOLEAN PARAMETERS ------------------ install-init-script Add an init script and set it to start on boot. + EXAMPLES -------- diff --git a/cdist/conf/type/__daemontools/manifest b/cdist/conf/type/__daemontools/manifest index 0763d7be..75f26ca0 100755 --- a/cdist/conf/type/__daemontools/manifest +++ b/cdist/conf/type/__daemontools/manifest @@ -1,17 +1,34 @@ #!/bin/sh -e pkg=$(cat "$__object/parameter/from-package") +servicedir=$(cat "$__object/parameter/servicedir") __package $pkg +__directory $servicedir --mode 755 if [ -f "$__object/parameter/install-init-script" ]; then + os=$(cat "$__global/explorer/os") init=$(cat "$__global/explorer/init") + case $init in init) - __config_file /etc/init.d/svscan --mode 755 --source "$__type/files/init.d-svscan" - require="$require __config_file/etc/init.d/svscan" __start_on_boot svscan - require="$require __start_on_boot/svscan" __process svscan --start 'service svscan start' - ;; + case $os in + freebsd) + __config_file /etc/rc.conf.d/svscan --source - <<-EOT + svscan_enable="YES" + svscan_servicedir="$servicedir" + EOT + require="$require __package/$pkg __directory/$servicedir __config_file/etc/rc.conf.d/svscan" \ + __process svscan --start 'service svscan start' + ;; + *) + __config_file /etc/init.d/svscan --mode 755 --source "$__type/files/init.d-svscan" + require="$require __config_file/etc/init.d/svscan" __start_on_boot svscan + require="$require __package/$pkg __directory/$servicedir __start_on_boot/svscan" \ + __process svscan --start 'service svscan start' + ;; + esac + ;; *) echo "Your init system ($init) is not supported by this type. Submit a patch at github.com/ungleich/cdist!" exit 1 diff --git a/cdist/conf/type/__daemontools/parameter/default/servicedir b/cdist/conf/type/__daemontools/parameter/default/servicedir new file mode 100644 index 00000000..b74e27f6 --- /dev/null +++ b/cdist/conf/type/__daemontools/parameter/default/servicedir @@ -0,0 +1 @@ +/service diff --git a/cdist/conf/type/__daemontools/parameter/optional b/cdist/conf/type/__daemontools/parameter/optional index 8eca305b..22c0805d 100644 --- a/cdist/conf/type/__daemontools/parameter/optional +++ b/cdist/conf/type/__daemontools/parameter/optional @@ -1 +1,2 @@ from-package +servicedir