Package management, before & after, config user

Username is not configurable in case you're not hip to using "captain". You
can now insert arbitrary commands before and after the deployment by way of
some variables (which aren't yet in the init logic) and added in support for
composer and npm install's post deploy
This commit is contained in:
Josh Sherman 2014-12-23 13:33:58 -05:00
parent c64eb7e583
commit 9c3c4ec5cc

40
ship
View file

@ -5,22 +5,32 @@ case $# in
# TODO go up the hierarchy to find .ship
source .ship
ssh captain@$SERVER "
cd $DESTINATION
git pull origin master
"
COMMANDS="cd $DESTINATION;"
if [ -n "$BEFORE" ]; then
COMMANDS="$COMMANDS $BEFORE;"
fi
COMMANDS="$COMMANDS git pull origin master;"
COMMANDS="$COMMANDS [ -e composer.json ] && composer install;"
COMMANDS="$COMMANDS [ -e package.json ] && npm install;"
if [ -n "$AFTER" ]; then
COMMANDS="$COMMANDS $AFTER;"
fi
ssh $USERNAME@$SERVER "$COMMANDS"
;;
3)
if [ "$1" == "init" ]
then
SERVER=$2
DESTINATION=$3
4)
if [ "$1" == "init" ]; then
USERNAME=$2
SERVER=$3
DESTINATION=$4
CLONEURL=`git config --get remote.origin.url`
ssh captain@$SERVER "
if [ -a $DESTINATION ]
then
if [ -a $DESTINATION ]; then
echo "Error: Destination exists"
exit 1
else
@ -28,9 +38,9 @@ case $# in
fi
"
if [ $? -eq 0 ]
then
echo "SERVER=$SERVER" > .ship
if [ $? -eq 0 ]; then
echo "USERNAME=$USERNAME" > .ship
echo "SERVER=$SERVER" >> .ship
echo "DESTINATION=$DESTINATION" >> .ship
fi
else
@ -39,7 +49,7 @@ case $# in
;;
*)
echo "Error: Invalid number of arguments"
echo "Usage: ship [init username server destination]"
exit 1
;;
esac