diff options
-rw-r--r-- | share/drupal7/drupal.make.yml | 21 | ||||
-rw-r--r-- | share/drupal8/Makefile | 168 | ||||
-rw-r--r-- | share/drupal8/drupal.make.yml | 9 | ||||
-rwxr-xr-x | templater | 62 |
4 files changed, 247 insertions, 13 deletions
diff --git a/share/drupal7/drupal.make.yml b/share/drupal7/drupal.make.yml new file mode 100644 index 0000000..5ae7edb --- /dev/null +++ b/share/drupal7/drupal.make.yml @@ -0,0 +1,21 @@ +core: 7.x +api: '2' +projects: + drupal: + version: '' + views: + version: '' + ctools: + version: '' + panels: + version: '' + feeds: + version: '' + libraries: + version: '' + features: + version: '' + strongarm: + version: '' + module_filter: + version: '' diff --git a/share/drupal8/Makefile b/share/drupal8/Makefile new file mode 100644 index 0000000..3ba982f --- /dev/null +++ b/share/drupal8/Makefile @@ -0,0 +1,168 @@ +# +# Makefile for a Drupal 8 Website +# + +# Parameters +CORE = 8 +PROJECT = drupal +ENV = dev +DATE = $(shell date +%Y%m%d) +CWD = $(shell pwd) +DESTDIR ?= vendor +DRUPAL = $(DESTDIR)/drupal-$(CORE) +DRUSH = drush -r $(DRUPAL) -l $(PROJECT) + +# Setup production environment +production: submodules post_receive drush settings ownership + +# Setup a development environment +#develop: submodules vagrant +develop: submodules kvmx + rm -rf $(DRUPAL)/sites/default + ln -s $(PROJECT) $(DRUPAL)/sites/default + vagrant ssh -c "$(DRUSH) pm-enable devel -y" + +# Install the platform +platform: drupal drush settings symlinks initdb cache + +# Keep code in sync +sync-code: update drush cache import + +# Initialize and update git submodules +submodules: + git submodule sync --recursive + git submodule update --init --recursive + +# Setup the virtual machine using vagrant +vagrant: + vagrant up + +# Setup the virtual machine using kvmx +kvmx: + kvmx up + +# Download drupal, setup folder structure and config file +# +# You might want to use "-n" to avoid _drush_recursive_copy cpu hog if previous +# installation already exists when using 9p filesystem +drupal: + #rm -rf $(DESTDIR)/drupal-$(CORE)* && drush pm-download -y -v drupal-$(CORE) --destination=/tmp/drupal && mv /tmp/drupal/drupal-$(CORE).* $(DESTDIR)/ + #drush pm-download -y -v drupal-$(CORE) --destination=$(DESTDIR) + #( cd $(DRUPAL)/.. && ln -s drupal-$(CORE).* drupal-$(CORE) ) + BASE=$(DESTDIR) drupal download 8 + +# Make the needed symlinks +symlinks: + ln -sf -t $(DRUPAL)/sites/$(PROJECT)/ $(CWD)/files + ln -sf -t $(DRUPAL)/sites/$(PROJECT)/ $(CWD)/config + ln -sf -t $(DRUPAL)/sites/$(PROJECT)/ $(CWD)/themes + ln -sf -t $(DRUPAL)/sites/$(PROJECT)/ $(CWD)/modules + ln -sf -t $(DRUPAL)/sites/$(PROJECT)/ $(CWD)/libraries + +# Default settings +default_settings: + test -s sites.php || cp $(DRUPAL)/sites/example.sites.php sites.php + test -s settings.dev.php || cp $(DRUPAL)/sites/default/default.settings.php settings.dev.php + test -s services.dev.yml || cp $(DRUPAL)/sites/default/default.services.yml services.dev.yml + +# Setup drupal settings +settings: default_settings + test -s $(DRUPAL)/sites/sites.php || cp sites.php $(DRUPAL)/sites/sites.php + mkdir -p $(DRUPAL)/sites/$(PROJECT) + test -s $(DRUPAL)/sites/$(PROJECT)/settings.$(ENV).php || cp settings.dev.php $(DRUPAL)/sites/$(PROJECT)/settings.$(ENV).php + test -s $(DRUPAL)/sites/$(PROJECT)/settings.php || ln -s settings.$(ENV).php $(DRUPAL)/sites/$(PROJECT)/settings.php + test -s $(DRUPAL)/sites/$(PROJECT)/services.$(ENV).yml || cp services.dev.yml $(DRUPAL)/sites/$(PROJECT)/services.$(ENV).yml + test -s $(DRUPAL)/sites/$(PROJECT)/services.yml || ln -s services.$(ENV).yml $(DRUPAL)/sites/$(PROJECT)/services.yml + chmod 640 $(DRUPAL)/sites/$(PROJECT)/settings.php + chmod 640 $(DRUPAL)/sites/$(PROJECT)/services.yml + +# Fix ownership +ownership: + sudo chown -R $(PROJECT). $(DRUPAL)/sites/$(PROJECT) + sudo chmod 755 $(DRUPAL)/sites/$(PROJECT) + +# Run drush makefile +drush: + sudo drush make -n --no-core drupal.make.yml $(DRUPAL) + +# Update the database +updatedb: + $(DRUSH) updatedb -y + +# Load the database dump, clear the drupal cache and fix image paths +# See https://www.drupal.org/node/628130 +initdb: + test -s sql/dumps/latest && gzip -dc sql/dumps/latest.sql.gz | $(DRUSH) sql-cli || true + test -s sql/dumps/latest && $(DRUSH) updatedb -y || true + +# Dump the database +dumpdb: + mkdir -p sql/dumps + rm -f sql/dumps/latest.sql.gz + rm -f sql/dumps/$(DATE).sql.gz + $(DRUSH) sql-dump > sql/dumps/$(DATE).sql + ( cd sql/dumps && gzip $(DATE).sql && ln -s $(DATE).sql.gz latest.sql.gz ) + +# Clear drupal cache +cache: + $(DRUSH) cache-rebuild + +# Destroy the database +destroydb: + echo "DROP DATABASE $(PROJECT); CREATE DATABASE $(PROJECT);" | $(DRUSH) sql-cli + +# Reinitializes the database +reinitdb: destroydb initdb + +# Cleanup develop environment +clean: + vagrant halt + vagrant destroy -f + rm -rf vendor/drupal* + +# Export configuration +export: + $(DRUSH) config-export -y + +# Import configuration +import: + $(DRUSH) config-import -y + +# Diff configuration +# Needs https://github.com/eriktufvesson/drush-config-diff +diff: + $(DRUSH) config-diff + +# Update the codebase +update: pull submodules + +# Upgrade modules +upgrade-modules: + $(DRUSH) up + +# Upgrade drupal +upgrade-drupal: + BASE=/vagrant/vendor drupal upgrade $(OLD) $(NEW) + +# Configure update hook on remote host +post_receive: + git config receive.denyCurrentBranch ignore + cd .git/hooks && ln -sf ../../bin/post-receive + +# Pull changes +pull: + git pull + +# Reset the working copy +reset: + #git reset HEAD + git checkout -f + +# Fix local folder permission +perms: + chmod 755 . + +# Deploy code pushed on remote host +deploy: perms reset submodules + drush cache-rebuild + drush config-import -y diff --git a/share/drupal8/drupal.make.yml b/share/drupal8/drupal.make.yml new file mode 100644 index 0000000..38154eb --- /dev/null +++ b/share/drupal8/drupal.make.yml @@ -0,0 +1,9 @@ +core: 8.x +api: '2' +projects: + drupal: + version: '' + devel: + version: '' + libraries: + version: '' @@ -10,13 +10,13 @@ BASENAME="`basename $0`" PROJECT="$1" shift MODULES="$*" -BOOTSTRAP="https://git.fluxo.info/puppet-bootstrap.git" +BOOTSTRAP="https://git.fluxo.info/puppet-bootstrap" CWD="`pwd`" # Initialize project function __templater_init { if [ ! -d "$PROJECT" ]; then - echo "Initializing $PROJECT..." + __templater_echo "Initializing $PROJECT..." mkdir -p $PROJECT fi } @@ -92,7 +92,7 @@ function templater_basic { # Git implementation function templater_git { if [ ! -d ".git" ]; then - __templater___templater_echo "Setting up git..." + __templater_echo "Setting up git..." touch .gitignore git init @@ -108,7 +108,7 @@ function templater_githooks { # TODO: check if githooks are already set if [ -d ".git" ]; then if which git-hooks &> /dev/null; then - __templater___templater_echo "Setting up git-hooks..." + __templater_echo "Setting up git-hooks..." git hooks --install fi else @@ -120,7 +120,7 @@ function templater_githooks { function templater_gitflow { if ! grep -q '^\[gitflow' .git/config; then if ! git branch --list develop | grep -q develop; then - __templater___templater_echo "Setting up git-flow..." + __templater_echo "Setting up git-flow..." git branch develop @@ -138,7 +138,7 @@ function templater_gitflow { # Vagrant implementation function templater_vagrant { if [ ! -e "Vagrantfile" ]; then - __templater___templater_echo "Setting up vagrant..." + __templater_echo "Setting up vagrant..." #__templater_checkout_develop vagrant init echo '.vagrant' >> .gitignore @@ -151,7 +151,7 @@ function templater_vagrant { # KVMX implementation function templater_kvmx { if [ ! -e "kvmxfile" ]; then - __templater___templater_echo "Setting up kvmx..." + __templater_echo "Setting up kvmx..." kvmx init #git commit -a -m "Adds kvmx support" else @@ -162,7 +162,7 @@ function templater_kvmx { # Puppet implementation function templater_puppet { if [ ! -d "puppet" ]; then - __templater___templater_echo "Setting up puppet..." + __templater_echo "Setting up puppet..." if [ ! -d '.git' ]; then __templater_echo "Error: puppet needs a working git setup, skipping" @@ -187,7 +187,7 @@ function templater_puppet { # Ikiwiki implementation function templater_ikiwiki { if [ ! -e "ikiwiki.yaml" ]; then - __templater___templater_echo "Setting up ikiwiki..." + __templater_echo "Setting up ikiwiki..." #__templater_checkout_develop __templater_copy_or_append ikiwiki .gitignore @@ -297,14 +297,50 @@ function templater_jekyll { # Drupal7 implementation function templater_drupal7 { - echo "TODO: drupal7" - true + if [ ! -e 'settings.dev.php' ]; then + __templater_echo "Setting up Drupal 7..." + + #if [ ! -e "Makefile" ]; then + # cp $DIRNAME/share/drupal7/Makefile . + ##elif ! grep -q ^drupal: Makefile; then + ## grep -v '^#' $DIRNAME/share/drupal7/Makefile >> Makefile + #else + # cp $DIRNAME/share/drupal7/Makefile Makefile.drupal7 + #fi + + if [ ! -e "drupal.make.yml" ]; then + cp $DIRNAME/share/drupal7/drupal.make.yml . + fi + + mkdir -p files themes modules libraries + mkdir -p vendor + else + __templater_echo "Drupal already set" + fi } # Drupal8 implementation function templater_drupal8 { - echo "TODO: drupal8" - true + if [ ! -e 'settings.dev.php' ]; then + __templater_echo "Setting up Drupal 8..." + + if [ ! -e "Makefile" ]; then + cp $DIRNAME/share/drupal8/Makefile . + #elif ! grep -q ^drupal: Makefile; then + # grep -v '^#' $DIRNAME/share/drupal8/Makefile >> Makefile + else + cp $DIRNAME/share/drupal8/Makefile Makefile.drupal8 + fi + + if [ ! -e "drupal.make.yml" ]; then + cp $DIRNAME/share/drupal8/drupal.make.yml . + fi + + mkdir -p files config themes modules libraries + mkdir -p vendor + else + __templater_echo "Drupal already set" + fi } # Syntax check |