]> gitweb.fluxo.info Git - scripts.git/commitdiff
Sandbox: be functional
authorSilvio Rhatto <rhatto@riseup.net>
Sat, 20 Jun 2015 14:09:11 +0000 (11:09 -0300)
committerSilvio Rhatto <rhatto@riseup.net>
Sat, 20 Jun 2015 14:09:11 +0000 (11:09 -0300)
sandbox

diff --git a/sandbox b/sandbox
index 0ad80e7827128e3fdf45c2cd8c8fc2a608c127d7..7eda3290297e508c6b28a9be80f7183df643142b 100755 (executable)
--- a/sandbox
+++ b/sandbox
@@ -12,19 +12,12 @@ REPO="$2"
 BOOTSTRAP="git://git.sarava.org/puppet-bootstrap.git"
 TEMPLATES="git://git.sarava.org/templates.git"
 
-# Syntax check
-if [ -z "$PROJECT" ]; then
-  echo "usage: $BASENAME <path> [url]"
-  exit 1
-fi
-
-# Clone or initialize
-if [ ! -z "$REPO" ]; then
-  git clone $URL $CODE/$PROJECT
-else
+function sandbox_init {
   echo "Initializing $PROJECT..."
   mkdir -p $CODE/$PROJECT
+}
 
+function sandbox_git {
   (
     cd $CODE/$PROJECT
     touch .gitignore
@@ -57,58 +50,78 @@ else
       git flow init -d
     fi
   )
-fi
+}
 
+function sandbox_ikiwiki {
 # Ikiwiki integration
-(
-  if [ ! -d "$HOME/file/templates" ]; then
-    echo "Please clone $TEMPLATES into $HOME/file/templates"
-  else
-    echo ""
-    echo "Setting up ikiwiki integration..."
-    cd $CODE/$PROJECT
-    git checkout develop
+  (
+    if [ ! -d "$HOME/file/templates" ]; then
+      echo "Please clone $TEMPLATES into $HOME/file/templates"
+    else
+      echo ""
+      echo "Setting up ikiwiki integration..."
+      cd $CODE/$PROJECT
+      git checkout develop
 
-    cat $HOME/file/templates/ikiwiki/.gitignore  >> .gitignore
+      cat $HOME/file/templates/ikiwiki/.gitignore  >> .gitignore
 
-    if [ ! -e "index.mdwn" ]; then
-      cp $HOME/file/templates/ikiwiki/index.mdwn .
-    fi
+      if [ ! -e "index.mdwn" ]; then
+        cp $HOME/file/templates/ikiwiki/index.mdwn .
+      fi
 
-    if [ ! -e "Makefile" ]; then
-      cp $HOME/file/templates/ikiwiki/Makefile .
-    elif ! grep -q ^wiki: Makefile; then
-      grep -v '^#' $HOME/file/templates/ikiwiki/Makefile >> Makefile
-    fi
+      if [ ! -e "Makefile" ]; then
+        cp $HOME/file/templates/ikiwiki/Makefile .
+      elif ! grep -q ^wiki: Makefile; then
+        grep -v '^#' $HOME/file/templates/ikiwiki/Makefile >> Makefile
+      fi
 
-    if [ ! -d "templates" ]; then
-      cp r $HOME/file/templates/ikiwiki/templates .
-    fi
+      if [ ! -d "templates" ]; then
+        cp r $HOME/file/templates/ikiwiki/templates .
+      fi
+
+      if [ ! -d "bootstrap" ]; then
+        cp r $HOME/file/bootstrap/ikiwiki/bootstrap .
+      fi
 
-    if [ ! -d "bootstrap" ]; then
-      cp r $HOME/file/bootstrap/ikiwiki/bootstrap .
+      git add .
+      git commit -a -m "Static site generation support using ikiwiki"
     fi
+  )
+}
 
-    git add .
-    git commit -a -m "Static site generation support using ikiwiki"
-  fi
-)
-
-# Vagrant integration
-(
-  echo ""
-  echo "Setting up vagrant integration..."
-  cd $CODE/$PROJECT
-  git checkout develop
-  echo '.vagrant' >> .gitignore
-  git commit -a -m "Adds vagrant support"
-
-  # Use the best approach
-  #git clone $BOOSTRAP $CODE/$PROJECT/puppet
-  #git submodule add $BOOSTRAP puppet
-  git remote add puppet $BOOTSTRAP
-  git subtree add --prefix puppet $BOOTSTRAP master --squash
-)
+function sandbox_vagrant {
+  # Vagrant integration
+  (
+    echo ""
+    echo "Setting up vagrant integration..."
+    cd $CODE/$PROJECT
+    git checkout develop
+    echo '.vagrant' >> .gitignore
+    git commit -a -m "Adds vagrant support"
+
+    # Use the best approach
+    #git clone $BOOSTRAP $CODE/$PROJECT/puppet
+    #git submodule add $BOOSTRAP puppet
+    git remote add puppet $BOOTSTRAP
+    git subtree add --prefix puppet $BOOTSTRAP master --squash
+  )
+}
+
+# Syntax check
+if [ -z "$PROJECT" ]; then
+  echo "usage: $BASENAME <path> [url]"
+  exit 1
+fi
+
+# Clone or initialize
+if [ ! -z "$REPO" ]; then
+  git clone $URL $CODE/$PROJECT
+else
+  sandbox_init
+  sandbox_git
+  sandbox_ikiwiki
+  sandbox_vagrant
+fi
 
 # Teardown
 echo "Welcome to your new project :)"