Merge remote branch 'nico/master'
This commit is contained in:
commit
f337612d36
12 changed files with 181 additions and 7 deletions
30
conf/type/__process/explorer/runs
Executable file
30
conf/type/__process/explorer/runs
Executable file
|
|
@ -0,0 +1,30 @@
|
|||
#!/bin/sh
|
||||
#
|
||||
# 2011 Nico Schottelius (nico-cdist at schottelius.org)
|
||||
#
|
||||
# This file is part of cdist.
|
||||
#
|
||||
# cdist is free software: 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.
|
||||
#
|
||||
# cdist is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with cdist. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
#
|
||||
# Check whether a process runs
|
||||
#
|
||||
|
||||
if [ -f "$__object/parameter/name" ]; then
|
||||
name="$(cat "$__object/parameter/name")"
|
||||
else
|
||||
name="$__object_id"
|
||||
fi
|
||||
|
||||
pgrep -x -f "$name" || true
|
||||
59
conf/type/__process/gencode-remote
Executable file
59
conf/type/__process/gencode-remote
Executable file
|
|
@ -0,0 +1,59 @@
|
|||
#!/bin/sh
|
||||
#
|
||||
# 2011 Nico Schottelius (nico-cdist at schottelius.org)
|
||||
#
|
||||
# This file is part of cdist.
|
||||
#
|
||||
# cdist is free software: 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.
|
||||
#
|
||||
# cdist is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with cdist. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
#
|
||||
# __file is a very basic type, which will probably be reused quite often
|
||||
#
|
||||
|
||||
if [ -f "$__object/parameter/name" ]; then
|
||||
name="$(cat "$__object/parameter/name")"
|
||||
else
|
||||
name="$__object_id"
|
||||
fi
|
||||
|
||||
runs="$(cat "$__object/explorer/runs")"
|
||||
state="$(cat "$__object/parameter/state")"
|
||||
|
||||
case "$state" in
|
||||
running)
|
||||
# Does not run, start it!
|
||||
if [ -z "$runs" ]; then
|
||||
if [ -f "$__object/parameter/start" ]; then
|
||||
cat "$__object/parameter/start"
|
||||
else
|
||||
echo "$name"
|
||||
fi
|
||||
fi
|
||||
;;
|
||||
stopped)
|
||||
# Runs, kill it!
|
||||
if [ "$runs" ]; then
|
||||
if [ -f "$__object/parameter/stop" ]; then
|
||||
cat "$__object/parameter/stop"
|
||||
else
|
||||
echo kill "${runs}"
|
||||
fi
|
||||
fi
|
||||
;;
|
||||
*)
|
||||
echo "Unknown state: $state" >&2
|
||||
exit 1
|
||||
;;
|
||||
|
||||
esac
|
||||
64
conf/type/__process/man.text
Normal file
64
conf/type/__process/man.text
Normal file
|
|
@ -0,0 +1,64 @@
|
|||
cdist-type__process(7)
|
||||
======================
|
||||
Nico Schottelius <nico-cdist--@--schottelius.org>
|
||||
|
||||
|
||||
NAME
|
||||
----
|
||||
cdist-type__process - Start or stop process
|
||||
|
||||
|
||||
DESCRIPTION
|
||||
-----------
|
||||
This cdist type allows you to define the state of a process.
|
||||
|
||||
|
||||
REQUIRED PARAMETERS
|
||||
-------------------
|
||||
state::
|
||||
State of the process: Either stopped or running.
|
||||
|
||||
|
||||
OPTIONAL PARAMETERS
|
||||
-------------------
|
||||
name::
|
||||
Process name to match on when using pgrep -f -x.
|
||||
|
||||
stop::
|
||||
Executable to use for stopping the process.
|
||||
|
||||
start::
|
||||
Executable to use for starting the process.
|
||||
|
||||
|
||||
EXAMPLES
|
||||
--------
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
# Start /usr/sbin/sshd if not running
|
||||
__process /usr/sbin/sshd --state running
|
||||
|
||||
# Start /usr/sbin/sshd if not running with a different binary
|
||||
__process /usr/sbin/sshd --state running --start "/etc/rc.d/sshd start"
|
||||
|
||||
# Stop the process using kill (the type default)
|
||||
__process /usr/sbin/sshd --state stopped
|
||||
|
||||
# Stop the process using /etc/rc.d/sshd stop
|
||||
__process /usr/sbin/sshd --state stopped --stop "/etc/rc.d/sshd stop"
|
||||
|
||||
# Ensure cups is running, which runs with -C ...:
|
||||
__process cups --start "/etc/rc.d/cups start" --state running \
|
||||
--name "/usr/sbin/cupsd -C /etc/cups/cupsd.conf"
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
|
||||
SEE ALSO
|
||||
--------
|
||||
- cdist-type(7)
|
||||
|
||||
|
||||
COPYING
|
||||
-------
|
||||
Copyright \(C) 2011 Nico Schottelius. Free use of this software is
|
||||
granted under the terms of the GNU General Public License version 3 (GPLv3).
|
||||
3
conf/type/__process/parameter/optional
Normal file
3
conf/type/__process/parameter/optional
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
name
|
||||
stop
|
||||
start
|
||||
1
conf/type/__process/parameter/required
Normal file
1
conf/type/__process/parameter/required
Normal file
|
|
@ -0,0 +1 @@
|
|||
state
|
||||
Loading…
Add table
Add a link
Reference in a new issue