move __run_command to types_submitted_for_inclusion directory

Signed-off-by: Nico Schottelius <nico@brief.schottelius.org>
This commit is contained in:
Nico Schottelius 2012-02-20 10:22:52 +01:00
commit cfb8e7d372
5 changed files with 6 additions and 0 deletions

View file

@ -0,0 +1,6 @@
This type is not much of use, as any type can issue code to be executed.
Thus you can implement the code directly in the calling type.
Or if you need to reuse it, create a type on its own.
Because this seems to be a common misunderstanding when people come from "non managed areas",
where script iexecution is the main focus, I documented this in cdist-hacker to clearify.

View file

@ -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 <http://www.gnu.org/licenses/>.
#
#
if [ -f "$__object/parameter/command" ]; then
cat "$__object/parameter/command"
else
echo "$name"
fi

View file

@ -0,0 +1,70 @@
cdist-type__run_command(7)
==========================
Benedikt Koeppel <code--@--benediktkoeppel.ch>
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).

View file

@ -0,0 +1 @@
command