fixes for gmg0p, which is t10
[fai-configs.git] / files / usr / lib / fai / get-config-dir-git / DEFAULT
1 #!/bin/bash
2
3 # (c) 2002-2006 Henning Glawe <glaweh@debian.org>
4 # (c) 2007 Holger Levsen <holger@layer-acht.org> for the modifications to use git
5
6 ### BEGIN SUBROUTINE INFO
7 # Provides-Var:
8 # Requires-Var: $FAI_CONFIG_SRC $FAI $LOGDIR
9 # Suggests-Var:
10 # Short-Description: get $FAI from a git repository.
11 ### END SUBROUTINE INFO
12
13 # matched string: "git://gitpath"
14 protocol=$(expr match "$FAI_CONFIG_SRC" '\([^:]*\)://')
15 gitpath=$(expr match "$FAI_CONFIG_SRC" '[^:]*://\([^[:space:]]\+\)')
16
17 case $protocol in
18 git)
19 giturl="git://$gitpath"
20 ;;
21 git+http)
22 echo git+http
23 giturl="http://$gitpath"
24 ;;
25 git+ssh)
26 echo git+ssh
27 giturl=$gitpath
28 ;;
29 *)
30 echo "get-config-dir-git: protocol $protocol not implemented"
31 exit 1
32 ;;
33 esac
34
35 if [ -d "$FAI/.git" ] ; then
36 echo "Updating git copy in $FAI"
37 cd $FAI
38 git pull
39 task_error 701 $?
40 else
41 echo "Checking out from git"
42 # cloning into an existing directory is not allowed
43 if [ -d $FAI ]; then rmdir $FAI; fi
44 git clone $giturl $FAI
45 task_error 702 $?
46 fi