From a6383c697ffa68ef0ecd4a0599db524ccdb9dda3 Mon Sep 17 00:00:00 2001 From: Silvio Rhatto Date: Fri, 17 Nov 2017 13:13:43 -0200 Subject: Adds diff option --- TODO.md | 2 +- share/templater/drupal8/files/Puppetfile | 47 ------------------------- share/templater/drupal8/files/puppet/Puppetfile | 47 +++++++++++++++++++++++++ share/templater/drupal8/setup | 4 +-- share/templater/templater/functions | 30 ++++++++++++++++ templater | 19 +++++++--- 6 files changed, 95 insertions(+), 54 deletions(-) delete mode 100644 share/templater/drupal8/files/Puppetfile create mode 100644 share/templater/drupal8/files/puppet/Puppetfile diff --git a/TODO.md b/TODO.md index 6ad302d..220a16c 100644 --- a/TODO.md +++ b/TODO.md @@ -24,7 +24,7 @@ TODO * Code: * Makefiles: non-conflicting target names with aliases/shorthands in the main Makefile * Check/detect/verify mode, telling which modules are installed and checking for missing things (like LICENSE) - * Update and diff modes to compare/update configs between a project and templater's defaults + * Update mode to update configs between a project and templater's defaults * If git is in use, commit all changes, but check first it there are non-commited changes in the repo * Hugo: tell the user about adding a theme: http://gohugo.io/getting-started/quick-start/ * Be verbose about the need to review and edit files, adding LICENSE headers into source files, etc diff --git a/share/templater/drupal8/files/Puppetfile b/share/templater/drupal8/files/Puppetfile deleted file mode 100644 index 85b9e3c..0000000 --- a/share/templater/drupal8/files/Puppetfile +++ /dev/null @@ -1,47 +0,0 @@ -# Basic modules -mod "augeas", - :git => "https://git.fluxo.info/puppet-augeas" -mod "backup", - :git => "https://git.fluxo.info/puppet-backup" -mod "backupninja", - :git => "https://git.fluxo.info/puppet-backupninja", - :ref => "develop" -mod "concat", - :git => "https://git.fluxo.info/puppet-concat" -mod "cron", - :git => "https://git.fluxo.info/puppet-cron" -mod "domain_check", - :git => "https://git.fluxo.info/puppet-domain_check" -mod "exim", - :git => "https://git.fluxo.info/puppet-exim" -mod "lsb", - :git => "https://git.fluxo.info/puppet-lsb" -mod "nodo", - :git => "https://git.fluxo.info/puppet-nodo" -mod "rsyslog", - :git => "https://git.fluxo.info/puppet-rsyslog" -mod "shellprompt", - :git => "https://git.fluxo.info/shellprompt" -mod "sshd", - :git => "https://git.fluxo.info/puppet-sshd", - :ref => "develop" -mod "ssl", - :git => "https://git.fluxo.info/puppet-ssl" -mod "stdlib", - :git => "https://git.fluxo.info/puppet-stdlib" -mod "user", - :git => "https://git.fluxo.info/puppet-user" -mod "tunnel", - :git => "https://git.fluxo.info/puppet-tunnel" - -# Additional modules -mod "mysql", - :git => "https://git.fluxo.info/puppet-mysql" -mod "database", - :git => "https://git.fluxo.info/puppet-database" -mod "apache", - :git => "https://git.fluxo.info/puppet-apache" -mod "php", - :git => "https://git.fluxo.info/puppet-php" -mod "drupal", - :git => "https://git.fluxo.info/puppet-drupal" diff --git a/share/templater/drupal8/files/puppet/Puppetfile b/share/templater/drupal8/files/puppet/Puppetfile new file mode 100644 index 0000000..85b9e3c --- /dev/null +++ b/share/templater/drupal8/files/puppet/Puppetfile @@ -0,0 +1,47 @@ +# Basic modules +mod "augeas", + :git => "https://git.fluxo.info/puppet-augeas" +mod "backup", + :git => "https://git.fluxo.info/puppet-backup" +mod "backupninja", + :git => "https://git.fluxo.info/puppet-backupninja", + :ref => "develop" +mod "concat", + :git => "https://git.fluxo.info/puppet-concat" +mod "cron", + :git => "https://git.fluxo.info/puppet-cron" +mod "domain_check", + :git => "https://git.fluxo.info/puppet-domain_check" +mod "exim", + :git => "https://git.fluxo.info/puppet-exim" +mod "lsb", + :git => "https://git.fluxo.info/puppet-lsb" +mod "nodo", + :git => "https://git.fluxo.info/puppet-nodo" +mod "rsyslog", + :git => "https://git.fluxo.info/puppet-rsyslog" +mod "shellprompt", + :git => "https://git.fluxo.info/shellprompt" +mod "sshd", + :git => "https://git.fluxo.info/puppet-sshd", + :ref => "develop" +mod "ssl", + :git => "https://git.fluxo.info/puppet-ssl" +mod "stdlib", + :git => "https://git.fluxo.info/puppet-stdlib" +mod "user", + :git => "https://git.fluxo.info/puppet-user" +mod "tunnel", + :git => "https://git.fluxo.info/puppet-tunnel" + +# Additional modules +mod "mysql", + :git => "https://git.fluxo.info/puppet-mysql" +mod "database", + :git => "https://git.fluxo.info/puppet-database" +mod "apache", + :git => "https://git.fluxo.info/puppet-apache" +mod "php", + :git => "https://git.fluxo.info/puppet-php" +mod "drupal", + :git => "https://git.fluxo.info/puppet-drupal" diff --git a/share/templater/drupal8/setup b/share/templater/drupal8/setup index f9c8dfc..738e4ec 100755 --- a/share/templater/drupal8/setup +++ b/share/templater/drupal8/setup @@ -43,9 +43,9 @@ function templater_drupal8 { fi if [ -d "puppet" ] && [ ! -e "puppet/Puppetfile" ]; then - cp $SHARE/drupal8/files/Puppetfile puppet/ + cp $SHARE/drupal8/files/puppet/Puppetfile puppet/ else - cp $SHARE/drupal8/files/Puppetfile puppet/Puppetfile.drupal8 + cp $SHARE/drupal8/files/puppet/Puppetfile puppet/Puppetfile.drupal8 fi if [ ! -e "bin/post-receive" ]; then diff --git a/share/templater/templater/functions b/share/templater/templater/functions index b8658d2..4507650 100644 --- a/share/templater/templater/functions +++ b/share/templater/templater/functions @@ -104,3 +104,33 @@ function templater_install_makefile { # echo Makefile.local >> .gitignore #fi } + +# Check differences +function templater_diff { + local module="$1" + local cwd="`pwd`" + + if [ -z "$module" ]; then + return + fi + + if [ ! -d "$SHARE/$module/files" ]; then + return + fi + + ( + cd $SHARE/$module/files + + find . -type f | while read file; do + # File exists, check differences + if [ -e "$cwd/$file" ]; then + diff -u $cwd/$file $file + else + # Use a templaterignore instead + if echo $file | grep -q -v 'example'; then + templater_echo "Missing $file" + fi + fi + done + ) +} diff --git a/templater b/templater index ad24eb3..06ae288 100755 --- a/templater +++ b/templater @@ -65,16 +65,27 @@ templater_init # Go to project folder cd $PROJECT &> /dev/null -# Setup modules +# Process modules if [ -z "$MODULES" ]; then for project in `templater_implementations`; do templater_ask $project done else for module in $MODULES; do - if `templater_implementations | grep -q "^$module"`; then - #templater_$module - $SHARE/$module/setup $SHARE + # Skip options + if echo $module | grep -q '^--'; then + continue + fi + + #if `templater_implementations | grep -q "^$module"`; then + if [ -d "$SHARE/$module" ]; then + # Dispatch + if echo $* | grep -q -- '--diff'; then + templater_diff $module + #elif echo $* | grep -q -- '--update'; then + else + $SHARE/$module/setup $SHARE + fi else templater_echo "No such module $module, skipping" fi -- cgit v1.2.3