diff --git a/bin/cdist-config b/bin/cdist-config index ccab81cc..991d23bb 100755 --- a/bin/cdist-config +++ b/bin/cdist-config @@ -19,7 +19,7 @@ # # -__cdist_version="1.4.1" +__cdist_version="1.5.0pre" # Fail if something bogus is going on set -u diff --git a/bin/cdist-type-emulator b/bin/cdist-type-emulator index 6294870a..b3ed1f3d 100755 --- a/bin/cdist-type-emulator +++ b/bin/cdist-type-emulator @@ -155,7 +155,7 @@ if [ -e "${__cdist_object_dir}" ]; then # Allow diff to fail set +e diff -ru "${__cdist_new_object_dir}/${__cdist_name_parameter}" \ - "${__cdist_object_dir}/${__cdist_name_parameter}" \ + "${__cdist_object_dir}/${__cdist_name_parameter}" \ > "$__cdist_tmp_file"; ret=$? set -e diff --git a/build.sh b/build.sh index b91db496..4b0311c5 100755 --- a/build.sh +++ b/build.sh @@ -51,9 +51,10 @@ case "$1" in manbuild) for src in ${MAN1DSTDIR}/*.text ${MAN7DSTDIR}/*.text; do echo "Compiling manpage and html for $src" - $A2XM "$src" - $A2XH "$src" + $A2XM "$src" & + $A2XH "$src" & done + wait ;; mandirs) diff --git a/conf/type/__process/explorer/runs b/conf/type/__process/explorer/runs new file mode 100755 index 00000000..240ebef9 --- /dev/null +++ b/conf/type/__process/explorer/runs @@ -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 . +# +# +# 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 diff --git a/conf/type/__process/gencode-remote b/conf/type/__process/gencode-remote new file mode 100755 index 00000000..f8da1795 --- /dev/null +++ b/conf/type/__process/gencode-remote @@ -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 . +# +# +# __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 diff --git a/conf/type/__process/man.text b/conf/type/__process/man.text new file mode 100644 index 00000000..3f7004c7 --- /dev/null +++ b/conf/type/__process/man.text @@ -0,0 +1,64 @@ +cdist-type__process(7) +====================== +Nico Schottelius + + +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). diff --git a/conf/type/__process/parameter/optional b/conf/type/__process/parameter/optional new file mode 100644 index 00000000..3411afb4 --- /dev/null +++ b/conf/type/__process/parameter/optional @@ -0,0 +1,3 @@ +name +stop +start diff --git a/conf/type/__process/parameter/required b/conf/type/__process/parameter/required new file mode 100644 index 00000000..ff72b5c7 --- /dev/null +++ b/conf/type/__process/parameter/required @@ -0,0 +1 @@ +state diff --git a/doc/changelog b/doc/changelog index 93d0f7e4..7faf789b 100644 --- a/doc/changelog +++ b/doc/changelog @@ -1,5 +1,7 @@ 1.5.0: * Add cache functionality + * New type __process + * Restructured execution: Run whole object at once (REPHRASE) (Steven Armstrong) 1.4.1: 2011-03-25 * New type __key_value (Steven Armstrong) diff --git a/doc/dev/logs/2011-03-27.pgrep b/doc/dev/logs/2011-03-27.pgrep new file mode 100644 index 00000000..fedfa81e --- /dev/null +++ b/doc/dev/logs/2011-03-27.pgrep @@ -0,0 +1,12 @@ +Some pgrep fun when grepping for -f /usr/lib/postfix/master: + +[23:08] kr:cdist% cat cache/localhost/out/object/__process/usr/lib/postfix/master/.cdist/explorer/runs | grep -e 2529 -e 2537 -e 2538 -e 2539 +nico 2529 0.0 0.0 14848 1816 pts/45 S+ 23:08 0:00 /bin/sh /home/users/nico/oeffentlich/rechner/projekte/cdist/bin/cdist-run-remote localhost __object="/var/lib/cdist/out/object/__process/usr/lib/postfix/master" __object_id="usr/lib/postfix/master" cdist-remote-explorer-run __type_explorer /var/lib/cdist/conf/type/__process/explorer /var/lib/cdist/out/object/__process/usr/lib/postfix/master/explorer +nico 2537 0.0 0.0 41976 2324 pts/45 S+ 23:08 0:00 ssh root@localhost export PATH="/var/lib/cdist/bin:$PATH"; __object="/var/lib/cdist/out/object/__process/usr/lib/postfix/master" __object_id="usr/lib/postfix/master" cdist-remote-explorer-run __type_explorer /var/lib/cdist/conf/type/__process/explorer /var/lib/cdist/out/object/__process/usr/lib/postfix/master/explorer +root 2538 0.0 0.0 11440 1264 ? Ss 23:08 0:00 bash -c export PATH="/var/lib/cdist/bin:$PATH"; __object="/var/lib/cdist/out/object/__process/usr/lib/postfix/master" __object_id="usr/lib/postfix/master" cdist-remote-explorer-run __type_explorer /var/lib/cdist/conf/type/__process/explorer /var/lib/cdist/out/object/__process/usr/lib/postfix/master/explorer +root 2539 0.0 0.0 11440 1524 ? S 23:08 0:00 /bin/sh /var/lib/cdist/bin/cdist-remote-explorer-run __type_explorer /var/lib/cdist/conf/type/__process/explorer /var/lib/cdist/out/object/__process/usr/lib/postfix/master/explorer +2529 +2537 +2538 +2539 + diff --git a/doc/dev/todo/TAKEME b/doc/dev/todo/TAKEME index 2881c06c..138f7714 100644 --- a/doc/dev/todo/TAKEME +++ b/doc/dev/todo/TAKEME @@ -5,7 +5,8 @@ Feel free to pick one! CORE ---- -Only build manpages if necessary for types as well as for the core! +- Only build manpages if necessary for types as well as for the core! +- support $__self = relative_type/object_id TYPES ------ @@ -17,3 +18,4 @@ Types to be written/extended: -> aka sed. - __cron + diff --git a/doc/dev/todo/niconext b/doc/dev/todo/niconext index 05a44503..e9a6ddfc 100644 --- a/doc/dev/todo/niconext +++ b/doc/dev/todo/niconext @@ -5,5 +5,5 @@ Cache: -> add function to cdist-config, import from cdist-cache -Core: - - support $__self = relative_type/object_id +remove --preseed from package_apt and add debconf_set_selection or similar + -> much cleaner!