diff options
author | Julien Dessaux | 2014-03-11 00:43:36 +0100 |
---|---|---|
committer | Julien Dessaux | 2014-03-11 00:43:36 +0100 |
commit | cf540a861757572e38e3d5fbd641b909953a3f9d (patch) | |
tree | 763574c3103bf4f355ca1058fa5b90d157d272aa | |
parent | Initial draft (diff) | |
download | cf-remote-master.tar.gz cf-remote-master.tar.bz2 cf-remote-master.zip |
Diffstat (limited to '')
-rwxr-xr-x | cf-remote | 42 |
1 files changed, 26 insertions, 16 deletions
@@ -8,6 +8,28 @@ REMOTE_HOST=localhost REMOTE_PORT=22 TUNNEL_PORT=2269 +function usage { + echo "Usage: $0 [OPTIONS] COMMAND [ARGS] +COMMANDS : + init : init the remote host testing environment + exec : update remote host and run cf-agent -K [ARGS] + clean : cleans the remote host testing environment +Options : + -b <branch> : the git branch you are testing (default master) + -l <remote_login> : the login to ssh with (default root) + -h <remote_host> : the host to test your policies onto (default localhost) + -p <remote_port> : the port to ssh to (default 22) + -t <tunnel_port> : the port with which to establish the reverse tunnel to your machine + -f : override remote lock" >&2 + exit 1 +} + +function cleanup { + echo "Unknown error, rerun with bash -x for further information" } +} + +trap cleanup ERR + function run_ssh { local CMD=$1 local RETURN=${2:-} @@ -34,22 +56,6 @@ function run_ssh_interactive { return $code } -function usage { - echo "Usage: $0 [OPTIONS] COMMAND [ARGS] -COMMANDS : - init : init the remote host testing environment - exec : update remote host and run cf-agent -K [ARGS] - clean : cleans the remote host testing environment -Options : - -b <branch> : the git branch you are testing (default master) - -l <remote_login> : the login to ssh with (default root) - -h <remote_host> : the host to test your policies onto (default localhost) - -p <remote_port> : the port to ssh to (default 22) - -t <tunnel_port> : the port with which to establish the reverse tunnel to your machine - -f : override remote lock" >&2 - exit 1 -} - function lock { run_ssh 'mkdir /srv/cfengine-lock' || { run_ssh "cat /srv/cfengine-lock/lock" owner @@ -89,6 +95,10 @@ case "${1:-}" in ;; exec) lock + run_ssh 'test -d /srv/cfengine' || { + echo "/srv/cfengine doesn't exist on ${REMOTE_HOST}, did you forget to run init?" + exit 1 + } run_ssh_interactive "cd /srv/cfengine && git remote update && git reset --hard origin/${BRANCH} && |