diff --git a/3screen.sh b/3screen.sh deleted file mode 100755 index d8df014..0000000 --- a/3screen.sh +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/sh -xrandr --output VIRTUAL1 --off --output DP1 --off --output HDMI1 --off --output VGA-1-1 --off --output LVDS1 --mode 1600x900 --pos 3840x180 --rotate normal --output VGA2 --mode 1920x1080 --pos 1920x0 --rotate normal --output DVI-2-0 --mode 1920x1080 --pos 0x0 --rotate normal diff --git a/changelog.txt b/changelog.txt deleted file mode 100644 index 84fecd3..0000000 --- a/changelog.txt +++ /dev/null @@ -1,157 +0,0 @@ -v1.1.4 -====== -2015-02-17 12:31:00 +0000 Toby Batch - - * Show change log before making the tag (HEAD, master) - -2015-02-16 10:44:52 +0000 Toby Batch - - * permissions (origin/master, origin/HEAD) - -2015-02-16 10:39:36 +0000 Toby Batch - - * permissions - -2015-02-16 10:33:09 +0000 Toby Batch - - * More permissions fixing - -2015-02-16 10:16:20 +0000 Toby Batch - - * Split dir and file permssion resetting - -2015-02-16 10:07:37 +0000 Toby Batch - - * Fixed permissions on settings files - -2015-02-10 11:27:44 +0000 asparaguscat - - * testing symlink had target and name the wrong way round - -2015-01-26 13:37:19 +0000 Toby Batch - - * Added a copy of robots.txt from the themes folder - -2015-01-23 14:09:13 +0000 Toby Batch - - * Removed check for rc dir - -2015-01-22 13:26:03 +0000 Toby Batch - - * Fixed bad changelog location in branches - -2015-01-22 13:19:43 +0000 Toby Batch - - * Changed the way symlinks are built (again) - -2015-01-21 12:51:28 +0000 Toby Batch - - * Switched rsync to --size-only (origin/develop, develop) - -2015-01-21 12:44:44 +0000 Toby Batch - - * More link wrangling - -+----- v1.0.1 14-12-10_12-56 -----+ - -2014-12-10 11:55:36 +0000 Toby batch - - * Added the get opts to make -m work (origin/master, origin/HEAD) - -2014-12-10 11:14:41 +0000 Toby batch - - * Added -m support to the checkuser - -2014-12-10 11:13:16 +0000 Toby batch - - * Added -m support to drop user - -2014-12-09 22:21:50 +0000 Toby Batch - - * Added better debug - -2014-12-09 21:40:20 +0000 Toby Batch - - * Total refactor of drupal-release to ntdr - -2014-12-09 10:22:21 +0000 Toby Batch - - * Moved some function into drupal-functions - -2014-12-08 15:05:47 +0000 Toby Batch - - * Removed tabs-api-client from the branches check - -2014-12-08 15:05:26 +0000 Toby Batch - - * Improved error reporting - -2014-12-08 14:52:45 +0000 Toby Batch - - * Added drupal-tag - -2014-12-02 23:03:30 +0000 Toby Batch - - * Fixed bad if - -2014-12-02 22:31:44 +0000 Toby Batch - - * Made drupal-release idempotent - -2014-12-02 16:43:48 +0000 Toby Batch - - * Adding pre-syncing - -2014-12-02 08:48:58 +0000 Toby Batch - - * Added updb - -2014-12-01 16:06:11 +0000 Toby Batch - - * Added drush up to the deployment. - -2014-12-01 11:28:09 +0000 Toby Batch - - * I fixed alias name for new testing/rc name formats - -2014-12-01 10:40:07 +0000 Toby Batch not latest - - - * Switched the new release to increment testing - -2014-11-27 11:39:23 +0000 Toby Batch - - * Added updb to drupal release - -2014-11-27 11:36:31 +0000 Toby Batch - - * Added date to drupal-release - -2014-11-26 16:07:33 +0000 Toby batch - - * Prevented branches erroring on tabs-api-client - -2014-11-26 15:37:08 +0000 Toby batch - - * add updb - -2014-11-21 16:20:08 +0000 Toby Batch - - * Made the command actually work - -2014-11-21 16:17:37 +0000 Toby Batch - - * Added a multi site release for drupal - -2014-11-19 11:43:31 +0000 Toby Batch - - * Added usage to drupal-tag - -2014-11-14 10:28:41 +0000 Toby Batch - - * Added SASS compile to drupal-release - -2014-11-14 09:55:48 +0000 Toby Batch - - * Added a very simple tagger - diff --git a/cottage_mirror.sh b/cottage_mirror.sh deleted file mode 100644 index d22fb0d..0000000 --- a/cottage_mirror.sh +++ /dev/null @@ -1,15 +0,0 @@ -#!/bin/bash - -LIST=`ls -d /var/www/sites/live/*` - -for drupalpath in $LIST; do - aliaspath=$drupalpath/sites/all/drush - if [ -d $aliaspath ]; then - aliasfile=`ls $drupalpath/sites/all/drush | grep -v live | sort | head -n 1` - aliasname=`basename $aliasfile .alias.drushrc.php` - # drush -r $drupalpath status - # drush -r $drupalpath @$aliasname status - drush -y -r $drupalpath rsync @$aliasname @self - drush -y -r $drupalpath sql-sync @$aliasname @self - fi -done diff --git a/driplet b/driplet deleted file mode 100644 index 73f0de6..0000000 --- a/driplet +++ /dev/null @@ -1,9 +0,0 @@ -#!/bin/bash - -curl -X POST --data "type=power_off" "https://api.digitalocean.com/v2/droplets/590041/actions" -H "Authorization: Bearer $TOKEN" -curl -X POST --data "type=snapshot&name=snap01" "https://api.digitalocean.com/v2/droplets/590041/actions" -H "Authorization: Bearer $TOKEN" -do - # has it finished? - curl -X POST --data "type=power_on" "https://api.digitalocean.com/v2/droplets/590041/actions" -H "Authorization: Bearer $TOKEN" -done - diff --git a/drupal-clean-site b/drupal-clean-site deleted file mode 100755 index 44afe85..0000000 --- a/drupal-clean-site +++ /dev/null @@ -1,10 +0,0 @@ -#!/bin/bash - -for x in $(find /var/www/html/?? -maxdepth 1 -type d -mtime +30); do - /usr/bin/ansible-playbook \ - -i "/var/lib/jenkins/jobs/_ntdr-pas/workspace/inventory/intranet" \ - --vault-password-file ~/.vault_pass.txt \ - --limit=jenkins \ - --extra-vars="local=${x} archive=/var/tmp/old-builds/$(basename $x).tgz" \ - /var/lib/jenkins/jobs/_ntdr-pas/workspace/clean-drupal.yml -done diff --git a/drupal-cron b/drupal-cron deleted file mode 100755 index b71e9f9..0000000 --- a/drupal-cron +++ /dev/null @@ -1,68 +0,0 @@ -#!/bin/bash - -USAGE="$0 [-h] [-d path-to-drush] [-s sites-folder]" - -function _usage() { - echo $USAGE - cat <> ~/.bashrc - $HOME/.composer/vendor/bin/phpcs --config-set installed_paths $HOME/.composer/vendor/drupal/coder/coder_sniffer - source ~/.bashrc - fi - - mkdir -p $HOME/.neontabs - logfile=$HOME/.neontabs/$(basename $0).$(date +"%y-%m-%d_%H-%M").log - filelist="$(locate .git/config)" - this="$(realpath $0)" - for repo in $filelist; do - dotgit="$(dirname $repo)" - repo_root="$(dirname $dotgit)" - precommithook=$repo_root/.git/hooks/pre-commit - # Is this a drupal enabled repo - if [ -e $repo_root/.drupal_repo ]; then - # Does the precommit hook exist - if [ ! -e $precommithook ]; then - ln -s $this $precommithook - msg="drupal enabled, adding hook to: $repo_root" - echo $msg >> $logfile - echo $msg - else - echo "pre-commit hook exists, skipping: $precommithook" >> $logfile - fi - else - echo "not a drupal repo, skipping: $repo_root" >> $logfile - fi - done - exit -fi - -ESC_SEQ="\x1b[" -COL_RESET=$ESC_SEQ"39;49;00m" -COL_RED=$ESC_SEQ"31;01m" -COL_GREEN=$ESC_SEQ"32;01m" -COL_YELLOW=$ESC_SEQ"33;01m" -COL_BLUE=$ESC_SEQ"34;01m" -COL_MAGENTA=$ESC_SEQ"35;01m" -COL_CYAN=$ESC_SEQ"36;01m" - -SCRIPT=$BASH_SOURCE -SCRIPT_PATH=`dirname $SCRIPT` -PROJECT=`realpath $SCRIPT_PATH/../..` -STAGED_FILES_CMD=`git status --porcelain |awk '{print $2}'` -PHPCS=`which phpcs` - -echo "Script: $SCRIPT" -echo "Script path: $SCRIPT_PATH" -echo "Root path: $PROJECT" -echo "PHP CS: $PHPCS" - -which php > /dev/null -if [ $? != 0 ]; then - echo "PHP not installed, please install php cli and re-commit." - exit 1 -fi - -if [ ! -e $PHPCS ]; then - echo "PHPCS not installed, use conpser to get it:" - echo " composer install" - exit 1 -fi - -# Determine if a file list is passed -if [ "$#" -eq 1 ]; then - oIFS=$IFS - IFS=' - ' - SFILES="$1" - IFS=$oIFS -fi -SFILES=${SFILES:-$STAGED_FILES_CMD} - -echo "Checking PHP Lint..." -for file in $STAGED_FILES_CMD; do - if [ -e $file ]; then - filename=$(basename "$file") - ext="${filename##*.}" - if [ "$ext" == "php" ] ||[ "$ext" == "module" ] ||[ "$ext" == "inc" ] || [ "$ext" == "install" ]; then - php -l -d display_errors=0 $PROJECT/$file - if [ $? != 0 ]; then - echo "Fix the error before commit." - exit 1 - fi - fi - fi -done - -echo "Checking for debug statements" -fail=0 -for file in $STAGED_FILES_CMD; do - if [ -e $file ]; then - debug=0 - filename=$(basename "$file") - # echo $filename - ext="${filename##*.}" - if [ "$ext" == "php" ] ||[ "$ext" == "module" ] || [ "$ext" == "inc" ] || [ "$ext" == "install" ] || [ "$ext" == "js" ]; then - grep " dpm(\| dvm(\| dpr(\| dvr(\| kpr(\| dargs(\| dd(\| db_queryd(\| console.log" $PROJECT/$file > /dev/null - debug=$((debug + $?)) - echo PROJECT/$file $debug - if [ $debug == 0 ]; then - echo -e "Debug code found in ${COL_RED}${file}${COL_RESET}:" - grep -n "dpm(\|dvm(\|dpr(\|dvr(\|kpr(\|dargs(\|dd(\|db_queryd(\|console.log" $PROJECT/$file - fail=1 - fi - fi - fi -done -# echo "DEBUG = $debug" -if [ $fail != 0 ]; then - echo "Codign standard errors found, exiting, no commit" - exit 1 -fi - -for file in $STAGED_FILES_CMD; do - if [ -e $file ]; then - filename=$(basename "$file") - ext="${filename##*.}" - if [ "$ext" == "php" ] ||[ "$ext" == "module" ] ||[ "$ext" == "inc" ] || [ "$ext" == "install" ]; then - echo "Running Code Sniffer..." - $PHPCS --standard=Drupal --encoding=utf-8 -n -p $PROJECT/$file - if [ $? != 0 ]; then - echo "Fix the error before commit." - exit 1 - fi - fi - fi -done - -exit $? diff --git a/drupal-release b/drupal-release deleted file mode 100755 index 812ec5f..0000000 --- a/drupal-release +++ /dev/null @@ -1,278 +0,0 @@ -#!/bin/bash - -# TODO Dump both dbs as single line inserts and diff them - -set -e - -source `dirname $0`/colours -NO_ARGS=0 -VERBOSE=off -USAGE="$0 [-v] [-h] [-r remote-drupal-root] [-l local-drupal-root] [[-b ] | [-f release]] [-m mysql-root-pass] remoteuser remotehost" - -if [ $# -eq "$NO_ARGS" ]; then - echo $USAGE - exit 1 -fi - -# Set defaults -DRUPAL_LOCAL_ROOT=`pwd` - -source `dirname $0`/drupal-functions - -function usage { - echo $USAGE - cat <] - Sites are release in a x.y.z format where versions are major.minor.patch - The script will bump that version by one in the category specified. If - ommitted the script will ask. --f release - If specified this release value will override the m.m.p number --m mysql-root-pass - The script expects to find the remote mysql root password in an environment - variable MYSQL_ROOT_PASSWORD. This parameter can override that. -EOF -} - -# End functions -############################### - -# OPTS=`getopt -o v -r drupal_remote_root -l drupal_local_root -b bumpup -f force-version: -- "$@"` - -while getopts "r:l:b:f:m:vh" options; do - case $options in - v) VERBOSE='verbose';; - h) usage; exit 0;; - r) DRUPAL_REMOTE_ROOT="$OPTARG";; - l) DRUPAL_LOCAL_ROOT="$OPTARG";; - b) BUMP="$OPTARG";; - f) RELEASE="$OPTARG";; - m) MYSQL_ROOT_PASSWORD="$OPTARG";; - esac -done - -shift $((OPTIND-1)) -RUSER=$1 -RHOST=$2 - -# check the most common write permission -if [ ! -w "$DRUPAL_LOCAL_ROOT" ] ; then - echo -e $COL_RED"Cannot write to ${DRUPAL_LOCAL_ROOT}. Writting change log will fail."$COL_RESET - echo -e $COL_CYAN"chown $USER:`id -gn $USER` ${DRUPAL_LOCAL_ROOT}"$COL_RESET - echo -e $COL_CYAN"chown $USER:`id -gn $USER` ${DRUPAL_LOCAL_ROOT}/changelog.txt"$COL_RESET - exit 1 -fi - -if [ ! -w "$DRUPAL_LOCAL_ROOT/sites/all/drush" ] ; then - echo -e $COL_RED"Cannot write to ${DRUPAL_LOCAL_ROOT}/sites/all/drush. Writting alias file log will fail."$COL_RESET - echo -e $COL_CYAN"chown $USER:`id -gn $USER` ${DRUPAL_LOCAL_ROOT}/sites/all/drush"$COL_RESET - exit 1 -fi - -if [ ! -w "$DRUPAL_LOCAL_ROOT/sites/default" ] ; then - echo -e $COL_RED"Cannot write to ${DRUPAL_LOCAL_ROOT}/sites/default Writting new settings file log will fail."$COL_RESET - echo -e $COL_CYAN"chown $USER:`id -gn $USER` ${DRUPAL_LOCAL_ROOT}/sites/default"$COL_RESET - exit 1 -fi - -# Check we have required params -if [ -z $RUSER ]; then - echo -e $COL_RED"Missing remote user"$COL_RESET - echo $USAGE - exit 1 -elif [ -z $RHOST ]; then - echo -e $COL_RED"Missing remote host"$COL_RESET - echo $USAGE - exit 1 -elif [ -z "$DRUPAL_LOCAL_ROOT" ] || [ ! -f "$DRUPAL_LOCAL_ROOT/cron.php" ]; then - echo -e $COL_RED"The local drupal root ($DRUPAL_LOCAL_ROOT) does not seem to be a drupal site"$COL_RESET - exit 1 -fi - -if [ -z "$DRUPAL_REMOTE_ROOT" ]; then - ssh $RUSER@$RHOST ls -d /var/www/latest - if [ "$?" == 0 ]; then - DRUPAL_REMOTE_ROOT=/var/www/latest - else - ssh $RUSER@$RHOST ls -d /var/www/testing - if [ "$?" == 0 ]; then - DRUPAL_REMOTE_ROOT=/var/www/testing - fi - fi -fi - -if [ -z "$DRUPAL_REMOTE_ROOT" ]; then - echo -e $COL_RED"Cannot locate remote drupal root"$COL_RESET - exit 1 -fi - -getRemotePath $DRUPAL_REMOTE_ROOT -getVersionElements $CURRENT -RBASE=`dirname $RPATH` - -CURRENT_ALIAS=$(aliasname $RHOST) - -# If we don't have a alias file in the current site we can't proceed -set +e # turn off exit on error here -RALIAS=$RPATH/sites/all/drush/$CURRENT.$CURRENT_ALIAS.alias.drushrc.php -ssh $RUSER@$RHOST ls $RALIAS > /dev/null -if [ "$?" != '0' ]; then - echo -e $COL_RED"Cannot find alias file for remote site\n ssh $RUSER@$RHOST ls $RALIAS"$COL_RESET -fi -set -e - -bumpUp $MAJOR_VERSION $MINOR_VERSION $PATCH_VERSION $BUMP - -# Quick sanity check -if [ "$BRAND" != `basename $DRUPAL_LOCAL_ROOT` ]; then - echo -e $COL_YELLOW"Brand code from remote ($BRAND) != Sniffed BC from $DRUPAL_LOCAL_ROOT"$COL_RESET -fi - -touch $DRUPAL_LOCAL_ROOT/changelog.txt -echo "+----- $RELEASE -----+" > $DRUPAL_LOCAL_ROOT/changelog.new -date +"%y-%m-%d_%H-%M" >> $DRUPAL_LOCAL_ROOT/changelog.new -branches -l -p $DRUPAL_LOCAL_ROOT >> $DRUPAL_LOCAL_ROOT/changelog.new -if [ "$?" != 0 ]; then - echo $COL_RED"Git branches are out of sync: 'branches -l -p $DRUPAL_LOCAL_ROOT'"$COL_RESET -fi -echo -e "\n" >> $DRUPAL_LOCAL_ROOT/changelog.new -cat $DRUPAL_LOCAL_ROOT/changelog.txt >> $DRUPAL_LOCAL_ROOT/changelog.new -mv $DRUPAL_LOCAL_ROOT/changelog.new $DRUPAL_LOCAL_ROOT/changelog.txt - -RELEASE_ALIAS=$(aliasname $RHOST) -ALIAS_FILE=$DRUPAL_LOCAL_ROOT/sites/all/drush/$RELEASE.$RELEASE_ALIAS.alias.drushrc.php -echo "Local alias file: $ALIAS_FILE" - -echo ' $ALIAS_FILE -drush -r $DRUPAL_LOCAL_ROOT sa --full --with-db @self >> $ALIAS_FILE -sed -i "s/'root' => .*/'root' => '\/var\/www\/$RELEASE',/g" $ALIAS_FILE -sed -i "s/self/${RELEASE}.${RELEASE_ALIAS}/g" $ALIAS_FILE -sed -i "/#name/a 'remote-host' => '${RHOST}'," $ALIAS_FILE -sed -i "/#name/a 'remote-user' => '${RUSER}'," $ALIAS_FILE -sed -i "s/ 'database' => .*/ 'database' => '$RELEASE',/g" $ALIAS_FILE -sed -i "s/ 'username' => .*/ 'username' => '$RELEASE',/g" $ALIAS_FILE -sed -i "s/ 'password' => .*/ 'password' => '$RELEASE',/g" $ALIAS_FILE - -debug "+-------------------------------------------------+" -debug "${COL_BLUE}Remote user${COL_RESET} $RUSER" -debug "${COL_BLUE}Remote host${COL_RESET} $RHOST" -debug "${COL_BLUE}remote path${COL_RESET} $RPATH" -debug "${COL_BLUE}local path${COL_RESET} $DRUPAL_LOCAL_ROOT" -debug "${COL_BLUE}current${COL_RESET} $CURRENT" -debug "${COL_BLUE}version from remote${COL_RESET} $BRAND / $MAJOR_VERSION / $MINOR_VERSION / $PATCH_VERSION" -debug "${COL_BLUE}version passed${COL_RESET} $RELEASE" -debug "${COL_BLUE}bump${COL_RESET} $BUMP" -debug "${COL_BLUE}aliasfile${COL_RESET} $ALIAS_FILE" -debug "${COL_BLUE}Mysql root pass${COL_RESET} $MYSQL_ROOT_PASSWORD" -debug "${COL_BLUE}Alias file${COL_RESET} $RELEASE_ALIAS" -debug "+-------------------------------------------------+" - -cat < .*/ 'database' => '$RELEASE',/g" $TMP_SETTINGS -sed -i "s/ 'username' => .*/ 'username' => '$RELEASE',/g" $TMP_SETTINGS -sed -i "s/ 'password' => .*/ 'password' => '$RELEASE',/g" $TMP_SETTINGS - -echo -e $COL_GREEN"Pre-syncing /var/www/${CURRENT} up to /var/www/${RELEASE}"$COL_RESET -ssh ${RUSER}@${RHOST} "mkdir -p /var/www/${RELEASE} && rsync -a -O --no-p --no-o /var/www/${CURRENT}/ /var/www/${RELEASE}/" - -echo -e $COL_GREEN"Sync $DRUPAL_LOCAL_ROOT/* up to ${RUSER}@${RHOST}:/var/www/${RELEASE}"$COL_RESET -set +e -rsync -a $DRUPAL_LOCAL_ROOT/* ${RUSER}@${RHOST}:/var/www/${RELEASE} -if [ "$?" != "0" ]; then - echo -e $COL_RED"There where errors syncing files, check output above"$COL_RESET - exit 1 -fi -ssh ${RUSER}@${RHOST} "rsync -a -O --no-p --no-o /var/www/${CURRENT}/sites/default/files /var/www/${RELEASE}/sites/default" -set -e - -echo -e $COL_GREEN"Fixing permissions"$COL_RESET -ssh ${RUSER}@${RHOST} "find /var/www/$RELEASE -type d -exec chmod 2775 {} \;" -ssh ${RUSER}@${RHOST} "find /var/www/$RELEASE -type f -exec chmod 2664 {} \;" - -echo -e $COL_GREEN"chmod run, I shouldn't have rights to change ownership you may need to run:"$COL_RESET -echo -e $COL_YELLOW" sudo chown -R www-data:www-data /var/www/$RELEASE/sites/*/files"$COL_RESET - -REMOTE_SETTINGS=/var/www/$RELEASE/sites/default/settings.php -scp $TMP_SETTINGS ${RUSER}@${RHOST}:$REMOTE_SETTINGS -ssh ${RUSER}@${RHOST} chmod a-w /var/www/$RELEASE/sites/default/settings.php /var/www/$RELEASE/sites/* - -echo -e $COL_GREEN"Dumping remote DB"$COL_RESET -ssh ${RUSER}@${RHOST} drush -r /var/www/$CURRENT sql-dump --result-file=/tmp/dump.sql - -echo -e $COL_GREEN"Diffing DBs to $DRUPAL_LOCAL_ROOT/${CURRENT}-${RELEASE}.diff"$COL_RESET -ssh ${RUSER}@${RHOST} drush -r /var/www/$CURRENT sql-dump --ordered-dump > /tmp/${CURRENT}.sql -drush -r $DRUPAL_LOCAL_ROOT sql-dump --ordered-dump > /tmp/${RELEASE}.sql -diff /tmp/${CURRENT}.sql /tmp/${RELEASE}.sql > $DRUPAL_LOCAL_ROOT/${CURRENT}-${RELEASE}.diff - -echo -e $COL_GREEN"Creating remote DB"$COL_RESET -set +e -ssh ${RUSER}@${RHOST} "bash mysql-create-user-and-db -u $RELEASE -p $RELEASE -m $MYSQL_ROOT_PASSWORD" -set -e -if [ "$?" != "0" ]; then - SQL_FILE=/var/tmp/`date +"%y-%m-%d_%H-%M"`.sql - echo -e $COL_GREEN"Saving existiung dump to $SQL_FILE"$COL_RESET - cp /tmp/dump.sql $SQL_FILE -fi - -echo -e $COL_GREEN"Importing remote DB"$COL_RESET -ssh ${RUSER}@${RHOST} "drush -r /var/www/$RELEASE sql-cli < /tmp/dump.sql" -ssh ${RUSER}@${RHOST} rm /tmp/dump.sql - -echo -e $COL_GREEN"Compiling SASS"$COL_RESET -ssh ${RUSER}@${RHOST} "for x in `ls -d /var/www/$RELEASE/sites/all/themes/*theme`; do compass compile $x; done" - -echo -e $COL_GREEN"Running drush up"$COL_RESET -drush -r $DRUPAL_LOCAL_ROOT -y @$RELEASE.$RELEASE_ALIAS up - -echo -e $COL_GREEN"Running drush updb"$COL_RESET -drush -r $DRUPAL_LOCAL_ROOT -y @$RELEASE.$RELEASE_ALIAS updb - -echo -e $COL_GREEN"Clear caches"$COL_RESET -drush -r $DRUPAL_LOCAL_ROOT @$RELEASE.$RELEASE_ALIAS cc all - -echo -e $COL_GREEN"Done. You may now need to create/delete symlinks to actaully send it live"$COL_RESET diff --git a/drupal-tag b/drupal-tag deleted file mode 100755 index 39cc7f3..0000000 --- a/drupal-tag +++ /dev/null @@ -1,103 +0,0 @@ -#!/bin/bash - -USAGE="$0 [-y] [-o CURTAG] [-n NEWTAG] [-h] [/path/to/repo]" - -function usage { - echo $USAGE - cat <] - Sites are release in a x.y.z format where versions are major.minor.patch - The script will bump that version by one in the category specified. If - ommitted the script will ask. -EOF -} - -while getopts "yo:n:b:h" options; do - case $options in - o) OLDBRANCH="$OPTARG";; - n) NEWBRANCH="$OPTARG";; - b) BUMP="$OPTARG";; - y) YES=1;; - h) usage; exit;; - esac -done - -source `dirname $0`/drupal-functions - -shift $((OPTIND-1)) -if [ ! -z "$@" ]; then - ROOTPATH=$@ -else - ROOTPATH=`pwd` -fi - -# find .git folder -for x in `find $ROOTPATH -type d -name .git`; do - GIT=`dirname $x` - count=$(($count + 1)) -done - -if [ -z "$count" ]; then - echo $USAGE - echo "Unable to find .git folder, aborting" - exit 1 -elif [ "$count" -gt "1" ]; then - echo $USAGE - echo "Found multiple git repos, cannot continue." - exit 1 -fi - -echo "Git found at $x, git folder set to $GIT" -GITCMD="git -C $GIT" - -NEWCHANGELOG=$ROOTPATH/newchangelog.txt -OLDCHANGELOG=$ROOTPATH/changelog.txt - -# find latest tag -if [ -z "$OLDBRANCH" ]; then - CUR_TAG=`$GITCMD describe --abbrev=0 --tags` -else - CUR_TAG=$OLDBRANCH -fi - -if [ -z "$NEWBRANCH" ]; then - getVersionElements $CUR_TAG - bumpUp ${MAJOR_VERSION} ${MINOR_VERSION} ${PATCH_VERSION} ${BUMP} - NEW_TAG="${MAJOR_VERSION}.${MINOR_VERSION}.${PATCH_VERSION}" -else - NEW_TAG="$NEWBRANCH" -fi - -echo $NEW_TAG > $NEWCHANGELOG -echo "======" >> $NEWCHANGELOG -$GITCMD log --no-merges --format="%ai %aN %b %n%n%x09* %s%d%n" $CUR_TAG..master >> $NEWCHANGELOG - -# Preview the changes -if [ -z "$YES" ]; then - less $NEWCHANGELOG - echo Current Tag: $CUR_TAG - echo New Tag: $NEW_TAG - - echo "Proceed (Y/n)" - a=0 - until [ "$a" == "y" ] || [ "$a" == "n" ]; do - read b - a=`echo $b | tr '[:upper:]' '[:lower:]'` - done - if [ "$a" == "n" ]; then - exit - fi -fi - -cat changelog.txt >> $NEWCHANGELOG -mv $NEWCHANGELOG changelog.txt -$GITCMD commit -a -m 'Updated change log' -$GITCMD tag $NEW_TAG -$GITCMD push origin master --tags diff --git a/ghib b/ghib new file mode 100755 index 0000000..58a7dac --- /dev/null +++ b/ghib @@ -0,0 +1,48 @@ +#!/bin/bash + +source /usr/local/bin/colours +USAGE="ghib [issue number]" + +which /usr/local/bin/ghi > /dev/null +if [ "$?" != 0 ]; then + echo "$0 depends on ghi, https://github.com/tobybatch/ghi" + echo "sudo gem install ghi" +fi + +if [ -z "$1" ]; then + echo $USAGE + exit 1; +fi + +if [ ! -z "$2" ]; then + ISSUE_NUM=$2; +fi + +if [ -z "$ISSUE_NUM" ]; then + ISSUE_LIST="$(ghi list $1)" + echo "${ISSUE_LIST}" + echo + echo -e $COL_GREEN"Choose issue number"$COL_RESET + read ISSUE_NUM +fi + +TITLE="$(ghi show $ISSUE_NUM $1 | head -n1)" +echo -e $COL_YELLOW"Title: $TITLE"$COL_RESET +CLEAN=${TITLE,,} +CLEAN=${CLEAN//[^a-zA-Z0-9 ]/} +CLEAN=$(echo $CLEAN | sed 's/ /_/g') +echo -e $COL_YELLOW"Sanitized title: $CLEAN"$COL_RESET + +EXISTS=$(git show-ref refs/heads/$CLEAN) +if [ -n "$EXISTS" ]; then + echo 'Branch exists' + exit 0 +fi + +echo -e $COL_GREEN"Creating a branch named $CLEAN from develop (y/n)"$COL_RESET +read a +if [ "$a" == 'y' ] || [ "$a" == 'Y']; then + git checkout develop + git checkout -b $CLEAN +fi + diff --git a/movie-preview b/movie-preview deleted file mode 100755 index 114879b..0000000 --- a/movie-preview +++ /dev/null @@ -1,112 +0,0 @@ -#!/bin/bash - -SUBJECT=$1 -TARGET=$HOME/.thumbs/$SUBJECT -FNAME=`basename $SUBJECT` -LOG=/tmp/mv.log - -echo `date`>>$LOG - -mkdir -p "$TARGET" -pushd "$TARGET" - -if [ -f new.jpg ] -then - echo "Thumbnail exists" -else - - length=`mplayer -identify "$SUBJECT" -nosound -vc dummy -vo null|grep ID_LENGTH|awk -F = '{print $2}'` - - # interval=$(($length/6)) - interval=$(echo "$length/17" | bc) - _01=$((interval*1)) - _02=$((interval*2)) - _03=$((interval*3)) - _04=$((interval*4)) - _05=$((interval*5)) - _06=$((interval*6)) - _07=$((interval*7)) - _08=$((interval*8)) - _09=$((interval*9)) - _10=$((interval*10)) - _11=$((interval*11)) - _12=$((interval*12)) - _13=$((interval*13)) - _14=$((interval*14)) - _15=$((interval*15)) - _16=$((interval*16)) - - # echo Interval 1: $_01>>$LOG - # echo Interval 2: $_02>>$LOG - # echo Interval 3: $_03>>$LOG - # echo Interval 4: $_04>>$LOG - # echo Interval 5: $_05>>$LOG - # echo Interval 6: $_06>>$LOG - - echo SUBJECT: $SUBJECT>>$LOG - echo TARGET: $TARGET>>$LOG - echo FNAME: $FNAME>>$LOG - - mplayer "$SUBJECT" -ss $_01 -frames 1 -nolirc -nosound -vo jpeg - mv 00000001.jpg 01.jpg - - mplayer "$SUBJECT" -ss $_02 -frames 1 -nolirc -nosound -vo jpeg - mv 00000001.jpg 02.jpg - - mplayer "$SUBJECT" -ss $_03 -frames 1 -nolirc -nosound -vo jpeg - mv 00000001.jpg 03.jpg - - mplayer "$SUBJECT" -ss $_04 -frames 1 -nolirc -nosound -vo jpeg - mv 00000001.jpg 04.jpg - - mplayer "$SUBJECT" -ss $_05 -frames 1 -nolirc -nosound -vo jpeg - mv 00000001.jpg 05.jpg - - mplayer "$SUBJECT" -ss $_06 -frames 1 -nolirc -nosound -vo jpeg - mv 00000001.jpg 06.jpg - - mplayer "$SUBJECT" -ss $_07 -frames 1 -nolirc -nosound -vo jpeg - mv 00000001.jpg 07.jpg - - mplayer "$SUBJECT" -ss $_08 -frames 1 -nolirc -nosound -vo jpeg - mv 00000001.jpg 08.jpg - - mplayer "$SUBJECT" -ss $_09 -frames 1 -nolirc -nosound -vo jpeg - mv 00000001.jpg 09.jpg - - mplayer "$SUBJECT" -ss $_10 -frames 1 -nolirc -nosound -vo jpeg - mv 00000001.jpg 10.jpg - - mplayer "$SUBJECT" -ss $_11 -frames 1 -nolirc -nosound -vo jpeg - mv 00000001.jpg 11.jpg - - mplayer "$SUBJECT" -ss $_12 -frames 1 -nolirc -nosound -vo jpeg - mv 00000001.jpg 12.jpg - - mplayer "$SUBJECT" -ss $_13 -frames 1 -nolirc -nosound -vo jpeg - mv 00000001.jpg 13.jpg - - mplayer "$SUBJECT" -ss $_14 -frames 1 -nolirc -nosound -vo jpeg - mv 00000001.jpg 14.jpg - - mplayer "$SUBJECT" -ss $_15 -frames 1 -nolirc -nosound -vo jpeg - mv 00000001.jpg 15.jpg - - mplayer "$SUBJECT" -ss $_16 -frames 1 -nolirc -nosound -vo jpeg - mv 00000001.jpg 16.jpg - - # 96x72 - for x in *.jpg - do - convert -scale 160x120 $x new.$x - mv new.$x $x - done - - # montage -label %f -frame 5 -background #336699 -geometry +4+4 rose.jpg red-ball.png frame.jpg - montage -frame 5 -tile 4x4 -geometry +4+4 ??.jpg new.jpg - rm {01,02,03,04,05,06,07,08,09,10,11,12,13,14,15,16}.jpg -fi - -gqview -t new.jpg - -popd diff --git a/now b/now deleted file mode 100755 index e2e74f5..0000000 --- a/now +++ /dev/null @@ -1,7 +0,0 @@ -#!/bin/bash - -if [ "$1" == 'short' ]; then - date +"%y-%m-%d" -else - date +"%y-%m-%d_%H-%M" -fi diff --git a/ntdeploy b/ntdeploy deleted file mode 100755 index 185fe84..0000000 --- a/ntdeploy +++ /dev/null @@ -1,109 +0,0 @@ -#!/bin/bash - -set -e -source `dirname $0`/colours -source `dirname $0`/ntdr.functions.sh - -NO_ARGS=0 -VERBOSE=off -USAGE="$0 [-y] [-v] [-h] [-r remote-drupal-root] [-l local-drupal-root] [-f release] [-m mysql-root-pass] -b brandcode remoteuser@remotehost" - -if [ "$#" -eq "$NO_ARGS" ]; then - echo $USAGE - exit 1 -fi - -# Set defaults -DRUPAL_LOCAL_ROOT=`pwd` -DRUPAL_REMOTE_ROOT=/var/www - -while getopts "yr:l:b:f:m:b:vh" options; do - case $options in - y) YES="-y";; - v) VERBOSE='verbose';; - h) echo $USAGE; exit 0;; - r) DRUPAL_REMOTE_ROOT="$OPTARG";; - l) DRUPAL_LOCAL_ROOT="$OPTARG";; - f) RELEASE="$OPTARG";; - b) BC="$OPTARG";; - m) MYSQL_ROOT_PASSWORD="$OPTARG";; - esac -done - -# Export this so sub-functions can see it -export VERBOSE - -shift $((OPTIND-1)) -RUSER=`echo $1 | awk -F @ '{print $1}'` -RHOST=`echo $1 | awk -F @ '{print $2}'` - -if [ -z "$MYSQL_ROOT_PASSWORD" ]; then - echo -e $COL_RED"No root password, cannot proceed"$COL_RESET - echo $USAGE - exit 1; -fi - -if [ -z "$BC" ]; then - echo -e $COL_RED"No brand code, cannot proceed"$COL_RESET - echo $USAGE - exit 1; -fi - -if [ ! -z "$VERBOSE" ]; then - PROGRESS="--progress" -fi - -if [ -z "$RELEASE" ]; then - RELEASE=${BC}_0.0.1 -fi - -# Check remote folder exist -echo -e "${COL_GREEN}Checking remote servers dirs${COL_RESET}" -ntdr_checkRemoteDirExists $RUSER $RHOST $DRUPAL_REMOTE_ROOT - -NEW_VERSION=$RELEASE -NEW_REMOTE_PATH=$DRUPAL_REMOTE_ROOT/$RELEASE - -echo -e "${COL_GREEN}Creating new files${COL_RESET}" -ntdr_createAlias $DRUPAL_LOCAL_ROOT $NEW_VERSION ${RHOST} -ntdr_createChangeLog $DRUPAL_LOCAL_ROOT $NEW_VERSION -ntdr_createSettingFile $DRUPAL_LOCAL_ROOT $NEW_VERSION - -echo -e "${COL_GREEN}Creating new robots.txt${COL_RESET}" -cp $DRUPAL_LOCAL_ROOT/robots.txt $DRUPAL_LOCAL_ROOT/robots.bak -cat > $DRUPAL_LOCAL_ROOT/robots.txt < $DUMPFILE -ssh $RUSER@$RHOST drush -r ${NEW_REMOTE_PATH} sqlc < $DUMPFILE - -mv $DRUPAL_LOCAL_ROOT/robots.bak $DRUPAL_LOCAL_ROOT/robots.txt - -echo -e "${COL_GREEN}Creating symlinks${COL_RESET}" -set +e -ssh $RUSER@$RHOST "rm $DRUPAL_REMOTE_ROOT/rc" -ssh $RUSER@$RHOST "rm $DRUPAL_REMOTE_ROOT/latest" -ssh $RUSER@$RHOST "rm $DRUPAL_REMOTE_ROOT/testing" -set -e -ssh $RUSER@$RHOST "ln -s ${DRUPAL_REMOTE_ROOT}/testingdir $DRUPAL_REMOTE_ROOT/testing" -ssh $RUSER@$RHOST "ln -s ${DRUPAL_REMOTE_ROOT}/testing $DRUPAL_REMOTE_ROOT/rc" -ssh $RUSER@$RHOST "ln -s ${NEW_REMOTE_PATH} $DRUPAL_REMOTE_ROOT/latest" - -echo -e "${COL_GREEN}All done.${COL_RESET}" diff --git a/ntdr b/ntdr deleted file mode 100755 index 487ebcb..0000000 --- a/ntdr +++ /dev/null @@ -1,217 +0,0 @@ -#!/bin/bash - -# Release files to rc.foo.com and testing.foo.com -# Fetch sql from rc.foo.com/latest -# and load that sql into both new sites - -set -e - -CWD=`dirname $0` -source $CWD/colours -source $CWD/ntdr.functions.sh - -NO_ARGS=0 -VERBOSE=off -USAGE="$0 [-y] [-v] [-h] [-s] [-r remote-drupal-root] [-l local-drupal-root] [[-b ] | [-f release]] [-m mysql-root-pass] remoteuser@remotehost" - -if [ $# -eq "$NO_ARGS" ]; then - echo $USAGE - exit 1 -fi - -# Set defaults -DRUPAL_LOCAL_ROOT=`pwd` -DRUPAL_REMOTE_ROOT=/var/www - -while getopts "yr:l:b:f:m:Vvsh" options; do - case $options in - y) YES="-y";; - v) VERBOSE='verbose';; - V) VERBOSE='very_verbose';; - h) ntdr_usage; exit 0;; - s) SKIP_SYMLINKS=1;; - r) DRUPAL_REMOTE_ROOT="$OPTARG";; - l) DRUPAL_LOCAL_ROOT="$OPTARG";; - b) BUMP="$OPTARG";; - f) RELEASE="$OPTARG";; - m) MYSQL_ROOT_PASSWORD="$OPTARG";; - esac -done - -# Export this so sub-functions can see it -export VERBOSE - -shift $((OPTIND-1)) -RUSER=`echo $1 | awk -F @ '{print $1}'` -RHOST=`echo $1 | awk -F @ '{print $2}'` - -RC_HOST=rc.${RHOST} - -LATEST_DIR=$DRUPAL_REMOTE_ROOT/latest -TESTING_DIR=$DRUPAL_REMOTE_ROOT/testing - -echo -e "${COL_GREEN}Initial Settings${COL_RESET}" -ntdr_debug "${COL_CYAN}DRUPAL_REMOTE_ROOT${COL_RESET} ${DRUPAL_REMOTE_ROOT}" -ntdr_debug "${COL_CYAN}DRUPAL_LOCAL_ROOT${COL_RESET} ${DRUPAL_LOCAL_ROOT}" -ntdr_debug "${COL_CYAN}BUMP${COL_RESET} ${BUMP}" -ntdr_debug "${COL_CYAN}RELEASE${COL_RESET} ${RELEASE}" -ntdr_debug "${COL_CYAN}MYSQL_ROOT_PASSWORD${COL_RESET} ${MYSQL_ROOT_PASSWORD}" -ntdr_debug "${COL_CYAN}RUSER${COL_RESET} ${RUSER}" -ntdr_debug "${COL_CYAN}RHOST${COL_RESET} ${RHOST}" -ntdr_debug "${COL_CYAN}RC_HOST${COL_RESET} ${RC_HOST}" -ntdr_debug "${COL_CYAN}LATEST_DIR${COL_RESET} ${LATEST_DIR}" -ntdr_debug "${COL_CYAN}TESTING_DIR${COL_RESET} ${TESTING_DIR}" - -# Check remote folders exist -echo -e "${COL_GREEN}Checking remote servers dirs${COL_RESET}" -ntdr_checkRemoteDirExists $RUSER $RC_HOST $LATEST_DIR -ntdr_checkRemoteDirExists $RUSER $RC_HOST $TESTING_DIR - -CURRENT_LIVE_REAL_DIR=`ntdr_remotePath $RUSER $RC_HOST $LATEST_DIR` -CURRENT_TEST_REAL_DIR=`ntdr_remotePath $RUSER $RC_HOST $TESTING_DIR` -CURRENT_LIVE_VERSION=`basename $CURRENT_LIVE_REAL_DIR` -CURRENT_TEST_VERSION=`basename $CURRENT_TEST_REAL_DIR` -ntdr_debug "${COL_CYAN}CURRENT_LIVE_REAL_DIR${COL_RESET} ${CURRENT_LIVE_REAL_DIR}" -ntdr_debug "${COL_CYAN}CURRENT_LIVE_VERSION${COL_RESET} ${CURRENT_LIVE_VERSION}" -ntdr_debug "${COL_CYAN}CURRENT_TEST_VERSION${COL_RESET} ${CURRENT_TEST_VERSION}" - -LIVE_DUMP_FILE=$CURRENT_LIVE_VERSION-live-`date +"%y-%m-%d_%H-%M"`.sql -TEST_DUMP_FILE=$CURRENT_TEST_VERSION-testing-`date +"%y-%m-%d_%H-%M"`.sql - -if [ -z "$RELEASE" ]; then - echo -e "${COL_GREEN}Computing version numbers from${COL_RESET} testing version ${CURRENT_TEST_VERSION} (Live: ${CURRENT_LIVE_VERSION})" - # Get version numbers BRAND MAJOR_VERSION MINOR_VERSION PATCH_VERSION - if [ "$CURRENT_TEST_VERSION" == 'testingdir' ]; then - ntdr_versionElements $CURRENT_LIVE_VERSION - else - ntdr_versionElements $CURRENT_TEST_VERSION - fi - # this will create MAJOR_VERSION MINOR_VERSION PATCH_VERSION based on current test site version - ntdr_bumpUp $MAJOR_VERSION $MINOR_VERSION $PATCH_VERSION $BUMP - NEW_VERSION=${BRAND}_${MAJOR_VERSION}.${MINOR_VERSION}.${PATCH_VERSION} -else - NEW_VERSION=$RELEASE -fi -ntdr_debug "${COL_CYAN}NEW_VERSION${COL_RESET} ${NEW_VERSION}" - -NEW_REMOTE_PATH=$DRUPAL_REMOTE_ROOT/${NEW_VERSION} -VHOST_REMOTE_PATH=$DRUPAL_REMOTE_ROOT/`echo ${NEW_VERSION} | sed -e "s|\.|_|g"` - -echo -e "${COL_GREEN}Preparing to remote copy${COL_RESET}" -echo -e "\t${RUSER}@${RC_HOST}:${CURRENT_LIVE_REAL_DIR} ${RUSER}@${RC_HOST}:${NEW_REMOTE_PATH}" -echo -e "${COL_GREEN}Then rsync${COL_RESET}" -echo -e "\t${DRUPAL_LOCAL_ROOT}/* to ${RUSER}@${RC_HOST}:${NEW_REMOTE_PATH}" -echo -e "${COL_GREEN}Then create a database/user/password:${COL_RESET} ${NEW_VERSION}" -echo -e "${COL_GREEN}The restore the DB from${COL_RESET} ${LIVE_DUMP_FILE}" -echo -e "${COL_MAGENTA}Proceed (y/N)?${COL_RESET}" - -if [ -z "$YES" ]; then - read a - if [ "$a" != 'y' ] && [ "$a" != 'Y' ]; then - echo Aborting - exit 0 - fi -fi - -mkdir -p ~/.nt_tabs -# Get the database from latest -echo -e "${COL_GREEN}Fetching live DB${COL_RESET}" -ntdr_debug "${COL_CYAN}Dump file $LIVE_DUMP_FILE${COL_RESET}" -ntdr_dumpRemoteDB $RUSER $RC_HOST $LATEST_DIR /var/tmp/$LIVE_DUMP_FILE -scp $RUSER@$RC_HOST:/var/tmp/$LIVE_DUMP_FILE ~/.nt_tabs/$LIVE_DUMP_FILE - -echo -e "${COL_GREEN}Create new alias files${COL_RESET}" -ntdr_createAlias $DRUPAL_LOCAL_ROOT $NEW_VERSION $RC_HOST - -echo -e "${COL_GREEN}Create changelog${COL_RESET}" -ntdr_createChangeLog $DRUPAL_LOCAL_ROOT $NEW_VERSION - -echo -e "${COL_GREEN}Prepare settings file${COL_RESET}" -ntdr_createSettingFile $DRUPAL_LOCAL_ROOT $NEW_VERSION - -for SITE in $RC_HOST; do - echo -e "${COL_GREEN}Pre-fix permission on ${SITE}${COL_RESET}" - ssh -t $RUSER@$SITE sudo /usr/local/share/Shell-tools/ntdrchown ${CURRENT_LIVE_REAL_DIR} - if [ -e ${CURRENT_TEST_REAL_DIR}/sites/default/settings.php ]; then - ssh -t $RUSER@$SITE sudo /usr/local/share/Shell-tools/ntdrchown ${CURRENT_TEST_REAL_DIR} - fi -done - -echo -e "${COL_GREEN}Pre-fix local permissions" -sudo ntdrchown -a ${DRUPAL_LOCAL_ROOT} - -echo -e "${COL_GREEN}Pre-sync${COL_RESET}" -ssh $RUSER@$RC_HOST rsync -a --size-only --no-p -O --no-g --exclude=tabs-imagecache --exclude=.sass-cache ${CURRENT_LIVE_REAL_DIR}/ ${NEW_REMOTE_PATH} - -echo -e "${COL_GREEN}Sync up${COL_RESET}" -if [ "$VERBOSE" != "off" ]; then - if [ "$VERBOSE" == "very_verbose" ]; then - PROGRESS="--progress" - elif [ "$VERBOSE" == "verbose" ]; then - PROGRESS="-v" - fi -fi - -ntdr_debug "Rsync down files" -rsync -a $PROGRESS --size-only --no-p -O --no-g --exclude=tabs-imagecache --exclude=.sass-cache $RUSER@$RC_HOST:${CURRENT_LIVE_REAL_DIR}/sites/default/files ${DRUPAL_LOCAL_ROOT}/sites/default - -ntdr_debug "Syncing to $RUSER@$RC_HOST:${NEW_REMOTE_PATH}" -rsync -a $PROGRESS --size-only --no-p -O --no-g --exclude=tabs-imagecache --exclude=.sass-cache ${DRUPAL_LOCAL_ROOT}/* $RUSER@$RC_HOST:${NEW_REMOTE_PATH} - -echo -e "${COL_GREEN}Rsync up files${COL_RESET}" -rsync -a $PROGRESS --size-only --no-p -O --no-g --exclude=tabs-imagecache --exclude=.sass-cache ${DRUPAL_LOCAL_ROOT}/sites/default/files $RUSER@$RC_HOST:${CURRENT_LIVE_REAL_DIR}/sites/default - -for HOST in $RC_HOST; do - echo -e "${COL_GREEN}Change settings files on $HOST${COL_RESET}" - ssh $RUSER@$HOST chmod 664 ${NEW_REMOTE_PATH}/sites/default/settings.php - ssh $RUSER@$HOST chmod 775 ${NEW_REMOTE_PATH}/sites/default - - ssh $RUSER@$HOST cp ${NEW_REMOTE_PATH}/sites/default/${NEW_VERSION}_settings.php ${NEW_REMOTE_PATH}/sites/default/settings.php - - ssh $RUSER@$HOST chmod 664 ${NEW_REMOTE_PATH}/sites/default/settings.php - ssh $RUSER@$HOST chmod 775 ${NEW_REMOTE_PATH}/sites/default - - echo -e "${COL_GREEN}Create new DB if needed on $HOST${COL_RESET}" - ntdr_createRemoteDB $RUSER $HOST $CURRENT_LIVE_REAL_DIR $MYSQL_ROOT_PASSWORD $NEW_VERSION - - echo -e "${COL_GREEN}Fix perms on $HOST${COL_RESET}" - ssh $RUSER@$HOST "find ${NEW_REMOTE_PATH}/sites/default -type d -exec chmod 2775 {} \;" -done -# echo -e $COL_GREEN"chmod run, I shouldn't have rights to change ownership you may need to run:"$COL_RESET -# echo -e $COL_YELLOW" sudo chown -R www-data:www-data ${NEW_REMOTE_PATH}/sites/*/files"$COL_RESET - -echo -e "${COL_GREEN}Upload db to both${COL_RESET}" -drush @${NEW_VERSION}.rc sqlc < ~/.nt_tabs/${LIVE_DUMP_FILE} - -echo -e "${COL_GREEN}Drush up${COL_RESET}" -drush @${NEW_VERSION}.rc $YES up - -echo -e "${COL_GREEN}Drush updb${COL_RESET}" -drush @${NEW_VERSION}.rc $YES updb - -echo -e "${COL_GREEN}Preserve robots.txt${COL_RESET}" -set +e -ssh $RUSER@$RC_HOST cp ${NEW_REMOTE_PATH}/robots.txt ${NEW_REMOTE_PATH}/robots.${NEW_VERSION}.txt -ssh $RUSER@$RC_HOST cp /var/www/testing/robots.txt ${NEW_REMOTE_PATH}/robots.txt -set -e - -echo -e "${COL_GREEN}Drush cc all${COL_RESET}" -drush @${NEW_VERSION}.rc cc all - -for SITE in $RC_HOST; do - if [ -z "$SKIP_SYMLINKS" ]; then - echo -e "${COL_GREEN}Updating symlinks on ${SITE}${COL_RESET}" - ssh $RUSER@$SITE "rm ${DRUPAL_REMOTE_ROOT}/testing" - ssh $RUSER@$SITE "ln -s ${NEW_REMOTE_PATH} ${DRUPAL_REMOTE_ROOT}/testing" - ssh $RUSER@$SITE "ln -s ${NEW_REMOTE_PATH} ${VHOST_REMOTE_PATH}" - else - echo -e "${COL_YELLOW}Skipping symlinksb${COL_RESET}" - fi - - echo -e "${COL_GREEN}Fix permissions on ${SITE}${COL_RESET}" - ssh -t $RUSER@$SITE "sudo /usr/local/share/Shell-tools/ntdrchown ${NEW_REMOTE_PATH}" - - echo -e "${COL_GREEN}Compass compile${COL_RESET}" - ssh $RUSER@$SITE "ntdr-compass /var/www/latest/sites/all/themes/" -done - diff --git a/ntdr-compass b/ntdr-compass deleted file mode 100755 index 20cc822..0000000 --- a/ntdr-compass +++ /dev/null @@ -1,20 +0,0 @@ -#!/bin/bash - -CWD=`dirname $0` -source $CWD/colours - -# Theme path -THEME_PATH=$1 - -if [ -z "$THEME_PATH" ]; then - THEME_PATH=`pwd` -fi - -for x in $THEME_PATH/*; do - if [ -d "$x" ]; then - echo -e "${COL_GREEN}Compass compile ${x}${COL_RESET}" - compass compile $x - else - echo -e "${COL_YELLOW}Not a theme: ${x}${COL_RESET}" - fi -done diff --git a/ntdr.functions.sh b/ntdr.functions.sh deleted file mode 100644 index 75120b7..0000000 --- a/ntdr.functions.sh +++ /dev/null @@ -1,258 +0,0 @@ -#!/bin/bash - -function ntdr_aliasname { - aliasname=$(echo $1 | awk -F '.' '{print $1}') - isnumeric=$(echo $aliasname | grep "[^0-9]") - if [ -z "$isnumeric" ]; then - # The first element is a numer, it's probably an IP - echo $1 - else - echo $aliasname - fi -} - -function ntdr_bumpUp { - MAJOR_VERSION=$1 - MINOR_VERSION=$2 - PATCH_VERSION=$3 - BUMP=$4 - - until [ "$BUMP" == "patch" ] || [ "$BUMP" == "minor" ] || [ "$BUMP" == "major" ]; do - echo -n "Bump which version Major|mInor|Patch? [m/i/P]? " - read a - case $a in - M) BUMP=major;; - m) BUMP=major;; - I) BUMP=minor;; - i) BUMP=minor;; - P) BUMP=patch;; - p) BUMP=patch;; - esac - done - - case $BUMP in - patch) PATCH_VERSION=$(($PATCH_VERSION + 1));; - minor) MINOR_VERSION=$(($MINOR_VERSION + 1)); PATCH_VERSION=0;; - major) MAJOR_VERSION=$(($MAJOR_VERSION + 1)); MINOR_VERSION=0; PATCH_VERSION=0;; - esac - - export PATCH_VERSION - export MINOR_VERSION - export MAJOR_VERSION -} - -function ntdr_checkRemoteDirExists { - RUSER=$1 - RHOST=$2 - RPATH=$3 - set +e - ssh $RUSER@$RHOST ls -d $RPATH > /dev/null - if [ "$?" != 0 ]; then - echo -e $COL_RED"${RUSER}@${RHOST}:${RPATH} does not exist."$COL_REST - exit 1 - fi - set -e -} - -# check the most common write permission -function ntdr_checkWritePerms { - if [ ! -w "$DRUPAL_LOCAL_ROOT" ] ; then - echo -e $COL_RED"Cannot write to ${DRUPAL_LOCAL_ROOT}. Writting change log will fail."$COL_RESET - echo -e $COL_CYAN"chown $USER:`id -gn $USER` ${DRUPAL_LOCAL_ROOT}"$COL_RESET - echo -e $COL_CYAN"chown $USER:`id -gn $USER` ${DRUPAL_LOCAL_ROOT}/changelog.txt"$COL_RESET - exit 1 - fi - - if [ ! -w "$DRUPAL_LOCAL_ROOT/sites/all/drush" ] ; then - echo -e $COL_RED"Cannot write to ${DRUPAL_LOCAL_ROOT}/sites/all/drush. Writting alias file log will fail."$COL_RESET - echo -e $COL_CYAN"chown $USER:`id -gn $USER` ${DRUPAL_LOCAL_ROOT}/sites/all/drush"$COL_RESET - exit 1 - fi - - if [ ! -w "$DRUPAL_LOCAL_ROOT/sites/default" ] ; then - echo -e $COL_RED"Cannot write to ${DRUPAL_LOCAL_ROOT}/sites/default Writting new settings file log will fail."$COL_RESET - echo -e $COL_CYAN"chown $USER:`id -gn $USER` ${DRUPAL_LOCAL_ROOT}/sites/default"$COL_RESET - exit 1 - fi -} - -# Check we have required params -function ntdr_checkParams { - if [ -z $RUSER ]; then - echo -e $COL_RED"Missing remote user"$COL_RESET - echo $USAGE - exit 1 - elif [ -z $RHOST ]; then - echo -e $COL_RED"Missing remote host"$COL_RESET - echo $USAGE - exit 1 - elif [ -z "$DRUPAL_LOCAL_ROOT" ] || [ ! -f "$DRUPAL_LOCAL_ROOT/cron.php" ]; then - echo -e $COL_RED"The local drupal root ($DRUPAL_LOCAL_ROOT) does not seem to be a drupal site"$COL_RESET - exit 1 - fi -} - -function ntdr_createAlias { - DRUPAL_LOCAL_ROOT=$1 - RELEASE=$2 - RHOST=$3 - - RELEASE_ALIAS=$(ntdr_aliasname $RHOST) - ALIAS_PATH=$DRUPAL_LOCAL_ROOT/sites/all/drush - mkdir -p $ALIAS_PATH - ALIAS_FILE=$ALIAS_PATH/$RELEASE.$RELEASE_ALIAS.alias.drushrc.php - echo ' $ALIAS_FILE - drush -r $DRUPAL_LOCAL_ROOT sa --full --with-db @self >> $ALIAS_FILE - sed -i "s/'root' => .*/'root' => '\/var\/www\/$RELEASE',/g" $ALIAS_FILE - sed -i "s/self/${RELEASE}.${RELEASE_ALIAS}/g" $ALIAS_FILE - sed -i "/#name/a 'remote-host' => '${RHOST}'," $ALIAS_FILE - sed -i "/#name/a 'remote-user' => '${RUSER}'," $ALIAS_FILE - sed -i "s/ 'database' => .*/ 'database' => '$RELEASE',/g" $ALIAS_FILE - sed -i "s/ 'username' => .*/ 'username' => '$RELEASE',/g" $ALIAS_FILE - sed -i "s/ 'password' => .*/ 'password' => '$RELEASE',/g" $ALIAS_FILE -} - -function ntdr_createRemoteDB { - RUSER=$1 - RHOST=$2 - RPATH=$3 - PASS=$4 - RELEASE=$5 - - set +e - ssh $RUSER@$RHOST "mysql-checkuser -u ${RELEASE} -m ${PASS}" - RETVAL=$? - set -e - if [ "$RETVAL" != 0 ]; then - _DUMP_FILE=${RELEASE}-`date +"%y-%m-%d_%H-%M"`.sql - ntdr_debug "${COL_CYAN}User or DB ${RELEASE} exists, dumping it to ${_DUMP_FILE}${COL_RESET}" - ntdr_dumpRemoteDB $RUSER $RHOST $RPATH /var/tmp/$_DUMP_FILE - else - echo ssh $RUSER@$RHOST "mysql-create-user-and-db -u ${RELEASE} -p ${RELEASE} -m ${PASS}" - ssh $RUSER@$RHOST "mysql-create-user-and-db -u ${RELEASE} -p ${RELEASE} -m ${PASS}" - fi -} - -function ntdr_createSettingFile { - DRUPAL_LOCAL_ROOT=$1 - RELEASE=$2 - - ntdr_debug "${COL_CYAN}Prepare ${RELEASE}_settings.php for release${COL_RESET}" - LOCAL_SETTINGS_DIR=$DRUPAL_LOCAL_ROOT/sites/default - LOCAL_SETTINGS=$LOCAL_SETTINGS_DIR/settings.php - TMP_SETTINGS=$LOCAL_SETTINGS_DIR/${RELEASE}_settings.php - chmod 755 $LOCAL_SETTINGS_DIR - if [ -e "$TMP_SETTINGS" ]; then - chmod 664 $TMP_SETTINGS - fi - cp $LOCAL_SETTINGS $TMP_SETTINGS - sed -i "s/ 'database' => .*/ 'database' => '$RELEASE',/g" $TMP_SETTINGS - sed -i "s/ 'username' => .*/ 'username' => '$RELEASE',/g" $TMP_SETTINGS - sed -i "s/ 'password' => .*/ 'password' => '$RELEASE',/g" $TMP_SETTINGS - chmod 555 $LOCAL_SETTINGS_DIR - chmod 444 $TMP_SETTINGS -} - -function ntdr_debug { - if [ ! -z "$VERBOSE" ]; then - echo -e $1 - fi -} - -function ntdr_dumpRemoteDB { - RUSER=$1 - RHOST=$2 - RPATH=$3 - DUMPFILE=$4 - ssh $RUSER@$RHOST "drush -r $RPATH sql-dump --ordered-dump --structure-tables-key=common > $DUMPFILE" -} - -function ntdr_remotePath { - export RPATH=`ssh $1@$2 realpath $3` - export CURRENT=`basename $RPATH` - - echo $RPATH -} - -function ntdr_usage { - echo $USAGE - cat <] - Sites are release in a x.y.z format where versions are major.minor.patch - The script will bump that version by one in the category specified. If - ommitted the script will ask. --f release - If specified this release value will override the m.m.p number --m mysql-root-pass - The script expects to find the remote mysql root password in an environment - variable MYSQL_ROOT_PASSWORD. This parameter can override that. -EOF -} - -function ntsl_usage { - echo $USAGE - cat < $DRUPAL_LOCAL_ROOT/changelog.new -date +"%y-%m-%d_%H-%M" >> $DRUPAL_LOCAL_ROOT/changelog.new -set +e -branches -l -p $DRUPAL_LOCAL_ROOT >> $DRUPAL_LOCAL_ROOT/changelog.new -if [ "$?" != 0 ]; then - echo $COL_RED"Git branches are out of sync: 'branches -l -p $DRUPAL_LOCAL_ROOT'"$COL_RESET -fi -set -e -echo -e "\n" >> $DRUPAL_LOCAL_ROOT/changelog.new -cat $DRUPAL_LOCAL_ROOT/changelog.txt >> $DRUPAL_LOCAL_ROOT/changelog.new -mv $DRUPAL_LOCAL_ROOT/changelog.new $DRUPAL_LOCAL_ROOT/changelog.txt diff --git a/reclone b/reclone deleted file mode 100755 index 84d60bf..0000000 --- a/reclone +++ /dev/null @@ -1,14 +0,0 @@ -#!/bin/bash - -if [ -z "$1" ]; then - _PATH=`pwd` -else - _PATH=$1 -fi - -for GIT in `find $_PATH -type d -name .git`; do - URL=`git -C $GIT config --get remote.origin.url` - TARGET=`dirname $GIT` - mv $TARGET `dirname $TARGET`/_`basename $TARGET` - git clone $URL $TARGET -done diff --git a/remote-mirror b/remote-mirror deleted file mode 100755 index 4b10d51..0000000 --- a/remote-mirror +++ /dev/null @@ -1,80 +0,0 @@ -#!/bin/bash - -USAGE="$0 configfile" - -if [ -z $1 ]; then - echo "Unable to proceed. Config file not specified." - echo $USAGE - exit 1 -fi - -source $1 - -# print_msg MESSAGE FLAG -# -# param MESSAGE The mnessage to print -# param FLAG If the flag is not empty print the message -function print_msg { - if [ ! -z "$2" ]; then - echo $1 - fi -} - -print_msg "Using config file $1" $VERBOSE - -if [ -z $SSH_USER ]; then - echo "Cannot proceed without SSH_USER" - exit 2 -fi - -if [ -z $R_HOST ]; then - echo "Cannot proceed without R_HOST" - exit 4 -fi - -SSH_CON=$SSH_USER@$R_HOST - -print_msg "SSH_CON=$SSH_CON" $VERBOSE - -# run pre commands, here we could stop servers, flush dbs etc -if [ ! -z "$R_PRECOMMAND" ]; then - print_msg "R_PRECOMMAND=$R_PRECOMMAND" $VERBOSE - ssh $SSH_CON "$R_PRECOMMAND" -fi - -# dump remote db -if [ ! -z "$R_DB_DUMP" ]; then - print_msg "R_DB_DUMP=$R_DB_DUMP" $VERBOSE - ssh $SSH_CON "$R_DB_DUMP>$R_DUMP_SQL" -fi - -PROGRESS='' -if [ ! -z $VERBOSE ]; then - PROGRESS="--progress" -fi - -# sync file systems -if [ ! -z "$R_TARGET" ]; then - print_msg "R_TARGET=$R_TARGET" $VERBOSE - rsync \ - --exclude=".svn" \ - $PROGRESS \ - --delete \ - -a \ - $SSH_CON:$R_TARGET `dirname $R_TARGET` -fi - -if [ ! -z "$L_MYSQL" ]; then - # restore db - print_msg "Restoring DB [$L_MYSQL < $R_DUMP_SQL]" $VERBOSE - $L_MYSQL < $R_DUMP_SQL - if [ -z "$SKIP_FLUSH_PRIVS" ]; then - $L_MYSQL -e "FLUSH PRIVILEGES;" - fi -fi - -# run post commands -if [ ! -z "$R_POSTCOMMAND" ]; then - print_msg "R_POSTCOMMAND=$R_POSTCOMMAND" $VERBOSE - /bin/bash $R_POSTCOMMAND -fi diff --git a/remote-mirror.sample.conf b/remote-mirror.sample.conf deleted file mode 100755 index 7774a01..0000000 --- a/remote-mirror.sample.conf +++ /dev/null @@ -1,37 +0,0 @@ -#!/bin/bash - -VERBOSE=1 - -# The user to connect to the remote site as. This user will need public key access -# as a shell user. -SSH_USER=root - -# The remote host name to mirror -R_HOST=www.gofigurative.com - -# This is the command to execute as a db dump on the remote server. If you cannot -# execute a single command then create a shell script on the remote machine an call -# it here. If this value is empty no DB dump is done. -R_DB_DUMP="/usr/bin/mysqldump -u root -pPASSWORD --add-drop-database --all-databases --quote-names" - -# Where to place the dump, note this should be relative to the the backup root -R_DUMP_SQL=dump.sql - -# Command to execute before executing the dump and mirror. Stop servers, etc. If -# there is more than one command to execute then create a shell script on the remote -# machine an call it here. -# R_PRECOMMAND= UNTESTED - -# Command to execute after executing the dump and mirror. Stop servers, etc. If -# there is more than one command to execute then create a shell script on the remote -# machine an call it here. -# R_POSTCOMMAND= UNTESTED - -# This is the root of the backup. All files in this directory will be mirrored. -# IMPORTANT: Also this is where the backup will be mirrored to on the local machine. The local target is assessed -R_TARGET=/var/www - -# The command to use to connect to the db for drops/restores. This user must be -# able to drop/create dbs and users. If this value is empty no restore will be -# attempted. This will need to the same password as was set on the remote server -L_MYSQL="/usr/bin/mysql -u root -pPASSWORD" diff --git a/securitycam b/securitycam deleted file mode 100755 index 5eaaa70..0000000 --- a/securitycam +++ /dev/null @@ -1,34 +0,0 @@ -#!/bin/bash - -set -e -set -x - -# 20150219161426-01.jpg -# 20130501091550_57.jpg - -# ORIGIMG="/tmp/foo/95-20150219161426-01.jpg" -# ORIGIMG="/tmp/foo/000DC5D252CC()_0_20130501091550_57.jpg" -# ROOT='/var/tmp/cam01' -ROOT=$1 -ORIGIMG=$2 - -ORIGIMG=`echo $ORIGIMG | sed -e "s/-/_/g"` - -IFS='_' read -a parts <<< "$ORIGIMG" - -# IMG=${parts[1]}_${parts[2]} -# IMG="$( cut -d '_' -f 3,4 <<< "$ORIGIMG" )" -IMG=${parts[${#arr[@]}-2]}_${parts[${#arr[@]}-1]} - -YEAR="$( cut -c 1,2,3,4 <<< "$IMG" )" -MONTH="$( cut -c 5,6 <<< "$IMG" )" -DAY="$( cut -c 7,8 <<< "$IMG" )" -HOUR="$( cut -c 9,10 <<< "$IMG" )" -MINUTE="$( cut -c 11,12 <<< "$IMG" )" -SECOND="$( cut -c 13,14 <<< "$IMG" )" -NAME="$( cut -c 16,17,18,19,20,21 <<< "$IMG" )" -DIR="$YEAR/$MONTH/$DAY/$HOUR/$MINUTE" -FILE="$YEAR-$MONTH-$DAY-$HOUR:$MINUTE:$SECOND-$NAME" - -echo mkdir -p $DIR -echo mv "$ORIGIMG" $ROOT/$DIR/$FILE diff --git a/shazam b/shazam deleted file mode 100755 index b3ef473..0000000 --- a/shazam +++ /dev/null @@ -1,46 +0,0 @@ -#!/bin/bash - -#!/bin/bash - -USAGE="$0 " - -# TODO - getopts and help output -# TODO - make it work on non debian systems -if [ -z $1 ]; then - DR=/var/www -else - DR=$1 -fi - -_USER=$SUDO_USER - -if [ -z "$_USER" ]; then - echo "You must run this script using sudo" - exit 1 -fi - -echo $DR -if [ -z "$DR" ]; then - echo "Usage: $0 path_to_drupal_site_root" - exit 2 -fi - -if [ ! -d "$DR" ]; then - echo "Drupal dir doesnot exist" - echo $USEAGE - exit 3 -fi - -sudo su - www-data -s /bin/bash -c "drush -r $DR cc all" - -# SITESDIR="$DR/sites" - -# PS3="Choose site to clear:" -# select name in $SITESDIR/* -# do - # break -# done - -# if [ ! -z "$name" ]; then - # sudo su - www-data -s /bin/bash -c "drush -r $DR -l http://`basename $name` cc all" -# fi diff --git a/vbox-new b/vbox-new deleted file mode 100755 index 0509d47..0000000 --- a/vbox-new +++ /dev/null @@ -1,77 +0,0 @@ -#!/bin/bash - -NO_ARGS=0 -USAGE="`basename $0` machinename [-m memory] [-d disksize] [-i iso]" - -function fullusage() { - cat < // for getcwd -#include // for MAX_PATH -//#include // for cout and cin - -#include - -// function to return the current working directory -// this is generally the application path -int main( int argc, char *argv[] ) -{ - if ( argv[1] != NULL ) - { - int i = chdir (argv[1]); - } - // _MAX_PATH is the maximum length allowed for a path - char currentPath[1024]; - // use the function to get the path - getcwd(currentPath,1024); - printf ( "%s\n", currentPath ); - return 0; -}