forked from ungleich-public/cdist
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.
This commit is contained in:
parent
23eba4c5e1
commit
ad4aa19c3e
4 changed files with 97 additions and 0 deletions
26
conf/type/__run_command/gencode-remote
Executable file
26
conf/type/__run_command/gencode-remote
Executable 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
|
70
conf/type/__run_command/man.text
Normal file
70
conf/type/__run_command/man.text
Normal 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).
|
1
conf/type/__run_command/parameter/optional
Normal file
1
conf/type/__run_command/parameter/optional
Normal file
|
@ -0,0 +1 @@
|
||||||
|
command
|
0
conf/type/__run_command/parameter/required
Normal file
0
conf/type/__run_command/parameter/required
Normal file
Loading…
Reference in a new issue