From ad4aa19c3e54d16096dca9555e3398a9ce941522 Mon Sep 17 00:00:00 2001 From: Benedikt Koeppel Date: Sun, 12 Feb 2012 15:08:34 +0100 Subject: [PATCH] new type __run_command This cdist type allows you to run a specific command once at installation time. optional parameter: --command Command (with arguments) to run. --- conf/type/__run_command/gencode-remote | 26 ++++++++ conf/type/__run_command/man.text | 70 ++++++++++++++++++++++ conf/type/__run_command/parameter/optional | 1 + conf/type/__run_command/parameter/required | 0 4 files changed, 97 insertions(+) create mode 100755 conf/type/__run_command/gencode-remote create mode 100644 conf/type/__run_command/man.text create mode 100644 conf/type/__run_command/parameter/optional create mode 100644 conf/type/__run_command/parameter/required diff --git a/conf/type/__run_command/gencode-remote b/conf/type/__run_command/gencode-remote new file mode 100755 index 00000000..7ffd9a7b --- /dev/null +++ b/conf/type/__run_command/gencode-remote @@ -0,0 +1,26 @@ +#!/bin/sh +# +# 2012 Benedikt Koeppel (code at benediktkoeppel.ch) +# +# 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 . +# +# + +if [ -f "$__object/parameter/command" ]; then + cat "$__object/parameter/command" +else + echo "$name" +fi diff --git a/conf/type/__run_command/man.text b/conf/type/__run_command/man.text new file mode 100644 index 00000000..5ea553c3 --- /dev/null +++ b/conf/type/__run_command/man.text @@ -0,0 +1,70 @@ +cdist-type__run_command(7) +========================== +Benedikt Koeppel + + +NAME +---- +cdist-type__run_command - Run a command + + +DESCRIPTION +----------- +This cdist type allows you to run a specific command once at installation time. + + +REQUIRED PARAMETERS +------------------- + + +OPTIONAL PARAMETERS +------------------- +command:: + Command (with arguments) to run. + + If no command is give, then the object_id is executed. + + + +EXAMPLES +-------- + +-------------------------------------------------------------------------------- +# Run a command +__run_command "/etc/init.d/mysql restart" +# runs `/etc/init.d/mysql restart` (the "object_id") + +# Run the same command: +__run_command restart-mysql --command "/etc/init.d/mysql restart" +# runs `/etc/init.d/mysql restart` (the --command argument) +# additionally, it can easily be referenced (for example in a require="..." +#as __run_command/restart-mysql + +# Run a script: +__run_command install-pear --command "$(cat <<-EOF + /usr/bin/pear install --force Auth + /usr/bin/pear install --force HTML_Template_IT-1.2.1 + /usr/bin/pear install --force MDB2 + /usr/bin/pear install --force MDB2#mysql + /usr/bin/pear config-set preferred_state beta; + /usr/bin/pear install --force --alldeps Spreadsheet_Excel_Writer; + /usr/bin/pear config-set preferred_state stable + /usr/bin/pear install --force HTTP_Request + /usr/bin/pear install --force Mail + /usr/bin/pear install --force Auth_HTTP + /usr/bin/pear install --force XML_RPC +EOF +)" + +-------------------------------------------------------------------------------- + + +SEE ALSO +-------- +- cdist-type(7) + + +COPYING +------- +Copyright \(C) 2012 Benedikt Koeppel. Free use of this software is +granted under the terms of the GNU General Public License version 3 (GPLv3). diff --git a/conf/type/__run_command/parameter/optional b/conf/type/__run_command/parameter/optional new file mode 100644 index 00000000..aa56d324 --- /dev/null +++ b/conf/type/__run_command/parameter/optional @@ -0,0 +1 @@ +command diff --git a/conf/type/__run_command/parameter/required b/conf/type/__run_command/parameter/required new file mode 100644 index 00000000..e69de29b