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