Hi FAI folks, while trying to add a git+ssh:// handler and switch to it from git:// (in between softupdate runs), I noticed that switching $FAI_CONFIG_SRC seems to be poorly supported right now. For instance, get-config-dir-git currently includes
if [ -d $FAI ]; then rmdir $FAI; fi but this will fail if $FAI is not empty. Other methods, such as get-config-dir-svn, don't even bother to check whether anything is in place before trying a checkout, and in general, none of the revision control methods checks whether the current contents of $FAI is from the same source as the present $FAI_CONFIG_SRC. (Oh and incidentally get-config-dir-nfs doesn't even bother to check whether the mountpoint exists.) Here's my current working copy of get-config-dir-git. My question is whether it's OK to just clobber $FAI with rm -rf. #!/bin/bash # (c) 2002-2006 Henning Glawe <[email protected]> # (c) 2007 Holger Levsen <[email protected]> # (c) 2011 Michael Goetze <[email protected]> ### BEGIN SUBROUTINE INFO # Provides-Var: # Requires-Var: $FAI_CONFIG_SRC $FAI $LOGDIR # Suggests-Var: # Short-Description: get $FAI from a git repository. ### END SUBROUTINE INFO # matched string: "git://gitpath" protocol=$(expr match "$FAI_CONFIG_SRC" '\([^:]*\)://') gitpath=$(expr match "$FAI_CONFIG_SRC" '[^:]*://\([^[:space:]]\+\)') case $protocol in git) giturl="git://$gitpath" ;; git+http) giturl="http://$gitpath" ;; git+ssh) giturl="ssh://$gitpath" ;; *) echo "get-config-dir-git: protocol $protocol not implemented" exit 1 ;; esac export GIT_DIR="$FAI/.git" if [ -d "$GIT_DIR" ] && [ `git remote show -n origin | egrep -m1 -o '[^[:space:]]+://.+'` == "$giturl" ]; then echo "Updating git copy in $FAI" git pull task_error 701 $? else echo "Checking out from git" # cloning into an existing directory is not allowed if [ -d $FAI ]; then rm -rf $FAI; fi git clone $giturl $FAI task_error 702 $? fi Regards, Michael
