-
Notifications
You must be signed in to change notification settings - Fork 0
/
pubrelease.sh
executable file
·54 lines (45 loc) · 1.16 KB
/
pubrelease.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
53
54
#!/bin/bash
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%%.*}"
RELEASE_DIR="/data/pubreleases/colabalancer/"
for HOST in "$@"
do
echo "Deploying $RELEASE_NAME to $HOST"
scp -C "$TARBALL" "$HOST:/tmp"
scp ./upgrade.sh "$HOST:/tmp/upgrade_$RELEASE_NAME.sh"
# shellcheck disable=SC2029
ssh "$HOST" "sudo mkdir -p $RELEASE_DIR && \
sudo cp /tmp/upgrade_$RELEASE_NAME.sh $RELEASE_DIR && \
sudo cp /tmp/$TARBALL $RELEASE_DIR && \
echo '$RELEASE_NAME' | sudo tee $RELEASE_DIR/latest"
if [ $? -eq 0 ]
then
curl -X POST "https://$USER:[email protected]/deploy/colabalancer_pubrelease/$HOST"
else
echo "OMG DEPLOY FAILED"
exit 1
fi
done