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:
parent
c64eb7e583
commit
9c3c4ec5cc
1 changed files with 25 additions and 15 deletions
40
ship
40
ship
|
@ -5,22 +5,32 @@ case $# in
|
||||||
# TODO go up the hierarchy to find .ship
|
# TODO go up the hierarchy to find .ship
|
||||||
source .ship
|
source .ship
|
||||||
|
|
||||||
ssh captain@$SERVER "
|
COMMANDS="cd $DESTINATION;"
|
||||||
cd $DESTINATION
|
|
||||||
git pull origin master
|
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)
|
4)
|
||||||
if [ "$1" == "init" ]
|
if [ "$1" == "init" ]; then
|
||||||
then
|
USERNAME=$2
|
||||||
SERVER=$2
|
SERVER=$3
|
||||||
DESTINATION=$3
|
DESTINATION=$4
|
||||||
CLONEURL=`git config --get remote.origin.url`
|
CLONEURL=`git config --get remote.origin.url`
|
||||||
|
|
||||||
ssh captain@$SERVER "
|
ssh captain@$SERVER "
|
||||||
if [ -a $DESTINATION ]
|
if [ -a $DESTINATION ]; then
|
||||||
then
|
|
||||||
echo "Error: Destination exists"
|
echo "Error: Destination exists"
|
||||||
exit 1
|
exit 1
|
||||||
else
|
else
|
||||||
|
@ -28,9 +38,9 @@ case $# in
|
||||||
fi
|
fi
|
||||||
"
|
"
|
||||||
|
|
||||||
if [ $? -eq 0 ]
|
if [ $? -eq 0 ]; then
|
||||||
then
|
echo "USERNAME=$USERNAME" > .ship
|
||||||
echo "SERVER=$SERVER" > .ship
|
echo "SERVER=$SERVER" >> .ship
|
||||||
echo "DESTINATION=$DESTINATION" >> .ship
|
echo "DESTINATION=$DESTINATION" >> .ship
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
|
@ -39,7 +49,7 @@ case $# in
|
||||||
;;
|
;;
|
||||||
|
|
||||||
*)
|
*)
|
||||||
echo "Error: Invalid number of arguments"
|
echo "Usage: ship [init username server destination]"
|
||||||
exit 1
|
exit 1
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue