source: locker/deploy/bin/trac @ 999

Last change on this file since 999 was 702, checked in by andersk, 17 years ago
Make trac work from all URLs.
  • Property svn:executable set to *
File size: 2.0 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->RewriteConfig();
55
56system(qw(/usr/bin/trac-admin tracdata permission add), $human, 'TRAC_ADMIN');
57
58chmod 0777, '.htaccess';
59unlink '.htaccess.in';
60
61open OUT, '>tracdata/.htaccess';
62print OUT 'Deny from all\n';
63close OUT;
64chmod 0777, 'tracdata/.htaccess';
65
66exit 0;
Note: See TracBrowser for help on using the repository browser.