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"
29 initial_sha1
=$
(git rev-parse
--revs-only HEAD
)
30 lastgood_sha1
=$
(git rev-parse
--revs-only ppg
/lastgood
)
32 # resilient wrt server availability...
33 git fetch
--prune ||
echo "WARNING: error in git fetch"
35 if [[ "$headname" = "refs/heads/production" ]]; then
36 $PPG_EXEC_PATH/ppg-update-production ||
exit 1
38 # On EL6, git pull does not know --prune
39 if ! git pull
--ff-only ; then
40 echo "ERROR: Failed to auto-merge with ff-only,"
41 echo " perhaps the current branch needs to"
42 echo " track a remote branch or you have dirty state."
43 echo " You can merge by hand and use ppg-apply"
47 uptodate_sha1
=$
(git rev-parse
--revs-only HEAD
)
49 echo "Executing command"
51 echo " "ppg-apply
"$@"
53 echo "Log of changes to apply"
55 if [ -n "$lastgood_sha1" ]; then
56 if [[ "$uptodate_sha1" != "$lastgood_sha1" ]]; then
57 git
--no-pager log
--oneline -n 100 ${lastgood_sha1}..
${uptodate_sha1}
59 echo "No changes in git"
61 unconditional_hour
=$
(( ( $
(hostnametoint
) % 18 ) + 5 ))
62 global_ini_changed
=$
( test /mnt
/data
/conf
/global.ini
-nt /mnt
/data
/conf
/global.ini.parsed
)$?
63 # incrond triggered runs use PPG_NOTLAZY
64 # global.ini newer than global.ini.parsed will skip lazy too
65 if [[ -z "${PPG_NOTLAZY}" && $global_ini_changed -ne 0 ]]; then
67 if [ ${this_hour} -ne ${unconditional_hour} ]; then
68 exec $PPG_EXEC_PATH/ppg-push-empty-report
73 git
--no-pager log
--oneline -n 100 ${uptodate_sha1}
76 exec $PPG_EXEC_PATH/ppg-apply
"$@"