Skip to content

Instantly share code, notes, and snippets.

@yevrah
Created April 26, 2016 04:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yevrah/c00b532c5e02e7c1808b37ebac1ed5bc to your computer and use it in GitHub Desktop.
Save yevrah/c00b532c5e02e7c1808b37ebac1ed5bc to your computer and use it in GitHub Desktop.
Bash: Productionalise
#!/bin/bash
# Take a snopshot of code and sym link it to a published apached location
# Created By: Javier Woodhouse
user=$1
symbolic_path=$2
source=$3
date_part=`date +"%Y%m%d-%I%M%S"`
destination="$user.$date_part"
#
# Preconditions
#
if [ "$source" == "" ]; then
# No input given, show usage and get out of here!
echo " Usage: producitonalise.sh user symbolic_path source "
echo " "
echo " user : Snapshot permissions and ownerships will be "
echo " assigned to this user. "
echo " symbolic_path : Symbolic path that will be updated to point "
echo " to the specified source code. "
echo " source : Source code to snapshot and point symlink to. "
echo " "
echo " Example: To productionalise the current staging environment "
echo " "
echo " > cd /home/var/www/ "
echo " > productionalise.sh production production_code staging "
exit 0
fi
if [ ! -L $symbolic_path ]; then
# Check that provided link is a proper symlink
echo "[ERRPR] Symbolic path provided is not a valid symlink: $symbolic_path"
exit 0;
fi
#
# Lets setup the new environment
#
cp -R "$3" "$destination"
chown -R $user:$user $destination
rm $symbolic_path
ln -s $destination $symbolic_path
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment