1 | #!/usr/bin/perl |
---|
2 | use strict; |
---|
3 | use FindBin qw($Bin); |
---|
4 | use lib $Bin; |
---|
5 | use onserver; |
---|
6 | use Cwd; |
---|
7 | use File::Path; |
---|
8 | use URI::Escape; |
---|
9 | use DBI; |
---|
10 | use Config::IniFiles; |
---|
11 | |
---|
12 | setup(); |
---|
13 | |
---|
14 | print "\nEnter the name of your project (the title of this Trac instance).\n"; |
---|
15 | print "Project name: "; |
---|
16 | my $name=<STDIN>; |
---|
17 | chomp($name); |
---|
18 | |
---|
19 | my $dbh = DBI->connect("DBI:mysql:database=$sqldb;host=$sqlhost", $sqluser, $sqlpass, {RaiseError => 1}); |
---|
20 | $dbh->do('alter database collate utf8_general_ci'); |
---|
21 | |
---|
22 | my $dbstring = "mysql://" . uri_escape($sqluser) . ":" . uri_escape($sqlpass) . "\@$sqlhost/$sqldb"; |
---|
23 | |
---|
24 | print "\nEnter the type of version-control repository this project uses.\n"; |
---|
25 | print "You'll have to set up the repo yourself; feel free to ask scripts@ for help.\n"; |
---|
26 | print "If you don't want version-control integration, take the default.\n"; |
---|
27 | print "Repository type (default svn; also bzr, git, hg): "; |
---|
28 | my $repotype=<STDIN>; |
---|
29 | chomp($repotype); |
---|
30 | $repotype = $repotype ? $repotype : 'svn'; |
---|
31 | |
---|
32 | print "\nEnter the path to the version-control repository.\n"; |
---|
33 | print "If you don't want version-control integration, leave blank.\n"; |
---|
34 | print "Path to repository: "; |
---|
35 | my $repopath=<STDIN>; |
---|
36 | chomp($repopath); |
---|
37 | |
---|
38 | print STDERR "running trac-admin:\n"; |
---|
39 | system(qw(/usr/bin/trac-admin tracdata initenv), |
---|
40 | $name, $dbstring, $repotype, $repopath); |
---|
41 | # XXX this exposes the SQL password on the command line |
---|
42 | |
---|
43 | #aka perl -pe 's/\@ADDREND\@/$addrend/g' <.htaccess.in >.htaccess |
---|
44 | open IN, '<.htaccess.in'; open OUT, '>.htaccess'; |
---|
45 | while (<IN>) { |
---|
46 | s/\@ADDREND\@/~$USER\/$addrend/g; |
---|
47 | print OUT $_; |
---|
48 | } |
---|
49 | close IN; close OUT; |
---|
50 | |
---|
51 | my $cfg = Config::IniFiles->new(-file => 'tracdata/conf/trac.ini'); |
---|
52 | $cfg->setval('trac', 'default_charset', 'utf-8'); |
---|
53 | $cfg->AddSection('components'); |
---|
54 | $cfg->newval('components', 'webadmin.*', 'enabled'); |
---|
55 | $cfg->newval('components', 'tracext.git.*', 'enabled') if $repotype eq "git"; |
---|
56 | $cfg->RewriteConfig(); |
---|
57 | |
---|
58 | system(qw(/usr/bin/trac-admin tracdata permission add), $human, 'TRAC_ADMIN'); |
---|
59 | |
---|
60 | chmod 0777, '.htaccess'; |
---|
61 | unlink '.htaccess.in'; |
---|
62 | |
---|
63 | open OUT, '>tracdata/.htaccess'; |
---|
64 | print OUT "Deny from all\n"; |
---|
65 | close OUT; |
---|
66 | chmod 0777, 'tracdata/.htaccess'; |
---|
67 | |
---|
68 | exit 0; |
---|