source: branches/fc11-dev/locker/deploy/bin/trac @ 1148

Last change on this file since 1148 was 1015, checked in by mitchb, 14 years ago
Fix generation of the fallback htaccess file for trac. Using single quotes results in the literal characters \n and no end-of-line, and thus a malformed htaccess file.
  • Property svn:executable set to *
File size: 2.1 KB
Line 
1#!/usr/bin/perl
2use strict;
3use lib '/mit/scripts/deploy/bin';
4use onserver;
5use Cwd;
6use File::Path;
7use URI::Escape;
8use DBI;
9use Config::IniFiles;
10
11setup();
12
13print "\nEnter the name of your project (the title of this Trac instance).\n";
14print "Project name: ";
15my $name=<STDIN>;
16chomp($name);
17
18my $dbh = DBI->connect("DBI:mysql:database=$sqldb;host=$sqlhost", $sqluser, $sqlpass, {RaiseError => 1});
19$dbh->do('alter database collate utf8_general_ci');
20
21my $dbstring = "mysql://" . uri_escape($sqluser) . ":" . uri_escape($sqlpass) . "\@$sqlhost/$sqldb";
22
23print "\nEnter the type of version-control repository this project uses.\n";
24print "You'll have to set up the repo yourself; feel free to ask scripts@ for help.\n";
25print "If you don't want version-control integration, take the default.\n";
26print "Repository type (default svn; also bzr, git, hg): ";
27my $repotype=<STDIN>;
28chomp($repotype);
29$repotype = $repotype ? $repotype : 'svn';
30
31print "\nEnter the path to the version-control repository.\n";
32print "If you don't want version-control integration, leave blank.\n";
33print "Path to repository: ";
34my $repopath=<STDIN>;
35chomp($repopath);
36
37print STDERR "running trac-admin:\n";
38system(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
43open IN, '<.htaccess.in'; open OUT, '>.htaccess';
44while (<IN>) {
45    s/\@ADDREND\@/~$USER\/$addrend/g;
46    print OUT $_;
47}
48close IN; close OUT;
49
50my $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->newval('components', 'gitplugin.*', 'enabled') if $repotype eq "git";
55$cfg->RewriteConfig();
56
57system(qw(/usr/bin/trac-admin tracdata permission add), $human, 'TRAC_ADMIN');
58
59chmod 0777, '.htaccess';
60unlink '.htaccess.in';
61
62open OUT, '>tracdata/.htaccess';
63print OUT "Deny from all\n";
64close OUT;
65chmod 0777, 'tracdata/.htaccess';
66
67exit 0;
Note: See TracBrowser for help on using the repository browser.