diff options
author | Silvio Rhatto <rhatto@riseup.net> | 2017-10-26 11:16:12 -0200 |
---|---|---|
committer | Silvio Rhatto <rhatto@riseup.net> | 2017-10-26 11:16:12 -0200 |
commit | aae84cd0073d96ee5da4d936845567c1c9545322 (patch) | |
tree | 90561f508351349b547d7072be3cc68746acaced | |
parent | 0df620bcfbd18a8573005f0c1c8d9fedfbb51c4e (diff) | |
download | scripts-aae84cd0073d96ee5da4d936845567c1c9545322.tar.gz scripts-aae84cd0073d96ee5da4d936845567c1c9545322.tar.bz2 |
Templater enhancements and fixes
-rwxr-xr-x | templater | 47 |
1 files changed, 30 insertions, 17 deletions
@@ -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 |