install.sh: Actually check if $cfg_git_bin provides git-mirror
[girocco/mytab.git] / jobs / shlib.sh
blob0d0f84f4e068eab3bac0ba6fee64b98e77c469c7
1 #!/bin/bash
4 # Import all the variables from Girocco::Config to the local environment,
5 # prefixing them with 'cfg_'. E.g. $cfg_admin is admin's mail address now.
6 __girocco_conf="$GIROCCO_CONF"
7 [ -n "$__girocco_conf" ] || __girocco_conf="Girocco::Config"
8 [ -z "$basedir" ] || __girocco_extrainc="-I$basedir"
9 eval $(perl -I. $__girocco_extrainc -M$__girocco_conf -le \
10 'foreach (keys %Girocco::Config::) {
11 my $val = ${$Girocco::Config::{$_}}; $val ||= "";
12 print "cfg_$_=\"$val\"";
13 }')
16 alias git="$cfg_git_bin"
19 # bang CMD... will execute the command with well-defined failure mode;
20 # set bang_action to string of the failed action ('clone', 'update', ...);
21 # pre-set bang_once=1 to make sure jobs banging on a repo repeatedly will
22 # not spam the owner; re-define the bang_trap() function to do custom
23 # cleanup before bailing out
24 bang() {
25 if "$@" >>"$bang_log" 2>&1; then
26 # All right. Cool.
27 return;
29 if ! [ -e .banged ]; then
31 echo "$* failed with error code $?"
32 [ "$bang_once" ] && echo "you will not receive any more notifications until recovery"
33 echo "Log follows:"
34 cat "$bang_log"
35 } | mail -s "[$cfg_name] $proj $bang_action failed" "$mail,$cfg_admin"
37 touch .banged
38 bang_trap
39 exit 1
42 # Default bang settings:
43 bang_setup() {
44 bang_action="lame_programmer"
45 bang_once=
46 bang_trap() { :; }
47 bang_log="$(mktemp -t repomgr-XXXXXX)"
48 trap "rm \"\$bang_log\"" EXIT
52 # List all Git repositories in current directory, one-per-line
53 get_repo_list_here() {
54 find . -name base_url | cut -c 3- | sed -e 's/\/base_url$//'