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
# 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
)
}
-# 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
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..."
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
(
echo ""
echo "Setting up vagrant implementation..."
- cd $PROJECT
+ cd $PROJECT &> /dev/null
#__templater_checkout_develop
vagrant init
echo '.vagrant' >> .gitignore
(
echo ""
echo "Setting up vagrant implementation..."
- cd $PROJECT
+ cd $PROJECT &> /dev/null
kvmx init
git commit -a -m "Adds kvmx support"
)
(
echo ""
echo "Setting up puppet implementation..."
- cd $PROJECT
+ cd $PROJECT &> /dev/null
# Use the best approach
#git clone $BOOSTRAP $PROJECT/puppet
else
echo ""
echo "Setting up ikiwiki implementation..."
- cd $PROJECT
+ cd $PROJECT &> /dev/null
#__templater_checkout_develop
if [ ! -e ".gitignore" ]; 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/'
__templater_init
# Setup modules
-if [ ! -z "$MODULES" ]; then
+if [ -z "$MODULES" ]; then
for project in `__templater_implementations`; do
__templater_ask $project
done