AT-4848: Added a condition to handle a false positive.
[atutor.git] / bundle.sh
1 #! /bin/csh -f
2 #########################################################################
3 # ATutor bundle script                                                  #
4 # ./bundle [VERSION] to specify an optional version number              #
5 # Author: Joel Kronenberg - IDRC, Oct 2003                              #
6 #########################################################################
7 # Updated Sept 2011 for GitHub Greg Gay
8 # Run this script on a server that has git and wget installed
9 # Issue the command './bundle.sh [VERSION]' to generate an ATutor distribution bundle
10 # In addition to creating a clone of the atutor/ATutor source code from GitHub
11 # This script retreives a copy of the latest English language from the atutor.ca language database via wget.
12 #
13
14 set now = `date +"%Y_%m_%d"`
15 set atutor_dir = "ATutor_$now"
16 set bundle = "ATutor"
17
18 set gitdir = "git://github.com/atutor/ATutor.git"
19 set gitexec = "git"
20
21 echo "ATutor Bundle Script for GitHub"
22 echo "--------------------"
23
24 if ($#argv > 0) then
25         set extension = "-$argv[1]"
26 else 
27         echo "No argument given. Run./bundle.sh [VERSION] to specify bundle version."
28         set extension = ""
29 endif
30
31 if ($#argv == "2") then
32         set ignore_mode = true
33 else
34         set ignore_mode = false
35 endif
36
37 echo "Using $atutor_dir as temp bundle directory."
38 echo "Using $bundle$extension.tar.gz as bundle name."
39 sleep 1
40 if (-e $atutor_dir) then
41         echo -n "Dir $atutor_dir exists. Overwrite? (y/q) "
42
43         set ans = $<
44         switch ($ans)
45             case q: 
46                 echo "$atutor_dir not touched. Exiting.\n"
47                exit
48             case y:
49                 echo "Removing old $atutor_dir"
50                 rm -r $atutor_dir
51         endsw
52 endif
53 sleep 1
54
55 echo "Cloning from GitHub to $atutor_dir"
56 echo "Leave Password empty if prompted."
57 mkdir $atutor_dir
58 #cp -R docs $atutor_dir/ATutor
59 #$svnexec --force export $gitdir
60 $gitexec clone $gitdir
61
62 mv 'ATutor/docs' $atutor_dir/ATutor
63 sleep 1
64
65 echo "Dumping language_text"
66 rm $atutor_dir/ATutor/install/db/atutor_language_text.sql
67 echo 'DROP TABLE `language_text`;' > $atutor_dir/ATutor/install/db/atutor_language_text.sql
68 wget --output-document=- http://atutor.ca/atutor/translate/dump_lang.php >> $atutor_dir/ATutor/install/db/atutor_language_text.sql
69
70 sleep 1
71
72 echo "Removing $atutor_dir/ATutor/include/config.inc.php"
73 rm -f $atutor_dir/ATutor/include/config.inc.php
74 echo -n "<?php /* This file is a placeholder. Do not delete. Use the automated installer. */ ?>" > $atutor_dir/ATutor/include/config.inc.php
75 sleep 1
76
77 echo "Removing $atutor_dir/ATutor/install/db/atutor_upgrade sql < 1.4"
78 rm -r $atutor_dir/ATutor/install/db/atutor_upgrade_1.0_to_1.1.sql
79 rm -r $atutor_dir/ATutor/install/db/atutor_upgrade_1.1_to_1.2.sql
80 rm -r $atutor_dir/ATutor/install/db/atutor_upgrade_1.2_to_1.3.sql
81 rm -r $atutor_dir/ATutor/install/db/atutor_upgrade_1.3_to_1.3.2.sql
82 rm -r $atutor_dir/ATutor/install/db/atutor_upgrade_1.3.2_to_1.4.sql
83 sleep 1
84
85
86 echo "Disabling AT_DEVEL if enabled."
87 sed "s/define('AT_DEVEL', 1);/define('AT_DEVEL', 0);/" $atutor_dir/ATutor/include/vitals.inc.php > $atutor_dir/vitals.inc.php
88 rm $atutor_dir/ATutor/include/vitals.inc.php
89 echo "Disabling AT_DEVEL_TRANSLATE if enabled."
90 sed "s/define('AT_DEVEL_TRANSLATE', 1);/define('AT_DEVEL_TRANSLATE', 0);/" $atutor_dir/vitals.inc.php > $atutor_dir/ATutor/include/vitals.inc.php
91 sleep 1
92 set date = `date`
93 echo -n "<?php "'$svn_data = '"'" >> $atutor_dir/ATutor/svn.php
94 echo $date >> $atutor_dir/ATutor/svn.ph
95 #echo "Bundled" `date` >> $atutor_dir/ATutor/svn.php
96 echo "';?>" >> $atutor_dir/ATutor/svn.php
97
98 echo "Targz'ing $bundle${extension}.tar.gz $atutor_dir/ATutor/"
99 sleep 1
100
101 if (-f "$bundle${extension}.tar.gz") then
102         echo -n "Bundle $bundle$extension.tar.gz exists. Overwrite? (y/n/q) "
103
104         set ans = $<
105
106         switch ($ans)
107             case q:
108                 echo "$bundle$extension.tar.gz not touched."
109                 exit
110             case y:
111                 echo "Removing old $bundle$extension.tar.gz"
112                 set final_name = "$bundle$extension.tar.gz"
113                 rm -r "$bundle$extension.tar.gz"
114                 breaksw
115             case n: 
116                 set time = `date +"%k_%M_%S"`
117                 set extension = "${extension}-${time}"
118                 echo "Saving as $bundle$extension.tar.gz instead.\n"
119                 set final_name = "$bundle$extension.tar.gz"
120                 breaksw
121         endsw
122 else
123         set final_name = "$bundle$extension.tar.gz"
124 endif   
125
126 echo "Creating $final_name"
127 cd $atutor_dir
128 tar -zcf $final_name ATutor/
129 mv $final_name ..
130 cd ..
131 sleep 1
132
133 if ($ignore_mode == true) then
134         set ans = "y"
135 else 
136         echo -n "Remove temp $atutor_dir directory? (y/n) "
137         set ans = $<
138 endif
139
140 if ($ans == "y") then
141         echo "Removing temp $atutor_dir directory"
142         rm -r $atutor_dir       
143         #remove the Git cloned directory
144         #rm -rf "ATutor"
145 endif
146
147 echo " >> Did you update check_atutor_version.php ?? <<"
148
149 echo "Bundle complete. Enjoy.Exiting."
150
151
152 exit 1