Created
April 26, 2016 04:21
-
-
Save yevrah/88f782a9e808d0c7d180100806f96a7e to your computer and use it in GitHub Desktop.
Bash: Productionalise
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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