Init wizard

Closes #7
This commit is contained in:
Josh Sherman 2014-12-23 14:50:06 -05:00
parent f1df104443
commit 2f305d592c

33
ship
View file

@ -1,4 +1,4 @@
#!/bin/sh #!/bin/bash
case $# in case $# in
0) 0)
@ -24,7 +24,7 @@ case $# in
COMMANDS="$COMMANDS git pull origin master;" COMMANDS="$COMMANDS git pull origin master;"
COMMANDS="$COMMANDS [ -e composer.json ] && composer install;" COMMANDS="$COMMANDS [ -e composer.json ] && composer install;"
COMMANDS="$COMMANDS [ -e package.json ] && npm install;" COMMANDS="$COMMANDS [ -e package.json ] && npm install;"
if [ -n "$AFTER" ] if [ -n "$AFTER" ]
then then
@ -55,16 +55,24 @@ case $# in
fi fi
;; ;;
4) 1)
if [ "$1" == "init" ] if [ "$1" == "init" ]
then then
USER=$2 echo -n "Remote user to ship as [captain]: "
SERVER=$3 read USER
DESTINATION=$4 USER=${USER:-captain}
echo -n "Server to deploy to: "
read SERVER
echo -n "Destination on server to deploy to: "
read DESTINATION
CLONEURL=`git config --get remote.origin.url` CLONEURL=`git config --get remote.origin.url`
ssh captain@$SERVER " ssh captain@$SERVER "
if [ -a $DESTINATION ]; then if [ -a $DESTINATION ]
then
echo "Error: Destination exists" echo "Error: Destination exists"
exit 1 exit 1
else else
@ -72,19 +80,16 @@ case $# in
fi fi
" "
if [ $? -eq 0 ] echo "USER=$USER" > .ship
then echo "SERVER=$SERVER" >> .ship
echo "USER=$USER" > .ship echo "DESTINATION=$DESTINATION" >> .ship
echo "SERVER=$SERVER" >> .ship
echo "DESTINATION=$DESTINATION" >> .ship
fi
else else
echo "Error: Invalid argument '$1'" echo "Error: Invalid argument '$1'"
fi fi
;; ;;
*) *)
echo "Usage: ship [init user server destination]" echo "Usage: ship [init]"
exit 1 exit 1
;; ;;
esac esac