Add simple __service type
This commit is contained in:
parent
ef2f4b9a00
commit
09540dc6bd
5 changed files with 84 additions and 0 deletions
8
cdist/conf/type/__service/explorer/service-manager
Executable file
8
cdist/conf/type/__service/explorer/service-manager
Executable file
|
@ -0,0 +1,8 @@
|
||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
# Assume systemd if systemctl is in PATH.
|
||||||
|
if [ "$(command -v systemctl)" ]; then
|
||||||
|
printf "systemd"
|
||||||
|
else
|
||||||
|
printf "unknown"
|
||||||
|
fi
|
9
cdist/conf/type/__service/gencode-remote
Executable file
9
cdist/conf/type/__service/gencode-remote
Executable file
|
@ -0,0 +1,9 @@
|
||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
manager="$(cat "$__object/explorer/service-manager")"
|
||||||
|
name=$__object_id
|
||||||
|
action="$(cat "$__object/parameter/action")"
|
||||||
|
|
||||||
|
if [ "$manager" = "unknown" ]; then
|
||||||
|
echo "service '$name' '$action'"
|
||||||
|
fi
|
51
cdist/conf/type/__service/man.rst
Normal file
51
cdist/conf/type/__service/man.rst
Normal file
|
@ -0,0 +1,51 @@
|
||||||
|
cdist-type__service(7)
|
||||||
|
======================
|
||||||
|
|
||||||
|
NAME
|
||||||
|
----
|
||||||
|
cdist-type__service - Run action on a system service
|
||||||
|
|
||||||
|
|
||||||
|
DESCRIPTION
|
||||||
|
-----------
|
||||||
|
This type allows you to run an action against a system service.
|
||||||
|
|
||||||
|
|
||||||
|
REQUIRED PARAMETERS
|
||||||
|
-------------------
|
||||||
|
action
|
||||||
|
Arbitrary parameter passed as action. Usually 'start', 'stop', 'reload' or 'restart'.
|
||||||
|
|
||||||
|
OPTIONAL PARAMETERS
|
||||||
|
-------------------
|
||||||
|
None.
|
||||||
|
|
||||||
|
|
||||||
|
BOOLEAN PARAMETERS
|
||||||
|
------------------
|
||||||
|
None.
|
||||||
|
|
||||||
|
|
||||||
|
EXAMPLES
|
||||||
|
--------
|
||||||
|
|
||||||
|
.. code-block:: sh
|
||||||
|
|
||||||
|
# Restart nginx service.
|
||||||
|
__service nginx --action restart
|
||||||
|
|
||||||
|
# Stop postfix service.
|
||||||
|
__service postfix --action stop
|
||||||
|
|
||||||
|
|
||||||
|
AUTHORS
|
||||||
|
-------
|
||||||
|
Timothée Floure <timothee.floure@ungleich.ch>
|
||||||
|
|
||||||
|
|
||||||
|
COPYING
|
||||||
|
-------
|
||||||
|
Copyright \(C) 2019 Timothée Floure. You can redistribute it
|
||||||
|
and/or modify it under the terms of the GNU General Public License as
|
||||||
|
published by the Free Software Foundation, either version 3 of the
|
||||||
|
License, or (at your option) any later version.
|
15
cdist/conf/type/__service/manifest
Normal file
15
cdist/conf/type/__service/manifest
Normal file
|
@ -0,0 +1,15 @@
|
||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
manager="$(cat "$__object/explorer/service-manager")"
|
||||||
|
|
||||||
|
name=$__object_id
|
||||||
|
action="$(cat "$__object/parameter/action")"
|
||||||
|
|
||||||
|
case "$manager" in
|
||||||
|
systemd)
|
||||||
|
__systemd_service "$name" --action "$action"
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
# Unknown: handled by `service $NAME $action` in gencode-remote.
|
||||||
|
;;
|
||||||
|
esac
|
1
cdist/conf/type/__service/parameter/required
Normal file
1
cdist/conf/type/__service/parameter/required
Normal file
|
@ -0,0 +1 @@
|
||||||
|
action
|
Loading…
Reference in a new issue