forked from mdpnp/mdpnp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
buildAndDeploy.sh
executable file
·48 lines (40 loc) · 1.42 KB
/
buildAndDeploy.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
#!/bin/sh
# Add --offline to the following line if no internet access
#
if [ -z "$SKIPBUILD" ]; then
./gradlew :interop-lab:demo-apps:distZip
fi
LOCATION=interop-lab/demo-apps/build/distributions
VERSION=`ls -rt ${LOCATION}/OpenICE-*.zip | tail -n 1 | sed -e 's/.*OpenICE-\(.*\).zip/\1/'`
TARGETS=`cat targets | sed '/^\s*#/d'`
PARCEL=OpenICE-${VERSION}
for TARGET in $TARGETS
do
echo Shipping ${PARCEL} bundle to $TARGET
ssh debian@$TARGET mkdir -p /home/debian/OpenICE
scp ${LOCATION}/$PARCEL.zip debian@$TARGET:/home/debian/OpenICE/ > $TARGET.scp.out &
done
echo Awaiting shipment completion
wait
for TARGET in $TARGETS
do
echo Decompressing to $TARGET
ssh debian@$TARGET unzip /home/debian/OpenICE/$PARCEL.zip -d /home/debian/OpenICE > $TARGET.unzip.out &
done
echo Awaiting decompression
wait
for TARGET in $TARGETS
do
echo Stopping device-adapter on $TARGET
ssh debian@$TARGET sudo service device-adapter stop
ssh debian@$TARGET rm /home/debian/OpenICE/OpenICE.current
echo Copying more files to $TARGET
scp log4j.properties debian@$TARGET:
scp device-adapter debian@$TARGET:/etc/init.d/device-adapter
ssh debian@$TARGET chmod 777 /home/debian/OpenICE/$PARCEL/bin/OpenICE
ssh debian@$TARGET ln -s /home/debian/OpenICE/$PARCEL /home/debian/OpenICE/OpenICE.current
rm $TARGET.scp.out
rm $TARGET.unzip.out
echo Restarting device-adapter on $TARGET
ssh debian@$TARGET sudo service device-adapter start
done