jobs/: Use Girocco::Config for all configurable values
[girocco.git] / jobs / shlib.sh
blob362ed040743b42344cca50c58c1c7d64be927c8d
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 eval $(perl -I. -MGirocco::Config -le 'foreach (keys %Girocco::Config::) { print "cfg_$_=\"".quotemeta(${$Girocco::Config::{$_}})."\""; }')
9 alias git="$git_bin"
12 # bang CMD... will execute the command with well-defined failure mode;
13 # set bang_action to string of the failed action ('clone', 'update', ...);
14 # pre-set bang_once=1 to make sure jobs banging on a repo repeatedly will
15 # not spam the owner; re-define the bang_trap() function to do custom
16 # cleanup before bailing out
17 bang() {
18 if "$@" >>"$bang_log" 2>&1; then
19 # All right. Cool.
20 return;
22 if ! [ -e .banged ]; then
24 echo "$* failed with error code $?"
25 [ "$bang_once" ] && echo "you will not receive any more notifications until recovery"
26 echo "Log follows:"
27 cat "$bang_log"
28 } | mail -s "[$cfg_name] $proj $bang_action failed" "$mail,$cfg_admin"
30 touch .banged
31 bang_trap
32 exit 1
35 # Default bang settings:
36 bang_action="lame_programmer"
37 bang_once=
38 bang_trap() { }
39 bang_log="$(mktemp -t repomgr-XXXXXX)"
40 trap "rm \"\$bang_log\"" EXIT
43 # List all Git repositories in current directory, one-per-line
44 get_repo_list_here() {
45 find . -name base_url | cut -c 3- | sed -e 's/\/base_url$//'