-
Notifications
You must be signed in to change notification settings - Fork 1
/
deploy.sh
executable file
·52 lines (43 loc) · 1.01 KB
/
deploy.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#!/bin/sh
if [ $# -eq 0 ]
then
echo "Usage: $0 release-name.tar.gz hostname0 hostname1 hostname2 ..."
exit 0
fi
DIR="$( cd "$( dirname "$0" )" && pwd )"
cd "$DIR" || (echo "cd $DIR failed!" && exit 1)
echo "$1" | grep '\.tar\.gz$'
if [ $? -eq 0 ]
then
TARBALL=$1
shift
else
echo "Building tarball..."
TARBALL="$(./build_release.sh | tail -n 1)"
echo "$TARBALL" | grep '\.tar\.gz$'
if [ $? -ne 0 ]
then
echo "ERROR BUILDING TARBALL!"
exit 1
fi
echo "Built $TARBALL"
fi
RELEASE_NAME=$(basename "$TARBALL")
RELEASE_NAME="${RELEASE_NAME%%.*}"
for HOST in "$@"
do
echo "Deploying $RELEASE_NAME to $HOST"
scp -C "$TARBALL" "$HOST:/tmp"
scp ./upgrade.sh "$HOST:/tmp/upgrade_$RELEASE_NAME.sh"
SSH_CMD="sudo /tmp/upgrade_$RELEASE_NAME.sh /tmp/$TARBALL"
# shellcheck disable=SC2029
ssh "$HOST" "$SSH_CMD"
# shellcheck disable=SC2181
if [ $? -eq 0 ]
then
curl -X POST "https://$USER:[email protected]/deploy/colab/$HOST" &
else
echo "OMG DEPLOY FAILED"
exit 1
fi
done