root commited on 2011-02-10 12:16:06
Showing 1 changed files, with 123 additions and 3 deletions.
... | ... |
@@ -12,17 +12,22 @@ SLEEP_ON_FAILED=10 |
12 | 12 |
CHECK_URL=http://www.roundcube.net/download |
13 | 13 |
DOWNLOAD=0 |
14 | 14 |
DOWNLOAD_DIR=$RC_HOME/../upstream |
15 |
+OWNER=root |
|
16 |
+GROUP=www-data |
|
15 | 17 |
|
16 | 18 |
DEBUG=0 |
19 |
+UPGRADE=0 |
|
20 |
+EXTRACT=0 |
|
17 | 21 |
|
18 | 22 |
function usage() { |
19 |
- echo "Usage : $0 [-v] [-d]" |
|
23 |
+ echo "Usage : $0 [-v] [-d] [-u]" |
|
20 | 24 |
echo " -v Verbose mode" |
21 | 25 |
echo " -d Download new release" |
26 |
+ echo " -u Upgrade installation" |
|
22 | 27 |
echo " -h Display this help" |
23 | 28 |
} |
24 | 29 |
|
25 |
-while getopts ":dvh" opt; do |
|
30 |
+while getopts ":dvhu" opt; do |
|
26 | 31 |
case $opt in |
27 | 32 |
v) |
28 | 33 |
DEBUG=1 |
... | ... |
@@ -30,6 +35,12 @@ while getopts ":dvh" opt; do |
30 | 35 |
d) |
31 | 36 |
DOWNLOAD=1 |
32 | 37 |
;; |
38 |
+ u) |
|
39 |
+ DOWNLOAD=1 |
|
40 |
+ UPGRADE=1 |
|
41 |
+ DEBUG=1 |
|
42 |
+ EXTRACT=1 |
|
43 |
+ ;; |
|
33 | 44 |
h) |
34 | 45 |
usage |
35 | 46 |
exit 0 |
... | ... |
@@ -110,11 +121,118 @@ then |
110 | 121 |
cd "$DOWNLOAD_DIR" |
111 | 122 |
DOWNLOAD_FILE="$( pwd )/roundcubemail-$newest.tar.gz" |
112 | 123 |
[ $DEBUG -eq 1 ] && echo "Download new release in $DOWNLOAD_FILE" |
113 |
- wget -q -O "$DOWNLOAD_FILE" "$DOWNLOAD_URL" |
|
124 |
+ #wget -q -O "$DOWNLOAD_FILE" "$DOWNLOAD_URL" |
|
125 |
+ if [ $EXTRACT -eq 1 ] |
|
126 |
+ then |
|
127 |
+ [ $DEBUG -eq 1 ] && echo "Extract new release" |
|
128 |
+ tar xzf $DOWNLOAD_FILE |
|
129 |
+ fi |
|
114 | 130 |
else |
115 | 131 |
echo "[WARNING] Le dossier de telechargement n'existe pas ($DOWNLOAD_DIR)." |
132 |
+ [ $UPGRADE -eq 1 ] && exit 1 |
|
133 |
+ fi |
|
134 |
+ fi |
|
135 |
+ |
|
136 |
+ if [ $UPGRADE -eq 1 ] |
|
137 |
+ then |
|
138 |
+ cd "$DOWNLOAD_DIR" |
|
139 |
+ default_src="$( pwd )/roundcubemail-$newest" |
|
140 |
+ src="" |
|
141 |
+ while [ ! -n "$src" ] |
|
142 |
+ do |
|
143 |
+ echo -n "Source de la nouvelle version [$default_src] : " |
|
144 |
+ read a |
|
145 |
+ if [ -n "$a" ] |
|
146 |
+ then |
|
147 |
+ src="$a" |
|
148 |
+ else |
|
149 |
+ src="$default_src" |
|
150 |
+ fi |
|
151 |
+ if [ ! -d "$src" ] |
|
152 |
+ then |
|
153 |
+ echo -n "[WARNING] Le dossier $src n'existe pas." |
|
154 |
+ [ ! -n "$a" ] && default_src="" |
|
155 |
+ fi |
|
156 |
+ done |
|
157 |
+ echo "Source : $src" |
|
158 |
+ |
|
159 |
+ cd "$RC_HOME/../" |
|
160 |
+ from="" |
|
161 |
+ while [ ! -n "$from" ] |
|
162 |
+ do |
|
163 |
+ echo -n "Installation source [$RC_HOME] : " |
|
164 |
+ read a |
|
165 |
+ if [ -n "$a" ] |
|
166 |
+ then |
|
167 |
+ if [ -d "$a" ] |
|
168 |
+ then |
|
169 |
+ from="$a" |
|
170 |
+ else |
|
171 |
+ echo "[ERROR] $a n'est pas un dossier valide" |
|
172 |
+ fi |
|
173 |
+ else |
|
174 |
+ from="$RC_HOME" |
|
175 |
+ fi |
|
176 |
+ done |
|
177 |
+ echo "From : $from" |
|
178 |
+ default_to="$( pwd )/roundcubemail-$newest" |
|
179 |
+ to="" |
|
180 |
+ while [ ! -n "$to" ] |
|
181 |
+ do |
|
182 |
+ echo -n "Destination de la nouvelle installation [$default_to] : " |
|
183 |
+ read a |
|
184 |
+ if [ -n "$a" ] |
|
185 |
+ then |
|
186 |
+ to="$a" |
|
187 |
+ else |
|
188 |
+ to="$default_to" |
|
189 |
+ fi |
|
190 |
+ if [ -d "$to" ] |
|
191 |
+ then |
|
192 |
+ echo -n "[WARNING] Le dossier $to existe deja. Celui-ci va etre deplace dans $to.old. Confirmez-vous votre choix [Y/n] ? " |
|
193 |
+ read b |
|
194 |
+ if [ "$b" == "n" -o "$b" == "N" ] |
|
195 |
+ then |
|
196 |
+ to="" |
|
197 |
+ [ ! -n "$a" ] && default_to="" |
|
198 |
+ else |
|
199 |
+ echo "Deplace $to dans $to.old" |
|
200 |
+ mv "$to" "$to.old" |
|
201 |
+ fi |
|
202 |
+ fi |
|
203 |
+ done |
|
204 |
+ echo "To : $to" |
|
205 |
+ echo "Copie de $from dans $to" |
|
206 |
+ rsync -a --copy-dirlinks "$from/" "$to/" |
|
207 |
+ |
|
208 |
+ echo "Mise a jour de l'installation $to a partir de $src : " |
|
209 |
+ for file in index.php bin/ SQL/ program/ installer/ skins/default/ plugins/ |
|
210 |
+ do |
|
211 |
+ echo " - Mise a jour de $file" |
|
212 |
+ rsync -a --delete $src/$file $to/$file |
|
213 |
+ chown $OWNER:$GROUP -R $to/$file |
|
214 |
+ done |
|
215 |
+ |
|
216 |
+ cd "$to" |
|
217 |
+ if [ -x "bin/update.sh" ] |
|
218 |
+ then |
|
219 |
+ echo "Lancement de l'utilitaire de verification de mise a jour" |
|
220 |
+ ./bin/update.sh |
|
221 |
+ fi |
|
222 |
+ |
|
223 |
+ if [ -L "$RC_HOME" ] |
|
224 |
+ then |
|
225 |
+ echo -n "Voulez-vous faire pointer le lien symbolique $RC_HOME vers cette nouvelle installation [Y/n] ? " |
|
226 |
+ read a |
|
227 |
+ if [ "$a" != "n" -a "$a" != "N" ] |
|
228 |
+ then |
|
229 |
+ echo " - Suppression de l'actuel lien $RC_HOME" |
|
230 |
+ rm -f $RC_HOME |
|
231 |
+ echo " - Creation du nouveau lien $RC_HOME vers $to" |
|
232 |
+ ln -s "$to" "$RC_HOME" |
|
116 | 233 |
fi |
117 | 234 |
fi |
235 |
+ else |
|
118 | 236 |
|
119 | 237 |
tmp=`mktemp` |
120 | 238 |
echo "New RoundCude release" > $tmp |
... | ... |
@@ -157,6 +275,8 @@ then |
157 | 275 |
[ $DEBUG -eq 1 ] && echo "Mail envoyé" |
158 | 276 |
fi |
159 | 277 |
rm -f $tmp |
278 |
+ |
|
279 |
+ fi |
|
160 | 280 |
else |
161 | 281 |
[ $DEBUG -eq 1 ] && echo "Pas de changement de version" |
162 | 282 |
fi |
163 | 283 |