Dateianhang 'svn-install.pl'
Herunterladen 1 #! /usr/local/bin/perl
2
3 $| = 1;
4 use LWP::Simple;
5
6 ##############################################################
7 # licensed under LGPL
8 # coded by Lars Gohlke
9 # reachable under http://www.lars-gohlke.de.vu
10 # contact http://www.lars-gohlke.de.vu/hp/?id=contact
11 ##############################################################
12 # Germany 2005/06/06
13 # this script is based on http://iedb.org/svn/svn-install.txt
14 #
15 # Step by step automatic installation of
16 # - subversion
17 # - apache
18 # - BerkelyDB
19 #
20 # download + installation is automated
21 #
22 # ***********************************************************
23 # history
24 # 2005/06/06
25 # * initial release
26 #
27 ##############################################################
28
29 my %_DIRS =(
30 "APACHE_STD" => "/usr/local/apache2/",
31 "DB_STD" => "/usr/local/BerkeleyDB.4.3"
32 );
33
34 my %_CONF = (
35 "APACHE"=>{
36 "file" => "httpd-2.0.54.tar.bz2",
37 "url" => "http://ftp.uni-erlangen.de/pub/mirrors/apache/httpd/",
38 "configure_opts" => [
39 "--enable-dav=shared",
40 "--with-gdbm=no",
41 "--enable-mod_deflate=shared",
42 "--enable-so",
43 "--with-berkeley-db=".$_DIRS{'DB_STD'},
44 "--with-dbm=db4"
45 ]
46 },
47 "DB" =>{
48 "file" => "db-4.3.28.NC.tar.gz",
49 "url" => "http://downloads.sleepycat.com/",
50 "libs" => "/usr/local/BerkeleyDB.4.3/lib"
51 },
52 "STATUS" =>{
53 "max_line_length" => 80,
54 "text_length" => 0,
55 "steps_to_end" => 26
56 },
57 "SVN" => {
58 "file" => "subversion-1.2.0.tar.bz2",
59 "url" => "http://subversion.tigris.org/downloads/",
60 "configure_opts" => [
61 "--with-apxs=".$_DIRS{'APACHE_STD'}."bin/apxs",
62 "--with-apr=".$_DIRS{'APACHE_STD'},
63 "--enable-mod_deflate=shared",
64 "--with-apr-util=".$_DIRS{'APACHE_STD'},
65 "--with-berkeley-db=".$_DIRS{'DB_STD'}
66 ]
67 },
68 "log_file" => " 1>>svn_install.log 2>>svn_install.log"
69 );
70
71 ### ADDON ###
72 my %APACHE_adjust = (
73 # these dirs will be renamed to dir_orig
74 # and replaced by an link to following
75 "cgi-bin" => "/srv/svn/apache_cgi-bin",
76 "conf" => "/srv/svn/apache_conf",
77 "htdocs" => "/srv/svn/apache_htdocs"
78 );
79
80 # Schritt 3
81 &get_superuser();
82 # zur Überprüfung (1)
83 &check_urls(1);
84 # Schritt 2 (2)
85 &download_svn(2);
86 # Schritt 4 (3)
87 &extract_svn(3);
88 # Schritt 5 (4)
89 &autogen_svn(4);
90 # Schritt 7 (5)
91 &download_db(5);
92 # Schritt 8-19 (6-11)
93 &install_db(6);
94 # Schritt 20
95 &download_apache(12);
96 # Schritt 21
97 &extract_apache(13);
98 # Schritt 22-28
99 &install_apache(14);
100 # Schritt 29-36
101 &install_svn(19);
102 # deleting dirs
103 &delete_dirs(24);
104
105 # if you know what you're doing uncomment this line
106 #&apache_adjust_install();
107
108 print "\n"x2,"so nun bitte ab Punkt 40 selber weitermachen","\n";
109 print "( go on creating repository and so on )\n";
110
111 print "\n"x2,"Bitte bei einem Upgrade nicht vergessen, den ServerRoot anzupassen","\n";
112 print "( don't forget to replace ServerRoot with correct one after you upgraded \n";
113
114
115 #*****************************************************************************
116 sub apache_adjust_install{
117 # for all paths to fit
118 foreach my $_dir (keys %APACHE_adjust){
119
120 if (-e $_DIRS{'APACHE_STD'}.$_dir ){
121 # go on, unless link exists
122 unless (-l $_DIRS{'APACHE_STD'}.$_dir){
123 rename( $_DIRS{'APACHE_STD'}.$_dir, $_DIRS{'APACHE_STD'}.$_dir."_orig" );
124
125 if ( -e $APACHE_adjust{$_dir} ){
126 print $APACHE_adjust{$_dir}," exists \n";
127 }
128 if ( symlink( $APACHE_adjust{$_dir} , $_DIRS{'APACHE_STD'}.$_dir ) ){
129 print "link ok\n";
130 }
131 else{
132 print "link failed\n";
133 }
134 }
135 }
136 else{
137 print "ERROR : \"",$_DIRS{'APACHE_STD'}.$_dir,"\" do not existing \n";
138 die;
139 }
140 }
141 }
142
143 sub delete_dirs{
144 my $_step = $_[0];
145 foreach my $_SECTION("SVN","APACHE","DB"){
146 my %_SECTION = %{$_CONF{ $_SECTION }};
147 (my $_dir = $_SECTION{"file"}) =~ s/\.tar\.(bz2|gz)$//i;
148
149 &progress($_step++);
150 &status("deleting $_dir","wait");
151 system("rm -rf $_dir");
152 &status("","ok");
153 }
154 }
155
156 #*****************************************************************************
157 sub install_svn{
158 my $_step = $_[0];
159 my $_SECTION = "SVN";
160
161 my $_sub = "install_".$_SECTION;
162 my %_SECTION = %{$_CONF{ $_SECTION }};
163
164 (my $_dir = $_SECTION{"file"}) =~ s/\.tar\.(bz2|gz)$//i;
165 chdir($_dir) || die "[func: $_sub] $^E \n";
166 # alte Bibliotheken löschen
167
168 &progress($_step);
169 &status("delete old libs");
170 system("rm -rf /usr/local/lib/lib{svn,neon}*");
171
172 my $_configure_opts = join(' ',@{$_SECTION{"configure_opts"}});
173 &_make(($_step+1), $_SECTION, "./configure ".$_configure_opts);
174 &_make(($_step+2), $_SECTION, "make");
175 &_make(($_step+3), $_SECTION, "make install");
176 &_make(($_step+4), $_SECTION, "make clean");
177
178 chdir("..");# in basedir
179
180
181 my $_cmd_output = `cat /etc/group | grep svn`;
182 unless( length($_cmd_output) > 0 ){
183 &progress( $_step+5);
184 &status("add $_SECTION");
185 system("groupadd -r svn");
186 }
187
188 $_cmd_output = `cat /etc/passwd | grep svn`;
189 unless( length($_cmd_output) > 0 ){
190 &progress( $_step+6);
191 &status("add user $_SECTION");
192 system("useradd -r -g svn svn");
193 }
194 }
195
196 #*****************************************************************************
197 sub _make{
198 my ($_step, $_section, $_cmd) = @_;
199
200 &progress($_step);
201 &status("$_cmd $_section","wait");
202 system($_cmd." ".$_CONF{"log_file"});
203 &status("","ok");
204 }
205
206
207 #*****************************************************************************
208 sub install_apache{
209 my $_step = $_[0];
210 my $_SECTION = "APACHE";
211
212 my $_sub = "install_".$_SECTION;
213 my %_SECTION = %{$_CONF{ $_SECTION }};
214
215 (my $_dir = $_SECTION{"file"}) =~ s/\.tar\.(bz2|gz)$//i;
216 chdir($_dir) || die "[func: $_sub] $^E \n";
217
218 &_make( $_step, $_SECTION, "./buildconf");
219
220 my $_configure_opts = join(' ',@{$_SECTION{"configure_opts"}});
221 &_make(($_step+1), $_SECTION, "./configure ".$_configure_opts);
222 &_make(($_step+2), $_SECTION, "make");
223 &_make(($_step+3), $_SECTION, "make install");
224 &_make(($_step+4), $_SECTION, "make clean");
225
226 chdir("..");# in basedir
227 }
228
229 #*****************************************************************************
230 sub extract_apache{
231 &progress($_[0]);
232 &extract_pack("APACHE");
233 }
234
235 #*****************************************************************************
236 sub extract_pack{
237 my %_SECTION = %{$_CONF{ $_[0] }};
238
239 my $_file_and_log = $_SECTION{"file"}." ".$_CONF{"log_file"};
240 &status("unpack + decompress ".$_SECTION{"file"},"wait");
241 if ( $_SECTION{"file"} =~ /\.tar\.bz2$/i) { `tar -xjf $_file_and_log`;}
242 elsif ( $_SECTION{"file"} =~ /\.tar\.gz$/i) { `tar -xzf $_file_and_log`;}
243 else { die "\n Filetyp unknown ".$_SECTION{"file"}."\n";}
244 &status("","ok");
245 }
246
247 #*****************************************************************************
248 sub download_apache{
249 &progress($_[0]);
250 &download_pack("APACHE");
251 }
252
253 #*****************************************************************************
254 sub download_pack{
255 my %_SECTION = %{$_CONF{ $_[0] }};
256 my $_exists = (-e $_SECTION{"file"} ) ? "ok" : "no";
257
258 &status("checking if \"".$_SECTION{"file"}."\" exists",$_exists);
259 if ( $_exists eq "no" ){
260 &status("downloading ".$_SECTION{"file"});
261 system("wget ". $_SECTION{"url"} . $_SECTION{"file"});
262 }
263 }
264
265 #*****************************************************************************
266 sub install_db{
267 my $_step = $_[0];
268 &progress($_step);
269 my $_SECTION = "DB";
270
271 my $_sub = "install_".$_SECTION;
272 my %_SECTION = %{$_CONF{ $_SECTION }};
273 &extract_pack( $_SECTION );
274
275 (my $_dir = $_SECTION{"file"}) =~ s/\.tar\.(bz2|gz)$//i;
276 chdir($_dir) || die "[func: $_sub] $^E \n";
277
278 # Wechsle in das build_unix Verzeichnis
279
280 chdir("build_unix") || die "[func: $_sub] $^E \n";
281
282 &_make(($_step+1), $_SECTION, "./configure ".$_configure_opts);
283 &_make(($_step+2), $_SECTION, "make");
284 &_make(($_step+3), $_SECTION, "make install");
285 &_make(($_step+4), $_SECTION, "make clean");
286
287 chdir("..");# in das DB-Dir
288 chdir("..");# in basedir
289
290 &progress($_step+5);
291 &status("installing DB libs","wait");
292 my $_DB_libs = $_SECTION{"libs"};
293 my $_cmd_fgrep = `fgrep $_DB_libs /etc/ld.so.conf`;
294 chomp($_cmd_fgrep);
295 unless( $_cmd_fgrep eq $_DB_libs){
296 system("echo $_DB_libs >> /etc/ld.so.conf");
297 system("ldconfig");
298 }
299 &status("","ok");
300 }
301
302 #*****************************************************************************
303 sub download_db{
304 &progress($_[0]);
305 &download_pack("DB");
306 }
307 #*****************************************************************************
308 sub autogen_svn{
309 &progress($_[0]);
310 my $_sub = "autogen_svn";
311 (my $_svn_dir = $_CONF{"SVN"}{"file"}) =~ s/\.tar\.(bz2|gz)$//i;
312 chdir($_svn_dir) || die "[func: $_sub] $^E \n";
313 &status("running \"autogen.sh\" in \"$_svn_dir\"");
314 if (-e "apr-util/xml/expat/autom4te.cache"){
315 system("rm -r apr-util/xml/expat/autom4te.cache");
316 }
317 system("./autogen.sh ".$_CONF{"log_file"});
318 chdir("..");
319 }
320
321 #*****************************************************************************
322 sub get_superuser{
323 (`id` =~ /uid\=([\d]+)/);
324 my $_id = $1;
325 if ( $_id > 0){
326 &status("change to ROOT and restart Script");
327 system("su ");
328 exit;
329 }
330 }
331
332 #*****************************************************************************
333 sub extract_svn{
334 &progress($_[0]);
335 &extract_pack("SVN");
336 }
337
338 #*****************************************************************************
339 sub check_urls{
340 &progress($_[0]);
341 print "\n";
342
343 while (($_section,$_vals) = each(%_CONF)){
344
345 if ( exists($_vals->{"url"}) && exists($_vals->{"file"}) ){
346 my $_url = $_vals->{"url"}.$_vals->{"file"};
347
348 &status("checking url ( ".$_vals->{"file"}." )","wait");
349
350 my $_list = head($_url);
351
352 if ( $_list > 0) {
353 &status("","ok");
354 }
355 else {
356 &status("","failed");
357 die "please check url: \"$_url\" \n";
358 }
359 }
360 }
361 }
362 #*****************************************************************************
363 sub download_svn{
364 &progress($_[0]);
365 &download_pack("SVN");
366 }
367
368 #*****************************************************************************
369 sub progress{
370 printf("step %02d/%02d ",$_[0],$_CONF{"STATUS"}{"steps_to_end"});
371 }
372
373 #*****************************************************************************
374 sub status{
375 my ($_text, $_status) = @_;
376
377 my $_length_text = ($_CONF{"STATUS"}{"text_length"} > 0) ? $_CONF{"STATUS"}{"text_length"} : length($_text);
378 my $_length_status = length($_status);
379
380 my $_space = $_CONF{"STATUS"}{"max_line_length"} - ( $_length_text + $_length_status);
381
382 print $_text;
383
384 if ( $_status eq "wait" ){
385 $_CONF{"STATUS"}{"text_length"} = $_length_text;
386 }
387 else{
388 $_CONF{"STATUS"}{"text_length"} = 0;
389 print " "x$_space,$_status."\n";
390 }
391 }
Gespeicherte Dateianhänge
Um Dateianhänge in eine Seite einzufügen sollte unbedingt eine Angabe wie attachment:dateiname benutzt werden, wie sie auch in der folgenden Liste der Dateien erscheint. Es sollte niemals die URL des Verweises ("laden") kopiert werden, da sich diese jederzeit ändern kann und damit der Verweis auf die Datei brechen würde.Sie dürfen keine Anhänge an diese Seite anhängen!