__daemontools*: add/improve; + add man pages
This commit is contained in:
parent
cf0ab2a5bd
commit
d30103e9d2
11 changed files with 199 additions and 0 deletions
63
cdist/conf/type/__daemontools/files/init.d-svscan
Normal file
63
cdist/conf/type/__daemontools/files/init.d-svscan
Normal file
|
@ -0,0 +1,63 @@
|
|||
#!/bin/bash
|
||||
### BEGIN INIT INFO
|
||||
# Provides: svscan
|
||||
# Required-Start:
|
||||
# Required-Stop:
|
||||
# Default-Start: 2 3 4 5
|
||||
# Default-Stop: 0 1 6
|
||||
# Short-Description: svscan
|
||||
# Description: djb svscan
|
||||
### END INIT INFO
|
||||
# from https://gist.githubusercontent.com/pacojp/5766990/raw/2ed009ab19515afc9e58291b636d673c5ca864b3/init.d.svscan
|
||||
# written by Adam McKenna <adam@debian.org>
|
||||
# edited by Kamila Součková <kamila@ksp.sk>
|
||||
|
||||
export PATH=$PATH:/usr/local/bin
|
||||
|
||||
l=/var/log/svscan
|
||||
|
||||
if [ ! -d $l ]; then
|
||||
mkdir $l
|
||||
chown daemon $l
|
||||
fi
|
||||
|
||||
case "$1" in
|
||||
start)
|
||||
echo -n "Starting daemontools: "
|
||||
if [ ! `pidof svscan` ]; then
|
||||
echo -n "svscan "
|
||||
env - PATH="$PATH" svscan /service 2>&1 | setuidgid daemon multilog t /var/log/svscan &
|
||||
echo "."
|
||||
else
|
||||
echo "already running."
|
||||
fi
|
||||
;;
|
||||
stop)
|
||||
echo -n "Stopping daemontools: "
|
||||
if [ `pidof svscan` ]; then
|
||||
echo -n "svscan"
|
||||
while [ `pidof svscan` ]; do
|
||||
kill `pidof svscan`
|
||||
echo -n "."
|
||||
done
|
||||
fi
|
||||
echo -n " services"
|
||||
for i in `ls -d /service/*`; do
|
||||
svc -dx $i
|
||||
echo -n "."
|
||||
done
|
||||
echo -n " logging "
|
||||
for i in `ls -d /service/*/log`; do
|
||||
svc -dx $i
|
||||
echo -n "."
|
||||
done
|
||||
echo ""
|
||||
;;
|
||||
restart|force-reload)
|
||||
$0 stop
|
||||
$0 start
|
||||
;;
|
||||
*)
|
||||
echo 'Usage: /etc/init.d/svscan {start|stop|restart|force-reload}'
|
||||
exit 1
|
||||
esac
|
42
cdist/conf/type/__daemontools/man.rst
Normal file
42
cdist/conf/type/__daemontools/man.rst
Normal file
|
@ -0,0 +1,42 @@
|
|||
cdist-type__daemontools(7)
|
||||
==========================
|
||||
|
||||
NAME
|
||||
----
|
||||
cdist-type__daemontools - Install daemontools
|
||||
|
||||
|
||||
DESCRIPTION
|
||||
-----------
|
||||
Install djb daemontools and (optionally) an init script.
|
||||
|
||||
|
||||
REQUIRED PARAMETERS
|
||||
-------------------
|
||||
None.
|
||||
|
||||
|
||||
OPTIONAL PARAMETERS
|
||||
-------------------
|
||||
from-package
|
||||
Package to install. Must be compatible with the original daemontools. Example: daemontools-encore. Default: daemontools.
|
||||
|
||||
BOOLEAN PARAMETERS
|
||||
------------------
|
||||
install-init-script
|
||||
Add an init script and set it to start on boot. Default yes.
|
||||
|
||||
EXAMPLES
|
||||
--------
|
||||
|
||||
.. code-block:: sh
|
||||
|
||||
__daemontools --from-package daemontools-encore # if you prefer
|
||||
|
||||
SEE ALSO
|
||||
--------
|
||||
cdist-type__daemontools_service
|
||||
|
||||
AUTHORS
|
||||
-------
|
||||
Kamila Součková <kamila--@--ksp.sk>
|
20
cdist/conf/type/__daemontools/manifest
Normal file
20
cdist/conf/type/__daemontools/manifest
Normal file
|
@ -0,0 +1,20 @@
|
|||
#!/bin/sh
|
||||
|
||||
pkg=$(cat "$__object/parameter/from-package")
|
||||
|
||||
__package $pkg
|
||||
|
||||
if [ -f "$__object/parameter/install-init-script" ]; then
|
||||
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'
|
||||
;;
|
||||
*)
|
||||
echo "Your init system ($init) is not supported by this type. Submit a patch at github.com/ungleich/cdist!"
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
fi
|
1
cdist/conf/type/__daemontools/parameter/boolean
Normal file
1
cdist/conf/type/__daemontools/parameter/boolean
Normal file
|
@ -0,0 +1 @@
|
|||
install-init-script
|
|
@ -0,0 +1 @@
|
|||
daemontools
|
1
cdist/conf/type/__daemontools/parameter/optional
Normal file
1
cdist/conf/type/__daemontools/parameter/optional
Normal file
|
@ -0,0 +1 @@
|
|||
from-package
|
0
cdist/conf/type/__daemontools/singleton
Normal file
0
cdist/conf/type/__daemontools/singleton
Normal file
1
cdist/conf/type/__daemontools_service/explorer/svc
Normal file
1
cdist/conf/type/__daemontools_service/explorer/svc
Normal file
|
@ -0,0 +1 @@
|
|||
command -v svc
|
63
cdist/conf/type/__daemontools_service/man.rst
Normal file
63
cdist/conf/type/__daemontools_service/man.rst
Normal file
|
@ -0,0 +1,63 @@
|
|||
cdist-type__daemontools_service(7)
|
||||
==================================
|
||||
|
||||
NAME
|
||||
----
|
||||
cdist-type__daemontools_service - Create a daemontools-compatible service dir.
|
||||
|
||||
|
||||
DESCRIPTION
|
||||
-----------
|
||||
Create a directory structure compatible with daemontools-like service management.
|
||||
|
||||
Note that svc must be present on the target system.
|
||||
|
||||
The object ID will be used as the service name.
|
||||
|
||||
REQUIRED PARAMETERS
|
||||
-------------------
|
||||
None.
|
||||
|
||||
OPTIONAL PARAMETERS
|
||||
-------------------
|
||||
run
|
||||
Command to run. exec-ing and stderr redirection will be added. One of run, run-file must be specified.
|
||||
|
||||
Example: `my-program`
|
||||
|
||||
run-file
|
||||
File to save as <servicedir>/run. One of run, run-file must be specified.
|
||||
|
||||
Example:
|
||||
.. code-block:: sh
|
||||
#!/bin/sh
|
||||
exec 2>&1
|
||||
exec my_program
|
||||
|
||||
|
||||
log-run
|
||||
Command to run for log consumption. Default: `multilog t ./main`
|
||||
|
||||
servicedir
|
||||
Directory to install into. Default: `/service`
|
||||
|
||||
BOOLEAN PARAMETERS
|
||||
------------------
|
||||
None.
|
||||
|
||||
EXAMPLES
|
||||
--------
|
||||
|
||||
.. code-block:: sh
|
||||
|
||||
require="__daemontools" __daemontools_service prometheus --run "setuidgid prometheus $GOBIN/prometheus $FLAGS"
|
||||
|
||||
|
||||
SEE ALSO
|
||||
--------
|
||||
cdist-type__daemontools
|
||||
|
||||
|
||||
AUTHORS
|
||||
-------
|
||||
Kamila Součková <kamila--@--ksp.sk>
|
|
@ -10,6 +10,13 @@ run=$(cat "$__object/parameter/run")
|
|||
runfile=$(cat "$__object/parameter/run-file")
|
||||
logrun=$(cat "$__object/parameter/log-run")
|
||||
|
||||
svc=$(cat "$__type/explorer/svc")
|
||||
|
||||
if [ -z "$svc" ]; then
|
||||
echo "svc not found! Install daemontools first: see __daemontools"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
badusage() {
|
||||
echo "__daemontools_service/$__object_id: exactly one of --run, --run-file must be set" >&2
|
||||
exit 1
|
||||
|
|
Loading…
Reference in a new issue