diff --git a/conf/type/__init_script/gencode-remote b/conf/type/__init_script/gencode-remote
new file mode 100644
index 00000000..d212feb7
--- /dev/null
+++ b/conf/type/__init_script/gencode-remote
@@ -0,0 +1,40 @@
+#!/bin/sh
+#
+# 2010-2011 Daniel Roth (dani-cdist@d-roth.li)
+#
+# 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/script" ]; then
+ script=$(cat "$__object/parameter/script")
+else
+ script="/$__object_id"
+fi
+
+if [ -f "$__object/parameter/base_dir" ]; then
+ base_dir=$(cat "$__object/parameter/base_dir")
+else
+ os="$(cat "$__global/explorer/os")"
+ case "$os" in
+ archlinux|netbsd|macosx|freebsd|openbsd) base_dir="/etc/rc.d" ;;
+ *) base_dir="/etc/init.d"
+ esac
+fi
+
+mode=$(cat "$__object/parameter/mode")
+
+echo "${base_dir}/${script} ${mode}"
diff --git a/conf/type/__init_script/man.text b/conf/type/__init_script/man.text
new file mode 100644
index 00000000..c33ff7b7
--- /dev/null
+++ b/conf/type/__init_script/man.text
@@ -0,0 +1,51 @@
+cdist-type__init_script(7)
+==========================
+Daniel Roth
+
+
+NAME
+----
+cdist-type__init_script - Use the init scripts
+
+
+DESCRIPTION
+-----------
+This type can be used to control your init scripts.
+
+
+REQUIRED PARAMETERS
+-------------------
+mode::
+ Specifies what shall be done with the init script (usually one of 'start'|'stop'|'restart'|'reload' or 'force-reload')
+
+
+OPTIONAL PARAMETERS
+-------------------
+script::
+ If supplied, use this as the init-script.
+ Otherwise the object_id is used.
+
+base_dir::
+ If supplied, this type uses this directory instead of '/etc/init.d'. The parameter will not need an ending slash.
+
+EXAMPLES
+--------
+
+--------------------------------------------------------------------------------
+# Reloads the configuration for lighttpd
+__init_script lighttpd --mode force-reload
+
+# Reloads the configuration for lighttpd
+__init_script lighty --script lighttpd --mode force-reload
+--------------------------------------------------------------------------------
+
+
+SEE ALSO
+--------
+- cdist-type(7)
+
+
+COPYING
+-------
+Copyright \(C) 2011 Daniel Roth. Free use of this software is
+granted under the terms of the GNU General Public License version 3 (GPLv3).
diff --git a/conf/type/__init_script/parameter/optional b/conf/type/__init_script/parameter/optional
new file mode 100644
index 00000000..5551a8f2
--- /dev/null
+++ b/conf/type/__init_script/parameter/optional
@@ -0,0 +1,2 @@
+script
+base_dir
diff --git a/conf/type/__init_script/parameter/required b/conf/type/__init_script/parameter/required
new file mode 100644
index 00000000..17ab372f
--- /dev/null
+++ b/conf/type/__init_script/parameter/required
@@ -0,0 +1 @@
+mode
diff --git a/doc/changelog b/doc/changelog
index 632ddb45..798c90e0 100644
--- a/doc/changelog
+++ b/doc/changelog
@@ -1,6 +1,7 @@
2.0.3:
* Improved logging, added --verbose, by more quiet by default
* Bugfix __user: Correct quoting (Steven Armstrong)
+ * FIXME: Support for __remote_exec and __remote_copy
2.0.2: 2011-09-27
* Add support for detection of OpenWall Linux (Matthias Teege)
diff --git a/doc/dev/logs/2011-10-06.ssh_scp_sudo_chroot b/doc/dev/logs/2011-10-06.ssh_scp_sudo_chroot
new file mode 100644
index 00000000..ec89a999
--- /dev/null
+++ b/doc/dev/logs/2011-10-06.ssh_scp_sudo_chroot
@@ -0,0 +1,87 @@
+Commands needed:
+ conf/cmd/remote_exec
+ conf/cmd/copy
+
+If ! conf/cmd/remote_exec:
+ use builtin
+If ! conf/cmd/copy:
+ use builtin
+
+--------------------------------------------------------------------------------
+
+--cmd-dir?
+$__cdist_cmd_dir
+
+--------------------------------------------------------------------------------
+ -> Depend on session!
+
+Builtin:
+ cdist.exec.run_or_fail(["scp", "-qr", source,
+ self.remote_user + "@" +
+ self.target_host + ":" +
+ destination])
+
+self.remote_prefix = ["ssh", self.remote_user + "@" + self.target_host]
+
+ self.remote_user = remote_user
+ self.remote_prefix = remote_prefix
+
+--------------------------------------------------------------------------------
+What is in a session?
+
+ base_dir
+ target_host
+
+--------------------------------------------------------------------------------
+remote_user
+ pseudo-static, can be hardcoded again
+--------------------------------------------------------------------------------
+
+Result:
+
+os.environ['__remote_exec'] = ["ssh", "-l", "root" ]
+
+os.environ['__remote_exec'] = ["ssh", "-o", "User=root" ]
+os.environ['__remote_copy'] = ["scp", "-o", "User=root" ]
+
+
+__remote_exec=~/sudossh __remote_copy=... cdist config localhost
+
+~/sudossh hostname $@...
+~/sudocopy a hostname:b
+
+~/chrootssh
+~/chrootcopy
+
+
+
+a)
+ 3 cmd verzeichnnise: cdist, sudo, chroot
+ pro aufruf variable ändern
+
+b)
+ 1 dir, mit zeug
+ pro aufruf variablen ändern
+
+
+conf/cmd/remote_exec
+
+args for __remote_exec
+ $1 = hostname
+ $2 - ... = stuff to be executed in /bin/sh on remote side
+ $2 - $7 = env
+ $7 - 12 = cmd
+
+
+args for __remote_copy
+ $1 = file here
+ $2 = hostname:destination
+
+--------------------------------------------------------------------------------
+There needs to be an easy way to change those cmds!
+--------------------------------------------------------------------------------
+Env-Passing:
+ _a=b test -> test can access $_a
+ _a=b test $_a -> $1 = "", because _a is *not* set within the shell
+ _a=b; test -> can access $_a
+ _a=b; test $_a -> $1 == "b"
diff --git a/doc/man/man1/cdist-config.text b/doc/man/man1/cdist-config.text
deleted file mode 100644
index 0c8b0735..00000000
--- a/doc/man/man1/cdist-config.text
+++ /dev/null
@@ -1,48 +0,0 @@
-cdist-config(1)
-===============
-Nico Schottelius
-
-
-NAME
-----
-cdist-config - Read basic cdist configuration
-
-
-DESCRIPTION
------------
-Cdist-config is sourced by cdist programs and provides hints on where to find
-types, manifests, etc. Generally speaking, it's just usable from within the
-core and is only of interest for cdist-developers.
-
-
-ENVIRONMENT VARIABLES
----------------------
-The following list contains environment variables that are known
-to be changed by users in various situations. To change the variable,
-use your current shell and export it, so all cdist-binaries know about it.
-
-__cdist_tmp_base_dir::
- Normally this points to /tmp. In case /tmp is not suitable for
- cdist (i.e. has noexec flag setup) you can change this variable
- to point to a better location.
-
-
-EXAMPLES
---------
-
-If /tmp has the noexec flag, you can use $HOME/.tmp for instance:
-
---------------------------------------------------------------------------------
-export __cdist_tmp_base_dir=$HOME/.tmp
---------------------------------------------------------------------------------
-
-
-SEE ALSO
---------
-cdist(7)
-
-
-COPYING
--------
-Copyright \(C) 2010-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/doc/man/man1/cdist-env.text b/doc/man/man1/cdist-env.text
deleted file mode 100644
index 9a736133..00000000
--- a/doc/man/man1/cdist-env.text
+++ /dev/null
@@ -1,49 +0,0 @@
-cdist-env(1)
-============
-Nico Schottelius
-
-
-NAME
-----
-cdist-env - Setup environment for using cdist
-
-
-SYNOPSIS
---------
-cdist-env
-
-
-DESCRIPTION
------------
-cdist-env outputs two strings suitable for usage in your current shell,
-so you can use cdist from the checkout. cdist-env essentially helps you
-to easily setup PATH and MANPATH.
-
-If you've multiple checkouts of cdist and run cdist-env from the various
-checkouts, a new run will prepend the last directory, thus ensures you
-can run it multiple times and does what one expects.
-
-EXAMPLES
---------
-For use in bourne shell variants (like dash, bash, ksh) as well as
-in csh variants (csh, tcsh):
-
---------------------------------------------------------------------------------
-eval `./bin/cdist-env`
---------------------------------------------------------------------------------
-
-For bourne shell, there is also a shorter version:
---------------------------------------------------------------------------------
-. ./bin/cdist-env
---------------------------------------------------------------------------------
-
-
-SEE ALSO
---------
-cdist(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/doc/man/man1/cdist-quickstart.text b/doc/man/man1/cdist-quickstart.text
deleted file mode 100644
index 087fd2d5..00000000
--- a/doc/man/man1/cdist-quickstart.text
+++ /dev/null
@@ -1,47 +0,0 @@
-cdist-quickstart(1)
-===================
-Nico Schottelius
-
-NAME
-----
-cdist-quickstart - Make use of cinit in 5 minutes
-
-
-SYNOPSIS
---------
-cdist-quickstart
-
-
-DESCRIPTION
------------
-cdist-quickstart is an interactive guide to cdist. It should be one
-of the first tools you use when you begin with cdist.
-
-
-EXAMPLES
---------
-To use cdist-quickstart, add the bin directory to your PATH, execute
-cdist-quickstart and enjoy cdist:
-
---------------------------------------------------------------------------------
-# Bourne shell example
-export PATH=$(pwd -P)/bin:$PATH
-
-# Alternatively, usable for csh and bsh, set's up PATH and MANPATH
-eval `./bin/cdist-env`
-
-# Let's go!
-cdist-quickstart
---------------------------------------------------------------------------------
-
-
-SEE ALSO
---------
-- cdist(7)
-- cdist-env(1)
-
-
-COPYING
--------
-Copyright \(C) 2010-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/doc/man/man1/cdist-type-emulator.text b/doc/man/man1/cdist-type-emulator.text
deleted file mode 100644
index 507c1054..00000000
--- a/doc/man/man1/cdist-type-emulator.text
+++ /dev/null
@@ -1,56 +0,0 @@
-cdist-type-emulator(1)
-======================
-Nico Schottelius
-
-
-NAME
-----
-cdist-type-emulator - Emulate type and record parameters and dependencies
-
-
-SYNOPSIS
---------
-cdist-type-emulator [TYPE ARGS]
-
-
-DESCRIPTION
------------
-cdist-type-emulator is normally called through a link to it of the
-name of a specifc type. It saves the given parameters into
-a parameters directory and the requirements into a require file.
-
-It checks whether the parameters are valid:
-
-- are required parameter given?
-- are all other required parameters specified as optional?
-
-
-EXAMPLES
---------
-Your manifest may contain stuff like this:
-
-
---------------------------------------------------------------------------------
-__addifnosuchline /tmp/linetest --line "test"
-
-__motd
---------------------------------------------------------------------------------
-
-In both cases, cdist-type-emulator is called instead of a real type.
-In the first case, the object id "/tmp/linetest" is recorded and the
-parameter "line" stored with the content "test".
-
-In the second case, __motd must be decleared as a singleton, as the
-object id is missing.
-
-
-SEE ALSO
---------
-- cdist(7)
-- cdist-type-build-emulation(1)
-
-
-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/doc/man/man7/cdist-hacker.text b/doc/man/man7/cdist-hacker.text
index b9f79d01..f8e3730e 100644
--- a/doc/man/man7/cdist-hacker.text
+++ b/doc/man/man7/cdist-hacker.text
@@ -46,9 +46,8 @@ work nor kill the authors brain:
private branch!
- Code to be included should be branched of the upstream "master" branch
- Exception: Bugfixes to a version branch
-- Code submissions should be in your master branch
- - Other branches are fine as well, but you need to tell me which branch
- your work is in!
+- On a merge request, always name the branch I should pull from
+- Always ensure **all** manpages build: ./build.sh man
- If you developed more than **one** feature, consider submitting them in
seperate branches. This way one feature can already be included, even if
the other needs to be improved.
diff --git a/lib/cdist/config.py b/lib/cdist/config.py
index fcc9ed7e..7aec7fa7 100644
--- a/lib/cdist/config.py
+++ b/lib/cdist/config.py
@@ -24,7 +24,9 @@ import datetime
import logging
log = logging.getLogger(__name__)
+<<<<<<< HEAD
import cdist.config_install
+>>>>>>> master
class Config(cdist.config_install.ConfigInstall):
pass
@@ -35,6 +37,9 @@ def config(args):
time_start = datetime.datetime.now()
+ os.environ['__remote_exec'] = "ssh -o User=root -q"
+ os.environ['__remote_copy'] = "scp -o User=root -q"
+
for host in args.host:
c = Config(host, initial_manifest=args.manifest, home=args.cdist_home, debug=args.debug)
if args.parallel:
diff --git a/lib/cdist/exec.py b/lib/cdist/exec.py
index 9cedefcc..a9b8d147 100644
--- a/lib/cdist/exec.py
+++ b/lib/cdist/exec.py
@@ -20,6 +20,7 @@
#
import logging
+import os
import subprocess
log = logging.getLogger(__name__)
@@ -32,6 +33,8 @@ def shell_run_or_debug_fail(script, *args, remote_prefix=False, **kargs):
args[0][:0] = [ "/bin/sh", "-e" ]
if remote_prefix:
+ remote_prefix = os.environ['__remote_exec'].split()
+ remote_prefix.append(os.environ['target_host'])
args[0][:0] = remote_prefix
log.debug("Shell exec cmd: %s", args)
@@ -43,6 +46,7 @@ def shell_run_or_debug_fail(script, *args, remote_prefix=False, **kargs):
subprocess.check_call(*args, **kargs)
except subprocess.CalledProcessError:
log.error("Code that raised the error:\n")
+
if remote_prefix:
run_or_fail(["cat", script], remote_prefix=remote_prefix)
@@ -60,6 +64,8 @@ def shell_run_or_debug_fail(script, *args, remote_prefix=False, **kargs):
def run_or_fail(*args, remote_prefix=False, **kargs):
if remote_prefix:
+ remote_prefix = os.environ['__remote_exec'].split()
+ remote_prefix.append(os.environ['target_host'])
args[0][:0] = remote_prefix
log.debug("Exec: " + " ".join(*args))
diff --git a/lib/cdist/path.py b/lib/cdist/path.py
index 2fcf3aea..c45ddcd6 100644
--- a/lib/cdist/path.py
+++ b/lib/cdist/path.py
@@ -57,8 +57,6 @@ class Path:
def __init__(self,
target_host,
- remote_user,
- remote_prefix,
initial_manifest=False,
base_dir=None,
debug=False):
@@ -72,9 +70,6 @@ class Path:
self.temp_dir = tempfile.mkdtemp()
self.target_host = target_host
- self.remote_user = remote_user
- self.remote_prefix = remote_prefix
-
# Input directories
self.conf_dir = os.path.join(self.base_dir, "conf")
self.cache_base_dir = os.path.join(self.base_dir, "cache")
@@ -135,28 +130,24 @@ class Path:
# FIXME: belongs to here - clearify remote*
def remote_mkdir(self, directory):
"""Create directory on remote side"""
- cdist.exec.run_or_fail(["mkdir", "-p", directory], remote_prefix=self.remote_prefix)
+ cdist.exec.run_or_fail(["mkdir", "-p", directory], remote_prefix=True)
# FIXME: belongs to here - clearify remote*
def remove_remote_dir(self, destination):
- cdist.exec.run_or_fail(["rm", "-rf", destination], remote_prefix=self.remote_prefix)
+ cdist.exec.run_or_fail(["rm", "-rf", destination], remote_prefix=True)
# FIXME: belongs to here - clearify remote*
def transfer_dir(self, source, destination):
"""Transfer directory and previously delete the remote destination"""
self.remove_remote_dir(destination)
- cdist.exec.run_or_fail(["scp", "-qr", source,
- self.remote_user + "@" +
- self.target_host + ":" +
- destination])
+ cdist.exec.run_or_fail(os.environ['__remote_copy'].split() +
+ ["-r", source, self.target_host + ":" + destination])
# FIXME: belongs to here - clearify remote*
def transfer_file(self, source, destination):
"""Transfer file"""
- cdist.exec.run_or_fail(["scp", "-q", source,
- self.remote_user + "@" +
- self.target_host + ":" +
- destination])
+ cdist.exec.run_or_fail(os.environ['__remote_copy'].split() +
+ [source, self.target_host + ":" + destination])
# FIXME: Explorer or stays
def global_explorer_output_path(self, explorer):