You are here

Docksal

Submitted by Alan Mels on Thu, 03/28/2019 - 12:04

0) ~/.drush/my.aliases.drushrc.php

<?php
 
/**
 * @file yoursite.aliases.drushrc.php
 * Site aliases for [your site domain]
 * Place this file at ~/.drush/  (~/ means your home path)
 *
 * Usage:
 *   To copy the development database to your local site:
 *   $ drush sql-sync @yoursite.dev @yoursite.local
 *   To copy your local database to the development site:
 *   $ drush sql-sync @yoursite.local @yoursite.dev --structure-tables-key=common --no-ordered-dump --sanitize=0 --no-cache
 *   To copy the production database to your local site:
 *   $ drush sql-sync @yoursite.prod @yoursite.local
 *   To copy all files in development site to your local site:
 *   $ drush rsync @yoursite.dev:%files @yoursite.local:%files
 *   Clear the cache in production:
 *   $ drush @yoursite.prod clear-cache all
 *
 * You can copy the site alias configuration of an existing site into a file
 * with the following commands:
 *   $ cd /path/to/settings.php/of/the/site/
 *   $ drush site-alias @self --full --with-optional >> ~/.drush/mysite.aliases.drushrc.php
 * Then edit that file to wrap the code in < ? php ? > tags.
 */
 
/**
 * Local alias
 * Set the root and site_path values to point to your local site
 */
 
$aliases['dev'] = array (
  'root' => '/var/www/docroot',
  'uri' => 'my.docksal',
  'path-aliases' => 
  array (
    '%drush' => '/usr/local/bin',
    '%sites' => 'sites',
    '%custom' => 'sites/all/modules/custom',
    '%theme' => 'sites/all/themes/altagrade',
  ),
);
 
$aliases['prod'] = array (
  'uri' => 'my.altagrade.com',
  'root' => '/home/altacom/domains/my.altagrade.com/public_html',
  'remote-user' => 'altacom',
  'remote-host' => '66.160.206.201',
  'ssh-options'  => '-p 19753',  // To change the default port on remote server
  'path-aliases' => array(
    '%sites' => 'sites',
    '%dump-dir' => '/tmp',
    '%custom' => 'sites/all/modules/custom',
    '%theme' => 'sites/all/themes/altagrade',
  ),
  'source-command-specific' => array (
    'sql-sync' => array (
      'no-cache' => TRUE,
      'structure-tables-key' => 'common',
    ),
  ),
  // No need to modify the following settings
  'command-specific' => array (
    'sql-sync' => array (
      'sanitize' => TRUE,
      'no-ordered-dump' => TRUE,
      'structure-tables' => array(
       // You can add more tables which contain data to be ignored by the database dump
        'common' => array('cache', 'cache_filter', 'cache_menu', 'cache_page', 'history', 'sessions', 'watchdog'),
      ),
    ),
  ),
);
 
?>

1) /home/docker/.bash_aliases

function pull-db() {
  cd /var/www/docroot
  drush -y sql-sync @prod @dev
  drush -y dis commerce_stripe
  drush -y rd commerce_payment_commerce_stripe
  drush -y dis varnish memcache_admin && drush -y dis masquerade memcache emaillog nicemessages
  drush -y dis masquerade_views memcache_admin
  drush -y en search_krumo
  drush vset error_level 2
  yes | drush -y en drush_extras
  drush -y en devel permissions_variable commerce_payment_example
  drush -y block-configure --module=devel --delta=switch_user --region=footer_firstcolumn --weight=0
  drush -y dis memcache
  drush -y dis varnish memcache_admin && drush -y dis masquerade memcache emaillog nicemessages
  drush uli 1
}
 
alias pull-private='drush -y rsync @prod:%private @dev:%private'
alias pull-theme='drush -y rsync @prod:%theme @dev:%theme'
alias pull-custom='drush -y rsync @prod:%custom @dev:%custom'
alias pull-files='drush -y rsync @prod:%files @dev:%files'
alias pull-all='drush -y rsync --exclude-conf @prod @dev'
alias push-theme='drush -y rsync @dev:%theme @prod:%theme'
alias push-custom='drush -y rsync @dev:%custom @prod:%custom'
 
alias custom='cd /var/www/docroot/sites/all/modules/custom'
alias theme='cd /var/www/docroot/sites/all/themes/altagrade'
 
export EDITOR="nano"
 
alias eba='nano ~/.bash_aliases'
alias lba='source ~/.bash_aliases'
alias ?='history'  # DISPLAYS HISTORY
alias x='exit'
alias yum='yum -y'
alias recall="history |grep $1"
 
tardir () {
tar cvzf ${1}.tgz ${1}
}
 
# Extract compressed file
extract () {
  if [ -f $1 ] && [ -r $1 ] ; then
    case $1 in
      (*.tar.bz|*.tbz)  tar -xjf $1;;
      (*.tar.bz2|*.tbz2)  tar xjf $1;;
      (*.tar.gz|*.tgz)    tar xzf $1;;
      (*.bz2)             bunzip2 $1;;
      (*.rar)             rar x $1;;
      (*.gz)              gunzip $1;;
      (*.tar)             tar xf $1;;
      (*.zip)             unzip $1;;
      (*.Z)               uncompress $1;;
      (*.7z)              7z x $1;;
      (*.deb)             sudo dpkg -i $1;;
      (*.rpm)             sudo alien -dik $1;;
      (*)                 echo "extract: unsupported format $1" ;;
  esac
    rm -rf $1
    ls -l
  else
    echo "extract: file not found or unreadable: $1"
  fi
}
 
# Find a file with a pattern in file name
function fn() { find . -type f -iname '*'$1'*' -ls ; }
# Find a file with a pattern in the content of the file
function fs() { grep -Ril "$1" .; }

2) Add the following lines to settings.local.php

error_reporting(-1);  // Have PHP complain about absolutely everything.
$conf['error_level'] = 2;  // Show all messages on your screen
ini_set('display_errors', TRUE);  // These lines give you content on WSOD pages.
ini_set('display_startup_errors', TRUE);
 
$base_url = 'https://my.docksal';
 
// Per https://cgit.drupalcode.org/commerce_billy/tree/modules/commerce_billy_pdf/README.txt
# $conf['commerce_billy_pdf_converter'] = 'wkhtmltopdf';
$conf['commerce_billy_pdf_converter'] = 'dompdf';
 
global $conf;
$conf['permissions'] = array();
$permissions = &$conf['permissions'];
 
// Access developer information.
$permissions['access devel information'] = array(
  'anonymous user',
  'authenticated user',
  'administrator',
);
 
// Switch users.
$permissions['switch users'] = array(
  'anonymous user',
  'authenticated user',
  'billing',
  'administrator',
);

3) After running fin bash, install wkhtmltopdf:

cd /usr/src
sudo wget https://github.com/wkhtmltopdf/wkhtmltopdf/releases/download/0.12.4/wkhtmltox-0.12.4_linux-generic-amd64.tar.xz
sudo tar -xvf wkhtmltox-0.12.4_linux-generic-amd64.tar.xz 
sudo cp wkhtmltox/bin/wkhtmltopdf /usr/bin/
sudo rm -rf wkhtmltox-0.12.4_linux-generic-amd64.tar.xz