lila/bin/prod/deploy

91 lines
1.8 KiB
Bash
Executable File

#!/bin/sh
. bin/lilarc
mode=$1
if [ -z $mode ]; then
echo "Empty deploy target"
exit 1
elif [ $mode = "main" ]; then
REMOTE="frank"
REMOTE_DIR="/home/lichess"
elif [ $mode = "paul" ]; then
REMOTE="paul"
REMOTE_DIR="/home/lila5"
elif [ $mode = "salim" ]; then
REMOTE="salim"
REMOTE_DIR="/home/lila5"
elif [ $mode = "salim2" ]; then
REMOTE="salim2"
REMOTE_DIR="/home/lila"
elif [ $mode = "hexal" ]; then
REMOTE="hexal"
REMOTE_DIR="/home/lila"
elif [ $mode = "matthews" ]; then
REMOTE="matthews"
REMOTE_DIR="/home/thibault/lila"
elif [ $mode = "local" ]; then
REMOTE="localhost"
REMOTE_DIR="/tmp/lila5"
else
echo "Unknown deploy target $mode"
exit 1
fi
lilalog "Deploy to $mode server $REMOTE:$REMOTE_DIR"
if [ $mode == "main" ]; then
lilalog "Notify users of pre deploy"
bin/cli-prod deploy pre
fi
if [ $mode == "main" ]; then
bin/compile-client
fi
sbt ";stage;exit"
if [ $? != 0 ]; then
lilalog "Deploy canceled"
exit 1
fi
RSYNC_OPTIONS=" \
--archive \
--force \
--delete \
--progress \
--compress \
--checksum \
--verbose \
--exclude conf/application.conf \
--exclude logs \
--exclude RUNNING_PID \
--exclude bin/.translate_version \
--exclude local
--exclude '*.psd'";
lilalog "Rsync scripts, binaries and assets"
stage="target/universal/stage"
rsync_command="rsync $RSYNC_OPTIONS bin $stage/bin $stage/lib public $REMOTE:$REMOTE_DIR"
echo "$rsync_command"
$rsync_command
echo "rsync complete"
read -n 1 -p "Press [Enter] to continue."
if [ $mode == "main" ]; then
lilalog "Notify users of post deploy"
bin/cli-prod deploy post
fi
if [ $mode == "main" ]; then
lilalog "Restart lichess"
ssh $REMOTE "service lichess restart"
fi
lilalog "Deploy complete"
if [ $mode != "local" ]; then
sleep 2
curl_prod
fi