Skip to content

Instantly share code, notes, and snippets.

@cullymason
Created August 14, 2013 00:27
Show Gist options
  • Save cullymason/6226998 to your computer and use it in GitHub Desktop.
Save cullymason/6226998 to your computer and use it in GitHub Desktop.
A little script to automate the deployment code from a cvs
#!/bin/bash
clear
# Global Variables
. ~/scripts/config/GLOBAL.cnf
# Text Styles
. ~/scripts/config/STYLES.cnf
# Functions
. ~/scripts/config/Functions.cnf
# Tests
. ~/scripts/config/Tests.cnf
# To Turn off tests set this to false
test_me=false
# Main
# =============
test_imports
echo ""
echo -e "$COL_GREEN ${underline} CZ_DEPLOY $COL_RESET"
# Ask what to deploy to devweb or prodweb or custom
get_destination
echo ""
# Ask if the module name is correct
# If it isnt ask what module they would like to update
get_module
echo ""
# Check if the module specified exists
# if the module doesnt exist ask if we would like to create (checkout) it
check_module
echo ""
# run cvs update on that directory
deploy
echo ""
echo "Done";
exit
#!/bin/bash
FUNCTIONS_IMPORTED="CHECK!"
function deploy() {
echo -e " ${bold}deploying...${normal}"
(cd $deploy_menu; cvs checkout $MODULE;)
}
function check_module() {
echo "${bold}checking${normal}: $deploy_menu/$MODULE"
if [ -d $deploy_menu/$MODULE ]
then
echo -e "- $COL_GREEN The path checks out $normal"
else
echo -n -e "The module, ${bold}$COL_CYAN$MODULE${normal}, does not exist. Would you like to create it?[y/n] "
read response
echo ""
if [ $response == "y" ]
then
(cd $deploy_menu; cvs checkout $MODULE;)
else
exit
fi
fi
}
function get_module() {
while true; do
echo -e "The default module is ${bold}$COL_CYAN$MODULE${normal}. Would you like to change it? [y/n] "
echo -n "Press Enter for ${bold}n${normal}: "
read response
if [ -z $response ] || [ $response == "n" ]
then
break
elif [ $response == "y" ]
then
read -e -p "Enter the path to the file: " -i "/usr/local/etc/" response
MODULE=$response
break
else
echo -e "$COL_RED Not a valid menu selection $COL_RESET"
echo ""
fi
done
}
function get_destination() {
while true; do
echo "Where would you like to deploy to?"
echo "[1] - Devweb"
echo "[2] - Prodweb"
echo "[3] - Custom"
echo -n "Your Response?: "
read response
if [ $response -eq 1 ]
then
echo -e "- ${bold}$COL_CYAN Devweb${normal} it is"
deploy_menu=$DEVWEB_PATH;
break
elif [ $response -eq 2 ]
then
echo -e "- ${bold}$COL_CYAN Prodweb${normal} it is"
deploy_menu=$PRODWEB_PATH;
break
elif [ $response -eq 3 ]
then
echo -n "What custom location would you like to deploy to?"
read response
if [ -d "$ROOT/$response" ]
then
deploy_menu="$ROOT/$response";
break
else
echo -n "That path does not exist. Would you like me to create it? [y/n]"
read create_path
if [ $create_path == "y" ]
then
mkdir $ROOT/$response
deploy_menu=$response;
break
else
exit
fi
fi
else
echo "That is not a valid selection..."
echo "Try again"
echo ""
fi
done
}
#!/bin/bash
GLOBAL_IMPORTED="CHECK!"
#Root Path
ROOT="/Users/cully/scripts"
# CVS Module Name
MODULE="testdrive"
# Deploy Paths
DEVWEB_PATH="$ROOT/devweb"
PRODWEB_PATH="$ROOT/prodweb"
# User Inputs
deploy_menu="0";
module_menu="0";
#Text Styles
STYLES_IMPORTED="CHECK!"
# Colors
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"
# Text Styles
underline=`tput smul`
nounderline=`tput rmul`
bold=`tput bold`
normal=`tput sgr0`
function test_imports()
{
if $test_me ; then
echo "Lets see how everything imported shall we?"
echo "- Global Variables: $GLOBAL_IMPORTED"
echo "- Functions: $FUNCTIONS_IMPORTED"
echo "- Styles: $STYLES_IMPORTED"
fi
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment