Remove debugging from recovery.cgi
[blerg.git] / scripts / write-environment-configs.pl
1 #!/usr/bin/perl
2 use Cwd qw/abs_path/;
3 use strict;
4
5 my $ENV_DIR = shift;
6 if (!defined $ENV_DIR) {
7     die "Please specify an environment directory to write configs into\n";
8 }
9 $ENV_DIR = abs_path($ENV_DIR);
10
11 # Shell
12 open C, '>', "$ENV_DIR/etc/env.sh";
13 print C <<EOD;
14 if [ -z "\$PATH" ]; then
15     PATH="$ENV_DIR/bin"
16 else
17     PATH="\$PATH:$ENV_DIR/bin"
18 fi
19 export PATH
20
21 if [ -z "\$PERL5LIB" ]; then
22     PERL5LIB="$ENV_DIR/lib/perl5"
23 else
24     PERL5LIB="\$PERL5LIB:$ENV_DIR/lib/perl5"
25 fi
26 export PERL5LIB
27
28 BLERG_HOME="$ENV_DIR"
29 export BLERG_HOME
30
31 BLERG_PATH="\$BLERG_HOME/data"
32 export BLERG_PATH
33 EOD
34 close C;
35
36 # nginx FastCGI params
37 open C, '>', "$ENV_DIR/etc/nginx-fastcgi-vars.conf";
38 print C <<EOD;
39 fastcgi_param BLERG_HOME "$ENV_DIR";
40 fastcgi_param BLERG_PATH "$ENV_DIR/data";
41 fastcgi_param PERL5LIB "$ENV_DIR/lib/perl5";
42 EOD
43 close C;
44
45 # Apache SetEnv
46 open C, '>', "$ENV_DIR/etc/apache-setenv.conf";
47 print C <<EOD;
48 SetEnv BLERG_HOME "$ENV_DIR"
49 SetEnv BLERG_PATH "$ENV_DIR/data"
50 SetEnv PERL5LIB "$ENV_DIR/lib/perl5"
51 EOD
52 close C;