From 216ea21933903be61e1fa0f4e19fb1848aca1f4f Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Sat, 26 Mar 2011 18:44:31 +0100 Subject: [PATCH 01/19] a lot of more stuff in 1.5.0 :-) Signed-off-by: Nico Schottelius --- doc/changelog | 1 + 1 file changed, 1 insertion(+) diff --git a/doc/changelog b/doc/changelog index 93d0f7e4..a99a0c3d 100644 --- a/doc/changelog +++ b/doc/changelog @@ -1,5 +1,6 @@ 1.5.0: * Add cache functionality + * Restructured execution: Run whole object at once (REPHRASE) 1.4.1: 2011-03-25 * New type __key_value (Steven Armstrong) From 74266df8aa3e9fa1fe16c8b18bd21124c88ff889 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Sat, 26 Mar 2011 18:46:58 +0100 Subject: [PATCH 02/19] rereformulate Signed-off-by: Nico Schottelius --- doc/changelog | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/changelog b/doc/changelog index a99a0c3d..b5908a36 100644 --- a/doc/changelog +++ b/doc/changelog @@ -1,6 +1,6 @@ 1.5.0: * Add cache functionality - * Restructured execution: Run whole object at once (REPHRASE) + * Restructured execution: Run whole object at once (REPHRASE) (Steven Armstrong) 1.4.1: 2011-03-25 * New type __key_value (Steven Armstrong) From 0a14aa080ce9d88366f691d8b521772b9e81f0c2 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Sat, 26 Mar 2011 23:04:06 +0100 Subject: [PATCH 03/19] prepare version change Signed-off-by: Nico Schottelius --- bin/cdist-config | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 From 4ba452874a666b6b2d774eee1eeb3b39d22df723 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Sat, 26 Mar 2011 23:45:41 +0100 Subject: [PATCH 04/19] add template for fancy idea __process Signed-off-by: Nico Schottelius --- conf/type/__process/explorer/cksum | 34 ++++++++++++++ conf/type/__process/explorer/exists | 30 +++++++++++++ conf/type/__process/gencode-local | 44 +++++++++++++++++++ conf/type/__process/gencode-remote | 46 +++++++++++++++++++ conf/type/__process/man.text | 61 ++++++++++++++++++++++++++ conf/type/__process/parameter/optional | 4 ++ 6 files changed, 219 insertions(+) create mode 100755 conf/type/__process/explorer/cksum create mode 100755 conf/type/__process/explorer/exists create mode 100755 conf/type/__process/gencode-local create mode 100755 conf/type/__process/gencode-remote create mode 100644 conf/type/__process/man.text create mode 100644 conf/type/__process/parameter/optional diff --git a/conf/type/__process/explorer/cksum b/conf/type/__process/explorer/cksum new file mode 100755 index 00000000..dcad99ba --- /dev/null +++ b/conf/type/__process/explorer/cksum @@ -0,0 +1,34 @@ +#!/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 . +# +# +# Retrieve the md5sum of a file to be created, if it is already existing. +# + +destination="/$__object_id" + +if [ -e "$destination" ]; then + if [ -f "$destination" ]; then + cksum < "$destination" + else + echo "NO REGULAR FILE" + fi +else + echo "NO FILE FOUND, NO CHECKSUM CALCULATED." +fi diff --git a/conf/type/__process/explorer/exists b/conf/type/__process/explorer/exists new file mode 100755 index 00000000..f8b85671 --- /dev/null +++ b/conf/type/__process/explorer/exists @@ -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 file exists or not +# + +destination="/$__object_id" + +if [ -e "$destination" ]; then + echo yes +else + echo no +fi diff --git a/conf/type/__process/gencode-local b/conf/type/__process/gencode-local new file mode 100755 index 00000000..1168919e --- /dev/null +++ b/conf/type/__process/gencode-local @@ -0,0 +1,44 @@ +#!/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 +# + +destination="/$__object_id" + +if [ -f "$__object/parameter/source" ]; then + source="$(cat "$__object/parameter/source")" + + if [ -f "$source" ]; then + local_cksum="$(cksum < "$source")" + remote_cksum="$(cat "$__object/explorer/cksum")" + + if [ "$local_cksum" != "$remote_cksum" ]; then + # FIXME: The username is ugly and hardcoded, replace after 1.0! + # Probably a better aproach is to have the user configured + # ~/.ssh/config to contain the right username + # Probably describe it in cdist-quickstart... + echo scp "$source" "root@${__target_host}:${destination}" + fi + else + echo "Source \"$source\" does not exist." >&2 + exit 1 + fi +fi diff --git a/conf/type/__process/gencode-remote b/conf/type/__process/gencode-remote new file mode 100755 index 00000000..7c5cf7ce --- /dev/null +++ b/conf/type/__process/gencode-remote @@ -0,0 +1,46 @@ +#!/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 +# + +destination="/$__object_id" + +# No source? Create empty file +if [ ! -f "$__object/parameter/source" ]; then + if [ no = "$(cat "$__object/explorer/exists")" ]; then + echo touch \"$destination\" + fi +fi + +# Mode settings +if [ -f "$__object/parameter/mode" ]; then + echo chmod \"$(cat "$__object/parameter/mode")\" \"$destination\" +fi + +# Group +if [ -f "$__object/parameter/group" ]; then + echo chgrp \"$(cat "$__object/parameter/group")\" \"$destination\" +fi + +# Owner +if [ -f "$__object/parameter/owner" ]; then + echo chown \"$(cat "$__object/parameter/owner")\" \"$destination\" +fi diff --git a/conf/type/__process/man.text b/conf/type/__process/man.text new file mode 100644 index 00000000..67ab53d1 --- /dev/null +++ b/conf/type/__process/man.text @@ -0,0 +1,61 @@ +cdist-type__file(7) +=================== +Nico Schottelius + + +NAME +---- +cdist-type__file - Create files + + +DESCRIPTION +----------- +This cdist type allows you to create files on the target. + + +REQUIRED PARAMETERS +------------------- +None. + + +OPTIONAL PARAMETERS +------------------- +group:: + Group to chgrp to. + +mode:: + Unix permissions, suitable for chmod. + +owner:: + User to chown to. + +source:: + If supplied, copy this file from the host running cdist to the target. + If not supplied, an empty file or directory will be created. + + +EXAMPLES +-------- + +-------------------------------------------------------------------------------- +# Create /etc/cdist-configured as an empty file +__file /etc/cdist-configured + +# Use __file from another type +__file /etc/issue --source "$__type/files/archlinux" + +# Supply some more settings +__file /etc/shadow --source "$__type/files/shadow" \ + --owner root --group shadow --mode 0640 +-------------------------------------------------------------------------------- + + +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..06120518 --- /dev/null +++ b/conf/type/__process/parameter/optional @@ -0,0 +1,4 @@ +group +mode +owner +source From 6c6ece859bb035429a67446dd41bf183d0a93370 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Sat, 26 Mar 2011 23:51:45 +0100 Subject: [PATCH 05/19] update documentation for __process Signed-off-by: Nico Schottelius --- conf/type/__process/man.text | 35 ++++++++--------------------------- 1 file changed, 8 insertions(+), 27 deletions(-) diff --git a/conf/type/__process/man.text b/conf/type/__process/man.text index 67ab53d1..2273f6f9 100644 --- a/conf/type/__process/man.text +++ b/conf/type/__process/man.text @@ -1,52 +1,33 @@ -cdist-type__file(7) -=================== +cdist-type__process(7) +====================== Nico Schottelius NAME ---- -cdist-type__file - Create files +cdist-type__process - Start or stop process DESCRIPTION ----------- -This cdist type allows you to create files on the target. +This cdist type allows you to define the state of a process. REQUIRED PARAMETERS ------------------- -None. +state:: + State of the process: Either stopped or running. OPTIONAL PARAMETERS ------------------- -group:: - Group to chgrp to. - -mode:: - Unix permissions, suitable for chmod. - -owner:: - User to chown to. - -source:: - If supplied, copy this file from the host running cdist to the target. - If not supplied, an empty file or directory will be created. - +None EXAMPLES -------- -------------------------------------------------------------------------------- -# Create /etc/cdist-configured as an empty file -__file /etc/cdist-configured - -# Use __file from another type -__file /etc/issue --source "$__type/files/archlinux" - -# Supply some more settings -__file /etc/shadow --source "$__type/files/shadow" \ - --owner root --group shadow --mode 0640 +__process /usr/sbin/sshd --state running --start "/etc/rc.d/sshd start" -------------------------------------------------------------------------------- From 06fe371b1df80492b300093b7db77ee47ad7dc39 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Sat, 26 Mar 2011 23:56:17 +0100 Subject: [PATCH 06/19] create type explorer "runs" Signed-off-by: Nico Schottelius --- conf/type/__process/explorer/cksum | 34 ------------------- conf/type/__process/explorer/{exists => runs} | 10 ++---- 2 files changed, 3 insertions(+), 41 deletions(-) delete mode 100755 conf/type/__process/explorer/cksum rename conf/type/__process/explorer/{exists => runs} (85%) diff --git a/conf/type/__process/explorer/cksum b/conf/type/__process/explorer/cksum deleted file mode 100755 index dcad99ba..00000000 --- a/conf/type/__process/explorer/cksum +++ /dev/null @@ -1,34 +0,0 @@ -#!/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 . -# -# -# Retrieve the md5sum of a file to be created, if it is already existing. -# - -destination="/$__object_id" - -if [ -e "$destination" ]; then - if [ -f "$destination" ]; then - cksum < "$destination" - else - echo "NO REGULAR FILE" - fi -else - echo "NO FILE FOUND, NO CHECKSUM CALCULATED." -fi diff --git a/conf/type/__process/explorer/exists b/conf/type/__process/explorer/runs similarity index 85% rename from conf/type/__process/explorer/exists rename to conf/type/__process/explorer/runs index f8b85671..685dd19e 100755 --- a/conf/type/__process/explorer/exists +++ b/conf/type/__process/explorer/runs @@ -18,13 +18,9 @@ # along with cdist. If not, see . # # -# Check whether file exists or not +# Check whether a process runs # -destination="/$__object_id" +process="$__object_id" -if [ -e "$destination" ]; then - echo yes -else - echo no -fi +pgrep -f "$process" || true From e4467de8fd9dfe044e65d2cce1972c102513441e Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Sun, 27 Mar 2011 00:05:30 +0100 Subject: [PATCH 07/19] describe how __process should work Signed-off-by: Nico Schottelius --- conf/type/__process/man.text | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/conf/type/__process/man.text b/conf/type/__process/man.text index 2273f6f9..623ec4b2 100644 --- a/conf/type/__process/man.text +++ b/conf/type/__process/man.text @@ -21,13 +21,28 @@ state:: OPTIONAL PARAMETERS ------------------- -None +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" -------------------------------------------------------------------------------- From e7c1d3f16b774c3b33f7b41aa7dbec4041dd6d5c Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Sun, 27 Mar 2011 00:07:39 +0100 Subject: [PATCH 08/19] add parameter Signed-off-by: Nico Schottelius --- conf/type/__process/gencode-local | 44 -------------------------- conf/type/__process/parameter/optional | 6 ++-- conf/type/__process/parameter/required | 1 + 3 files changed, 3 insertions(+), 48 deletions(-) delete mode 100755 conf/type/__process/gencode-local create mode 100644 conf/type/__process/parameter/required diff --git a/conf/type/__process/gencode-local b/conf/type/__process/gencode-local deleted file mode 100755 index 1168919e..00000000 --- a/conf/type/__process/gencode-local +++ /dev/null @@ -1,44 +0,0 @@ -#!/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 -# - -destination="/$__object_id" - -if [ -f "$__object/parameter/source" ]; then - source="$(cat "$__object/parameter/source")" - - if [ -f "$source" ]; then - local_cksum="$(cksum < "$source")" - remote_cksum="$(cat "$__object/explorer/cksum")" - - if [ "$local_cksum" != "$remote_cksum" ]; then - # FIXME: The username is ugly and hardcoded, replace after 1.0! - # Probably a better aproach is to have the user configured - # ~/.ssh/config to contain the right username - # Probably describe it in cdist-quickstart... - echo scp "$source" "root@${__target_host}:${destination}" - fi - else - echo "Source \"$source\" does not exist." >&2 - exit 1 - fi -fi diff --git a/conf/type/__process/parameter/optional b/conf/type/__process/parameter/optional index 06120518..4189bb2c 100644 --- a/conf/type/__process/parameter/optional +++ b/conf/type/__process/parameter/optional @@ -1,4 +1,2 @@ -group -mode -owner -source +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 From 97dd649f447a917c63200cce74d35aadfdc2b63b Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Sun, 27 Mar 2011 22:55:58 +0200 Subject: [PATCH 09/19] update todos Signed-off-by: Nico Schottelius --- doc/dev/todo/TAKEME | 4 +++- doc/dev/todo/niconext | 4 ++-- 2 files changed, 5 insertions(+), 3 deletions(-) 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! From d21cfa66a03e681bf3f24774eb1995c49c85a717 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Sun, 27 Mar 2011 22:58:42 +0200 Subject: [PATCH 10/19] +indent Signed-off-by: Nico Schottelius --- bin/cdist-type-emulator | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 From ec2971787090c11c5eb029a0a225ed1b9b56cc09 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Sun, 27 Mar 2011 22:59:00 +0200 Subject: [PATCH 11/19] in theory finish __process Signed-off-by: Nico Schottelius --- conf/type/__process/gencode-remote | 46 ++++++++++++++++-------------- 1 file changed, 25 insertions(+), 21 deletions(-) diff --git a/conf/type/__process/gencode-remote b/conf/type/__process/gencode-remote index 7c5cf7ce..219230db 100755 --- a/conf/type/__process/gencode-remote +++ b/conf/type/__process/gencode-remote @@ -21,26 +21,30 @@ # __file is a very basic type, which will probably be reused quite often # -destination="/$__object_id" +process="$__object_id" -# No source? Create empty file -if [ ! -f "$__object/parameter/source" ]; then - if [ no = "$(cat "$__object/explorer/exists")" ]; then - echo touch \"$destination\" - fi -fi +runs="$(cat "$__object/explorer/runs")" +state="$(cat "$__object/parameter/state")" -# Mode settings -if [ -f "$__object/parameter/mode" ]; then - echo chmod \"$(cat "$__object/parameter/mode")\" \"$destination\" -fi - -# Group -if [ -f "$__object/parameter/group" ]; then - echo chgrp \"$(cat "$__object/parameter/group")\" \"$destination\" -fi - -# Owner -if [ -f "$__object/parameter/owner" ]; then - echo chown \"$(cat "$__object/parameter/owner")\" \"$destination\" -fi +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 "$process" + 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 + ;; +esac From 4cd70b7abbf19a3a1b71d4e5176ec8b67f515576 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Sun, 27 Mar 2011 23:10:29 +0200 Subject: [PATCH 12/19] document pgrep fun Signed-off-by: Nico Schottelius --- doc/dev/logs/2011-03-27.pgrep | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 doc/dev/logs/2011-03-27.pgrep 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 + From 0e8d36f5928a5869f67eb79c55f3e1ff69973f08 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Sun, 27 Mar 2011 23:12:25 +0200 Subject: [PATCH 13/19] add -x to pgrep Signed-off-by: Nico Schottelius --- conf/type/__process/explorer/runs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/conf/type/__process/explorer/runs b/conf/type/__process/explorer/runs index 685dd19e..6d2bdf8c 100755 --- a/conf/type/__process/explorer/runs +++ b/conf/type/__process/explorer/runs @@ -23,4 +23,5 @@ process="$__object_id" -pgrep -f "$process" || true +ps aux +pgrep -x -f "$process" || true From 40b7b158c0c38708574a2d4354490de83df23c3c Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Sun, 27 Mar 2011 23:13:18 +0200 Subject: [PATCH 14/19] -debug Signed-off-by: Nico Schottelius --- conf/type/__process/explorer/runs | 1 - 1 file changed, 1 deletion(-) diff --git a/conf/type/__process/explorer/runs b/conf/type/__process/explorer/runs index 6d2bdf8c..19d259a6 100755 --- a/conf/type/__process/explorer/runs +++ b/conf/type/__process/explorer/runs @@ -23,5 +23,4 @@ process="$__object_id" -ps aux pgrep -x -f "$process" || true From b8002efa6d630006b333bb7e650f7092fcd3659e Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Sun, 27 Mar 2011 23:29:10 +0200 Subject: [PATCH 15/19] add support for __process --name (in theory) Signed-off-by: Nico Schottelius --- conf/type/__process/explorer/runs | 8 ++++++-- conf/type/__process/gencode-remote | 13 +++++++++++-- conf/type/__process/man.text | 3 +++ conf/type/__process/parameter/optional | 1 + 4 files changed, 21 insertions(+), 4 deletions(-) diff --git a/conf/type/__process/explorer/runs b/conf/type/__process/explorer/runs index 19d259a6..240ebef9 100755 --- a/conf/type/__process/explorer/runs +++ b/conf/type/__process/explorer/runs @@ -21,6 +21,10 @@ # Check whether a process runs # -process="$__object_id" +if [ -f "$__object/parameter/name" ]; then + name="$(cat "$__object/parameter/name")" +else + name="$__object_id" +fi -pgrep -x -f "$process" || true +pgrep -x -f "$name" || true diff --git a/conf/type/__process/gencode-remote b/conf/type/__process/gencode-remote index 219230db..f8da1795 100755 --- a/conf/type/__process/gencode-remote +++ b/conf/type/__process/gencode-remote @@ -21,7 +21,11 @@ # __file is a very basic type, which will probably be reused quite often # -process="$__object_id" +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")" @@ -33,7 +37,7 @@ case "$state" in if [ -f "$__object/parameter/start" ]; then cat "$__object/parameter/start" else - echo "$process" + echo "$name" fi fi ;; @@ -47,4 +51,9 @@ case "$state" in fi fi ;; + *) + echo "Unknown state: $state" >&2 + exit 1 + ;; + esac diff --git a/conf/type/__process/man.text b/conf/type/__process/man.text index 623ec4b2..5f49865b 100644 --- a/conf/type/__process/man.text +++ b/conf/type/__process/man.text @@ -21,6 +21,9 @@ state:: OPTIONAL PARAMETERS ------------------- +name:: + Process name to match on when using pgrep -f -x. + stop:: Executable to use for stopping the process. diff --git a/conf/type/__process/parameter/optional b/conf/type/__process/parameter/optional index 4189bb2c..3411afb4 100644 --- a/conf/type/__process/parameter/optional +++ b/conf/type/__process/parameter/optional @@ -1,2 +1,3 @@ +name stop start From 271aa95a4da8f20f258fdb428faa4660197fbefa Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Sun, 27 Mar 2011 23:32:28 +0200 Subject: [PATCH 16/19] add --name example to manpage Signed-off-by: Nico Schottelius --- conf/type/__process/man.text | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/conf/type/__process/man.text b/conf/type/__process/man.text index 5f49865b..d144498d 100644 --- a/conf/type/__process/man.text +++ b/conf/type/__process/man.text @@ -46,6 +46,11 @@ __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" + -------------------------------------------------------------------------------- From 741e505b1e90acd584fbf232ff4945bdea40c98a Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Sun, 27 Mar 2011 23:33:27 +0200 Subject: [PATCH 17/19] more interesting stuff for 1.5.0 Signed-off-by: Nico Schottelius --- doc/changelog | 1 + 1 file changed, 1 insertion(+) diff --git a/doc/changelog b/doc/changelog index b5908a36..7faf789b 100644 --- a/doc/changelog +++ b/doc/changelog @@ -1,5 +1,6 @@ 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 From 417ce618217a49a83d4d83cb5260bfba2a5a3abc Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Mon, 28 Mar 2011 08:54:41 +0200 Subject: [PATCH 18/19] -'' Signed-off-by: Nico Schottelius --- conf/type/__process/man.text | 1 - 1 file changed, 1 deletion(-) diff --git a/conf/type/__process/man.text b/conf/type/__process/man.text index d144498d..3f7004c7 100644 --- a/conf/type/__process/man.text +++ b/conf/type/__process/man.text @@ -50,7 +50,6 @@ __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" - -------------------------------------------------------------------------------- From dbe74dcc3330117d01df306833c019361c448742 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Mon, 28 Mar 2011 08:56:53 +0200 Subject: [PATCH 19/19] compile all manpages in parallel! Signed-off-by: Nico Schottelius --- build.sh | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) 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)