moved for svn-git switch
[mailer.git] / updater / .functions.sh
1 #!/bin/sh
2 # Self-test
3 if test "`basename $0`" = ".functions.sh"; then
4         echo "Bye..."
5         exit 0
6 fi
7
8 function ftp_init()
9 {
10         if test "$FTP_PASS" = ""; then
11                 echo "No FTP password file '$FTP_PSWD'.. Creating one"
12                 echo -n "Enter password to continue: "
13                 read -s pass1
14                 echo "okay"
15                 echo -n "Enter password again to confirm: "
16                 read -s pass2
17                 echo "okay"
18                 if test "$pass1" = "$pass2"; then
19                         if test ! "$pass1" = ""; then
20                                 echo -n "Creating password file ($FTP_PSWD)... "
21                                 echo -n "$pass1">$FTP_PSWD
22                                 FTP_PASS="`cat $FTP_PSWD >/dev/null 2>&1`"
23                                 echo "done"
24                          else
25                                 echo "Empty password entered!"
26                                 exit 0
27                         fi
28                  else
29                         echo "Passwords didn't match!"
30                         exit 0
31                 fi
32          else
33                 echo "FTP password loaded from file $FTP_PSWD."
34         fi
35 }
36
37 function ftp_upload()
38 {
39         cd $UPLOAD_DIR
40         echo -n "Uploading extensions... ("
41         for upload in $UPLOAD_EXT; do
42                 echo -n "$upload "
43                 TARGET="ext-$upload.*"
44                 $FTP -u $FTP_USER -p $FTP_PASS $FTP_HOST $FTP_DIR $TARGET > /dev/null 2>&1
45         done
46         echo ") done"
47 }
48
49 function cms_ftp_upload()
50 {
51         cd $CMS_UPLOAD_DIR
52         echo -n "Uploading CMS extensions... ("
53         for upload in $UPLOAD_CMS_EXT; do
54                 echo -n "$upload "
55                 TARGET="ext-$upload.*"
56                 $FTP -u $FTP_USER -p $FTP_PASS $FTP_HOST $CMS_FTP_DIR $TARGET > /dev/null 2>&1
57         done
58         echo ") done"
59 }
60
61 function themes_ftp_upload()
62 {
63         cd $THEMES_UPLOAD_DIR
64         echo -n "Uploading themes... ("
65         for upload in $UPLOAD_THEMES; do
66                 echo -n "$upload "
67                 TARGET="theme-$upload.*"
68                 $FTP -u $FTP_USER -p $FTP_PASS $FTP_HOST $THEMES_FTP_DIR $TARGET > /dev/null 2>&1
69         done
70         echo ") done"
71 }
72
73 function hp_ftp_upload()
74 {
75         cd $HP_UPLOAD_DIR
76         echo -n "Uploading HP extensions... ("
77         for upload in $UPLOAD_HP_EXT; do
78                 echo -n "$upload "
79                 TARGET="ext-$upload.*"
80                 $FTP -u $FTP_USER -p $FTP_PASS $FTP_HOST $HP_FTP_DIR $TARGET > /dev/null 2>&1
81         done
82         echo ") done"
83 }
84
85 function init_file_system()
86 {
87         echo -n "Creating missing dirs... "
88         mkdir $TARGET/ > /dev/null 2>&1
89         echo -n "."
90         mkdir $TARGET-$VER/ > /dev/null 2>&1
91         echo -n "."
92         mkdir $TARGET-$CMS/ > /dev/null 2>&1
93         echo -n "."
94         mkdir $TARGET-$CMS-$CMS_VER/ > /dev/null 2>&1
95         echo -n "."
96         mkdir $TARGET-$HP/ > /dev/null 2>&1
97         echo -n "."
98         mkdir $TARGET-$HP-$HP_VER/ > /dev/null 2>&1
99         echo -n "."
100         mkdir $THIS_DIR/org/cmds/ > /dev/null 2>&1
101         for sect in $CMDS_SECTIONS; do
102                 echo -n "."
103                 mkdir $THIS_DIR/org/cmds/$sect > /dev/null 2>&1
104                 cp $THIS_DIR/.htaccess_cmds $THIS_DIR/org/cmds/$sect/.htaccess > /dev/null 2>&1
105         done
106         echo " done"
107
108         echo -n "Copying files... "
109         cp $CP_OPTIONS $CP_FILES $TARGET > /dev/null 2>&1
110         echo -n "."
111         cp $CP_OPTIONS $CMS_FILES $TARGET-$CMS > /dev/null 2>&1
112         echo -n "."
113         cp $CP_OPTIONS $HP_FILES $TARGET-$HP > /dev/null 2>&1
114         echo " done"
115         echo -n "Removing logs and usage links... "
116         rm -f $TARGET/$HTML/logs $TARGRT/$HTML/usage > /dev/null 2>&1
117         echo -n "."
118         rm -f $TARGET-$CMS/$CMS/logs $TARGRT-$CMS/$CMS/usage > /dev/null 2>&1
119         echo -n "."
120         rm -f $TARGET-$HP/$HP/logs $TARGRT-$HP/$HP/usage > /dev/null 2>&1
121         echo " done"
122         cd $BASEDIR
123         echo -n "Converting files... "
124         for target in $CONV_FILES; do
125                 echo -n "."
126                 find $TARGET/ -type f -name "$target" -exec unix2dos -p {} \; > /dev/null 2>&1
127                 find $TARGET-$CMS/ -type f -name "$target" -exec unix2dos -p {} \; > /dev/null 2>&1
128                 find $TARGET-$HP/ -type f -name "$target" -exec unix2dos -p {} \; > /dev/null 2>&1
129         done
130         echo " done"
131         echo -n "Moving files... "
132         mv $TARGET/$HTML/inc2/* $TARGET/$HTML/inc/ > /dev/null 2>&1
133         rmdir $TARGET/$HTML/inc2 > /dev/null 2>&1
134         echo -n "."
135         mv $TARGET-$CMS/$CMS/inc2/* $TARGET-$CMS/$CMS/inc/ > /dev/null 2>&1
136         rmdir $TARGET-$CMS/$CMS/inc2 > /dev/null 2>&1
137         echo -n "."
138         mv $TARGET-$HP/$HP/inc2/* $TARGET-$HP/$HP/inc/ > /dev/null 2>&1
139         rmdir $TARGET-$HP/$HP/inc2 > /dev/null 2>&1
140         echo " done"
141         cd $TARGET
142 }
143
144 function remove_files()
145 {
146         cd $TARGET/..
147         echo -n "Removing files... "
148         rm -f $TAR_ARC* $CMS_TAR* $HP_TAR* > /dev/null 2>&1
149         echo -n "."
150         rm -f $ZIP_ARC* $CMS_ZIP* $HP_ZIP* > /dev/null 2>&1
151         cd $BASENAME
152         cp $CP_OPTIONS * ../$BASENAME-$VER > /dev/null 2>&1
153         echo -n "."
154         cd ../$BASENAME-$CMS
155         cp $CP_OPTIONS * ../$BASENAME-$CMS-$CMS_VER > /dev/null 2>&1
156         cd ../$BASENAME-$HP
157         cp $CP_OPTIONS * ../$BASENAME-$HP-$HP_VER > /dev/null 2>&1
158         cd ..
159         echo -n "."
160         find $BASENAME-$VER/ -name "CVS" -exec rm -rf {} \; > /dev/null 2>&1
161         echo -n "."
162         find $BASENAME-$CMS-$CMS_VER/ -name "CVS" -exec rm -rf {} \; > /dev/null 2>&1
163         echo -n "."
164         find $BASENAME-$HP-$HP_VER/ -name "CVS" -exec rm -rf {} \; > /dev/null 2>&1
165         echo -n "."
166         rm -rf $RM_FILES > /dev/null 2>&1
167         echo " done"
168 }
169
170 function ext_update()
171 {
172         # Create version file when it doesn't exists
173         if test ! -e "$BASEDIR/$EXT_DIR/$EXT-$e.ver"; then
174                 echo -n "0.0" > "$BASEDIR/$EXT_DIR/$EXT-$e.ver"
175         fi
176         # Create text file from template or set default text message
177         if test -e "$BASEDIR/$BASENAME/$HTML/templates/de/$HTML/ext/ext_$e.tpl"; then
178                 echo "de:`cat $BASEDIR/$BASENAME/$HTML/templates/de/$HTML/ext/ext_$e.tpl`" > "$BASEDIR/$EXT_DIR/$EXT-$e.txt"
179          elif test ! -e "$BASEDIR/$EXT_DIR/$EXT-$e.txt"; then
180                 echo "de:" > "$BASEDIR/$EXT_DIR/$EXT-$e.txt"
181         fi
182 }
183
184 function cms_ext_update()
185 {
186         # Create version file when it doesn't exists
187         if test ! -e "$BASEDIR/$CMS_EXT_DIR/$EXT-$e.ver"; then
188                 echo -n "0.0" > "$BASEDIR/$CMS_EXT_DIR/$EXT-$e.ver"
189         fi
190         # Create text file from template or set default text message
191         if test -e "$BASEDIR/$BASENAME/$HTML/templates/de/$HTML/ext/ext_$e.tpl"; then
192                 echo "de:`cat $BASEDIR/$BASENAME/$HTML/templates/de/$HTML/ext/ext_$e.tpl`" > "$BASEDIR/$CMS_EXT_DIR/$EXT-$e.txt"
193          elif test ! -e "$BASEDIR/$CMS_EXT_DIR/$EXT-$e.txt"; then
194                 echo "de:" > "$BASEDIR/$CMS_EXT_DIR/$EXT-$e.txt"
195         fi
196 }
197
198 function hp_ext_update()
199 {
200         # Create version file when it doesn't exists
201         if test ! -e "$BASEDIR/$HP_EXT_DIR/$EXT-$e.ver"; then
202                 echo -n "0.0" > "$BASEDIR/$HP_EXT_DIR/$EXT-$e.ver"
203         fi
204         # Create text file from template or set default text message
205         if test -e "$BASEDIR/$BASENAME/$HTML/templates/de/$HTML/ext/ext_$e.tpl"; then
206                 echo "de:`cat $BASEDIR/$BASENAME/$HTML/templates/de/$HTML/ext/ext_$e.tpl`" > "$BASEDIR/$HP_EXT_DIR/$EXT-$e.txt"
207          elif test ! -e "$BASEDIR/$HP_EXT_DIR/$EXT-$e.txt"; then
208                 echo "de:" > "$BASEDIR/$HP_EXT_DIR/$EXT-$e.txt"
209         fi
210 }
211
212 function cmds_update()
213 {
214         # Create version file when it doesn't exists
215         if test ! -e "$BASEDIR/$CMDS_DIR/$c_dir/$CMDS-$c.ver"; then
216                 echo -n "0.0" > "$BASEDIR/$CMDS_DIR/$c_dir/$CMDS-$c.ver"
217         fi
218         # Create text file from template or set default text message
219         if test -e "$THIS_DIR/html/templates/de/$HTML/engine/$CMDS/$c_dir/cmds_$c.tpl"; then
220                 echo "de:`cat $THIS_DIR/html/templates/de/$HTML/engine/$CMDS/$c_dir/cmds_$c.tpl`" > "$BASEDIR/$CMDS_DIR/$c_dir/$CMDS-$c.txt"
221          elif test ! -e "$BASEDIR/$CMDS_DIR/$c_dir/$CMDS-$c.txt"; then
222                 # Check if directory was found
223                 if test ! -e "$THIS_DIR/$HTML/templates/de/$HTML/engine/$CMDS/$c_dir/.htaccess"; then
224                         # Create missing directory
225                         mkdir "$THIS_DIR/$HTML/templates/de/$HTML/engine/$CMDS/" > /dev/null 2>&1
226                         mkdir "$THIS_DIR/$HTML/templates/de/$HTML/engine/$CMDS/$c_dir/" > /dev/null 2>&1
227                         # Copy missing .htaccess file
228                         cp $THIS_DIR/$HTML/templates/.htaccess "$THIS_DIR/$HTML/templates/de/$HTML/engine/$CMDS/$c_dir/" > /dev/null 2>&1
229                 fi
230                 # Create missing file
231                 echo -n "" > "$THIS_DIR/$HTML/templates/de/$HTML/engine/$CMDS/$c_dir/cmds_$c.tpl"
232                 echo -n "" > "templates/de/$HTML/engine/$CMDS/$c_dir/cmds_$c.tpl"
233                 # Update archive file with latest date
234                 zip -9qp "$BASEDIR/$CMDS_DIR/$c_dir/$CMDS-$c.zip" "templates/de/$HTML/engine/$CMDS/$c_dir/cmds_$c.tpl" "$BASEDIR/$CMDS_DIR/$c_dir/$CMDS-$c" "templates/de/$HTML/engine/$CMDS/$c_dir/.htaccess" > /dev/null 2>&1
235                 # Create missing file
236                 echo "de:" > "$BASEDIR/$CMDS_DIR/$c_dir/$CMDS-$c.txt"
237         fi
238 }
239
240 function theme_update()
241 {
242         # Create version file when it doesn't exists
243         if test ! -e "$BASEDIR/$THEME_DIR/$THEME-$t.ver"; then
244                 echo -n "0.0" > "$BASEDIR/$THEME_DIR/$THEME-$t.ver"
245         fi
246         # Create text file from template or set default text message
247         if test -e "$BASEDIR/$BASENAME/$HTML/templates/de/$HTML/ext/ext_$t.tpl"; then
248                 echo "de:`cat $BASEDIR/$BASENAME/$HTML/templates/de/$HTML/ext/ext_$t.tpl`" > "$BASEDIR/$THEME_DIR/$THEME-$t.txt"
249          elif test ! -e "$BASEDIR/$THEME_DIR/$THEME-$t.txt"; then
250                 echo -n "" > "$BASEDIR/$BASENAME/$HTML/templates/de/$HTML/ext/ext_$t.tpl"
251                 echo "de:" > "$BASEDIR/$THEME_DIR/$THEME-$t.txt"
252         fi
253 }
254
255 function zip_packages()
256 {
257         if test ! $TAR_MAX == ""; then
258                 cd $BASEDIR
259                 echo -n "Creating archive $TAR_MAX... "
260                 tar -cf $TAR_MAX $BASENAME-$VER/ > /dev/null 2>&1
261                 $BZIP2 -9f $TAR_MAX > /dev/null 2>&1
262                 echo "done"
263                 echo -n "Creating archive $ZIP_MAX... "
264                 $ZIP -9r  $ZIP_MAX $BASENAME-$VER/ > /dev/null 2>&1
265                 echo "done"
266                 cd $BASEDIR/$BASENAME-$VER/$HTML/
267                 echo -n "Creating $MAX extension archives... ("
268                 for e in $MAX_EXT; do
269                         rm -f "$BASEDIR/$EXT_DIR/$EXT-$e.zip"
270                         ###########
271                         find -name "*$e*" -exec $ZIP -9qrm "$BASEDIR/$EXT_DIR/$EXT-$e" {} \; > /dev/null 2>&1
272                         $ZIP -9q "$BASEDIR/$EXT_DIR/$EXT-$e.zip" $EXT_FILES > /dev/null 2>&1
273                         ###########
274                         ext_update
275                         echo -n "$e "
276                 done
277                 echo ") done"
278         fi
279         if test ! $TAR_MEDIUM == ""; then
280                 cd $BASEDIR
281                 echo -n "Creating archive $TAR_MEDIUM... "
282                 tar -cf $TAR_MEDIUM $BASENAME-$VER/ > /dev/null 2>&1
283                 $BZIP2 -9f $TAR_MEDIUM > /dev/null 2>&1
284                 echo "done"
285                 echo -n "Creating archive $ZIP_MEDIUM... "
286                 $ZIP -9r  $ZIP_MEDIUM $BASENAME-$VER/ > /dev/null 2>&1
287                 echo "done"
288                 cd $BASEDIR/$BASENAME-$VER/$HTML/
289                 echo -n "Creating $MEDIUM extension archives... ("
290                 for e in $MEDIUM_EXT; do
291                         rm -f "$BASEDIR/$EXT_DIR/$EXT-$e.zip"
292                         ###########
293                         find -name "*$e*" -exec $ZIP -9qrm "$BASEDIR/$EXT_DIR/$EXT-$e" {} \; > /dev/null 2>&1
294                         $ZIP -9q "$BASEDIR/$EXT_DIR/$EXT-$e.zip" $EXT_FILES > /dev/null 2>&1
295                         ###########
296                         ext_update
297                         echo -n "$e "
298                 done
299                 echo ") done"
300         fi
301         if test ! $TAR_SMALL == ""; then
302                 cd $BASEDIR
303                 echo -n "Creating archive $TAR_SMALL... "
304                 tar -cf $TAR_SMALL $BASENAME-$VER/ > /dev/null 2>&1
305                 $BZIP2 -9f $TAR_SMALL > /dev/null 2>&1
306                 echo "done"
307                 echo -n "Creating archive $ZIP_SMALL... "
308                 $ZIP -9r  $ZIP_SMALL $BASENAME-$VER/ > /dev/null 2>&1
309                 echo "done"
310                 cd $BASEDIR/$BASENAME-$VER/$HTML/
311                 echo -n "Creating $SMALL extension archives... ("
312                 for e in $SMALL_EXT; do
313                         rm -f "$BASEDIR/$EXT_DIR/$EXT-$e.zip"
314                         ###########
315                         find -name "*$e*" -exec $ZIP -9qrm "$BASEDIR/$EXT_DIR/$EXT-$e" {} \; > /dev/null 2>&1
316                         $ZIP -9q "$BASEDIR/$EXT_DIR/$EXT-$e.zip" $EXT_FILES > /dev/null 2>&1
317                         ###########
318                         ext_update
319                         echo -n "$e "
320                 done
321                 echo ") done"
322         fi
323 }
324
325 function zip_cmds()
326 {
327         cd $BASEDIR/$BASENAME-$VER/$HTML/
328         c_dir="status"
329         echo -n "Creating $c_dir command archives... ("
330         for c in $STATUS_CMDS; do
331                 rm -f "$BASEDIR/$CMDS_DIR/$CMDS-$c.zip"
332                 ###########
333                 $ZIP -9q "$BASEDIR/$CMDS_DIR/$c_dir/$CMDS-$c.zip" "inc/engine/$c_dir/cmd-$c.php" $CMDS_FILES > /dev/null 2>&1
334                 ###########
335                 cmds_update
336                 echo -n "$c "
337         done
338         echo ") done"
339
340         c_dir="export"
341         echo -n "Creating $c_dir command archives... ("
342         for c in $EXPORT_CMDS; do
343                 rm -f "$BASEDIR/$CMDS_DIR/$CMDS-$c.zip"
344                 ###########
345                 $ZIP -9q "$BASEDIR/$CMDS_DIR/$c_dir/$CMDS-$c.zip" "inc/engine/$c_dir/cmd-$c.php" $CMDS_FILES > /dev/null 2>&1
346                 ###########
347                 cmds_update
348                 echo -n "$c "
349         done
350         echo ") done"
351
352         c_dir="rmember"
353         echo -n "Creating $c_dir command archives... ("
354         for c in $RMEMBER_CMDS; do
355                 rm -f "$BASEDIR/$CMDS_DIR/$CMDS-$c.zip"
356                 ###########
357                 $ZIP -9q "$BASEDIR/$CMDS_DIR/$c_dir/$CMDS-$c.zip" "inc/engine/$c_dir/cmd-$c.php" $CMDS_FILES > /dev/null 2>&1
358                 ###########
359                 cmds_update
360                 echo -n "$c "
361         done
362         echo ") done"
363 }
364
365 function zip_debug_ext()
366 {
367         cd $BASEDIR/$BASENAME-$VER/$HTML/
368         echo -n "Creating debug extension archives... ("
369         for e in $DEBUG_EXT; do
370                 rm -f "$BASEDIR/$EXT_DIR/$EXT-$e.zip"
371                 ###########
372                 find -name "*$e*" -exec $ZIP -9qmr "$BASEDIR/$EXT_DIR/$EXT-$e" {} \; > /dev/null 2>&1
373                 $ZIP -9q "$BASEDIR/$EXT_DIR/$EXT-$e.zip" $EXT_FILES > /dev/null 2>&1
374                 ###########
375                 ext_update
376                 echo -n "$e "
377         done
378         echo ") done"
379 }
380
381 function zip_extensions()
382 {
383         cd $BASEDIR/$BASENAME-$VER/$HTML/
384         echo -n "Creating base extension archives... ("
385         for e in $BASE_EXT; do
386                 rm -f "$BASEDIR/$EXT_DIR/$EXT-$e.zip"
387                 EXC=""
388                 if test "$e" = "theme"; then
389                         EXC="-path ./theme -prune -o -print"
390                 fi
391                 ###########
392                 find $EXC -name "*$e*" -exec $ZIP -9qr "$BASEDIR/$EXT_DIR/$EXT-$e" {} \; > /dev/null 2>&1
393                 $ZIP -9q "$BASEDIR/$EXT_DIR/$EXT-$e.zip" $EXT_FILES > /dev/null 2>&1
394                 ###########
395                 ext_update
396                 echo -n "$e "
397         done
398         echo ") done"
399 }
400
401 function zip_cms_extensions()
402 {
403         cd $BASEDIR/$BASENAME-$CMS-$CMS_VER/$CMS/
404         echo -n "Creating $CMS extension archives... ("
405         for e in $CMS_EXT; do
406                 rm -f "$BASEDIR/$CMS_EXT_DIR/$EXT-$e.zip"
407                 EXC=""
408                 if test "$e" = "theme"; then
409                         EXC="-path ./theme -prune -o -print"
410                 fi
411                 ###########
412                 find $EXC -name "*$e*" -exec $ZIP -9qr "$BASEDIR/$CMS_EXT_DIR/$EXT-$e" {} \; > /dev/null 2>&1
413                 $ZIP -9q "$BASEDIR/$CMS_EXT_DIR/$EXT-$e.zip" $EXT_FILES > /dev/null 2>&1
414                 ###########
415                 cms_ext_update
416                 echo -n "$e "
417         done
418         for e in $CMS_EXTRA_EXT; do
419                 rm -f "$BASEDIR/$CMS_EXT_DIR/$EXT-$e.zip"
420                 ###########
421                 find -name "*$e*" -exec $ZIP -9qrm "$BASEDIR/$CMS_EXT_DIR/$EXT-$e" {} \; > /dev/null 2>&1
422                 $ZIP -9q "$BASEDIR/$CMS_EXT_DIR/$EXT-$e.zip" $EXT_FILES > /dev/null 2>&1
423                 ###########
424                 cms_ext_update
425                 echo -n "$e "
426         done
427         echo ") done"
428 }
429
430 function zip_hp_extensions()
431 {
432         cd $BASEDIR/$BASENAME-$HP-$HP_VER/$HP/
433         echo -n "Creating $HP extension archives... ("
434         for e in $HP_EXT; do
435                 rm -f "$BASEDIR/$HP_EXT_DIR/$EXT-$e.zip"
436                 EXC=""
437                 if test "$e" = "theme"; then
438                         EXC="-path ./theme -prune -o -print"
439                 fi
440                 ###########
441                 find $EXC -name "*$e*" -exec $ZIP -9qr "$BASEDIR/$HP_EXT_DIR/$EXT-$e" {} \; > /dev/null 2>&1
442                 $ZIP -9q "$BASEDIR/$HP_EXT_DIR/$EXT-$e.zip" $EXT_FILES > /dev/null 2>&1
443                 ###########
444                 hp_ext_update
445                 echo -n "$e "
446         done
447         for e in $HP_EXTRA_EXT; do
448                 rm -f "$BASEDIR/$HP_EXT_DIR/$EXT-$e.zip"
449                 ###########
450                 find -name "*$e*" -exec $ZIP -9qrm "$BASEDIR/$HP_EXT_DIR/$EXT-$e" {} \; > /dev/null 2>&1
451                 $ZIP -9q "$BASEDIR/$HP_EXT_DIR/$EXT-$e.zip" $EXT_FILES > /dev/null 2>&1
452                 ###########
453                 hp_ext_update
454                 echo -n "$e "
455         done
456         echo ") done"
457 }
458
459 function zip_base_themes()
460 {
461         cd $BASEDIR/$BASENAME-$VER/$HTML/
462         echo -n "Creating base theme archives... ("
463         for t in $BASE_THEMES; do
464                 rm -f "$BASEDIR/$THEME_DIR/$THEME-$t.zip"
465                 ###########
466                 find theme/ -name "*$t*" -exec $ZIP -9qr "$BASEDIR/$THEME_DIR/$THEME-$t" {} \; > /dev/null 2>&1
467                 $ZIP -9q "$BASEDIR/$THEME_DIR/$THEME-$t.zip" $THEME_FILES > /dev/null 2>&1
468                 ###########
469                 theme_update
470                 echo -n "$t "
471         done
472         echo ") done"
473 }
474
475 function zip_themes()
476 {
477         cd $BASEDIR/$BASENAME-$VER/$HTML/
478         echo -n "Creating theme archives... ("
479         for t in $THEMES; do
480                 rm -f "$BASEDIR/$THEME_DIR/$THEME-$t.zip"
481                 ###########
482                 find theme/ -name "*$t*" -exec $ZIP -9qmr "$BASEDIR/$THEME_DIR/$THEME-$t" {} \; > /dev/null 2>&1
483                 $ZIP -9q "$BASEDIR/$THEME_DIR/$THEME-$t.zip" $THEME_FILES > /dev/null 2>&1
484                 ###########
485                 theme_update
486                 echo -n "$t "
487         done
488         echo ") done"
489 }
490
491 function zip_base_archives()
492 {
493         cd $BASEDIR
494         # Tar ball
495         echo -n "Creating archive $TAR_ARC ... "
496         tar -cf $TAR_ARC $BASENAME-$VER/ > /dev/null 2>&1
497         $BZIP2 -9f $TAR_ARC > /dev/null 2>&1
498         echo "done"
499         echo -n "Creating archive $CMS_TAR ... "
500         tar -cf $CMS_TAR $BASENAME-$CMS-$CMS_VER/ > /dev/null 2>&1
501         $BZIP2 -9f $CMS_TAR > /dev/null 2>&1
502         echo "done"
503         echo -n "Creating archive $HP_TAR ... "
504         tar -cf $HP_TAR $BASENAME-$HP-$HP_VER/ > /dev/null 2>&1
505         $BZIP2 -9f $HP_TAR > /dev/null 2>&1
506         echo "done"
507
508         # ZIP file
509         echo -n "Creating archive $ZIP_ARC ... "
510         $ZIP -9r $ZIP_ARC $BASENAME-$VER/* > /dev/null 2>&1
511         echo "done"
512         echo -n "Creating archive $CMS_ZIP ... "
513         $ZIP -9r $CMS_ZIP $BASENAME-$CMS-$CMS_VER/* > /dev/null 2>&1
514         echo "done"
515         echo -n "Creating archive $HP_ZIP ... "
516         $ZIP -9r $HP_ZIP $BASENAME-$HP-$HP_VER/* > /dev/null 2>&1
517         echo "done"
518 }
519
520 function cvs_update()
521 {
522         cd $BASEDIR/$BASENAME
523         echo -n "Preparing upload... "
524         rm -rf $RM_FILES_CVS > /dev/null 2>&1
525         echo "done"
526         echo
527         cvs login || exit 255
528         echo
529         echo "Importing $BASENAME..."
530         cvs -z3 import -m "$LOG_MSG" -I \*.zip -I \*.bz2 "$BASENAME" "$BASENAME" start || exit 255
531         cd $BASEDIR/$BASENAME-$CMS
532         echo
533         echo "Importing $BASENAME-$CMS..."
534         cvs -z3 import -m "$LOG_MSG" -I \*.zip -I \*.bz2 "$BASENAME-$CMS" "$BASENAME-$CMS" start || exit 255
535         cd $BASEDIR/$BASENAME-$HP
536         echo
537         echo "Importing $BASENAME-$HP..."
538         cvs -z3 import -m "$LOG_MSG" -I \*.zip -I \*.bz2 "$BASENAME-$HP" "$BASENAME-$HP" start || exit 255
539         cd $BASEDIR
540         echo
541         echo -n "Logging CVS changes..."
542         cvs -z3 log $BASENAME > $CVS_LOG || exit 255
543         echo "done"
544         echo
545         cvs logout
546         echo
547         echo -n "Generating statistics... "
548         $JAVA -jar $STATS_CVS >/dev/null 2>&1
549         echo "done"
550         cd $STATS_OUT
551         echo -n "Uploading statistics... "
552         $FTP -u $FTP_USER -p $FTP_PASS $FTP_HOST $STATS_FTP_DIR *.* > /dev/null 2>&1
553         echo " done"
554         cd $BASEDIR
555 }
556
557 function stats_upload()
558 {
559         echo -n "Uploading statistics... "
560         $FTP -u $FTP_USER -p $FTP_PASS $FTP_HOST $STATS_FTP_DIR *.* > /dev/null 2>&1
561         echo " done"
562 }
563
564 function cvs_download()
565 {
566         cd $BASEDIR
567         echo -n "Preparing download... "
568         rm -rf $RM_FILES_CVS $BASENAME/* $BASENAME-$CMS/* $BASENAME-$HP/* > /dev/null 2>&1
569         echo "done"
570         echo
571         cvs login
572         echo "Connecting to CVS server..."
573         cvs -z3 checkout "$BASENAME" || exit 255
574         echo
575         echo "Connecting to CVS server..."
576         cvs -z3 checkout "$BASENAME-$CMS" "$BASENAME-$CMS" || exit 255
577         echo
578         echo "Connecting to CVS server..."
579         cvs -z3 checkout "$BASENAME-$HP" "$BASENAME-$HP" || exit 255
580         echo
581         cvs logout
582 }