Snippets

Ben Byrne Update demo user via shell

Created by Ben Byrne
#!/bin/bash

# figure out which site we're updating
# assumes current site
if [ -z "$1" ]; then
	SITE=$(echo $PWD | cut -d "/" -f5)
else
	SITE=$1
fi

if [ -z "$SITE" ]; then
	echo "Unable to determine site to update"
	exit 1
fi

echo "Site is $SITE"

# figure out which branch we're updating
# assumes master
if [ -z "$2" ]; then
	BRANCH="master"
else
	BRANCH=$2
fi

# switch to demo user, change directory, and run update
su -c "ssh-agent bash; ssh-add bitbucket; cd ~/sites/$SITE ; git pull origin $BRANCH" demo
echo "Demo user site $SITE updated with latest from $BRANCH"

Comments (0)

HTTPS SSH

You can clone a snippet to your computer for local editing. Learn more.