-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathUPDATE.sh
More file actions
executable file
·131 lines (105 loc) · 2.04 KB
/
UPDATE.sh
File metadata and controls
executable file
·131 lines (105 loc) · 2.04 KB
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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
#!/bin/bash
# author: lilong'en(lilongen@163.com)
# date: 4/13/2010
#
CcvId="ccv"
UpdatedAvailable=0
UpdateUsingLocalPackage=0
BuildPackageName=""
if [ $# -gt 0 ]
then
UpdatedAvailable=1
BuildPackageName=$1
UpdateUsingLocalPackage=1
fi
createUpdateWorkspace() {
if [ ! -d .update ]
then
mkdir .update
else
rm -rf .update/*
fi
}
checkVersion() {
echo
echo "Check whether updated build is available..."
echo
localVer=""
if [ -e VERSION ]
then
localVer=`cat VERSION`
fi
echo "Current build: $localVer"
echo "Check latest build..."
wget -P ".update" "http://ccv.sourceforge.net/VERSION"
remoteVer=`cat .update/VERSION`
echo "Latest build: $remoteVer"
echo
if [ "$localVer" = "" ] || [[ "$localVer" < "$remoteVer" ]]
then
UpdatedAvailable=1
fi
}
download() {
buildNO=${remoteVer##*.}
BuildPackageName="$CcvId-2.0-${buildNO}.tar.gz"
latest="http://sourceforge.net/projects/ccv/files/$BuildPackageName/download"
echo "Download CCV latest build..."
echo
wget -P ".update" $latest
}
update() {
echo
echo "upgrading..."
echo
cd .update
packageName="$CcvId.tar.gz"
tar -xzf $BuildPackageName
echo "Update files..."
echo
tar -xzf $packageName
rm -rf ccv/config/config.xml
rm -rf ccv/config/cvs.accounts
rm -rf $packageName
tar -czf $packageName ccv/
rm -rf ccv/
tar -xzf $packageName -C ../../
echo "Update files: finished"
cd ..
chmod 755 *
chmod 777 config/
chmod 777 config/CFG_PWD 1>/dev/null 2>/dev/null
chmod 777 operate/
chmod 777 web/reports/
echo
echo "Upgrade: done!"
echo "Now your CCV version is: $remoteVer";
echo
}
main() {
createUpdateWorkspace
if [ $UpdateUsingLocalPackage -eq 0 ]
then
checkVersion
fi
if [ $UpdatedAvailable -eq 1 ]
then
if [ $UpdateUsingLocalPackage -eq 0 ]
then
download
else
cp -f $BuildPackageName .update/ 1>/dev/null 2>/dev/null
fi
if [ ! -f ".update/$BuildPackageName" ]
then
echo "$BuildPackageName not exist!"
else
update
fi
else
echo
echo "Your CCV already is the latest package!"
echo
fi
}
main