-
Notifications
You must be signed in to change notification settings - Fork 1
/
integrationBoxUpdate.sh
executable file
·75 lines (63 loc) · 1.97 KB
/
integrationBoxUpdate.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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
#!/usr/bin/zsh
WS='/home/myles/workspace/webapp'
BUILDDIR="$WS/build"
MIRRORBASE='http://mirror.pelco.org/yapt/endura-pl4-x86_64'
RPMFOLDER=''
remote_choice='b'
local_choice='b'
# Check for a host
if [[ $# -lt 1 ]]; then
echo "Must specify host."
return 1
fi
if [[ $# -ge 3 ]]; then
read res'?Trunk or branch?(t/b): '
else
echo "Using remote $remote_choice local $local_choice"
res=$remote_choice
fi
# Looking for trunk dir
if [[ $remote_choice == 't' ]]; then
RPMFOLDER="$MIRRORBASE/webapp-SNAPSHOT"
elif [[ $remote_choice == 'b' ]]; then
RPMFOLDER="$MIRRORBASE/webapp"
else
echo "Invalid selection."
return 1
fi
if [[ $local_choice == 't' ]]; then
WEBDIR=`find $BUILDDIR -maxdepth 1 -type d -name '*SNAPSHOT*'`
elif [[ $local_choice == 'b' ]]; then
WEBDIR=`find $BUILDDIR -maxdepth 1 -type d -name 'webapp-[0-9]\.*'`
else
echo "Invalid selection."
return 1
fi
# Check for auxillary commands
if [[ $# -ge 2 ]]; then
if [[ $2 == 'backup' ]]; then
echo "Downloading RPM and uninstalling."
# download the rpm from mirror and uninstall from box
wget='wget '
rest='/`productconfig | grep webapp`.noarch.rpm && rpm -e `rpm -qa | grep webapp`'
/usr/bin/ssh -l root $1 "$wget$RPMFOLDER$rest"
elif [[ $2 == 'restore' ]]; then
echo "Removing var/html from $1"
/usr/bin/ssh -l root $1 'rm -rf /var/www/html/*'
echo "Restoring from backup."
# re-install from backed-up RPM
/usr/bin/ssh -l root $1 'rm -rf /var/www/html/* && rpm -ivh `ls | grep webapp` && rm `ls | grep webapp`'
return 0
else
echo "Unknown command"
return 1
fi
fi
if [[ -z "$WEBDIR" ]]; then
echo "No build folder found, check that you have run gwt-compile."
return 1
fi
echo "Removing var/html from $1"
/usr/bin/ssh -l root $1 'rm -rf /var/www/html/*'
echo "Copying to $1"
/usr/bin/scp -r $WEBDIR/sm5200 $WEBDIR/*.html $WEBDIR/*.css $WEBDIR/public root@$1:/var/www/html/