2014-10-17 12:02:52 +00:00
|
|
|
#!/bin/sh
|
2014-11-05 12:43:16 +00:00
|
|
|
if [ $# -ge 2 ]; then
|
2014-10-17 12:02:52 +00:00
|
|
|
SERVER=$1
|
2014-11-05 12:43:16 +00:00
|
|
|
BACKUP_DEST=$2
|
2014-10-17 12:02:52 +00:00
|
|
|
else
|
2014-11-05 12:43:16 +00:00
|
|
|
echo "Usage: sh ./deploy/deploy.sh server backup_dest [branch [user]]]"
|
2014-10-17 12:02:52 +00:00
|
|
|
exit 1
|
|
|
|
fi
|
2014-10-17 14:34:28 +00:00
|
|
|
if [ $# -ge 3 ]; then
|
2014-10-20 10:08:40 +00:00
|
|
|
BRANCH=$3
|
2014-10-17 12:02:52 +00:00
|
|
|
else
|
|
|
|
BRANCH="master"
|
|
|
|
fi
|
2014-10-17 14:34:28 +00:00
|
|
|
if [ $# -ge 4 ]; then
|
2014-10-20 10:08:40 +00:00
|
|
|
USER=$4
|
2014-10-17 12:02:52 +00:00
|
|
|
else
|
|
|
|
USER="core"
|
|
|
|
fi
|
2014-10-28 07:59:48 +00:00
|
|
|
|
2014-11-05 12:43:16 +00:00
|
|
|
echo "Server to deploy is $SERVER"
|
|
|
|
echo "Backups will live under $BACKUP_DEST"
|
|
|
|
echo "IndieHosters repo branch is $BRANCH"
|
2014-10-17 12:02:52 +00:00
|
|
|
echo "Remote user is $USER"
|
|
|
|
|
|
|
|
scp ./deploy/onServer.sh $USER@$SERVER:
|
2014-11-05 12:43:16 +00:00
|
|
|
|
2014-10-17 12:02:52 +00:00
|
|
|
ssh $USER@$SERVER sudo mkdir -p /var/lib/coreos-install/
|
2014-10-17 14:34:28 +00:00
|
|
|
scp cloud-config $USER@$SERVER:/var/lib/coreos-install/user_data
|
2014-11-05 12:43:16 +00:00
|
|
|
ssh $USER@$SERVER sudo sh ./onServer.sh $BRANCH $SERVER
|
|
|
|
|
|
|
|
# overrides BACKUP_DESTINATION from cloud-config
|
|
|
|
echo $BACKUP_DEST > ./deploy/tmp.txt
|
|
|
|
scp ./deploy/tmp.txt $USER@SERVER:/data/BACKUP_DESTINATION
|
|
|
|
rm ./deploy/tmp.txt
|