Force a non-lazy run if global.ini has changed
[puppet-git.git] / ppg-push-empty-report
blobe1881f4723e2db245fd88d36a7445ea2736a3e46
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 if [ -z "$GIT_DIR" ]; then
17 echo >&2 "Not in a git checkout"
18 exit 1
21 # puppet.conf syntax is compat with git config syntax
22 # (both are INI style). How lucky can we be? :-)
23 report_bool=$(git config -f $PUPPETCONF --bool --get agent.report)
25 # note: default is true
26 if [ "$report_bool" = 'false' ]; then
27 echo >&2 "ERROR: reports are disabled!"
28 exit 1
31 hostname=$(xhostname)
32 reportsdir='/etc/puppet/.ppg/reports'
33 mkdir -p ${reportsdir}/${hostname}
35 datestamp=$(date -u --rfc-3339=seconds|sed 's/ /_/')
36 reportfpath=${reportsdir}/${hostname}/${datestamp}.yaml
37 tempreport=$(mktemp -t ppg_report_XXXXX.yaml)
39 # use a tempfile to prevent partially prepared reports
40 # from making it to the dashboard server
41 cp ${PPG_EXEC_PATH}/unchanged.report ${tempreport}
42 report_time=$(echo $(date +"%Y-%m-%d %H:%M:%S.%6N %:z"))
43 /bin/sed -i "s,REPLACEMEDATESTAMP,${report_time},g" ${tempreport}
44 /bin/sed -i "s,REPLACEMEHOSTNAME,${hostname},g" ${tempreport}
45 mv ${tempreport} ${reportfpath}
47 # cleanup in case we have failures
48 find ${TMPDIR:/tmp} -xdev -type f -name 'ppg_report*yaml' -delete
50 exec $PPG_EXEC_PATH/ppg-push-reports