Force a non-lazy run if global.ini has changed
[puppet-git.git] / ppg-push-reports
blob48d08f7802899045f9f81679e3892b2e4d7ec6b6
1 #!/bin/bash
3 if [[ -n "${PPG_DEBUG}" ]]; then
4 set -x
5 fi
7 pushd /etc/puppet >/dev/null || exit 1
9 PPG_EXEC_PATH=$( dirname $(readlink -f "${BASH_SOURCE[0]}" ) )
10 GIT_EXEC_PATH=$(git --exec-path)
11 GIT_DIR=$(git rev-parse --git-dir)
12 export GIT_SSH="${PPG_EXEC_PATH}/ppg-ssh"
14 . ${PPG_EXEC_PATH}/ppg-functions
16 ### FIXME PROXYSERVER
17 if [ -z "$GIT_DIR" ]; then
18 echo >&2 "Not in a git checkout"
19 exit 1
22 reportsdir='/etc/puppet/.ppg/reports'
23 hostname=$(xhostname)
25 # compress each report before transfer. full reports
26 # are sizable and compress 10:1
27 gzip -9 -q ${reportsdir}/${hostname}/*yaml
29 remoteurl=$(git config --get remote.origin.url)
30 remoteurl=$(dirname ${remoteurl})/reports
31 if [[ "$remoteurl" =~ 'ssh:' ]] ; then
32 # the reports go to a "reports" directory right next to
33 # the puppet remote url. we must mangle the url a bit to make
34 # it edible to rsync/scp
35 # - remove the ssh:// or git+ssh:// prefix
36 # - add a : after hostname, before the first slash
37 remoteurl=$(echo $remoteurl | sed 's!^ssh://!!;s!^git+ssh://!!;s!/!:/!')
39 # Use sftp, which is awkward but co-exists easily with git-shell
40 # as we want our VMs to have very limited access.
41 # For recursive, easy ftp, we use lftp, in "reverse mirror mode"
42 # and --Remove-source-files performs the cleanup for us.
43 # exec so we exit with lftp's error code
44 exec lftp -c "set net:timeout 10; set net:max-retries 6; mirror -R --Remove-source-files ${reportsdir}/${hostname} sftp://${remoteurl}/ "
45 else
46 # local path
47 exec rsync -vr ${reportsdir}/${hostname} ${remoteurl}/