]> gitweb.fluxo.info Git - scripts.git/commitdiff
Templater enhancements and fixes
authorSilvio Rhatto <rhatto@riseup.net>
Thu, 26 Oct 2017 13:16:12 +0000 (11:16 -0200)
committerSilvio Rhatto <rhatto@riseup.net>
Thu, 26 Oct 2017 13:16:12 +0000 (11:16 -0200)
templater

index 8ff36f914ee469c267c24c8e61ef0c82e698fd7a..dc786f13a5d235507037ff0e4bb6e57d296800f0 100755 (executable)
--- a/templater
+++ b/templater
@@ -12,6 +12,14 @@ MODULES="$*"
 BOOTSTRAP="https://git.fluxo.info/puppet-bootstrap.git"
 TEMPLATES="https://git.fluxo.info/templates.git"
 
+# Initialize project
+function __templater_init {
+  if [ ! -d "$PROJECT" ]; then
+    echo "Initializing $PROJECT..."
+    mkdir -p $PROJECT
+  fi
+}
+
 # Read a parameter from user
 function __templater_ask {
   local input
@@ -35,7 +43,7 @@ function __templater_implementations {
 # Checkout to develop branch if available
 function __templater_checkout_develop {
   (
-    cd $PROJECT
+    cd $PROJECT &> /dev/null
 
     if git branch --list develop | grep -q develop; then
       git checkout develop
@@ -43,19 +51,11 @@ function __templater_checkout_develop {
   )
 }
 
-# Initialize project
-function __templater_init {
-  if [ ! -d "$PROJECT" ]; then
-    echo "Initializing $PROJECT..."
-    mkdir -p $PROJECT
-  fi
-}
-
 # Git implementation
 function templater_git {
   if [ ! -d "$PROJECT/.git" ]; then
   (
-    cd $PROJECT
+    cd $PROJECT &> /dev/null
     touch .gitignore
 
     echo "$PROJECT"                                     > README.md
@@ -70,8 +70,15 @@ function templater_git {
 
     git init
     git add .
-    git commit -m "Initial import"
+    #git commit -m "Initial import"
+  )
+  fi
+}
 
+# Git hooks implementation
+function templater_githooks {
+  if [ ! -d "$PROJECT/.git" ]; then
+  (
     if which git-hooks &> /dev/null; then
       echo ""
       echo "Installing hooks..."
@@ -85,7 +92,7 @@ function templater_git {
 function templater_gitflow {
   if ! grep -q '^\[gitflow' $PROJECT/.git/config; then
   (
-    cd $PROJECT
+    cd $PROJECT &> /dev/null
 
     if ! git branch --list develop | grep -q develop; then
       git branch develop
@@ -106,7 +113,7 @@ function templater_vagrant {
   (
     echo ""
     echo "Setting up vagrant implementation..."
-    cd $PROJECT
+    cd $PROJECT &> /dev/null
     #__templater_checkout_develop
     vagrant init
     echo '.vagrant' >> .gitignore
@@ -121,7 +128,7 @@ function templater_kvmx {
   (
     echo ""
     echo "Setting up vagrant implementation..."
-    cd $PROJECT
+    cd $PROJECT &> /dev/null
     kvmx init
     git commit -a -m "Adds kvmx support"
   )
@@ -134,7 +141,7 @@ function templater_puppet {
   (
     echo ""
     echo "Setting up puppet implementation..."
-    cd $PROJECT
+    cd $PROJECT &> /dev/null
 
     # Use the best approach
     #git clone $BOOSTRAP $PROJECT/puppet
@@ -153,7 +160,7 @@ function templater_ikiwiki {
     else
       echo ""
       echo "Setting up ikiwiki implementation..."
-      cd $PROJECT
+      cd $PROJECT &> /dev/null
       #__templater_checkout_develop
 
       if [ ! -e ".gitignore" ]; then
@@ -219,6 +226,12 @@ if [ -z "$PROJECT" ]; then
   echo "$BASENAME: create a new project folder and/or setup helper utilities"
   echo ""
   echo "usage: $BASENAME <path> [<module1> ... <moduleN>]"
+  echo ""
+  echo "examples":
+  echo ""
+  echo -e "\t templater myproject git ikiwiki # adds git and ikiwiki config into myproject"
+  echo -e "\t templater . pelican             # add pelican config into the current folder"
+  echo ""
   echo "available modules:"
   echo ""
   __templater_implementations | xargs -L 6 | column -t -c 6 | sed -e 's/^/\t/'
@@ -230,7 +243,7 @@ fi
 __templater_init
 
 # Setup modules
-if [ -z "$MODULES" ]; then
+if [ -z "$MODULES" ]; then
   for project in `__templater_implementations`; do
     __templater_ask $project
   done