summaryrefslogtreecommitdiff
path: root/files/update-puppet-conf.sh
blob: 9a2dd65b9e2100501a37e6c24da6b55edd43a3ce (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#!/bin/bash

# This file updates the /etc/puppet directory with recent changes to the
# /var/git/repositories/puppet repository and changes to other remote
# repositories configured as submodules of this puppet installation. This
# script it intended to be called from a cron-job or by a post-update hook.

PUPPET_DIR=/etc/puppet
ORIGIN_DIR=/var/git/repositories/puppet.git

unset GIT_DIR

if [ -d "${PUPPET_DIR}/.git" ] && [ -d "${ORIGIN_DIR}" ]; then
  cd ${PUPPET_DIR}
  #git checkout -f               || exit $?
  git reset HEAD --hard         || exit $?
  git pull ${ORIGIN_DIR} master || exit $?
  # See https://github.com/git/git/commit/c1c259e225cf39c7353c673ad2c7c84450d909c1
  git submodule update --init | grep -v "^Submodule "
  git clean -d -f
fi