Skip to content

Instantly share code, notes, and snippets.

View esolitos's full-sized avatar

Marlon (Esolitos) Saglia esolitos

View GitHub Profile
@esolitos
esolitos / deploy-config.yml
Last active October 18, 2016 08:34
Remove develop-only modules and export the config.
# This is a Drupal Console (chain file)[https://docs.drupalconsole.com/en/commands/chain.html].
# Needs to be deployed in `~/.console/chain` directory.
# Can be be run using `drupal chain --file=~/.console/chain/deploy-config.yml`.
#
# The purpouse if this chain is to remove "devel-only" modules and config from the configuration
# export, so that we can avoid issues in the syncronisation in Staging/Production.
#
commands:
# Remove 'devel' modules
- command: module:uninstall
@esolitos
esolitos / migrate-to-composer.sh
Last active October 27, 2016 13:45
Migrate from drush make based to composer based websites
#!/bin/sh
#
# Argument 1: Source drush-based drupal
# Argument 2: Destination composer-based drupal
#
OLD_ROOT=$1
NEW_ROOT=$2
if [ ! -d "$OLD_ROOT" ]; then
echo "Source directory not found!"
@esolitos
esolitos / settings.php (D7+Composer)
Last active January 6, 2017 11:38
Drupal 7 with Composer Manager example of settings and deploy script for Wodby.
<?php
# [...] All your config
/* Composer Manager configuration */
$conf['composer_manager_vendor_dir'] = realpath(DRUPAL_ROOT .'/../vendor');
$conf['composer_manager_file_dir'] = realpath(DRUPAL_ROOT .'/..');
# [...] more stuff
@esolitos
esolitos / .bashrc
Created February 22, 2017 11:10
Useful bash alias/function to update Drupal modules on Composer-Based Drupal 8 installations
# Update Drupal modules on composer-based setups
comp-drup() {
if [ -z "$1" ]; then echo -e "\e[31m[ERR] You MUST specify a module name\e[0m" 1>&2; return -1; fi;
if [ ! -f ./composer.json ]; then echo -e "\e[31m[ERR] Missing composer.json file. Are you sure you're in the correct directory? \e[0m" 1>&2; return -2; fi;
composer update "drupal/$1" --with-dependencies
}
varnishlog -aAD -w ./varnish-ban.log -P ./varnish-ban.pid -g raw -q "CLI ~ 'Rd ban obj.*'"
@esolitos
esolitos / script.sh
Last active March 10, 2017 14:14
Help with Wodby, Datadog, Docker
#!/bin/sh
# Some helper commands
# Get the container id based on a pid child process
ps faux | grep -C10 $MY_PID | grep "docker-containerd-shim"
# Given a container name gets the APP_NAME
# For example: $MY_CONTAINER_NAME="k8s_web-backend.416e49d_web-backend-5f3qk_bb561cbf-f330-4188-be92-2ea9f607b71f_69f3bc6a-e240-11e6-ab50-5efaafd16bc4_8950f42d"
docker exec -ti $(docker inspect --format="{{.ID}}:{{.Name}}" $(docker ps -aq --no-trunc) | grep $MY_CONTAINER_NAME | cut -f1 -d':') /usr/bin/env | grep APP_NAME
# Simplified version
@esolitos
esolitos / checkDNS.sh
Last active May 11, 2017 11:57
This will check the A record both for the provided NameServer and for the domain's own NameServer.
#!/bin/sh
#
# This will check the A record both for the provided NameServer
# and for the domain's specified NS
#
if [ "$1" = "--help" -o "$1" = "-h" ]; then
echo "\nUsage:"
echo "$0 \$NS_IP domain1.tld domain2.tld ..."
echo "Example: $0 8.8.8.8 google.com example.com\n"
@esolitos
esolitos / .bash_functions
Created July 22, 2017 11:28
MacOS X: Automatically swap php-fpm versions from brew
#!/bin/sh
#
# Swaps between php-fpm versions.
# This function assumes php binaries inslatted with brew
#
# @parameter Semplified php version number
# (eg. PHP 5.6 is simply 56, PHP7.0 is 70 and so on...)
#
php-fpm.swap-to() {
@esolitos
esolitos / 0. README.md
Last active July 24, 2017 11:57
Find Drupal modules that are not installed, but on the filesystem and do some actions on it.

Find non-useful Drupal modules

This is a collection of scripts will find modules (non core) that are in the codebase which are not installed and report their path. It will skip submodules (using the "project" key in the module info).

@esolitos
esolitos / drupal-auto-module-up.sh
Created August 2, 2017 09:48
Automatically updates a list of modules, asks for confirmation, and commits code changes. (has to be run from DRUPAL_ROOT)
#!/bin/bash
DRUSH=$(which drush)
GIT=$(which git)
if [ -z $DRUSH -o -z $GIT ]; then
echo "Missing drush!"
exit -1
fi