source: trunk/locker/deploy/bin/trac @ 1803

Last change on this file since 1803 was 1791, checked in by andersk, 13 years ago
trac: Mangle HTTP_REFERER to let the login link keep you on the same page. (Merge of r1526:1528 from branches/locker-dev to trunk, from andersk)
File size: 2.1 KB
RevLine 
[696]1#!/usr/bin/perl
2use strict;
[1222]3use FindBin qw($Bin);
4use lib $Bin;
[696]5use onserver;
6use Cwd;
7use File::Path;
8use URI::Escape;
[701]9use DBI;
10use Config::IniFiles;
[696]11
12setup();
13
14print "\nEnter the name of your project (the title of this Trac instance).\n";
15print "Project name: ";
16my $name=<STDIN>;
17chomp($name);
18
[701]19my $dbh = DBI->connect("DBI:mysql:database=$sqldb;host=$sqlhost", $sqluser, $sqlpass, {RaiseError => 1});
20$dbh->do('alter database collate utf8_general_ci');
21
[696]22my $dbstring = "mysql://" . uri_escape($sqluser) . ":" . uri_escape($sqlpass) . "\@$sqlhost/$sqldb";
23
24print "\nEnter the type of version-control repository this project uses.\n";
25print "You'll have to set up the repo yourself; feel free to ask scripts@ for help.\n";
26print "If you don't want version-control integration, take the default.\n";
27print "Repository type (default svn; also bzr, git, hg): ";
28my $repotype=<STDIN>;
29chomp($repotype);
30$repotype = $repotype ? $repotype : 'svn';
31
32print "\nEnter the path to the version-control repository.\n";
33print "If you don't want version-control integration, leave blank.\n";
34print "Path to repository: ";
35my $repopath=<STDIN>;
36chomp($repopath);
37
38print STDERR "running trac-admin:\n";
39system(qw(/usr/bin/trac-admin tracdata initenv),
[1261]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
44open IN, '<.htaccess.in'; open OUT, '>.htaccess';
45while (<IN>) {
[702]46    s/\@ADDREND\@/~$USER\/$addrend/g;
[696]47    print OUT $_;
48}
49close IN; close OUT;
50
[701]51my $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');
[1514]55$cfg->newval('components', 'tracext.git.*', 'enabled') if $repotype eq "git";
[701]56$cfg->RewriteConfig();
57
58system(qw(/usr/bin/trac-admin tracdata permission add), $human, 'TRAC_ADMIN');
59
[696]60chmod 0777, '.htaccess';
61unlink '.htaccess.in';
62
[700]63open OUT, '>tracdata/.htaccess';
[1015]64print OUT "Deny from all\n";
[700]65close OUT;
66chmod 0777, 'tracdata/.htaccess';
67
[696]68exit 0;
Note: See TracBrowser for help on using the repository browser.