summaryrefslogtreecommitdiff
path: root/FS/bin
diff options
context:
space:
mode:
authorivan <ivan>2006-12-14 09:27:26 +0000
committerivan <ivan>2006-12-14 09:27:26 +0000
commit7422aa77086326ba1e6032150ce5704d1003ea6f (patch)
tree9a69bc3c41f13a944198ae882933aa51cc9f6a5c /FS/bin
parentdcdf657e77ec7b46dc69e19a849a9c133123db7c (diff)
make the config directory configurable
Diffstat (limited to 'FS/bin')
-rw-r--r--FS/bin/freeside-addoutsource29
-rw-r--r--FS/bin/freeside-addoutsourceuser7
-rw-r--r--FS/bin/freeside-adduser2
-rw-r--r--FS/bin/freeside-deloutsource11
-rw-r--r--FS/bin/freeside-deloutsourceuser2
-rw-r--r--FS/bin/freeside-deluser2
-rw-r--r--FS/bin/freeside-queued2
-rw-r--r--FS/bin/freeside-selfservice-server5
-rwxr-xr-xFS/bin/freeside-setup3
-rw-r--r--FS/bin/freeside-sqlradius-radacctd2
-rwxr-xr-xFS/bin/freeside-upgrade50
11 files changed, 79 insertions, 36 deletions
diff --git a/FS/bin/freeside-addoutsource b/FS/bin/freeside-addoutsource
index 386e76315..8291c6434 100644
--- a/FS/bin/freeside-addoutsource
+++ b/FS/bin/freeside-addoutsource
@@ -2,24 +2,29 @@
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 && \
\
-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
diff --git a/FS/bin/freeside-addoutsourceuser b/FS/bin/freeside-addoutsourceuser
index 889d28adb..cbe792acc 100644
--- a/FS/bin/freeside-addoutsourceuser
+++ b/FS/bin/freeside-addoutsourceuser
@@ -4,16 +4,15 @@ username=$1
domain=$2
password=$3
realdomain=$4
-
+FREESIDE_CONF=%%%FREESIDE_CONF%%%
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 )
-# 2>/dev/null
freeside-adduser -g 1 $username
-htpasswd -b /usr/local/etc/freeside/htpasswd $username $password
+htpasswd -b $FREESIDE_CONF/htpasswd $username $password
diff --git a/FS/bin/freeside-adduser b/FS/bin/freeside-adduser
index a315f1082..237e29ef8 100644
--- a/FS/bin/freeside-adduser
+++ b/FS/bin/freeside-adduser
@@ -5,7 +5,7 @@ use vars qw($opt_s $opt_g $opt_n);
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;
diff --git a/FS/bin/freeside-deloutsource b/FS/bin/freeside-deloutsource
index 561853539..72aca048f 100644
--- a/FS/bin/freeside-deloutsource
+++ b/FS/bin/freeside-deloutsource
@@ -1,11 +1,12 @@
#!/bin/sh
domain=$1
+FREESIDE_CONF=%%%FREESIDE_CONF%%%
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
diff --git a/FS/bin/freeside-deloutsourceuser b/FS/bin/freeside-deloutsourceuser
index 96871e50c..dc4ff9cdc 100644
--- a/FS/bin/freeside-deloutsourceuser
+++ b/FS/bin/freeside-deloutsourceuser
@@ -2,5 +2,5 @@
username=$1
-freeside-deluser -h /usr/local/etc/freeside/htpasswd $username 2>/dev/null
+freeside-deluser -h %%%FREESIDE_CONF%%%/htpasswd $username 2>/dev/null
diff --git a/FS/bin/freeside-deluser b/FS/bin/freeside-deluser
index 57d6ce165..a2a361a83 100644
--- a/FS/bin/freeside-deluser
+++ b/FS/bin/freeside-deluser
@@ -5,7 +5,7 @@ use vars qw($opt_h);
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;
diff --git a/FS/bin/freeside-queued b/FS/bin/freeside-queued
index 9c2867963..d16513bdd 100644
--- a/FS/bin/freeside-queued
+++ b/FS/bin/freeside-queued
@@ -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();
diff --git a/FS/bin/freeside-selfservice-server b/FS/bin/freeside-selfservice-server
index 0ba97f6fb..fc04ee91e 100644
--- a/FS/bin/freeside-selfservice-server
+++ b/FS/bin/freeside-selfservice-server
@@ -18,6 +18,8 @@ use FS::Conf;
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
@@ -50,11 +52,10 @@ $ENV{HOME} = (getpwuid($>))[7]; #for ssh
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();
-
my $conf = new FS::Conf;
my $clientd = "/usr/local/sbin/freeside-selfservice-clientd"; #better name?
diff --git a/FS/bin/freeside-setup b/FS/bin/freeside-setup
index a51dfd7a0..ddc210f50 100755
--- a/FS/bin/freeside-setup
+++ b/FS/bin/freeside-setup
@@ -24,7 +24,7 @@ getopts("u:vd:");
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;
+
diff --git a/FS/bin/freeside-sqlradius-radacctd b/FS/bin/freeside-sqlradius-radacctd
index e98eaa015..bf415961c 100644
--- a/FS/bin/freeside-sqlradius-radacctd
+++ b/FS/bin/freeside-sqlradius-radacctd
@@ -23,7 +23,7 @@ drop_root();
adminsuidsetup $user;
-logfile( "/usr/local/etc/freeside/sqlradius-radacctd-log.". $FS::UID::datasrc );
+logfile( "%%%FREESIDE_CONF%%%/sqlradius-radacctd-log.". $FS::UID::datasrc );
daemonize2();
diff --git a/FS/bin/freeside-upgrade b/FS/bin/freeside-upgrade
index a1212ae98..3a4e4f8e3 100755
--- a/FS/bin/freeside-upgrade
+++ b/FS/bin/freeside-upgrade
@@ -1,23 +1,29 @@
#!/usr/bin/perl -w
use strict;
+use vars qw($opt_d $opt_q $opt_v);
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 );
-$DEBUG = 1;
-
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 $dbdef_file = "/usr/local/etc/freeside/dbdef.". datasrc;
+my $dbdef_file = "%%%FREESIDE_CONF%%%/dbdef.". datasrc;
dbdef_create($dbh, $dbdef_file);
@@ -26,7 +32,13 @@ reload_dbdef($dbdef_file);
$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;
@@ -43,7 +55,31 @@ sub dbdef_create { # reverse engineer the schema from the DB and save to file
}
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
+