make the config directory configurable
authorivan <ivan>
Thu, 14 Dec 2006 09:27:26 +0000 (09:27 +0000)
committerivan <ivan>
Thu, 14 Dec 2006 09:27:26 +0000 (09:27 +0000)
19 files changed:
FS/FS/Conf.pm
FS/FS/UID.pm
FS/FS/access_user.pm
FS/FS/part_export/vpopmail.pm
FS/bin/freeside-addoutsource
FS/bin/freeside-addoutsourceuser
FS/bin/freeside-adduser
FS/bin/freeside-deloutsource
FS/bin/freeside-deloutsourceuser
FS/bin/freeside-deluser
FS/bin/freeside-queued
FS/bin/freeside-selfservice-server
FS/bin/freeside-setup
FS/bin/freeside-sqlradius-radacctd
FS/bin/freeside-upgrade
Makefile
bin/dbdef-create
bin/mapsecrets2access_user
htetc/handler.pl

index 566d8e8..270b61c 100644 (file)
@@ -1,11 +1,15 @@
 package FS::Conf;
 
 package FS::Conf;
 
-use vars qw($default_dir @config_items @card_types $DEBUG );
+use vars qw($default_dir $base_dir @config_items @card_types $DEBUG );
 use IO::File;
 use File::Basename;
 use FS::ConfItem;
 use FS::ConfDefaults;
 
 use IO::File;
 use File::Basename;
 use FS::ConfItem;
 use FS::ConfDefaults;
 
+$base_dir = '%%%FREESIDE_CONF%%%';
+$default_dir = '%%%FREESIDE_CONF%%%';
+
+
 $DEBUG = 0;
 
 =head1 NAME
 $DEBUG = 0;
 
 =head1 NAME
@@ -52,13 +56,15 @@ $FS::Conf::default_dir has not been set.
 sub new {
   my($proto,$dir) = @_;
   my($class) = ref($proto) || $proto;
 sub new {
   my($proto,$dir) = @_;
   my($class) = ref($proto) || $proto;
-  my($self) = { 'dir' => $dir || $default_dir } ;
+  my($self) = { 'dir'      => $dir || $default_dir,
+                'base_dir' => $base_dir,
+              };
   bless ($self, $class);
 }
 
 =item dir
 
   bless ($self, $class);
 }
 
 =item dir
 
-Returns the directory.
+Returns the conf directory.
 
 =cut
 
 
 =cut
 
@@ -73,6 +79,23 @@ sub dir {
   $1;
 }
 
   $1;
 }
 
+=item base_dir
+
+Returns the base directory.  By default this is /usr/local/etc/freeside.
+
+=cut
+
+sub base_dir {
+  my($self) = @_;
+  my $base_dir = $self->{base_dir};
+  -e $base_dir or die "FATAL: $base_dir doesn't exist!";
+  -d $base_dir or die "FATAL: $base_dir isn't a directory!";
+  -r $base_dir or die "FATAL: Can't read $base_dir!";
+  -x $base_dir or die "FATAL: $base_dir not searchable (executable)!";
+  $base_dir =~ /^(.*)$/;
+  $1;
+}
+
 =item config KEY
 
 Returns the configuration value or values (depending on context) for key.
 =item config KEY
 
 Returns the configuration value or values (depending on context) for key.
index eb703d3..8dd928e 100644 (file)
@@ -21,7 +21,7 @@ use FS::CurrentUser;
 
 $freeside_uid = scalar(getpwnam('freeside'));
 
 
 $freeside_uid = scalar(getpwnam('freeside'));
 
-$conf_dir = "/usr/local/etc/freeside/";
+$conf_dir = "%%%FREESIDE_CONF%%%/";
 
 $AutoCommit = 1; #ours, not DBI
 
 
 $AutoCommit = 1; #ours, not DBI
 
@@ -99,7 +99,7 @@ sub forksuidsetup {
   }
 
   use FS::Schema qw(reload_dbdef);
   }
 
   use FS::Schema qw(reload_dbdef);
-  reload_dbdef("/usr/local/etc/freeside/dbdef.$datasrc")
+  reload_dbdef("$conf_dir/dbdef.$datasrc")
     unless $FS::Schema::setup_hack;
 
   FS::CurrentUser->load_user($user);
     unless $FS::Schema::setup_hack;
 
   FS::CurrentUser->load_user($user);
index 7529354..f45f17d 100644 (file)
@@ -2,6 +2,8 @@ package FS::access_user;
 
 use strict;
 use vars qw( @ISA $htpasswd_file );
 
 use strict;
 use vars qw( @ISA $htpasswd_file );
+use FS::UID;
+use FS::Conf;
 use FS::Record qw( qsearch qsearchs dbh );
 use FS::m2m_Common;
 use FS::access_usergroup;
 use FS::Record qw( qsearch qsearchs dbh );
 use FS::m2m_Common;
 use FS::access_usergroup;
@@ -9,8 +11,11 @@ use FS::agent;
 
 @ISA = qw( FS::m2m_Common FS::Record );
 
 
 @ISA = qw( FS::m2m_Common FS::Record );
 
-#kludge htpasswd for now
-$htpasswd_file = '/usr/local/etc/freeside/htpasswd';
+#kludge htpasswd for now (i hope this bootstraps okay)
+FS::UID->install_callback( sub {
+  my $conf = new FS::Conf;
+  $htpasswd_file = $conf->base_dir. '/htpasswd';
+} );
 
 =head1 NAME
 
 
 =head1 NAME
 
@@ -90,10 +95,13 @@ sub insert {
   local $FS::UID::AutoCommit = 0;
   my $dbh = dbh;
 
   local $FS::UID::AutoCommit = 0;
   my $dbh = dbh;
 
-  my $error =
-       $self->SUPER::insert(@_)
-    || $self->htpasswd_kludge()
-  ;
+  my $error = $self->htpasswd_kludge();
+  if ( $error ) {
+    $dbh->rollback or die $dbh->errstr if $oldAutoCommit;
+    return $error;
+  }
+
+  $error = $self->SUPER::insert(@_);
 
   if ( $error ) {
     $dbh->rollback or die $dbh->errstr if $oldAutoCommit;
 
   if ( $error ) {
     $dbh->rollback or die $dbh->errstr if $oldAutoCommit;
@@ -126,7 +134,6 @@ sub htpasswd_kludge {
   }
 }
 
   }
 }
 
-
 =item delete
 
 Delete this record from the database.
 =item delete
 
 Delete this record from the database.
@@ -183,10 +190,13 @@ sub replace {
   local $FS::UID::AutoCommit = 0;
   my $dbh = dbh;
 
   local $FS::UID::AutoCommit = 0;
   my $dbh = dbh;
 
-  my $error =
-       $new->SUPER::replace($old, @_)
-    || $new->htpasswd_kludge()
-  ;
+  my $error = $new->htpasswd_kludge();
+  if ( $error ) {
+    $dbh->rollback or die $dbh->errstr if $oldAutoCommit;
+    return $error;
+  }
+
+  $error = $new->SUPER::replace($old, @_);
 
   if ( $error ) {
     $dbh->rollback or die $dbh->errstr if $oldAutoCommit;
 
   if ( $error ) {
     $dbh->rollback or die $dbh->errstr if $oldAutoCommit;
index 0fc8266..bf558e3 100644 (file)
@@ -87,7 +87,7 @@ sub _export_delete {
 sub vpopmail_queue {
   my( $self, $svcnum, $method ) = (shift, shift, shift);
 
 sub vpopmail_queue {
   my( $self, $svcnum, $method ) = (shift, shift, shift);
 
-  my $exportdir = "/usr/local/etc/freeside/export." . datasrc;
+  my $exportdir = "%%%FREESIDE_CONF%%%/export." . datasrc;
   mkdir $exportdir, 0700 or die $! unless -d $exportdir;
   $exportdir .= "/vpopmail";
   mkdir $exportdir, 0700 or die $! unless -d $exportdir;
   mkdir $exportdir, 0700 or die $! unless -d $exportdir;
   $exportdir .= "/vpopmail";
   mkdir $exportdir, 0700 or die $! unless -d $exportdir;
index 386e763..8291c64 100644 (file)
@@ -2,24 +2,29 @@
 
 domain=$1
 
 
 domain=$1
 
+FREESIDE_CONF=%%%FREESIDE_CONF%%%
+
+#without this, [a-z]* matches CVS/, the copy doesn't return a sucessful error
+# status, and the rest of the commands aren't run
+export LANG=C
+
 createdb $domain && \
 \
 createdb $domain && \
 \
-mkdir /usr/local/etc/freeside/conf.DBI:Pg:dbname=$domain && \
+mkdir $FREESIDE_CONF/conf.DBI:Pg:dbname=$domain && \
 \
 \
-chown freeside /usr/local/etc/freeside/conf.DBI:Pg:dbname=$domain && \
+chown freeside $FREESIDE_CONF/conf.DBI:Pg:dbname=$domain && \
 \
 \
-cp /home/ivan/freeside/conf/[a-z]* /usr/local/etc/freeside/conf.DBI:Pg:dbname=$domain
-
-
-touch /usr/local/etc/freeside/conf.DBI:Pg:dbname=$domain/secrets && \
+cp /home/ivan/freeside/conf/[a-z]* $FREESIDE_CONF/conf.DBI:Pg:dbname=$domain && \
+\
+touch $FREESIDE_CONF/conf.DBI:Pg:dbname=$domain/secrets && \
 \
 \
-chown freeside /usr/local/etc/freeside/conf.DBI:Pg:dbname=$domain/secrets && \
+chown freeside $FREESIDE_CONF/conf.DBI:Pg:dbname=$domain/secrets && \
 \
 \
-chmod 600 /usr/local/etc/freeside/conf.DBI:Pg:dbname=$domain/secrets && \
+chmod 600 $FREESIDE_CONF/conf.DBI:Pg:dbname=$domain/secrets && \
 \
 \
-echo -e "DBI:Pg:dbname=$domain\nfreeside\n" >/usr/local/etc/freeside/conf.DBI:Pg:dbname=$domain/secrets && \
+echo -e "DBI:Pg:dbname=$domain\nfreeside\n" >$FREESIDE_CONF/conf.DBI:Pg:dbname=$domain/secrets && \
 \
 \
-mkdir /usr/local/etc/freeside/counters.DBI:Pg:dbname=$domain && \
-mkdir /usr/local/etc/freeside/cache.DBI:Pg:dbname=$domain && \
-mkdir /usr/local/etc/freeside/export.DBI:Pg:dbname=$domain
+mkdir $FREESIDE_CONF/counters.DBI:Pg:dbname=$domain && \
+mkdir $FREESIDE_CONF/cache.DBI:Pg:dbname=$domain && \
+mkdir $FREESIDE_CONF/export.DBI:Pg:dbname=$domain
 
 
index 889d28a..cbe792a 100644 (file)
@@ -4,16 +4,15 @@ username=$1
 domain=$2
 password=$3
 realdomain=$4
 domain=$2
 password=$3
 realdomain=$4
-
+FREESIDE_CONF=%%%FREESIDE_CONF%%%
 
 freeside-adduser -s conf.DBI:Pg:dbname=$domain/secrets \
                  -n \
                  $username #2>/dev/null
 
 
 freeside-adduser -s conf.DBI:Pg:dbname=$domain/secrets \
                  -n \
                  $username #2>/dev/null
 
-[ -e /usr/local/etc/freeside/dbdef.DBI:Pg:dbname=$domain ] \
+[ -e $FREESIDE_CONF/dbdef.DBI:Pg:dbname=$domain ] \
  || ( freeside-setup -d $realdomain -u $username )
  || ( freeside-setup -d $realdomain -u $username )
-# 2>/dev/null
 
 freeside-adduser -g 1 $username
 
 
 freeside-adduser -g 1 $username
 
-htpasswd -b /usr/local/etc/freeside/htpasswd $username $password
+htpasswd -b $FREESIDE_CONF/htpasswd $username $password
index a315f10..237e29e 100644 (file)
@@ -5,7 +5,7 @@ use vars qw($opt_s $opt_g $opt_n);
 use Fcntl qw(:flock);
 use Getopt::Std;
 
 use Fcntl qw(:flock);
 use Getopt::Std;
 
-my $FREESIDE_CONF = "/usr/local/etc/freeside";
+my $FREESIDE_CONF = "%%%FREESIDE_CONF%%%";
 
 getopts("s:g:n");
 my $user = shift or die &usage;
 
 getopts("s:g:n");
 my $user = shift or die &usage;
index 5618535..72aca04 100644 (file)
@@ -1,11 +1,12 @@
 #!/bin/sh
 
 domain=$1
 #!/bin/sh
 
 domain=$1
+FREESIDE_CONF=%%%FREESIDE_CONF%%%
 
 dropdb $domain && \
 
 dropdb $domain && \
-rm -rf /usr/local/etc/freeside/conf.DBI:Pg:host=localhost\;dbname=$domain && \
-rm -rf /usr/local/etc/freeside/counters.DBI:Pg:host=localhost\;dbname=$domain && \
-rm -rf /usr/local/etc/freeside/cache.DBI:Pg:host=localhost\;dbname=$domain && \
-rm -rf /usr/local/etc/freeside/export.DBI:Pg:host=localhost\;dbname=$domain && \
-rm /usr/local/etc/freeside/dbdef.DBI:Pg:host=localhost\;dbname=$domain
+rm -rf $FREESIDE_CONF/conf.DBI:Pg:host=localhost\;dbname=$domain && \
+rm -rf $FREESIDE_CONF/counters.DBI:Pg:host=localhost\;dbname=$domain && \
+rm -rf $FREESIDE_CONF/cache.DBI:Pg:host=localhost\;dbname=$domain && \
+rm -rf $FREESIDE_CONF/export.DBI:Pg:host=localhost\;dbname=$domain && \
+rm $FREESIDE_CONF/dbdef.DBI:Pg:host=localhost\;dbname=$domain
 
 
index 96871e5..dc4ff9c 100644 (file)
@@ -2,5 +2,5 @@
 
 username=$1
 
 
 username=$1
 
-freeside-deluser -h /usr/local/etc/freeside/htpasswd $username 2>/dev/null
+freeside-deluser -h %%%FREESIDE_CONF%%%/htpasswd $username 2>/dev/null
 
 
index 57d6ce1..a2a361a 100644 (file)
@@ -5,7 +5,7 @@ use vars qw($opt_h);
 use Fcntl qw(:flock);
 use Getopt::Std;
 
 use Fcntl qw(:flock);
 use Getopt::Std;
 
-my $FREESIDE_CONF = "/usr/local/etc/freeside";
+my $FREESIDE_CONF = "%%%FREESIDE_CONF%%%";
 
 getopts("h:");
 my $user = shift or die &usage;
 
 getopts("h:");
 my $user = shift or die &usage;
index 9c28679..d16513b 100644 (file)
@@ -41,7 +41,7 @@ while ( $@ ) {
   }
 }
 
   }
 }
 
-logfile( "/usr/local/etc/freeside/queuelog.". $FS::UID::datasrc );
+logfile( "%%%FREESIDE_CONF%%%/queuelog.". $FS::UID::datasrc );
 
 warn "completing daemonization (detaching))\n" if $DEBUG;
 daemonize2();
 
 warn "completing daemonization (detaching))\n" if $DEBUG;
 daemonize2();
index 0ba97f6..fc04ee9 100644 (file)
@@ -18,6 +18,8 @@ use FS::Conf;
 use FS::cust_bill;
 use FS::cust_pkg;
 
 use FS::cust_bill;
 use FS::cust_pkg;
 
+$FREESIDE_CONF = "%%%FREESIDE_CONF%%%";
+
 $Debug = 1; # 2 will turn on more logging
             # 3 will log packet contents, including passwords
 
 $Debug = 1; # 2 will turn on more logging
             # 3 will log packet contents, including passwords
 
@@ -50,11 +52,10 @@ $ENV{HOME} = (getpwuid($>))[7]; #for ssh
 adminsuidsetup $user;
 
 #logfile("/usr/local/etc/freeside/selfservice.". $FS::UID::datasrc); #MACHINE
 adminsuidsetup $user;
 
 #logfile("/usr/local/etc/freeside/selfservice.". $FS::UID::datasrc); #MACHINE
-logfile("/usr/local/etc/freeside/selfservice.$machine.log");
+logfile("$FREESIDE_SERVER/selfservice.$machine.log");
 
 daemonize2();
 
 
 daemonize2();
 
-
 my $conf = new FS::Conf;
 
 my $clientd = "/usr/local/sbin/freeside-selfservice-clientd"; #better name?
 my $conf = new FS::Conf;
 
 my $clientd = "/usr/local/sbin/freeside-selfservice-clientd"; #better name?
index a51dfd7..ddc210f 100755 (executable)
@@ -24,7 +24,7 @@ getopts("u:vd:");
 getsecrets($opt_u); #$user);
 
 #needs to match FS::Record
 getsecrets($opt_u); #$user);
 
 #needs to match FS::Record
-my($dbdef_file) = "/usr/local/etc/freeside/dbdef.". datasrc;
+my($dbdef_file) = "%%%FREESIDE_CONF%%%/dbdef.". datasrc;
 
 ###
 
 
 ###
 
@@ -127,3 +127,4 @@ sub usage {
 
 1;
 
 
 1;
 
+
index e98eaa0..bf41596 100644 (file)
@@ -23,7 +23,7 @@ drop_root();
 
 adminsuidsetup $user;
 
 
 adminsuidsetup $user;
 
-logfile( "/usr/local/etc/freeside/sqlradius-radacctd-log.". $FS::UID::datasrc );
+logfile( "%%%FREESIDE_CONF%%%/sqlradius-radacctd-log.". $FS::UID::datasrc );
 
 daemonize2();
 
 
 daemonize2();
 
index a1212ae..3a4e4f8 100755 (executable)
@@ -1,23 +1,29 @@
 #!/usr/bin/perl -w
 
 use strict;
 #!/usr/bin/perl -w
 
 use strict;
+use vars qw($opt_d $opt_q $opt_v);
 use vars qw($DEBUG $DRY_RUN);
 use vars qw($DEBUG $DRY_RUN);
-use Term::ReadKey;
+use Getopt::Std;
 use DBIx::DBSchema 0.31;
 use FS::UID qw(adminsuidsetup checkeuid datasrc );  #getsecrets);
 use FS::CurrentUser;
 use FS::Schema qw( dbdef dbdef_dist reload_dbdef );
 
 use DBIx::DBSchema 0.31;
 use FS::UID qw(adminsuidsetup checkeuid datasrc );  #getsecrets);
 use FS::CurrentUser;
 use FS::Schema qw( dbdef dbdef_dist reload_dbdef );
 
-$DEBUG = 1;
-
 die "Not running uid freeside!" unless checkeuid();
 
 die "Not running uid freeside!" unless checkeuid();
 
+getopts("dq");
+
+$DEBUG = !$opt_q;
+#$DEBUG = $opt_v;
+
+$DRY_RUN = $opt_d;
+
 my $user = shift or die &usage;
 $FS::CurrentUser::upgrade_hack = 1;
 my $dbh = adminsuidsetup($user);
 
 #needs to match FS::Schema...
 my $user = shift or die &usage;
 $FS::CurrentUser::upgrade_hack = 1;
 my $dbh = adminsuidsetup($user);
 
 #needs to match FS::Schema...
-my $dbdef_file = "/usr/local/etc/freeside/dbdef.". datasrc;
+my $dbdef_file = "%%%FREESIDE_CONF%%%/dbdef.". datasrc;
 
 dbdef_create($dbh, $dbdef_file);
 
 
 dbdef_create($dbh, $dbdef_file);
 
@@ -26,7 +32,13 @@ reload_dbdef($dbdef_file);
 
 $DBIx::DBSchema::DEBUG = $DEBUG;
 $DBIx::DBSchema::Table::DEBUG = $DEBUG;
 
 $DBIx::DBSchema::DEBUG = $DEBUG;
 $DBIx::DBSchema::Table::DEBUG = $DEBUG;
-dbdef->update_schema( dbdef_dist, $dbh );
+
+if ( $DRY_RUN ) {
+  print join(";\n", dbdef->sql_update_schema( dbdef_dist, $dbh ) ). ";\n";
+  exit;
+} else {
+  dbdef->update_schema( dbdef_dist, $dbh );
+}
 
 $dbh->commit or die $dbh->errstr;
 
 
 $dbh->commit or die $dbh->errstr;
 
@@ -43,7 +55,31 @@ sub dbdef_create { # reverse engineer the schema from the DB and save to file
 }
 
 sub usage {
 }
 
 sub usage {
-  die "Usage:\n  freeside-upgrade user\n"; 
+  die "Usage:\n  freeside-upgrade [ -d ] [ -q | -v ] user\n"; 
 }
 
 }
 
-1;
+=head1 NAME
+
+freeside-upgrade - Upgrades database schema for new freeside verisons.
+
+=head1 SYNOPSIS
+
+  freeside-adduser [ -d ] [ -q | -v ]
+
+=head1 DESCRIPTION
+
+Reads your existing database schema and updates it to match the current schema,
+adding any columns or tables necessary.
+
+  [ -d ]: Dry run; output SQL statements (to STDOUT) only, but do not execute
+          them.
+
+  [ -q ]: Run quietly.  This may become the default at some point.
+
+  [ -v ]: Run verbosely, sending debugging information to STDERR.  This is the
+          current default.
+
+=head1 SEE ALSO
+
+=cut
+
index 85e9e92..c9a3e67 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -9,10 +9,13 @@ DATASOURCE = DBI:Pg:dbname=freeside
 DB_USER = freeside
 DB_PASSWORD=
 
 DB_USER = freeside
 DB_PASSWORD=
 
+#changable now
+FREESIDE_CONF = /usr/local/etc/freeside
+
 TEMPLATE = mason
 
 TEMPLATE = mason
 
-MASON_HANDLER = /usr/local/etc/freeside/handler.pl
-MASONDATA = /usr/local/etc/freeside/masondata
+MASON_HANDLER = ${FREESIDE_CONF}/handler.pl
+MASONDATA = ${FREESIDE_CONF}/masondata
 
 #deb
 FREESIDE_DOCUMENT_ROOT = /var/www/freeside
 
 #deb
 FREESIDE_DOCUMENT_ROOT = /var/www/freeside
@@ -89,8 +92,7 @@ RT_DB_DATABASE = freeside
 
 #---
 
 
 #---
 
-#not changable yet
-FREESIDE_CONF = /usr/local/etc/freeside
+
 #rt/config.layout.in
 RT_PATH = /opt/rt3
 
 #rt/config.layout.in
 RT_PATH = /opt/rt3
 
@@ -153,11 +155,13 @@ forcehtmlman:
 install-docs: docs
        [ -e ${FREESIDE_DOCUMENT_ROOT} ] && mv ${FREESIDE_DOCUMENT_ROOT} ${FREESIDE_DOCUMENT_ROOT}.`date +%Y%m%d%H%M%S` || true
        cp -r ${TEMPLATE}docs ${FREESIDE_DOCUMENT_ROOT}
 install-docs: docs
        [ -e ${FREESIDE_DOCUMENT_ROOT} ] && mv ${FREESIDE_DOCUMENT_ROOT} ${FREESIDE_DOCUMENT_ROOT}.`date +%Y%m%d%H%M%S` || true
        cp -r ${TEMPLATE}docs ${FREESIDE_DOCUMENT_ROOT}
+       chown -R freeside:freeside ${FREESIDE_DOCUMENT_ROOT}
        cp htetc/handler.pl ${MASON_HANDLER}
        cp htetc/handler.pl ${MASON_HANDLER}
-       perl -p -i -e "\
-         s'%%%FREESIDE_DOCUMENT_ROOT%%%'${FREESIDE_DOCUMENT_ROOT}'g; \
-         s'%%%RT_ENABLED%%%'${RT_ENABLED}'g; \
-       " ${MASON_HANDLER}
+         perl -p -i -e "\
+           s'%%%FREESIDE_DOCUMENT_ROOT%%%'${FREESIDE_DOCUMENT_ROOT}'g; \
+           s'%%%RT_ENABLED%%%'${RT_ENABLED}'g; \
+           s'%%%FREESIDE_CONF%%%'${FREESIDE_CONF}'g;\
+         " ${MASON_HANDLER}
        [ ! -e ${MASONDATA} ] && mkdir ${MASONDATA} || true
        chown -R freeside ${MASONDATA}
 
        [ ! -e ${MASONDATA} ] && mkdir ${MASONDATA} || true
        chown -R freeside ${MASONDATA}
 
@@ -179,7 +183,17 @@ perl-modules:
        make; \
        perl -p -i -e "\
          s/%%%VERSION%%%/${VERSION}/g;\
        make; \
        perl -p -i -e "\
          s/%%%VERSION%%%/${VERSION}/g;\
-       " blib/lib/FS.pm; \
+         s|%%%FREESIDE_CONF%%%|${FREESIDE_CONF}|g;\
+       " blib/lib/FS.pm;\
+       perl -p -i -e "\
+         s|%%%FREESIDE_CONF%%%|${FREESIDE_CONF}|g;\
+       " blib/lib/FS/*.pm;\
+       perl -p -i -e "\
+         s|%%%FREESIDE_CONF%%%|${FREESIDE_CONF}|g;\
+       " blib/lib/FS/part_export/*.pm;\
+       perl -p -i -e "\
+         s|%%%FREESIDE_CONF%%%|${FREESIDE_CONF}|g;\
+       " blib/script/*
 
 install-perl-modules: perl-modules
        [ -L ${PERL_INC_DEV_KLUDGE}/FS ] \
 
 install-perl-modules: perl-modules
        [ -L ${PERL_INC_DEV_KLUDGE}/FS ] \
@@ -213,6 +227,7 @@ install-apache:
            ( [ ${RT_ENABLED} -eq 1 ] && install -o root -m 755 htetc/freeside-rt.conf ${APACHE_CONF} || true ) && \
            perl -p -i -e "\
              s'%%%FREESIDE_DOCUMENT_ROOT%%%'${FREESIDE_DOCUMENT_ROOT}'g; \
            ( [ ${RT_ENABLED} -eq 1 ] && install -o root -m 755 htetc/freeside-rt.conf ${APACHE_CONF} || true ) && \
            perl -p -i -e "\
              s'%%%FREESIDE_DOCUMENT_ROOT%%%'${FREESIDE_DOCUMENT_ROOT}'g; \
+             s'%%%FREESIDE_CONF%%%'${FREESIDE_CONF}'g; \
            " ${APACHE_CONF}/freeside-*.conf \
          ) || true
 
            " ${APACHE_CONF}/freeside-*.conf \
          ) || true
 
index 2283b53..5063a3c 100755 (executable)
@@ -13,7 +13,7 @@ $FS::CurrentUser::upgrade_hack = 1;
 my($dbh)=adminsuidsetup $user;
 
 #needs to match FS::Record
 my($dbh)=adminsuidsetup $user;
 
 #needs to match FS::Record
-my($dbdef_file) = "/usr/local/etc/freeside/dbdef.". datasrc;
+my($dbdef_file) = "%%%FREESIDE_CONF%%%/dbdef.". datasrc;
 
 my $dbdef = new_native DBIx::DBSchema $dbh;
 
 
 my $dbdef = new_native DBIx::DBSchema $dbh;
 
index 4efd90b..945f130 100755 (executable)
@@ -46,8 +46,10 @@ unless ( $supergroup ) {
 }
 my $supergroupnum = $supergroup->groupnum;
 
 }
 my $supergroupnum = $supergroup->groupnum;
 
-my $mapsecrets = '/usr/local/etc/freeside/mapsecrets';
-open(MAPSECRETS, "<$mapsecrets") or die $!;
+my $conf = new FS::Conf;
+my $dir = $conf->base_dir;
+my $mapsecrets = "$dir/mapsecrets";
+open(MAPSECRETS, "<$mapsecrets") or die "Can't open $mapsecrets: $!";
 while (<MAPSECRETS>) {
   /([\w]+)\s+secrets\s*$/ or die "unparsable line in mapsecrets: $_";
   my $username = $1;
 while (<MAPSECRETS>) {
   /([\w]+)\s+secrets\s*$/ or die "unparsable line in mapsecrets: $_";
   my $username = $1;
index 89287d7..3f3886b 100644 (file)
@@ -60,7 +60,7 @@ my $ah = new HTML::Mason::ApacheHandler (
                 [ 'freeside' => '%%%FREESIDE_DOCUMENT_ROOT%%%'    ],
                 [ 'rt'       => '%%%FREESIDE_DOCUMENT_ROOT%%%/rt' ],
               ],
                 [ 'freeside' => '%%%FREESIDE_DOCUMENT_ROOT%%%'    ],
                 [ 'rt'       => '%%%FREESIDE_DOCUMENT_ROOT%%%/rt' ],
               ],
-  data_dir=>'/usr/local/etc/freeside/masondata',
+  data_dir=>'%%%FREESIDE_CONF%%%/masondata',
   #out_mode=>'stream',
 
   #RT
   #out_mode=>'stream',
 
   #RT