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