Skip to content

Instantly share code, notes, and snippets.

@matglas
matglas / cleanup-builds.sh
Created September 3, 2013 06:18
Clean up old build in Kraftwagen.
#!/bin/bash
DIR=`pwd`
if [ -d "$DIR/builds" ]
then
CURRENT=`ls -1 builds | sort | tail -1`
read -p "Do you want to remove all the old builds except $CURRENT (y/n)" -n 1 -s REMOVE_OLD_BUILDS
@matglas
matglas / d-file-perms.sh
Created September 3, 2013 06:34
Reset Drupal code base file permissions.
#!/bin/bash
cd `drush dd`
sudo chown [user]:[group] -R .
sudo find . -type d -exec chmod u=rwx,g=rx,o= '{}' \;
sudo find . -type d -exec chmod u=rwx,g=rx,o= '{}' \;
cd sites
for d in ./*/files
@matglas
matglas / webform_create.install
Last active December 23, 2015 10:28
Dynamicly add a webform.
<?php
/**
* Implements hook_install().
*/
function hook_install() {
// Create Contact form from data file
// Define your components.
# Install dnsmasq
sudo apt-get install dnsmasq
# Add lines to a configuration file in /etc/dnsmasq.d
# Don't use .local as address. That won't work.
nano dnsservers
> server=8.8.8.8
> server=8.8.4.4
@matglas
matglas / kwscripts
Last active August 29, 2015 13:55
Go to a kw directory
#!/bin/bash
#
# Include this script in your .bashrc like this:
# . ~/scripts/kwscripts
ROOT="/home/vhosts/"
function kws() {
project=$1
vhosts=$ROOT
#!/bin/bash
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
# Git ref to checkout in the ./src directory
NO_FETCH=$2
REF=$1
# Don't use - or . in the project name!
PROJECT=`basename $DIR`
@matglas
matglas / reset.sh
Created September 11, 2014 21:06
Platform reset.sh for kraftwagen skeleton development
#!/bin/bash
# Reset
sudo rm -rf cnf/settings.php
sudo rm -rf cnf/files
sudo rm -rf builds
sudo rm -rf build
sudo rm -rf src
# Create new project.
@matglas
matglas / hook_permission.php
Last active August 29, 2015 14:13
Template for drupal permissions.
/**
* Implements hook_permission().
*/
function ZZMODULE_permission() {
$perms = array();
// Allow access to certain pages based on this permissions
$perms['administer XX'] = array(
'title' => t('Administer [ZZMODULE] settings'),
'description' => t('Administer the settings of [ZZMODULE].')
@matglas
matglas / update-kw-env.sh
Created April 23, 2015 09:57
Update a kw environment to latest version.
#!/bin/bash
# Usage: sh update.sh fase
# fase-1 or empty makes the pull
# fase-2 executes the script
#
# If you want to run a specific version checkout that
# version first in the src folder with git checkout [ref].
# Don't use a branch there because it still does a pull
# on the branch (if it is setup as a tracking branch).
@matglas
matglas / panel_context_pane.php
Created September 16, 2015 14:15
Loading a panel with context programaticly
<?php
ctools_include('context');
ctools_include('content');
// Load ctools context from the arguments.
$context = array();
$context_arguments = array(
'identifier' => 'node', // Required: Identifier to the panel.
'name' => 'entity_id:node', // Required: Identifier used by argument plugins.
'title' => 'Node', // Optional.