From 9c3c4ec5cc54f28e11cc7e86d36667532544c7bb Mon Sep 17 00:00:00 2001 From: Josh Sherman Date: Tue, 23 Dec 2014 13:33:58 -0500 Subject: [PATCH] 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 --- ship | 40 +++++++++++++++++++++++++--------------- 1 file changed, 25 insertions(+), 15 deletions(-) diff --git a/ship b/ship index e19dd71..b2f7f9a 100755 --- a/ship +++ b/ship @@ -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