Fix submitted form detection
[girocco/ztw.git] / clone.sh
blobb01ac8448f9924d082d4b1bb1a6da456da0a9cae
1 #!/bin/bash
3 export PATH=/home/pasky/bin:$PATH
5 set -e
7 log="$(mktemp -t repomgr-XXXXXX)"
8 proj="$1"
9 cd "$proj"
10 url="$(cat base_url)"
11 mail="$(cat .admin_contact)"
13 bang() {
14 if ! "$@" >>"$log" 2>&1; then
16 echo "$* failed with error code $?"
17 echo "Log follows:"
18 cat "$log"
19 } | mail -s "[repo.or.cz] $proj clone failed" "$mail",pasky@ucw.cz
21 rm -rf /srv/git/$proj.git
22 cd .. && rm -rf "$proj"
23 rm "$log"
24 exit 1
28 bang git clone --bare "$url" repodir
29 GIT_DIR=repodir bang git repack -a -d
30 ! [ -d /srv/git/"$proj".git ]
31 bang mv repodir /srv/git/"$proj".git
32 bang mv base_url /srv/git/"$proj".git/description
33 bang mv .admin_contact /srv/git/"$proj".git/owner
34 cd .. && rm -rf "$proj"
35 # NO bang AT THIS POINT! rm -rf depends on cwd.
36 echo "Congratulations!" | mail -s "[repo.or.cz] $proj clone completed" "$mail",pasky@ucw.cz
37 rm "$log"