[696] | 1 | #!/usr/bin/perl |
---|
| 2 | use strict; |
---|
[1223] | 3 | use FindBin qw($Bin); |
---|
| 4 | use lib $Bin; |
---|
[696] | 5 | use onserver; |
---|
| 6 | use Cwd; |
---|
| 7 | use File::Path; |
---|
| 8 | use URI::Escape; |
---|
[701] | 9 | use DBI; |
---|
| 10 | use Config::IniFiles; |
---|
[696] | 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 | |
---|
[701] | 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 | |
---|
[696] | 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), |
---|
[1262] | 40 | $name, $dbstring, $repotype, $repopath); |
---|
[696] | 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>) { |
---|
[702] | 46 | s/\@ADDREND\@/~$USER\/$addrend/g; |
---|
[696] | 47 | print OUT $_; |
---|
| 48 | } |
---|
| 49 | close IN; close OUT; |
---|
| 50 | |
---|
[701] | 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'); |
---|
[1512] | 55 | $cfg->newval('components', 'tracext.git.*', 'enabled') if $repotype eq "git"; |
---|
[1556] | 56 | $cfg->newval('components', 'tracext.hg.*', 'enabled') if $repotype eq "hg"; |
---|
[701] | 57 | $cfg->RewriteConfig(); |
---|
| 58 | |
---|
| 59 | system(qw(/usr/bin/trac-admin tracdata permission add), $human, 'TRAC_ADMIN'); |
---|
| 60 | |
---|
[696] | 61 | chmod 0777, '.htaccess'; |
---|
| 62 | unlink '.htaccess.in'; |
---|
| 63 | |
---|
[700] | 64 | open OUT, '>tracdata/.htaccess'; |
---|
[1015] | 65 | print OUT "Deny from all\n"; |
---|
[700] | 66 | close OUT; |
---|
| 67 | chmod 0777, 'tracdata/.htaccess'; |
---|
| 68 | |
---|
[696] | 69 | exit 0; |
---|