Improve example hooks and remove bashisms in them.
[metastore.git] / examples / git-metapull
bloba7a3f7e67b7a4aa881d018e61c23fb4321cf1fa4
1 #!/bin/bash
3 # This script can be used instead of git-pull when updating a remote
4 # repo to make sure the metadata matches what is stored in the repo.
5 # It will do a git-pull, show a list of changes to be made to the metadata,
6 # and after getting confirmation, apply the changes.
8 DO_MTIME=yes
9 MSFILE=".metadata"
10 umask 0077
12 [ "$DO_MTIME" = "yes" ] && MSFLAGS="-m"
14 exit_on_fail() {
15 "$@"
16 if [ $? -ne 0 ]; then
17 echo "Failed to execute: $@" >&2
18 exit 1
22 exit_on_fail \
23 git-pull
25 if [ ! -e "$MSFILE" ]; then
26 echo "\"$MSFILE\" missing" >&2
27 exit 1
30 echo "Going to apply the following metadata changes" >&2
32 metastore -c $MSFLAGS -f "$MSFILE" >&2
34 printf "%s" "Ok to apply? (y/n): " >&2
35 read REPLY
36 echo ""
38 if [ "$REPLY" != "y" ]; then
39 echo "Aborted" >&2
40 exit 1
43 exit_on_fail \
44 metastore -a $MSFLAGS -f "$MSFILE"
46 exit 0