3 if [[ -n "${PPG_DEBUG}" ]]; then
8 PPG_EXEC_PATH
=$
( dirname $
(readlink
-f "${BASH_SOURCE[0]}" ) )
9 GIT_EXEC_PATH
=$
(git
--exec-path)
10 export GIT_SSH
="${PPG_EXEC_PATH}/ppg-ssh"
12 .
${PPG_EXEC_PATH}/ppg-functions
14 pushd /etc
/puppet
>/dev
/null ||
exit 1
15 GIT_DIR
=$
(git rev-parse
--git-dir)
17 if [ -z "$GIT_DIR" ]; then
18 echo >&2 "Not in a git checkout"
22 headname
=$
(git rev-parse
--symbolic-full-name --revs-only HEAD
)
24 if [[ "$headname" != "refs/heads/production" ]]; then
25 echo >&2 "WARNING: Not on production branch"
28 initial_sha1
=$
(git rev-parse
--revs-only HEAD
)
29 lastgood_sha1
=$
(git rev-parse
--revs-only refs
/heads
/ppg
/lastgood
)
31 # resilient wrt server availability...
32 git fetch ||
echo "WARNING: error in git fetch"
34 if [[ "$headname" = "refs/heads/production" ]]; then
35 $PPG_EXEC_PATH/ppg-update-production ||
exit 1
37 if ! git pull
--ff-only ; then
38 echo "ERROR: Failed to auto-merge with ff-only,"
39 echo " perhaps the current branch needs to"
40 echo " track a remote branch or you have dirty state."
41 echo " You can merge by hand and use ppg-apply"
45 uptodate_sha1
=$
(git rev-parse
--revs-only HEAD
)
47 echo "Executing command"
49 echo " "ppg-apply
"$@"
51 echo "Log of changes to apply"
53 if [ -n "$lastgood_sha1" ]; then
54 if [[ "$uptodate_sha1" != "$lastgood_sha1" ]]; then
55 git log
--oneline ${lastgood_sha1}..
${uptodate_sha1}
57 echo "No changes in git"
59 unconditional_hour
=$
(( ( $
(hostnametoint
) % 18 ) + 5 ))
60 # incrond triggered runs use PPG_NOTLAZY
61 if [[ -z "${PPG_NOTLAZY}" ]]; then
63 if [ ${this_hour} -ne ${unconditional_hour} ]; then
64 exec $PPG_EXEC_PATH/ppg-push-empty-report
69 git log
--oneline ${uptodate_sha1}
72 exec $PPG_EXEC_PATH/ppg-apply
"$@"