source: branches/locker-dev/locker/deploy/bin/trac @ 1223

Last change on this file since 1223 was 1223, checked in by ezyang, 15 years ago
Merge scriptsdev changes from trunk (in practice, it should be the other way around).
  • Property svn:executable set to *
File size: 2.1 KB
Line 
1#!/usr/bin/perl
2use strict;
3use FindBin qw($Bin);
4use lib $Bin;
5use onserver;
6use Cwd;
7use File::Path;
8use URI::Escape;
9use DBI;
10use Config::IniFiles;
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
19my $dbh = DBI->connect("DBI:mysql:database=$sqldb;host=$sqlhost", $sqluser, $sqlpass, {RaiseError => 1});
20$dbh->do('alter database collate utf8_general_ci');
21
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),
40       $name, $dbstring, $repotype, $repopath, '/usr/share/trac/templates');
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>) {
46    s/\@ADDREND\@/~$USER\/$addrend/g;
47    print OUT $_;
48}
49close IN; close OUT;
50
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');
55$cfg->newval('components', 'gitplugin.*', 'enabled') if $repotype eq "git";
56$cfg->RewriteConfig();
57
58system(qw(/usr/bin/trac-admin tracdata permission add), $human, 'TRAC_ADMIN');
59
60chmod 0777, '.htaccess';
61unlink '.htaccess.in';
62
63open OUT, '>tracdata/.htaccess';
64print OUT "Deny from all\n";
65close OUT;
66chmod 0777, 'tracdata/.htaccess';
67
68exit 0;
Note: See TracBrowser for help on using the repository browser.