]> git.openstreetmap.org Git - chef.git/blob - cookbooks/cplanet/templates/default/update.erb
Handle planet updates that need multiple passes correctly
[chef.git] / cookbooks / cplanet / templates / default / update.erb
1 #!/bin/sh
2
3 # DO NOT EDIT - This file is being maintained by Chef
4
5 USER="<%= @user %>"
6 DIR="<%= @basedir %>"
7 LOGDIR="${DIR}/log"
8
9 # start logging
10
11 exec >"${LOGDIR}/$(date +%Y%m%d-%H%M).log" 2>&1
12
13 echo "Updating planet file..."
14 sudo -u "$USER" "$DIR/bin/update-planet"
15
16 echo "Running jobs..."
17 if [ -d "$DIR/jobs" ]; then
18     for job in `find "$DIR/jobs" -type f -executable | sort`; do
19         user=`stat '--format=%U' $job`
20         echo "Running '$job' as user '$user'..."
21         su -c "$job" "$user"
22     done
23 fi
24
25 echo
26 echo "Expire old logs..."
27 find "${LOGDIR}" -mtime +28 -delete
28
29 echo "Done."
30