scripts: purge use of test '-a' and '-o' ops and clean up
[girocco.git] / toolbox / update-all-projects.sh
blob0d305e54b611b70bb1a0028dc24e459f928cf850
1 #!/bin/sh
3 # Update all current projects config and hooks
5 # If one or more project names are given, just update those instead
7 # update-all-projects [--dry-run] [projname]...
9 set -e
11 . @basedir@/shlib.sh
13 force=
14 dryrun=
15 [ "$1" != "--force" ] && [ "$1" != "-f" ] || { force=1; shift; }
16 [ "$1" != "--dry-run" ] && [ "$1" != "-n" ] || { dryrun=1; shift; }
17 case "$1" in -*) echo "Invalid options: $1" >&2; exit 1;; esac
19 umask 002
21 if [ -z "$cfg_owning_group" ]; then
22 if [ -z "$force" ]; then
23 echo "No owning_group set, refusing to run without --force" >&2
24 exit 1
28 mydir="$(cd "$(dirname "$0")" && pwd -P)"
29 required='update-all-config.sh update-all-hooks.sh'
30 bad=
31 for r in $required; do
32 if ! [ -x "$mydir/$r" ]; then
33 echo "missing required script: $mydir/$r" >&2
34 bad=1
36 done
37 [ -z "$bad" ] || exit 1
38 echo "Running update-all-config..."
39 "$mydir/update-all-config.sh" ${force:+--force} ${dryrun:+--dry-run} "$@"
40 echo "Running update-all-hooks..."
41 "$mydir/update-all-hooks.sh" ${force:+--force} ${dryrun:+--dry-run} "$@"