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