43f623e25ee138f09300ae044d08b3922a8f934e
[acontent.git] / docs / bundle_acontent.sh
1 #! /bin/csh -f
2 #########################################################################
3 # AContent bundle script                                                  #
4 # ./bundle [VERSION] to specify an optional version number              #
5 # Author: Greg Gay - IDI, July 2010                              #
6 #########################################################################
7
8 set now = `date +"%Y_%m_%d"`
9 set acontent_dir = "AContent_$now"
10 set bundle = "AContent"
11 set svndir = "http://svn.atutor.ca/repos/transformable2/trunk/docs/"
12 set svnexec = "svn"
13
14 echo "\033[1mAContent Bundle Script [for CVS 1.3.1+] \033[0m"
15 echo "--------------------"
16
17 if ($#argv > 0) then
18         set extension = "-$argv[1]"
19 else 
20         echo "\nNo argument given. Run \033[1m./bundle_acontent.sh [VERSION]\033[0m to specify bundle version."
21         set extension = ""
22 endif
23
24 if ($#argv == "2") then
25         set ignore_mode = true
26 else
27         set ignore_mode = false
28 endif
29
30 echo "\nUsing $acontent_dir as temp bundle directory."
31 echo "Using $bundle$extension.tar.gz as bundle name."
32 sleep 1
33 if (-e $acontent_dir) then
34         echo -n "\nDir $acontent_dir exists. Overwrite? (y/q) "
35
36         set ans = $<
37         switch ($ans)
38             case q: 
39                 echo "\n$acontent_dir not touched. Exiting.\n"
40                exit
41             case y:
42                 echo "\nRemoving old $acontent_dir"
43                 rm -r $acontent_dir
44         endsw
45 endif
46 sleep 1
47
48 echo "\nExporting from SVN/ to $acontent_dir"
49 mkdir $acontent_dir
50 $svnexec --force export $svndir
51 mv 'docs' $acontent_dir/AContent
52 sleep 1
53
54 echo "\nDumping language_text"
55 rm $acontent_dir/AContent/install/db/language_text.sql
56 echo "DROP TABLE language_text;" > $acontent_dir/AContent/install/db/language_text.sql
57 wget --output-document=- http://atutor.ca/atutor/translate/dump_lang_acontent.php >> $acontent_dir/AContent/install/db/language_text.sql
58
59 sleep 1
60
61 echo "\nRemoving $acontent_dir/AContent/include/config.inc.php"
62 rm -f $acontent_dir/AContent/include/config.inc.php
63 echo -n "<?php /* This file is a placeholder. Do not delete. Use the automated installer. */ ?>" > $acontent_dir/AContent/include/config.inc.php
64 sleep 1
65
66
67
68 echo "\nDisabling TR_DEVEL if enabled."
69 sed "s/define('TR_DEVEL', 1);/define('TR_DEVEL', 0);/" $acontent_dir/AContent/include/vitals.inc.php > $acontent_dir/vitals.inc.php
70 rm $acontent_dir/AContent/include/vitals.inc.php
71 echo "\nDisabling AT_DEVEL_TRANSLATE if enabled."
72 sed "s/define('AT_DEVEL_TRANSLATE', 1);/define('AT_DEVEL_TRANSLATE', 0);/" $acontent_dir/vitals.inc.php > $acontent_dir/AContent/include/vitals.inc.php
73 sleep 1
74
75 echo -n "<?php "'$svn_data = '"'" >> $acontent_dir/AContent/svn.php
76 $svnexec log  -q -r HEAD http://svn.atutor.ca/repos/transformable2/trunk/  >> $acontent_dir/AContent/svn.php
77 echo -n "';?>" >> $acontent_dir/AContent/svn.php
78
79 echo "\nTargz'ing $bundle${extension}.tar.gz $acontent_dir/AContent/"
80 sleep 1
81
82 if (-f "$bundle${extension}.tar.gz") then
83         echo -n "\nBundle $bundle$extension.tar.gz exists. Overwrite? (y/n/q) "
84
85         set ans = $<
86
87         switch ($ans)
88             case q:
89                 echo "\n$bundle$extension.tar.gz not touched."
90                 exit
91             case y:
92                 echo "\nRemoving old $bundle$extension.tar.gz"
93                 set final_name = "$bundle$extension.tar.gz"
94                 rm -r "$bundle$extension.tar.gz"
95                 breaksw
96             case n: 
97                 set time = `date +"%k_%M_%S"`
98                 set extension = "${extension}-${time}"
99                 echo "\nSaving as $bundle$extension.tar.gz instead.\n"
100                 set final_name = "$bundle$extension.tar.gz"
101                 breaksw
102         endsw
103 else
104         set final_name = "$bundle$extension.tar.gz"
105 endif   
106
107 echo "Creating \033[1m$final_name\033[0m"
108 cd $acontent_dir
109 tar -zcf $final_name AContent/
110 mv $final_name ..
111 cd ..
112 sleep 1
113
114 if ($ignore_mode == true) then
115         set ans = "y"
116 else 
117         echo -n "\nRemove temp $acontent_dir directory? (y/n) "
118         set ans = $<
119 endif
120
121 if ($ans == "y") then
122         echo "\nRemoving temp $acontent_dir directory"
123         rm -r $acontent_dir
124 endif
125
126 echo "\n\033[1m >> Did you update check_acontent_version.php ?? << \033[0m"
127
128 echo "\n\033[1mBundle complete. Enjoy.\n\nExiting.\033[0m"
129
130
131 exit 1