summaryrefslogtreecommitdiff
path: root/FS/bin
diff options
context:
space:
mode:
Diffstat (limited to 'FS/bin')
-rwxr-xr-xFS/bin/freeside-addgroup50
-rw-r--r--FS/bin/freeside-addoutsource32
-rw-r--r--FS/bin/freeside-addoutsourceuser18
-rw-r--r--FS/bin/freeside-adduser119
-rwxr-xr-xFS/bin/freeside-apply-credits21
-rwxr-xr-xFS/bin/freeside-count-active-customers17
-rwxr-xr-xFS/bin/freeside-daily104
-rwxr-xr-xFS/bin/freeside-dbdef-create47
-rwxr-xr-xFS/bin/freeside-delete-addr_blocks31
-rw-r--r--FS/bin/freeside-deloutsource14
-rw-r--r--FS/bin/freeside-deloutsourceuser6
-rw-r--r--FS/bin/freeside-deluser64
-rwxr-xr-xFS/bin/freeside-disable-reasons64
-rwxr-xr-xFS/bin/freeside-email55
-rwxr-xr-xFS/bin/freeside-expiration-alerter226
-rwxr-xr-xFS/bin/freeside-fetch89
-rwxr-xr-xFS/bin/freeside-history-requeue100
-rwxr-xr-xFS/bin/freeside-init-config45
-rwxr-xr-xFS/bin/freeside-monthly91
-rw-r--r--FS/bin/freeside-prepaidd106
-rwxr-xr-xFS/bin/freeside-prune-applications63
-rw-r--r--FS/bin/freeside-queued250
-rw-r--r--FS/bin/freeside-radgroup76
-rw-r--r--FS/bin/freeside-reexport71
-rwxr-xr-xFS/bin/freeside-reset-fixed69
-rw-r--r--FS/bin/freeside-selfservice-server240
-rw-r--r--FS/bin/freeside-setinvoice42
-rwxr-xr-xFS/bin/freeside-setup160
-rwxr-xr-xFS/bin/freeside-sqlradius-dedup-group82
-rw-r--r--FS/bin/freeside-sqlradius-radacctd150
-rwxr-xr-xFS/bin/freeside-sqlradius-reset104
-rw-r--r--FS/bin/freeside-sqlradius-seconds58
-rwxr-xr-xFS/bin/freeside-sqlradius-set-lastlog102
-rwxr-xr-xFS/bin/freeside-upgrade175
34 files changed, 0 insertions, 2941 deletions
diff --git a/FS/bin/freeside-addgroup b/FS/bin/freeside-addgroup
deleted file mode 100755
index 7b30f7d95..000000000
--- a/FS/bin/freeside-addgroup
+++ /dev/null
@@ -1,50 +0,0 @@
-#!/usr/bin/perl
-
-use strict;
-use vars qw($opt_s);
-use Getopt::Std;
-use FS::UID qw(adminsuidsetup);
-use FS::Record qw(qsearch);
-use FS::CurrentUser;
-use FS::AccessRight;
-use FS::access_group;
-use FS::access_right;
-use FS::access_groupagent;
-
-getopts("s");
-my $user = shift or die &usage; #just for adminsuidsetup
-my $group = shift or die &usage;
-
-$FS::CurrentUser::upgrade_hack = 1;
-#adminsuidsetup $rootuser;
-adminsuidsetup $user;
-
-my $access_group = new FS::access_group { 'groupname' => $group };
-my $error = $access_group->insert;
-die $error if $error;
-
-if ( $opt_s ) {
- foreach my $rightname ( FS::AccessRight->rights ) {
- my $access_right = new FS::access_right {
- 'righttype' => 'FS::access_group',
- 'rightobjnum' => $access_group->groupnum,
- 'rightname' => $rightname,
- };
- my $ar_error = $access_right->insert;
- die $ar_error if $ar_error;
- }
-
- foreach my $agent ( qsearch('agent', {} ) ) {
- my $access_groupagent = new FS::access_groupagent {
- 'groupnum' => $access_group->groupnum,
- 'agentnum' => $agent->agentnum,
- };
- my $aga_error = $access_groupagent->insert;
- die $aga_error if $aga_error;
- }
-}
-
-sub usage {
- die "Usage:\n\n freeside-addgroup [ -s ] username groupname"
-}
-
diff --git a/FS/bin/freeside-addoutsource b/FS/bin/freeside-addoutsource
deleted file mode 100644
index 9cb12195a..000000000
--- a/FS/bin/freeside-addoutsource
+++ /dev/null
@@ -1,32 +0,0 @@
-#!/bin/sh
-
-domain=$1
-
-FREESIDE_CONF=%%%FREESIDE_CONF%%%
-FREESIDE_CACHE=%%%FREESIDE_CACHE%%%
-FREESIDE_EXPORT=%%%FREESIDE_EXPORT%%%
-
-#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 $FREESIDE_CONF/conf.DBI:Pg:dbname=$domain && \
-\
-chown freeside $FREESIDE_CONF/conf.DBI:Pg:dbname=$domain && \
-\
-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 $FREESIDE_CONF/conf.DBI:Pg:dbname=$domain/secrets && \
-\
-chmod 600 $FREESIDE_CONF/conf.DBI:Pg:dbname=$domain/secrets && \
-\
-echo -e "DBI:Pg:dbname=$domain\nfreeside\n" >$FREESIDE_CONF/conf.DBI:Pg:dbname=$domain/secrets && \
-\
-mkdir $FREESIDE_CACHE/counters.DBI:Pg:dbname=$domain && \
-mkdir $FREESIDE_CACHE/cache.DBI:Pg:dbname=$domain && \
-mkdir $FREESIDE_EXPORT/export.DBI:Pg:dbname=$domain
-
diff --git a/FS/bin/freeside-addoutsourceuser b/FS/bin/freeside-addoutsourceuser
deleted file mode 100644
index cbe792acc..000000000
--- a/FS/bin/freeside-addoutsourceuser
+++ /dev/null
@@ -1,18 +0,0 @@
-#!/bin/sh
-
-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 $FREESIDE_CONF/dbdef.DBI:Pg:dbname=$domain ] \
- || ( freeside-setup -d $realdomain -u $username )
-
-freeside-adduser -g 1 $username
-
-htpasswd -b $FREESIDE_CONF/htpasswd $username $password
diff --git a/FS/bin/freeside-adduser b/FS/bin/freeside-adduser
deleted file mode 100644
index 237e29ef8..000000000
--- a/FS/bin/freeside-adduser
+++ /dev/null
@@ -1,119 +0,0 @@
-#!/usr/bin/perl -w
-
-use strict;
-use vars qw($opt_s $opt_g $opt_n);
-use Fcntl qw(:flock);
-use Getopt::Std;
-
-my $FREESIDE_CONF = "%%%FREESIDE_CONF%%%";
-
-getopts("s:g:n");
-my $user = shift or die &usage;
-
-if ( $opt_s ) {
-
- #if ( -e "$FREESIDE_CONF/mapsecrets" ) {
- # open(MAPSECRETS,"<$FREESIDE_CONF/mapsecrets")
- # or die "can't open $FREESIDE_CONF/mapsecrets: $!";
- # while (<MAPSECRETS>) {
- # /^(\S+) / or die "unparsable line in mapsecrets: $_";
- # die "user $user already exists\n" if $user eq $1;
- # }
- # close MAPSECRETS;
- #}
-
- #insert new entry before a wildcard...
- open(MAPSECRETS,"<$FREESIDE_CONF/mapsecrets")
- and flock(MAPSECRETS,LOCK_EX)
- or die "can't open $FREESIDE_CONF/mapsecrets: $!";
- open(NEW,">$FREESIDE_CONF/mapsecrets.new")
- or die "can't open $FREESIDE_CONF/mapsecrets.new: $!";
- while(<MAPSECRETS>) {
- if ( /^\*\s/ ) {
- print NEW "$user $opt_s\n";
- }
- print NEW $_;
- }
- close MAPSECRETS or die "can't close $FREESIDE_CONF/mapsecrets: $!";
- close NEW or die "can't close $FREESIDE_CONF/mapsecrets.new: $!";
- rename("$FREESIDE_CONF/mapsecrets.new", "$FREESIDE_CONF/mapsecrets")
- or die "can't move mapsecrets.new into place: $!";
-
-}
-
-###
-
-exit if $opt_n;
-
-###
-
-use FS::UID qw(adminsuidsetup);
-use FS::CurrentUser;
-use FS::access_user;
-use FS::access_usergroup;
-
-$FS::CurrentUser::upgrade_hack = 1;
-#adminsuidsetup $rootuser;
-adminsuidsetup $user;
-
-my $access_user = new FS::access_user {
- 'username' => $user,
- '_password' => 'notyet',
- 'first' => 'Firstname', # $opt_f ||
- 'last' => 'Lastname', # $opt_l ||
-};
-my $au_error = $access_user->insert;
-die $au_error if $au_error;
-
-if ( $opt_g ) {
-
- my $access_usergroup = new FS::access_usergroup {
- 'usernum' => $access_user->usernum,
- 'groupnum' => $opt_g,
- };
- my $aug_error = $access_usergroup->insert;
- die $aug_error if $aug_error;
-
-}
-
-###
-
-sub usage {
- die "Usage:\n\n freeside-adduser [ -n ] [ -s ] [ -g groupnum ] username [ password ]"
-}
-
-=head1 NAME
-
-freeside-adduser - Command line interface to add (freeside) users.
-
-=head1 SYNOPSIS
-
- freeside-adduser [ -n ] [ -s ] [ -g groupnum ] username [ password ]
-
-=head1 DESCRIPTION
-
-Adds a user to the Freeside billing system. This is for adding users (internal
-sales/tech folks) to the web interface, not for adding customer accounts.
-
-This functionality is now available in the web interface as well, under
-B<Configuration | Employees | View/Edit employees>.
-
- -g: initial groupnum
-
- Development/multi-DB options:
-
- -s: alternate secrets file
-
- -n: no ACL added, for bootstrapping
-
-=head1 NOTE
-
-No explicit htpasswd options are available in 1.7 - passwordsa are now
-maintained automatically.
-
-=head1 SEE ALSO
-
-Base Freeside documentation
-
-=cut
-
diff --git a/FS/bin/freeside-apply-credits b/FS/bin/freeside-apply-credits
deleted file mode 100755
index ea6a7bdd0..000000000
--- a/FS/bin/freeside-apply-credits
+++ /dev/null
@@ -1,21 +0,0 @@
-#!/usr/bin/perl -Tw
-
-use strict;
-use vars qw( $user $cust_main @customers );
-use FS::UID qw(adminsuidsetup);
-use FS::Record qw(qsearch);
-use FS::cust_main;
-
-$user = shift or die &usage;
-&adminsuidsetup( $user );
-
-my @customers = qsearch('cust_main', {} );
-die "No customers" unless (scalar(@customers) > 0);
-
-foreach $cust_main (@customers) {
- print "Applying credits for customer #". $cust_main->custnum;
- $cust_main->apply_credits;
-}
-
-
-
diff --git a/FS/bin/freeside-count-active-customers b/FS/bin/freeside-count-active-customers
deleted file mode 100755
index 759085a73..000000000
--- a/FS/bin/freeside-count-active-customers
+++ /dev/null
@@ -1,17 +0,0 @@
-#!/bin/sh
-
-domain=$1
-
-echo "\t
-select count(*) from cust_main where
- 0 < ( SELECT COUNT(*) FROM cust_pkg
- WHERE cust_pkg.custnum = cust_main.custnum
- AND ( cust_pkg.cancel IS NULL
- OR cust_pkg.cancel = 0
- )
- )
- OR 0 = ( SELECT COUNT(*) FROM cust_pkg
- WHERE cust_pkg.custnum = cust_main.custnum
- );
-" | psql -U freeside -q $domain | head -1
-
diff --git a/FS/bin/freeside-daily b/FS/bin/freeside-daily
deleted file mode 100755
index 13079b4f9..000000000
--- a/FS/bin/freeside-daily
+++ /dev/null
@@ -1,104 +0,0 @@
-#!/usr/bin/perl -w
-
-use strict;
-use Getopt::Std;
-use FS::UID qw(adminsuidsetup);
-
-&untaint_argv; #what it sounds like (eww)
-use vars qw(%opt);
-getopts("p:a:d:vl:sy:nm", \%opt);
-
-my $user = shift or die &usage;
-adminsuidsetup $user;
-
-use FS::Cron::bill qw(bill);
-bill(%opt);
-
-#what to do about the below when using -m? that is the question.
-
-use FS::Cron::notify qw(notify_flat_delay);
-notify_flat_delay(%opt);
-
-use FS::Cron::expire_user_pref qw(expire_user_pref);
-expire_user_pref();
-
-use FS::Cron::vacuum qw(vacuum);
-vacuum();
-
-use FS::Cron::backup qw(backup_scp);
-backup_scp();
-
-###
-# subroutines
-###
-
-sub untaint_argv {
- foreach $_ ( $[ .. $#ARGV ) { #untaint @ARGV
- #$ARGV[$_] =~ /^([\w\-\/]*)$/ || die "Illegal arguement \"$ARGV[$_]\"";
- # Date::Parse
- $ARGV[$_] =~ /^(.*)$/ || die "Illegal arguement \"$ARGV[$_]\"";
- $ARGV[$_]=$1;
- }
-}
-
-sub usage {
- die "Usage:\n\n freeside-daily [ -d 'date' ] user [ custnum custnum ... ]\n";
-}
-
-###
-# documentation
-###
-
-=head1 NAME
-
-freeside-daily - Run daily billing and invoice collection events.
-
-=head1 SYNOPSIS
-
- freeside-daily [ -d 'date' ] [ -y days ] [ -p 'payby' ] [ -a agentnum ] [ -s ] [ -v ] [ -l level ] [ -m ] user [ custnum custnum ... ]
-
-=head1 DESCRIPTION
-
-Bills customers and runs invoice collection events. Should be run from
-crontab daily.
-
-Bills customers. Searches for customers who are due for billing and calls
-the bill and collect methods of a cust_main object. See L<FS::cust_main>.
-
- -d: Pretend it's 'date'. Date is in any format Date::Parse is happy with,
- but be careful.
-
- -y: In addition to -d, which specifies an absolute date, the -y switch
- specifies an offset, in days. For example, "-y 15" would increment the
- "pretend date" 15 days from whatever was specified by the -d switch
- (or now, if no -d switch was given).
-
- -n: When used with "-d" and/or "-y", specifies that invoices should be dated
- with today's date, irregardless of the pretend date used to pre-generate
- the invoices.
-
- -p: Only process customers with the specified payby (I<CARD>, I<DCRD>, I<CHEK>, I<DCHK>, I<BILL>, I<COMP>, I<LECB>)
-
- -a: Only process customers with the specified agentnum
-
- -s: re-charge setup fees
-
- -v: enable debugging
-
- -l: debugging level
-
- -m: Experimental multi-process mode uses the job queue for multi-process and/or multi-machine billing.
-
-user: From the mapsecrets file - see config.html from the base documentation
-
-custnum: if one or more customer numbers are specified, only bills those
-customers. Otherwise, bills all customers.
-
-=head1 BUGS
-
-=head1 SEE ALSO
-
-L<FS::cust_main>, config.html from the base documentation
-
-=cut
-
diff --git a/FS/bin/freeside-dbdef-create b/FS/bin/freeside-dbdef-create
deleted file mode 100755
index a04f42521..000000000
--- a/FS/bin/freeside-dbdef-create
+++ /dev/null
@@ -1,47 +0,0 @@
-#!/usr/bin/perl -Tw
-
-use strict;
-use DBI;
-use DBIx::DBSchema 0.26;
-use FS::UID qw(adminsuidsetup datasrc driver_name);
-use FS::Schema;
-
-my $user = shift or die &usage;
-
-$FS::Schema::setup_hack = 1;
-$FS::CurrentUser::upgrade_hack = 1;
-my($dbh)=adminsuidsetup $user;
-
-#needs to match FS::Record
-my($dbdef_file) = "%%%FREESIDE_CONF%%%/dbdef.". datasrc;
-
-my $dbdef = new_native DBIx::DBSchema $dbh;
-
-#print $dbdef->pretty_print;
-
-#important
-$dbdef->save($dbdef_file);
-
-sub usage {
- die "Usage:\n dbdef-create user\n";
-}
-
-=head1 NAME
-
-freeside-dbdef-create - Recreate database schema cache
-
-=head1 SYNOPSIS
-
- freeside-dbdef-create user
-
-=head1 DESCRIPTION
-
-Reverse engineers the database schema and recreates the dbdef cache file.
-
-=head1 SEE ALSO
-
-L<DBIx::DBSchema>
-
-=cut
-
-1;
diff --git a/FS/bin/freeside-delete-addr_blocks b/FS/bin/freeside-delete-addr_blocks
deleted file mode 100755
index a7e99766a..000000000
--- a/FS/bin/freeside-delete-addr_blocks
+++ /dev/null
@@ -1,31 +0,0 @@
-#!/usr/bin/perl -Tw
-
-use strict;
-use vars qw( $user $block @blocks );
-use FS::UID qw(adminsuidsetup);
-use FS::Record qw(qsearch);
-use FS::addr_block;
-use FS::svc_broadband;
-
-$user = shift or die &usage;
-&adminsuidsetup( $user );
-
-@blocks = qsearch('addr_block', {} );
-die "No address blocks" unless (scalar(@blocks) > 0);
-
-foreach $block (@blocks) {
- my @devices = qsearch('svc_broadband', { 'blocknum' => $block->blocknum } );
- if (@devices) {
- print "Skipping block " . $block->ip_gateway . " / " . $block->ip_netmask;
- print "\n";
- }else{
- print "Deleting block " . $block->ip_gateway . " / " . $block->ip_netmask;
- print "\n";
- $block->delete;
- }
-}
-
-
-sub usage {
- "Usage:\n freeside-delete-addr_blocks user \n";
-}
diff --git a/FS/bin/freeside-deloutsource b/FS/bin/freeside-deloutsource
deleted file mode 100644
index afc3a0118..000000000
--- a/FS/bin/freeside-deloutsource
+++ /dev/null
@@ -1,14 +0,0 @@
-#!/bin/sh
-
-domain=$1
-FREESIDE_CONF=%%%FREESIDE_CONF%%%
-FREESIDE_CACHE=%%%FREESIDE_CACHE%%%
-FREESIDE_EXPORT=%%%FREESIDE_EXPORT%%%
-
-dropdb $domain && \
-rm -rf $FREESIDE_CONF/conf.DBI:Pg:host=localhost\;dbname=$domain && \
-rm -rf $FREESIDE_CACHE/counters.DBI:Pg:host=localhost\;dbname=$domain && \
-rm -rf $FREESIDE_CACHE/cache.DBI:Pg:host=localhost\;dbname=$domain && \
-rm -rf $FREESIDE_EXPORT/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
deleted file mode 100644
index dc4ff9cdc..000000000
--- a/FS/bin/freeside-deloutsourceuser
+++ /dev/null
@@ -1,6 +0,0 @@
-#!/bin/sh
-
-username=$1
-
-freeside-deluser -h %%%FREESIDE_CONF%%%/htpasswd $username 2>/dev/null
-
diff --git a/FS/bin/freeside-deluser b/FS/bin/freeside-deluser
deleted file mode 100644
index a2a361a83..000000000
--- a/FS/bin/freeside-deluser
+++ /dev/null
@@ -1,64 +0,0 @@
-#!/usr/bin/perl -w
-
-use strict;
-use vars qw($opt_h);
-use Fcntl qw(:flock);
-use Getopt::Std;
-
-my $FREESIDE_CONF = "%%%FREESIDE_CONF%%%";
-
-getopts("h:");
-my $user = shift or die &usage;
-
-if ( $opt_h ) {
- open(HTPASSWD,"<$opt_h")
- and flock(HTPASSWD,LOCK_EX)
- or die "can't open $opt_h: $!";
- open(HTPASSWD_TMP,">$opt_h.tmp") or die "can't open $opt_h.tmp: $!";
- while (<HTPASSWD>) {
- print HTPASSWD_TMP $_ unless /^$user:/;
- }
- close HTPASSWD_TMP;
- rename "$opt_h.tmp", "$opt_h" or die $!;
- flock(HTPASSWD,LOCK_UN);
- close HTPASSWD;
-}
-
-open(MAPSECRETS,"<$FREESIDE_CONF/mapsecrets")
- and flock(MAPSECRETS,LOCK_EX)
- or die "can't open $FREESIDE_CONF/mapsecrets: $!";
-open(MAPSECRETS_TMP,">>$FREESIDE_CONF/mapsecrets.tmp")
- or die "can't open $FREESIDE_CONF/mapsecrets.tmp: $!";
-while (<MAPSECRETS>) {
- print MAPSECRETS_TMP $_ unless /^$user\s/;
-}
-close MAPSECRETS_TMP;
-rename "$FREESIDE_CONF/mapsecrets.tmp", "$FREESIDE_CONF/mapsecrets" or die $!;
-flock(MAPSECRETS,LOCK_UN);
-close MAPSECRETS;
-
-sub usage {
- die "Usage:\n\n freeside-deluser [ -h htpasswd_file ] username"
-}
-
-=head1 NAME
-
-freeside-deluser - Command line interface to add (freeside) users.
-
-=head1 SYNOPSIS
-
- freeside-deluser [ -h htpasswd_file ] username
-
-=head1 DESCRIPTION
-
-Adds a user to the Freeside billing system. This is for adding users (internal
-sales/tech folks) to the web interface, not for adding customer accounts.
-
- -h: Also delete from the given htpasswd filename
-
-=head1 SEE ALSO
-
-L<freeside-adduser>, L<htpasswd>(1), base Freeside documentation
-
-=cut
-
diff --git a/FS/bin/freeside-disable-reasons b/FS/bin/freeside-disable-reasons
deleted file mode 100755
index 0af460919..000000000
--- a/FS/bin/freeside-disable-reasons
+++ /dev/null
@@ -1,64 +0,0 @@
-#!/usr/bin/perl -w
-
-use strict;
-use vars qw($opt_t $opt_e);
-use Getopt::Std;
-use FS::UID qw(adminsuidsetup);
-use FS::Record qw(qsearch qsearchs);
-use FS::reason_type;
-use FS::reason;
-
-getopts('t:e');
-
-my $user = shift or die &usage;
-adminsuidsetup $user;
-
-die &usage
- unless ($opt_t);
-
-$FS::Record::nowarn_identical = 1;
-
-my @reason = ();
-if ( $opt_t ) {
- $opt_t =~ /^(\d+)$/ or die "invalid reason_type";
- @reason = qsearch('reason', { reason_type => $1 } );
- die "no reasons found\n" unless @reason;
-} else {
- die "no reason_type specified\n";
-}
-
-foreach my $reason ( @reason ) {
- if ( $opt_e ) {
- $reason->disabled('');
- }else{
- $reason->disabled('Y');
- }
- my $error = $reason->replace
- if $reason->modified;
- die $error if $error;
-}
-
-
-sub usage {
- die "Usage:\n\n freeside-disable-reasons -t reason_type [ -e ] user\n";
-}
-
-=head1 NAME
-
-freeside-disable-reasons - Command line tool to set the disabled column for reasons
-
-=head1 SYNOPSIS
-
- freeside-disable-reasons -t reason_type [ -e ] user
-
-=head1 DESCRIPTION
-
- Disables the reasons of the specified reason type.
- Enables instead if -e is specified.
-
-=head1 SEE ALSO
-
-L<FS::reason>, L<FS::reason_type>
-
-=cut
-
diff --git a/FS/bin/freeside-email b/FS/bin/freeside-email
deleted file mode 100755
index 7a93f78ee..000000000
--- a/FS/bin/freeside-email
+++ /dev/null
@@ -1,55 +0,0 @@
-#!/usr/bin/perl -Tw
-
-use strict;
-use FS::UID qw(adminsuidsetup);
-use FS::Conf;
-use FS::Record qw(qsearch);
-use FS::svc_acct;
-
-&untaint_argv; #what it sounds like (eww)
-my $user = shift or die &usage;
-
-adminsuidsetup $user;
-
-my $conf = new FS::Conf;
-
-my @svc_acct = qsearch('svc_acct', {});
-my @emails = map $_->email, @svc_acct;
-
-print join("\n", @emails), "\n";
-
-# subroutines
-
-sub untaint_argv {
- foreach $_ ( $[ .. $#ARGV ) { #untaint @ARGV
- #$ARGV[$_] =~ /^([\w\-\/]*)$/ || die "Illegal arguement \"$ARGV[$_]\"";
- # Date::Parse
- $ARGV[$_] =~ /^(.*)$/ || die "Illegal arguement \"$ARGV[$_]\"";
- $ARGV[$_]=$1;
- }
-}
-
-sub usage {
- die "Usage:\n\n freeside-email user\n";
-}
-
-=head1 NAME
-
-freeside-email - Prints email addresses of all users on STDOUT
-
-=head1 SYNOPSIS
-
- freeside-email user
-
-=head1 DESCRIPTION
-
-Prints the email addresses of all customers on STDOUT, separated by newlines.
-
-user: From the mapsecrets file - see config.html from the base documentation
-
-=head1 BUGS
-
-=head1 SEE ALSO
-
-=cut
-
diff --git a/FS/bin/freeside-expiration-alerter b/FS/bin/freeside-expiration-alerter
deleted file mode 100755
index ffd75f9a5..000000000
--- a/FS/bin/freeside-expiration-alerter
+++ /dev/null
@@ -1,226 +0,0 @@
-#!/usr/bin/perl -Tw
-
-use strict;
-use Date::Format;
-use Time::Local;
-use Text::Template;
-use Getopt::Std;
-use Net::SMTP;
-use Mail::Header;
-use Mail::Internet;
-use FS::Conf;
-use FS::UID qw(adminsuidsetup);
-use FS::Record qw(qsearch);
-use FS::cust_main;
-
-use vars qw($smtpmachine @body);
-
-#hush, perl!
-$FS::alerter::_template::first = "";
-$FS::alerter::_template::last = "";
-$FS::alerter::_template::company = "";
-$FS::alerter::_template::payby = "";
-$FS::alerter::_template::expdate = "";
-
-# Set the mail program and other variables
-my $mail_sender = "billing\@mydomain.tld"; # or invoice_from if available
-my $failure_recipient = "postmaster"; # or invoice_from if available
-my $warning_time = 30 * 24 * 60 * 60;
-my $urgent_time = 15 * 24 * 60 * 60;
-my $panic_time = 5 * 24 * 60 * 60;
-my $window_time = 24 * 60 * 60;
-
-&untaint_argv; #what it sounds like (eww)
-
-#we're at now now (and later).
-my($_date)= $^T;
-
-# Get the current month
-my ($sec,$min,$hour,$mday,$mon,$year) =
- (localtime($_date) )[0,1,2,3,4,5];
-$mon++;
-
-# Login to the database
-my $user = shift or die &usage;
-adminsuidsetup $user;
-
-# Get the needed configuration files
-my $conf = new FS::Conf;
-$smtpmachine = $conf->config('smtpmachine');
-$mail_sender = $conf->config('invoice_from')
- if $conf->exists('invoice_from');
-$failure_recipient = $conf->config('invoice_from')
- if $conf->exists('invoice_from');
-
-
-my(@customers)=qsearch('cust_main',{});
-if (scalar(@customers) == 0)
-{
- exit 1;
-}
-
-# Prepare for sending email
-
-$ENV{MAILADDRESS} = $mail_sender;
-my $header = new Mail::Header ( [
- "From: Account Processor",
- "To: $failure_recipient",
- "Sender: $mail_sender",
- "Reply-To: $mail_sender",
- "Subject: Unnotified Billing Arrangement Expirations",
-] );
-
-my @alerter_template = $conf->config('alerter_template')
- or die "cannot load config file alerter_template";
-
-my $alerter = new Text::Template (TYPE => 'ARRAY', SOURCE => [ map "$_\n", @alerter_template ])
- or die "can't create new Text::Template object: Text::Template::ERROR";
-$alerter->compile() or die "can't compile template: Text::Template::ERROR";
-
-# Now I can start looping
-foreach my $customer (@customers)
-{
- my $paydate = $customer->getfield('paydate');
- next if $paydate =~ /^\s*$/; #skip empty expiration dates
-
- my $custnum = $customer->getfield('custnum');
- my $first = $customer->getfield('first');
- my $last = $customer->getfield('last');
- my $company = $customer->getfield('company');
- my $payby = $customer->getfield('payby');
- my $payinfo = $customer->getfield('payinfo');
- my $daytime = $customer->getfield('daytime');
- my $night = $customer->getfield('night');
-
- my ($payyear,$paymonth,$payday) = split (/-/,$paydate);
-
- my $expire_time = timelocal(0,0,0,$payday,--$paymonth,$payyear);
-
- #credit cards expire at the end of the month/year of their exp date
- if ($payby eq 'CARD' || $payby eq 'DCRD') {
- ($paymonth < 11) ? $paymonth++ : ($paymonth=0, $payyear++);
- $expire_time = timelocal(0,0,0,$payday,$paymonth,$payyear);
- $expire_time--;
- }
-
- if (($expire_time < $_date + $warning_time &&
- $expire_time > $_date + $warning_time - $window_time) ||
- ($expire_time < $_date + $urgent_time &&
- $expire_time > $_date + $urgent_time - $window_time) ||
- ($expire_time < $_date + $panic_time &&
- $expire_time > $_date + $panic_time - $window_time)) {
-
-
-
- my @packages = $customer->ncancelled_pkgs;
- if (scalar(@packages) != 0) {
- my @invoicing_list = $customer->invoicing_list;
- if ( grep { $_ ne 'POST' } @invoicing_list ) {
- my $header = new Mail::Header ( [
- "From: $mail_sender",
- "To: ". join(', ', grep { $_ ne 'POST' } @invoicing_list ),
- "Sender: $mail_sender",
- "Reply-To: $mail_sender",
- "Date: ". time2str("%a, %d %b %Y %X %z", time),
- "Subject: Billing Arrangement Expiration",
- ] );
- $FS::alerter::_template::first = $first;
- $FS::alerter::_template::last = $last;
- $FS::alerter::_template::company = $company;
- if ($payby eq 'CARD' || $payby eq 'DCRD') {
- $FS::alerter::_template::payby = "credit card (" .
- substr($payinfo, 0, 2) . "xxxxxxxxxx" .
- substr($payinfo, -4) . ")";
- }elsif ($payby eq 'COMP') {
- $FS::alerter::_template::payby = "complimentary account";
- }else{
- $FS::alerter::_template::payby = "current method";
- }
- $FS::alerter::_template::expdate = $expire_time;
-
- $FS::alerter::_template::company_name = $conf->config('company_name');
- $FS::alerter::_template::company_address =
- join("\n", $conf->config('company_address') ). "\n";
-
- my $message = new Mail::Internet (
- 'Header' => $header,
- 'Body' => [ $alerter->fill_in( PACKAGE => 'FS::alerter::_template' ) ],
- );
- $!=0;
- $message->smtpsend( Host => $smtpmachine )
- or $message->smtpsend( Host => $smtpmachine, Debug => 1 )
- or die "Can't send expiration email: $!";
-
- } elsif ( ! @invoicing_list || grep { $_ eq 'POST' } @invoicing_list ) {
- push @body, sprintf(qq{%5d %-32.32s %4s %10s %12s %12s},
- $custnum,
- $first . " " . $last . " " . $company,
- $payby,
- $paydate,
- $daytime,
- $night);
- }
- }
- }
-}
-
-# Now I need to send EMAIL
-if (scalar(@body)) {
- my $message = new Mail::Internet (
- 'Header' => $header,
- 'Body' => [ (@body) ],
- );
- $!=0;
- $message->smtpsend( Host => $smtpmachine )
- or $message->smtpsend( Host => $smtpmachine, Debug => 1 )
- or die "can't send alerter failure email to $failure_recipient".
- " via server $smtpmachine with SMTP: $!";
-}
-
-# subroutines
-sub untaint_argv {
- foreach $_ ( $[ .. $#ARGV ) { #untaint @ARGV
- $ARGV[$_] =~ /^([\w\-\/]*)$/ || die "Illegal argument \"$ARGV[$_]\"";
- $ARGV[$_]=$1;
- }
-}
-
-sub usage {
- die "Usage:\n\n freeside-expiration-alerter user\n";
-}
-
-=head1 NAME
-
-freeside-expiration-alerter - Emails notifications of credit card expirations.
-
-=head1 SYNOPSIS
-
- freeside-expiration-alerter user
-
-=head1 DESCRIPTION
-
-Emails customers notice that their credit card or other billing arrangement
-is about to expire. Usually run as a cron job.
-
-user: From the mapsecrets file - see config.html from the base documentation
-
-=head1 BUGS
-
-Yes..... Use at your own risk. No guarantees or warrantees of any
-kind apply to this program. Parts of this program are hacked from
-other GNU licensed software created mainly by Ivan Kohler.
-
-This is released under the GNU Public License. See www.gnu.org
-for more information regarding this license.
-
-=head1 SEE ALSO
-
-L<FS::cust_main>, config.html from the base documentation
-
-=head1 AUTHOR
-
-Jeff Finucane <jeff@cmh.net>
-
-=cut
-
-
diff --git a/FS/bin/freeside-fetch b/FS/bin/freeside-fetch
deleted file mode 100755
index 89a4f29af..000000000
--- a/FS/bin/freeside-fetch
+++ /dev/null
@@ -1,89 +0,0 @@
-#!/usr/bin/perl -Tw
-
-use strict;
-use LWP::UserAgent;
-use FS::UID qw(adminsuidsetup);
-use FS::Record qw(qsearchs);
-use FS::Misc qw(send_email);
-
-my $user = shift or die &usage;
-my $employeelist = shift or die &usage;
-my $url = shift or die &usage;
-adminsuidsetup $user;
-
-my @employees = split ',', $employeelist;
-
-foreach my $employee (@employees) {
-
- $employee =~ /^(\w+)$/;
-
- my $access_user = qsearchs( 'access_user', { 'username' => $1 } );
- unless ($access_user) {
- warn "Can't find employee $employee... skipping";
- next;
- }
-
- my $email_address = $access_user->option('email_address');
- unless ($email_address) {
- warn "No email address for $employee... skipping";
- next;
- }
-
- no warnings 'redefine';
- local *LWP::UserAgent::get_basic_credentials = sub {
- return ($access_user->username, $access_user->_password);
- };
-
- my $ua = new LWP::UserAgent;
- $ua->agent("FreesideFetcher/0.1 " . $ua->agent);
-
- my $req = new HTTP::Request GET => $url;
- my $res = $ua->request($req);
-
- my %options = ( 'from' => $email_address,
- 'to' => $email_address,
- 'subject' => 'subject',
- 'body' => $res->content,
- );
-
- $options{'content-type'} = $res->content_type
- if $res->content_type;
- $options{'content-encoding'} = $res->content_encoding
- if $res->content_encoding;
-
- if ($res->is_success) {
- send_email %options;
- }else{
- warn "fetching $url failed for $employee: " . $res->status_line;
- }
-}
-
-sub usage {
- die "Usage:\n\n freeside-fetch user employee[,employee ...] url\n\n";
-}
-
-=head1 NAME
-
-freeside-fetch - Send a freeside page to a list of employees.
-
-=head1 SYNOPSIS
-
- freeside-fetch user employee[,employee ...] url
-
-=head1 DESCRIPTION
-
- Fetches a web page specified by url as if employee and emails it to
- employee. Useful when run out of cron to send freeside web pages.
-
- user: From the mapsecrets file - a user with access to the freeside database
-
- employee: the username of an employee to receive the emailed page. May be a comma separated list
-
- url: the web page to be received
-
-=head1 BUGS
-
- Can leak employee usernames and passwords if requested to access inappropriate urls.
-
-=cut
-
diff --git a/FS/bin/freeside-history-requeue b/FS/bin/freeside-history-requeue
deleted file mode 100755
index 77a4332a3..000000000
--- a/FS/bin/freeside-history-requeue
+++ /dev/null
@@ -1,100 +0,0 @@
-#!/usr/bin/perl -w
-
-use strict;
-use vars qw($opt_j $opt_d);
-use Getopt::Std;
-use Date::Parse;
-use FS::UID qw(adminsuidsetup);
-use FS::Record qw(qsearch qsearchs);
-use FS::queue;
-
-getopts('j:d');
-
-my $user = shift or die &usage;
-adminsuidsetup $user;
-
-my $start = shift or die &usage;
-my $end = shift or die &usage;
-
-$start = str2time($start) unless $start =~ /^(\d+)$/;
-$end = str2time($end) unless $end =~ /^(\d+)$/;
-
-my $extra_sql = "AND history_date >= $start AND history_date <= $end";
-
-my $hashref = { 'history_action' => 'insert' };
-
-$hashref->{'job'} = $opt_j if $opt_j;
-
-my @h_queue = qsearch({
- 'table' => 'h_queue',
- 'hashref' => $hashref,
- 'extra_sql' => $extra_sql,
-});
-
-my $num = 0;
-
-foreach my $h_queue (@h_queue) {
-
- my @queue_args = qsearch({
- 'table' => 'h_queue_arg',
- 'hashref' => { 'history_action' => 'insert',
- 'jobnum' => $h_queue->jobnum,
- },
- 'order_by' => 'argnum',
- });
-
- my @args = map {
- my $arg = $_->arg;
- $arg =~ s/^db\.suicidegirls\.com$/sg-account/;
- $arg;
- } @queue_args;
-
- my $queue = new FS::queue {
- map { $_ => $h_queue->$_() }
- qw( job _date status statustext svcnum )
- };
-
- if ( $opt_d ) { #dry run
- print "requeueing job: ". join(' ', @args). "\n";
- my $error = $queue->check;
- die "error requeueing job ". $h_queue->jobnum. ": $error" if $error;
- } else {
- print "requeueing job: ". join(' ', @args). "\n";
- my $error = $queue->insert(@args);
- #warn "error requeueing job ". $h_queue->jobnum. ": $error\n" if $error;
- print "error requeueing job ". $h_queue->jobnum. ": $error\n" if $error;
- }
-
- $num++;
-
-}
-
-print "requeued $num jobs\n";
-
-sub usage {
- die "Usage:\n\n freeside-history-requeue user start_timestamp end_timestamp\n";
-}
-
-=head1 NAME
-
-freeside-history-requeue - Command line tool to re-trigger export jobs for existing services
-
-=head1 SYNOPSIS
-
- freeside-history-requeue [ -j job ] [ -d ] user start_timestamp end_timestamp
-
-=head1 DESCRIPTION
-
- Re-queues all queued jobs for the specified time period.
-
- -j: specifies that only jobs with this job string are re-queued.
-
- -d: dry run
-
-=head1 SEE ALSO
-
-L<freeside-reexport>, L<freeside-sqlradius-reset>, L<FS::part_export>
-
-=cut
-
-1;
diff --git a/FS/bin/freeside-init-config b/FS/bin/freeside-init-config
deleted file mode 100755
index fe4729c40..000000000
--- a/FS/bin/freeside-init-config
+++ /dev/null
@@ -1,45 +0,0 @@
-#!/usr/bin/perl -Tw
-
-use strict;
-use vars qw($opt_u $opt_f $opt_v);
-use Getopt::Std;
-use FS::UID qw(adminsuidsetup checkeuid dbh);
-use FS::CurrentUser;
-use FS::Record qw(qsearch);
-use FS::Conf;
-
-
-die "Not running uid freeside!" unless checkeuid();
-
-getopts("u:vf");
-my $dir = shift or die &usage;
-
-$FS::CurrentUser::upgrade_hack = 1;
-$FS::UID::AutoCommit = 0;
-$FS::UID::callback_hack = 1;
-adminsuidsetup $opt_u; #$user;
-
-$|=1;
-
-if (!scalar(qsearch('conf', {})) || $opt_f) {
- my $error = FS::Conf::init_config($dir);
- if ($error) {
- warn "CONFIGURATION INITIALIZATION FAILED\n";
- dbh->rollback or die dbh->errstr;
- die $error if $error;
- }
-}
-
-warn "Freeside database initialized - committing transaction\n" if $opt_v;
-
-dbh->commit or die dbh->errstr;
-dbh->disconnect or die dbh->errstr;
-
-warn "Configuration initialization committed successfully\n" if $opt_v;
-
-sub usage {
- die "Usage:\n freeside-init-config [ -v ] [ -f ] directory\n"
- # [ -u user ] for devel/multi-db installs
-}
-
-1;
diff --git a/FS/bin/freeside-monthly b/FS/bin/freeside-monthly
deleted file mode 100755
index 1e41b780e..000000000
--- a/FS/bin/freeside-monthly
+++ /dev/null
@@ -1,91 +0,0 @@
-#!/usr/bin/perl -w
-
-use strict;
-use Getopt::Std;
-use FS::UID qw(adminsuidsetup);
-
-&untaint_argv; #what it sounds like (eww)
-#use vars qw($opt_d $opt_v $opt_p $opt_a $opt_s $opt_y);
-use vars qw(%opt);
-getopts("p:a:d:vsy:", \%opt);
-
-my $user = shift or die &usage;
-adminsuidsetup $user;
-
-use FS::Cron::bill qw(bill);
-bill(%opt, 'check_freq'=>'1m' );
-
-###
-# subroutines
-###
-
-sub untaint_argv {
- foreach $_ ( $[ .. $#ARGV ) { #untaint @ARGV
- #$ARGV[$_] =~ /^([\w\-\/]*)$/ || die "Illegal arguement \"$ARGV[$_]\"";
- # Date::Parse
- $ARGV[$_] =~ /^(.*)$/ || die "Illegal arguement \"$ARGV[$_]\"";
- $ARGV[$_]=$1;
- }
-}
-
-sub usage {
- die "Usage:\n\n freeside-monthly [ -d 'date' ] user [ custnum custnum ... ]\n";
-}
-
-###
-# documentation
-###
-
-=head1 NAME
-
-freeside-monthly - Run monthly billing and invoice collection events.
-
-=head1 SYNOPSIS
-
- freeside-monthly [ -d 'date' ] [ -y days ] [ -p 'payby' ] [ -a agentnum ] [ -s ] [ -v ] user [ custnum custnum ... ]
-
-=head1 DESCRIPTION
-
-Bills customers and runs invoice collection events, for the alternate monthly
-event chain. If you have defined monthly event checks, should be run from
-crontab monthly.
-
-Bills customers. Searches for customers who are due for billing and calls
-the bill and collect methods of a cust_main object. See L<FS::cust_main>.
-
- -d: Pretend it's 'date'. Date is in any format Date::Parse is happy with,
- but be careful.
-
- -y: In addition to -d, which specifies an absolute date, the -y switch
- specifies an offset, in days. For example, "-y 15" would increment the
- "pretend date" 15 days from whatever was specified by the -d switch
- (or now, if no -d switch was given).
-
- -p: Only process customers with the specified payby (I<CARD>, I<DCRD>, I<CHEK>, I<DCHK>, I<BILL>, I<COMP>, I<LECB>)
-
- -a: Only process customers with the specified agentnum
-
- -s: re-charge setup fees
-
- -v: enable debugging
-
-user: From the mapsecrets file - see config.html from the base documentation
-
-custnum: if one or more customer numbers are specified, only bills those
-customers. Otherwise, bills all customers.
-
-=head1 NOTE
-
-In most cases, you would use freeside-daily only and not freeside-monthly.
-freeside-monthly would only be used in cases where you have events that can
-only be run once each month, for example, batching invoices to a third-party
-print/mail provider.
-
-=head1 BUGS
-
-=head1 SEE ALSO
-
-L<freeside-daily>, L<FS::cust_main>, config.html from the base documentation
-
-=cut
-
diff --git a/FS/bin/freeside-prepaidd b/FS/bin/freeside-prepaidd
deleted file mode 100644
index a68db3913..000000000
--- a/FS/bin/freeside-prepaidd
+++ /dev/null
@@ -1,106 +0,0 @@
-#!/usr/bin/perl -w
-
-use strict;
-use FS::Daemon qw(daemonize1 drop_root logfile daemonize2 sigint sigterm);
-use FS::UID qw(adminsuidsetup);
-use FS::Record qw(qsearch qsearchs);
-use FS::cust_pkg;
-
-my $user = shift or die &usage;
-
-#daemonize1('freeside-sprepaidd', $user); #keep unique pid files w/multi installs
-daemonize1('freeside-prepaidd');
-
-drop_root();
-
-adminsuidsetup($user);
-
-logfile( "/usr/local/etc/freeside/prepaidd-log.". $FS::UID::datasrc );
-
-daemonize2();
-
-#--
-
-while (1) {
-
- foreach my $cust_pkg (
- qsearch( {
- 'select' => 'cust_pkg.*, part_pkg.plan',
- 'table' => 'cust_pkg',
- 'addl_from' => 'LEFT JOIN part_pkg USING ( pkgpart )',
- #'hashref' => { 'plan' => 'prepaid' },#should check part_pkg::is_prepaid
- #'extra_sql' => "AND bill < ". time.
- 'hashref' => {},
- 'extra_sql' => "WHERE plan = 'prepaid' AND bill < ". time.
- " AND bill IS NOT NULL".
- " AND ( susp IS NULL OR susp = 0)".
- " AND ( cancel IS NULL OR cancel = 0)"
- } )
- ) {
-
- my $work_cust_pkg = $cust_pkg;
-
- my $cust_main = $cust_pkg->cust_main;
- if ( $cust_main->total_unapplied_payments > 0
- or $cust_main->total_credited > 0
- )
- {
- #this needs a flag to say only do the prepaid packages...
- # and only try em if the renewal price matches.. but this will do for now
- my $b_error = $cust_main->bill;
- if ( $b_error ) {
- warn "Error billing customer #". $cust_main->custnum;
- next;
- }
- $b_error = $cust_main->apply_payments_and_credits;
- if ( $b_error ) {
- warn "Error applying payments&credits, customer #". $cust_main->custnum;
- next;
- }
-
- $work_cust_pkg = qsearchs('cust_pkg', { 'pkgnum' => $work_cust_pkg->pkgnum } );
-
- next
- if $cust_main->balance <= 0
- and $work_cust_pkg->bill >= time;
- }
-
- my $action = $work_cust_pkg->part_pkg->option('recur_action') || 'suspend';
-
- my $error = $work_cust_pkg->$action();
-
- warn "Error ${action}ing package ". $work_cust_pkg->pkgnum.
- " for custnum ". $work_cust_pkg->custnum.
- ": $error\n"
- if $error;
- }
-
- die "exiting" if sigterm() || sigint();
- sleep 5;
-
-}
-
-#--
-
-sub usage {
- die "Usage:\n\n freeside-prepaidd user\n";
-}
-
-=head1 NAME
-
-freeside-prepaidd - Real-time daemon for prepaid packages
-
-=head1 SYNOPSIS
-
- freeside-prepaidd
-
-=head1 DESCRIPTION
-
-Runs continuously and suspends or cancels any prepaid customer packages which
-have passed their renewal date (next bill date).
-
-=head1 SEE ALSO
-
-=cut
-
-1;
diff --git a/FS/bin/freeside-prune-applications b/FS/bin/freeside-prune-applications
deleted file mode 100755
index d2b6efe0b..000000000
--- a/FS/bin/freeside-prune-applications
+++ /dev/null
@@ -1,63 +0,0 @@
-#!/usr/bin/perl -w
-
-use strict;
-use vars qw($opt_d $opt_q $opt_v); # $opt_n instead of $opt_d?
-use vars qw($DEBUG $DRY_RUN);
-use Getopt::Std;
-use FS::UID qw(adminsuidsetup checkeuid);
-use FS::Misc::prune qw(prune_applications);
-
-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;
-my $dbh = adminsuidsetup($user);
-
-my $hashref = {};
-
-$hashref->{dry_run} = 1 if $DRY_RUN;
-$hashref->{debug} = 1 if $DEBUG;
-
-print join "\n", prune_applications($hashref);
-print "\n" if $DRY_RUN;
-
-$dbh->commit or die $dbh->errstr;
-
-###
-
-sub usage {
- die "Usage:\n freeside-prune-applications [ -d ] [ -q | -v ] user\n";
-}
-
-=head1 NAME
-
-freeside-prune-applications - Removes stray applications of credit, payment to
- bills, refunds, etc.
-
-=head1 SYNOPSIS
-
- freeside-prune-applications [ -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; display affected records (to STDOUT) only, but do not
- remove 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
-
diff --git a/FS/bin/freeside-queued b/FS/bin/freeside-queued
deleted file mode 100644
index 93d735d1a..000000000
--- a/FS/bin/freeside-queued
+++ /dev/null
@@ -1,250 +0,0 @@
-#!/usr/bin/perl -w
-
-use strict;
-use vars qw( $DEBUG $kids $max_kids %kids );
-use POSIX qw(:sys_wait_h);
-use IO::File;
-use FS::UID qw(adminsuidsetup forksuidsetup driver_name dbh myconnect);
-use FS::Daemon qw(daemonize1 drop_root logfile daemonize2 sigint sigterm);
-use FS::Record qw(qsearch qsearchs);
-use FS::queue;
-use FS::queue_depend;
-
-# no autoloading for non-FS classes...
-use Net::SSH 0.07;
-
-$DEBUG = 0;
-
-$max_kids = '10'; #guess it should be a config file...
-$kids = 0;
-
-my $user = shift or die &usage;
-
-warn "starting daemonization (forking)\n" if $DEBUG;
-#daemonize1('freeside-queued',$user); #to keep pid files unique w/multi installs
-daemonize1('freeside-queued');
-
-warn "dropping privledges\n" if $DEBUG;
-drop_root();
-
-
-$ENV{HOME} = (getpwuid($>))[7]; #for ssh
-
-warn "connecting to database\n" if $DEBUG;
-$@ = 'not connected';
-while ( $@ ) {
- eval { adminsuidsetup $user; };
- if ( $@ ) {
- warn $@;
- warn "sleeping for reconnect...\n";
- sleep 5;
- }
-}
-
-logfile( "%%%FREESIDE_LOG%%%/queuelog.". $FS::UID::datasrc );
-
-warn "completing daemonization (detaching))\n" if $DEBUG;
-daemonize2();
-
-#--
-
-my $warnkids=0;
-while (1) {
-
- &reap_kids;
- #prevent runaway forking
- if ( $kids >= $max_kids ) {
- warn "WARNING: maximum $kids children reached\n" unless $warnkids++;
- &reap_kids;
- sleep 1; #waiting for signals is cheap
- next;
- }
- $warnkids=0;
-
- unless ( dbh && dbh->ping ) {
- warn "WARNING: connection to database lost, reconnecting...\n";
-
- eval { $FS::UID::dbh = myconnect; };
-
- unless ( !$@ && dbh && dbh->ping ) {
- warn "WARNING: still no connection to database, sleeping for retry...\n";
- sleep 10;
- next;
- } else {
- warn "WARNING: reconnected to database\n";
- }
- }
-
- #my($job, $ljob);
- #{
- # my $oldAutoCommit = $FS::UID::AutoCommit;
- # local $FS::UID::AutoCommit = 0;
- $FS::UID::AutoCommit = 0;
-
- #assuming mysql 4.1 w/subqueries now
- #my $nodepend = driver_name eq 'mysql'
- # ? ''
- # : 'AND 0 = ( SELECT COUNT(*) FROM queue_depend'.
- # ' WHERE queue_depend.jobnum = queue.jobnum ) ';
- my $nodepend = 'AND 0 = ( SELECT COUNT(*) FROM queue_depend'.
- ' WHERE queue_depend.jobnum = queue.jobnum ) ';
-
- my $job = qsearchs(
- 'queue',
- { 'status' => 'new' },
- '',
- driver_name eq 'mysql'
- ? "$nodepend ORDER BY jobnum LIMIT 1 FOR UPDATE"
- : "$nodepend ORDER BY jobnum FOR UPDATE LIMIT 1"
- ) or do {
- # if $oldAutoCommit {
- dbh->commit or do {
- warn "WARNING: database error, closing connection: ". dbh->errstr;
- undef $FS::UID::dbh;
- next;
- };
- # }
- sleep 5; #connecting to db is expensive
- next;
- };
-
- #assuming mysql 4.1 w/subqueries now
- #if ( driver_name eq 'mysql'
- # && qsearch('queue_depend', { 'jobnum' => $job->jobnum } ) ) {
- # dbh->commit or die dbh->errstr; #if $oldAutoCommit;
- # sleep 5; #would be better if mysql could do everything in query above
- # next;
- #}
-
- my %hash = $job->hash;
- $hash{'status'} = 'locked';
- my $ljob = new FS::queue ( \%hash );
- my $error = $ljob->replace($job);
- if ( $error ) {
- warn "WARNING: database error locking job, closing connection: ".
- dbh->errstr;
- undef $FS::UID::dbh;
- next;
- }
-
- # if $oldAutoCommit {
- dbh->commit or do {
- warn "WARNING: database error, closing connection: ". dbh->errstr;
- undef $FS::UID::dbh;
- next;
- };
- # }
-
- $FS::UID::AutoCommit = 1;
- #}
-
- my @args = $ljob->args;
- splice @args, 0, 1, $ljob if $args[0] eq '_JOB';
-
- defined( my $pid = fork ) or do {
- warn "WARNING: can't fork: $!\n";
- my %hash = $job->hash;
- $hash{'status'} = 'failed';
- $hash{'statustext'} = "[freeside-queued] can't fork: $!";
- my $ljob = new FS::queue ( \%hash );
- my $error = $ljob->replace($job);
- die $error if $error;
- next; #don't increment the kid counter
- };
-
- if ( $pid ) {
- $kids++;
- $kids{$pid} = 1;
- } else { #kid time
-
- #get new db handle
- $FS::UID::dbh->{InactiveDestroy} = 1;
-
- forksuidsetup($user);
-
- #auto-use classes...
- #if ( $ljob->job =~ /(FS::part_export::\w+)::/ ) {
- if ( $ljob->job =~ /(FS::part_export::\w+)::/
- || $ljob->job =~ /(FS::\w+)::/
- )
- {
- my $class = $1;
- eval "use $class;";
- if ( $@ ) {
- warn "job use $class failed";
- my %hash = $ljob->hash;
- $hash{'status'} = 'failed';
- $hash{'statustext'} = $@;
- my $fjob = new FS::queue( \%hash );
- my $error = $fjob->replace($ljob);
- die $error if $error;
- exit; #end-of-kid
- };
- }
-
- my $eval = "&". $ljob->job. '(@args);';
- warn 'running "&'. $ljob->job. '('. join(', ', @args). ")\n" if $DEBUG;
- eval $eval; #throw away return value? suppose so
- if ( $@ ) {
- warn "job $eval failed";
- my %hash = $ljob->hash;
- $hash{'status'} = 'failed';
- $hash{'statustext'} = $@;
- my $fjob = new FS::queue( \%hash );
- my $error = $fjob->replace($ljob);
- die $error if $error;
- } else {
- $ljob->delete;
- }
-
- exit;
- #end-of-kid
- }
-
-} continue {
- if ( sigterm() ) {
- warn "received TERM signal; exiting\n";
- exit;
- }
- if ( sigint() ) {
- warn "received INT signal; exiting\n";
- exit;
- }
-}
-
-sub usage {
- die "Usage:\n\n freeside-queued user\n";
-}
-
-sub reap_kids {
- foreach my $pid ( keys %kids ) {
- my $kid = waitpid($pid, WNOHANG);
- if ( $kid > 0 ) {
- $kids--;
- delete $kids{$kid};
- }
- }
-}
-
-=head1 NAME
-
-freeside-queued - Job queue daemon
-
-=head1 SYNOPSIS
-
- freeside-queued user
-
-=head1 DESCRIPTION
-
-Job queue daemon. Should be running at all times.
-
-user: from the mapsecrets file - see config.html from the base documentation
-
-=head1 VERSION
-
-=head1 BUGS
-
-=head1 SEE ALSO
-
-=cut
-
diff --git a/FS/bin/freeside-radgroup b/FS/bin/freeside-radgroup
deleted file mode 100644
index ed85626d2..000000000
--- a/FS/bin/freeside-radgroup
+++ /dev/null
@@ -1,76 +0,0 @@
-#!/usr/bin/perl -w
-
-use strict;
-use FS::UID qw(adminsuidsetup);
-use FS::Record qw(qsearch);
-use FS::cust_svc;
-use FS::svc_acct;
-
-&untaint_argv; #what it sounds like (eww)
-
-my($user, $action, $groupname, $svcpart) = @ARGV;
-
-adminsuidsetup $user;
-
-my @svc_acct = map { $_->svc_x } qsearch('cust_svc', { svcpart => $svcpart } );
-
-if ( lc($action) eq 'add' ) {
- foreach my $svc_acct ( @svc_acct ) {
- my @groups = $svc_acct->radius_groups;
- next if grep { $_ eq $groupname } @groups;
- push @groups, $groupname;
- my %hash = $svc_acct->hash;
- $hash{usergroup} = \@groups;
- my $new = new FS::svc_acct \%hash;
- my $error = $new->replace($svc_acct);
- die $error if $error;
- }
-} else {
- die &usage;
-}
-
-# subroutines
-
-sub untaint_argv {
- foreach $_ ( $[ .. $#ARGV ) { #untaint @ARGV
- $ARGV[$_] =~ /^(.*)$/ || die "Illegal arguement \"$ARGV[$_]\"";
- $ARGV[$_]=$1;
- }
-}
-
-sub usage {
- die "Usage:\n\n freeside-radgroup user action groupname svcpart\n";
-}
-
-=head1 NAME
-
-freeside-radgroup - Command line utility to manipulate radius groups
-
-=head1 SYNOPSIS
-
- freeside-addgroup user action groupname svcpart
-
-=head1 DESCRIPTION
-
- B<user> is a freeside user as added with freeside-adduser.
-
- B<command> is the action to take. Available actions are: I<add>
-
- B<groupname> is the group to add (or remove, etc.)
-
- B<svcpart> specifies which accounts will be updated.
-
-=head1 EXAMPLES
-
-freeside-radgroup freesideuser add groupname 3
-
-Adds I<groupname> to all accounts with service definition 3.
-
-=head1 BUGS
-
-=head1 SEE ALSO
-
-L<freeside-adduser>, L<FS::svc_acct>, L<FS::part_svc>
-
-=cut
-
diff --git a/FS/bin/freeside-reexport b/FS/bin/freeside-reexport
deleted file mode 100644
index 54af9dd80..000000000
--- a/FS/bin/freeside-reexport
+++ /dev/null
@@ -1,71 +0,0 @@
-#!/usr/bin/perl -w
-
-use strict;
-use vars qw($opt_s $opt_u $opt_p);
-use Getopt::Std;
-use FS::UID qw(adminsuidsetup);
-use FS::Record qw(qsearch qsearchs);
-use FS::part_export;
-use FS::svc_acct;
-use FS::cust_svc;
-
-my $user = shift or die &usage;
-adminsuidsetup $user;
-
-my $export_x = shift or die &usage;
-my @part_export;
-if ( $export_x =~ /^(\d+)$/ ) {
- @part_export = qsearchs('part_export', { exportnum=>$1 } )
- or die "exportnum $export_x not found\n";
-} else {
- @part_export = qsearch('part_export', { exporttype=>$export_x } )
- or die "no exports of type $export_x found\n";
-}
-
-getopts('s:u:p:');
-
-my @svc_x = ();
-if ( $opt_s ) {
- my $cust_svc = qsearchs('cust_svc', { svcnum=>$opt_s } )
- or die "svcnum $opt_s not found\n";
- push @svc_x, $cust_svc->svc_x;
-} elsif ( $opt_u ) {
- my $svc_x = qsearchs('svc_acct', { username=>$opt_u } )
- or die "username $opt_u not found\n";
- push @svc_x, $svc_x;
-} elsif ( $opt_p ) {
- push @svc_x, map { $_->svc_x } qsearch('cust_svc', { svcpart=>$opt_p } );
- die "no services with svcpart $opt_p found\n" unless @svc_x;
-}
-
-foreach my $part_export ( @part_export ) {
- foreach my $svc_x ( @svc_x ) {
- my $error = $part_export->export_insert($svc_x);
- die $error if $error;
- }
-}
-
-
-sub usage {
- die "Usage:\n\n freeside-reexport user exportnum|exporttype [ -s svcnum | -u username | -p svcpart ]\n";
-}
-
-=head1 NAME
-
-freeside-reexport - Command line tool to re-trigger export jobs for existing services
-
-=head1 SYNOPSIS
-
- freeside-reexport user exportnum|exporttype [ -s svcnum | -u username | -p svcpart ]
-
-=head1 DESCRIPTION
-
- Re-queues the export job for the specified exportnum or exporttype(s) and
- specified service (selected by svcnum or username).
-
-=head1 SEE ALSO
-
-L<freeside-sqlradius-reset>, L<FS::part_export>
-
-=cut
-
diff --git a/FS/bin/freeside-reset-fixed b/FS/bin/freeside-reset-fixed
deleted file mode 100755
index 5829d441b..000000000
--- a/FS/bin/freeside-reset-fixed
+++ /dev/null
@@ -1,69 +0,0 @@
-#!/usr/bin/perl -w
-
-use strict;
-use vars qw($opt_p $opt_s $opt_r);
-use Getopt::Std;
-use FS::UID qw(adminsuidsetup);
-use FS::Record qw(qsearch qsearchs);
-use FS::cust_svc;
-use FS::svc_Common;
-
-getopts('p:s:r');
-
-my $user = shift or die &usage;
-adminsuidsetup $user;
-
-die &usage
- if ($opt_p && $opt_s);
-
-$FS::Record::nowarn_identical = 1;
-$FS::svc_Common::noexport_hack = 1
- unless $opt_r;
-
-my @svc_x = ();
-if ( $opt_s ) {
- $opt_s =~ /^(\d+)$/ or die "invalid svcnum";
- my $cust_svc = qsearchs('cust_svc', { svcnum => $1 } )
- or die "svcnum $opt_s not found\n";
- push @svc_x, $cust_svc->svc_x;
-} elsif ( $opt_p ) {
- $opt_p =~ /^(\d+)$/ or die "invalid svcpart";
- push @svc_x, map { $_->svc_x } qsearch('cust_svc', { svcpart => $1 } );
- die "no services with svcpart $opt_p found\n" unless @svc_x;
-} else {
- push @svc_x, map { $_->svc_x } qsearch('cust_svc', {} );
- die "no services found\n" unless @svc_x;
-}
-
-foreach my $svc_x ( @svc_x ) {
- my $result = $svc_x->setfixed;
- die $result unless ref($result);
- my $error = $svc_x->replace
- if $svc_x->modified;
- die $error if $error;
-}
-
-
-sub usage {
- die "Usage:\n\n freeside-reset-fixed user [ -s svcnum | -p svcpart ] [ -r ]\n";
-}
-
-=head1 NAME
-
-freeside-reset-fixed - Command line tool to set the fixed columns for existing services
-
-=head1 SYNOPSIS
-
- freeside-reset-fixed user [ -s svcnum | -p svcpart ] [ -r ]
-
-=head1 DESCRIPTION
-
- Resets the fixed columns for the specified service part or service number.
- Re-exports the service if -r is specified.
-
-=head1 SEE ALSO
-
-L<freeside-reexport>, L<FS::part_svc>
-
-=cut
-
diff --git a/FS/bin/freeside-selfservice-server b/FS/bin/freeside-selfservice-server
deleted file mode 100644
index 2087e7130..000000000
--- a/FS/bin/freeside-selfservice-server
+++ /dev/null
@@ -1,240 +0,0 @@
-#!/usr/bin/perl -w
-
-use strict;
-use vars qw( $FREESIDE_LOG $FREESIDE_LOCK );
-use vars qw( $Debug %kids $kids $max_kids $ssh_pid %old_ssh_pid $keepalives );
-use subs qw( lock_write unlock_write myshutdown usage );
-use Fcntl qw(:flock);
-use POSIX qw(:sys_wait_h);
-use IO::Handle;
-use IO::Select;
-use IO::File;
-use Storable 2.09 qw(nstore_fd fd_retrieve);
-use Net::SSH qw(sshopen2);
-use FS::Daemon qw(daemonize1 drop_root logfile daemonize2 sigint sigterm);
-use FS::UID qw(adminsuidsetup forksuidsetup);
-use FS::ClientAPI;
-use FS::ClientAPI_SessionCache;
-
-use FS::Conf;
-use FS::cust_svc;
-
-$FREESIDE_LOG = "%%%FREESIDE_LOG%%%";
-$FREESIDE_LOCK = "%%%FREESIDE_LOCK%%%";
-
-$Debug = 1; # 2 will turn on more logging
- # 3 will log packet contents, including passwords
-
-$max_kids = '10'; #?
-$keepalives = 0; #let clientd turn it on, so we don't barf on old ones
-$kids = 0;
-
-my $user = shift or die &usage;
-my $machine = shift or die &usage;
-my $tag = scalar(@ARGV) ? shift : '';
-
-my $lock_file = "$FREESIDE_LOCK/selfservice.$machine.writelock";
-
-# to keep pid files unique w/multi machines (and installs!)
-# $FS::UID::datasrc not posible
-daemonize1("freeside-selfservice-server","$user.$machine");
-
-#false laziness w/Daemon::drop_root
-my $freeside_gid = scalar(getgrnam('freeside'))
- or die "can't find freeside group\n";
-
-open(LOCKFILE,">$lock_file") or die "can't open $lock_file: $!";
-chown $FS::UID::freeside_uid, $freeside_gid, $lock_file;
-
-drop_root();
-
-$ENV{HOME} = (getpwuid($>))[7]; #for ssh
-
-adminsuidsetup $user;
-
-#logfile("/usr/local/etc/freeside/selfservice.". $FS::UID::datasrc); #MACHINE
-logfile("$FREESIDE_LOG/selfservice.$machine.log");
-
-daemonize2();
-
-my $conf = new FS::Conf;
-if ( $conf->exists('selfservice-ignore_quantity') ) {
- $FS::cust_svc::ignore_quantity = 1;
- $FS::cust_svc::ignore_quantity = 1; #now it is used twice.
-}
-
-#clear the signup info cache so an "/etc/init.d/freeside restart" will pick
-#up new info... (better as a callback in Signup.pm?)
-my $cache = new FS::ClientAPI_SessionCache( {
- 'namespace' => 'FS::ClientAPI::Signup',
-} );
-$cache->remove('signup_info_cache');
-
-my $clientd = "/usr/local/sbin/freeside-selfservice-clientd"; #better name?
-
-my $warnkids=0;
-while (1) {
- my($writer,$reader,$error) = (new IO::Handle, new IO::Handle, new IO::Handle);
- warn "connecting to $machine\n" if $Debug;
-
- $ssh_pid = sshopen2($machine,$reader,$writer,$clientd,$tag);
-
-# nstore_fd(\*writer, {'hi'=>'there'});
-
- warn "entering main loop\n" if $Debug;
- my $undisp = 0;
- my $keepalive_count = 0;
- my $s = IO::Select->new( $reader );
- while (1) {
-
- &reap_kids;
-
- warn "waiting for packet from client\n" if $Debug && !$undisp;
- $undisp = 1;
- my @handles = $s->can_read(5);
- unless ( @handles ) {
- myshutdown() if sigint() || sigterm();
- if ( $keepalives && $keepalive_count++ > 10 ) {
- $keepalive_count = 0;
- lock_write;
- nstore_fd( { _token => '_keepalive' }, $writer );
- unlock_write;
- }
- next;
- }
-
- $undisp = 0;
-
- warn "receiving packet from client\n" if $Debug;
-
- my $packet = eval { fd_retrieve($reader); };
- if ( $@ ) {
- warn "Storable error receiving packet from client".
- " (assuming lost connection): $@\n"
- if $Debug;
- if ( $ssh_pid ) {
- warn "sending TERM signal to ssh process $ssh_pid\n" if $Debug;
- kill 'TERM', $ssh_pid;
- $old_ssh_pid{$ssh_pid} = 1;
- $ssh_pid = 0;
- }
- last;
- }
- warn "packet received\n".
- join('', map { " $_=>$packet->{$_}\n" } keys %$packet )
- if $Debug > 2;
-
- if ( $packet->{_packet} eq '_enable_keepalive' ) {
- warn "enabling keep alives\n" if $Debug;
- $keepalives=1;
- next;
- }
-
- #prevent runaway forking
- my $warnkids = 0;
- while ( $kids >= $max_kids ) {
- warn "WARNING: maximum $kids children reached\n" unless $warnkids++;
- &reap_kids;
- sleep 1;
- }
-
- warn "forking child\n" if $Debug;
- defined( my $pid = fork ) or die "can't fork: $!";
- if ( $pid ) {
- $kids++;
- $kids{$pid} = 1;
- warn "child $pid spawned\n" if $Debug;
- } else { #kid time
-
- ##get new db handle
- $FS::UID::dbh->{InactiveDestroy} = 1;
- forksuidsetup($user);
-
- #get db handle
- #adminsuidsetup($user);
-
- my $type = $packet->{_packet};
- warn "calling $type handler\n" if $Debug;
- my $rv = eval { FS::ClientAPI->dispatch($type, $packet); };
- if ( $@ ) {
- warn my $error = "WARNING: error dispatching $type: $@";
- $rv = { _error => $error };
- }
- $rv->{_token} = $packet->{_token}; #identifier
-
- open(LOCKFILE,">$lock_file") or die "can't open $lock_file: $!";
- lock_write;
- warn "sending response\n" if $Debug;
- nstore_fd($rv, $writer) or die "FATAL: can't send response: $!";
- $writer->flush or die "FATAL: can't flush: $!";
- unlock_write;
-
- warn "child exiting\n" if $Debug;
- exit; #end-of-kid
- }
-
- }
-
- myshutdown if sigint() || sigterm();
- warn "connection lost, reconnecting\n" if $Debug;
- sleep 3;
-
-}
-
-###
-# utility subroutines
-###
-
-sub reap_kids {
- #warn "reaping kids\n";
- foreach my $pid ( keys %kids ) {
- my $kid = waitpid($pid, WNOHANG);
- if ( $kid > 0 ) {
- $kids--;
- delete $kids{$kid};
- }
- }
-
- foreach my $pid ( keys %old_ssh_pid ) {
- waitpid($pid, WNOHANG) and delete $old_ssh_pid{$pid};
- }
- #warn "done reaping\n";
-}
-
-sub myshutdown {
- &reap_kids;
- my $wait = 12; #wait up to 1 minute
- while ( $kids > 0 && $wait-- ) {
- warn "waiting for $kids children to terminate";
- sleep 5;
- &reap_kids;
- }
- warn "abandoning $kids children" if $kids;
- kill 'TERM', $ssh_pid if $ssh_pid;
- die "exiting";
-}
-
-sub lock_write {
- warn "locking $lock_file mutex for write to write stream\n" if $Debug > 1;
-
- #broken on freebsd?
- #flock($writer, LOCK_EX) or die "FATAL: can't lock write stream: $!";
-
- flock(LOCKFILE, LOCK_EX) or die "FATAL: can't lock $lock_file: $!";
-
-}
-
-sub unlock_write {
- warn "unlocking $lock_file mutex\n" if $Debug > 1;
-
- #broken on freebsd?
- #flock($writer, LOCK_UN) or die "WARNING: can't release write lock: $!";
-
- flock(LOCKFILE, LOCK_UN) or die "FATAL: can't unlock $lock_file: $!";
-
-}
-
-sub usage {
- die "Usage:\n\n freeside-selfservice-server user machine\n";
-}
-
diff --git a/FS/bin/freeside-setinvoice b/FS/bin/freeside-setinvoice
deleted file mode 100644
index 708e2fa30..000000000
--- a/FS/bin/freeside-setinvoice
+++ /dev/null
@@ -1,42 +0,0 @@
-#!/usr/bin/perl
-
-use strict;
-use FS::UID qw(adminsuidsetup);
-use FS::Conf;
-use FS::Record qw(qsearch qsearchs);
-use FS::cust_main;
-use FS::svc_acct;
-
-&untaint_argv; #what it sounds like (eww)
-my $user = shift or die &usage;
-
-adminsuidsetup $user;
-
-foreach my $cust_main (
- grep { ! scalar($_->invoicing_list) }
- qsearch( 'cust_main', {} )
-) {
- my @dest;
- my @cust_pkg = $cust_main->ncancelled_pkgs;
- foreach my $cust_pkg ( @cust_pkg ) {
- foreach my $cust_svc ( $cust_pkg->cust_svc ) {
- my $svc_acct = qsearchs( 'svc_acct', { 'svcnum' => $cust_svc->svcnum } );
- push @dest, $svc_acct->svcnum if $svc_acct;
- }
- }
- push @dest, 'POST' unless @dest;
- $cust_main->invoicing_list(\@dest);
-}
-
-sub untaint_argv {
- foreach $_ ( $[ .. $#ARGV ) { #untaint @ARGV
- $ARGV[$_] =~ /^(.*)$/ || die "Illegal arguement \"$ARGV[$_]\"";
- $ARGV[$_]=$1;
- }
-}
-
-sub usage {
- die "Usage:\n\n freeside-setinvoice user\n";
-}
-
-
diff --git a/FS/bin/freeside-setup b/FS/bin/freeside-setup
deleted file mode 100755
index 9b16d78cb..000000000
--- a/FS/bin/freeside-setup
+++ /dev/null
@@ -1,160 +0,0 @@
-#!/usr/bin/perl -Tw
-
-#to delay loading dbdef until we're ready
-BEGIN { $FS::Schema::setup_hack = 1; }
-
-use strict;
-use vars qw($opt_u $opt_d $opt_v);
-use Getopt::Std;
-use FS::UID qw(adminsuidsetup datasrc checkeuid getsecrets);
-use FS::CurrentUser;
-use FS::Schema qw( dbdef_dist reload_dbdef );
-use FS::Record qw( qsearch );
-#use FS::raddb;
-use FS::Setup qw(create_initial_data);
-use FS::Conf;
-
-die "Not running uid freeside!" unless checkeuid();
-
-#my %attrib2db =
-# map { lc($FS::raddb::attrib{$_}) => $_ } keys %FS::raddb::attrib;
-
-getopts("u:vd:");
-my $config_dir = shift || 'conf' ;
-$config_dir =~ /^([\w.:=]+)$/
- or die "unacceptable configuration directory name";
-$config_dir = $1;
-
-getsecrets($opt_u);
-
-#needs to match FS::Record
-my($dbdef_file) = "%%%FREESIDE_CONF%%%/dbdef.". datasrc;
-
-###
-
-my $username_len = 32;
-
-#print "\n\n", <<END, ":";
-#Freeside tracks the RADIUS User-Name, check attribute Password and
-#reply attribute Framed-IP-Address for each user. You can specify additional
-#check and reply attributes (or you can add them later with the
-#fs-radius-add-check and fs-radius-add-reply programs).
-#
-#First enter any additional RADIUS check attributes you need to track for each
-#user, separated by whitespace.
-#END
-#my @check_attributes = map { $attrib2db{lc($_)} or die "unknown attribute $_"; }
-# split(" ",&getvalue);
-#
-#print "\n\n", <<END, ":";
-#Now enter any additional reply attributes you need to track for each user,
-#separated by whitespace.
-#END
-#my @attributes = map { $attrib2db{lc($_)} or die "unknown attribute $_"; }
-# split(" ",&getvalue);
-#
-#print "\n\n", <<END, ":";
-#Do you wish to enable the tracking of a second, separate shipping/service
-#address?
-#END
-#my $ship = &_yesno;
-#
-#sub getvalue {
-# my($x)=scalar(<STDIN>);
-# chop $x;
-# $x;
-#}
-#
-#sub _yesno {
-# print " [y/N]:";
-# my $x = scalar(<STDIN>);
-# $x =~ /^y/i;
-#}
-
-#my @check_attributes = (); #add later
-#my @attributes = (); #add later
-#my $ship = $opt_s;
-
-###
-# create a dbdef object from the old data structure
-###
-
-my $dbdef = dbdef_dist(datasrc);
-
-#important
-$dbdef->save($dbdef_file);
-&FS::Schema::reload_dbdef($dbdef_file);
-
-###
-# create 'em
-###
-
-$FS::CurrentUser::upgrade_hack = 1;
-$FS::UID::callback_hack = 1;
-my $dbh = adminsuidsetup $opt_u; #$user;
-$FS::UID::callback_hack = 0;
-
-#create tables
-$|=1;
-
-foreach my $statement ( $dbdef->sql($dbh) ) {
- $dbh->do( $statement )
- or die "CREATE error: ". $dbh->errstr. "\ndoing statement: $statement";
-}
-
-#now go back and reverse engineer the db
-#so we pick up the correct column DEFAULTs for #oidless inserts
-dbdef_create($dbh, $dbdef_file);
-delete $FS::Schema::dbdef_cache{$dbdef_file}; #force an actual reload
-reload_dbdef($dbdef_file);
-
-warn "Freeside schema initialized - commiting transaction\n" if $opt_v;
-
-$dbh->commit or die $dbh->errstr;
-$dbh->disconnect or die $dbh->errstr;
-
-warn "Database schema committed successfully\n" if $opt_v;
-
-warn "Initializing freeside configuration\n" if $opt_v;
-$FS::UID::callback_hack = 1;
-$dbh = adminsuidsetup $opt_u;
-$FS::UID::callback_hack = 0;
-if (!scalar(qsearch('conf', {}))) {
- my $error = FS::Conf::init_config($config_dir);
- if ($error) {
- $dbh->rollback or die $dbh->errstr;
- die $error;
- }
-}
-
-warn "Freeside configuration initialized - commiting transaction\n" if $opt_v;
-
-$dbh->commit or die $dbh->errstr;
-$dbh->disconnect or die $dbh->errstr;
-
-warn "Freeside configuration committed successfully\n" if $opt_v;
-
-$dbh = adminsuidsetup $opt_u;
-create_initial_data('domain' => $opt_d);
-
-warn "Freeside database initialized - commiting transaction\n" if $opt_v;
-
-$dbh->commit or die $dbh->errstr;
-$dbh->disconnect or die $dbh->errstr;
-
-warn "Database initialization committed successfully\n" if $opt_v;
-
-sub dbdef_create { # reverse engineer the schema from the DB and save to file
- my( $dbh, $file ) = @_;
- my $dbdef = new_native DBIx::DBSchema $dbh;
- $dbdef->save($file);
-}
-
-sub usage {
- die "Usage:\n freeside-setup -d domain.name [ -v ] [ config/dir ]\n"
- # [ -u user ] for devel/multi-db installs
-}
-
-1;
-
-
diff --git a/FS/bin/freeside-sqlradius-dedup-group b/FS/bin/freeside-sqlradius-dedup-group
deleted file mode 100755
index 441d50f62..000000000
--- a/FS/bin/freeside-sqlradius-dedup-group
+++ /dev/null
@@ -1,82 +0,0 @@
-#!/usr/bin/perl -w
-
-use strict;
-use vars qw( %seen @dups );
-use Getopt::Std;
-use FS::UID qw(adminsuidsetup);
-use FS::Record qw(qsearch qsearchs);
-use FS::part_export;
-
-my %allowed_types = map { $_ => 1 } qw ( sqlradius sqlradius_withdomain );
-
-my $user = shift or die &usage;
-adminsuidsetup $user;
-
-my $export_x = shift;
-my @part_export;
-if ( !defined($export_x) ) {
- @part_export = qsearch('part_export', {} );
-} elsif ( $export_x =~ /^(\d+)$/ ) {
- @part_export = qsearchs('part_export', { exportnum=>$1 } )
- or die "exportnum $export_x not found\n";
-} else {
- @part_export = qsearch('part_export', { exporttype=>$export_x } )
- or die "no exports of type $export_x found\n";
-}
-
-@part_export = grep { $allowed_types{$_->exporttype} } @part_export
- or die "No sqlradius exports specified.";
-
-foreach my $part_export ( @part_export ) {
- my $dbh = DBI->connect( map $part_export->option($_),
- qw ( datasrc username password ) );
-
- my $sth = $dbh->prepare("SELECT id,username,groupname
- FROM usergroup ORDER By username,groupname,id")
- or die $dbh->errstr;
- $sth->execute() or die $sth->errstr;
-
- @dups = (); %seen = ();
- while (my $row = $sth->fetchrow_arrayref ) {
- my ($userid, $username, $groupname) = @$row;
- unless ( exists($seen{$username}{$groupname}) ) {
- $seen{$username}{$groupname} = $userid;
- next;
- }
- push @dups, $userid;
- }
-
- $sth = $dbh->prepare("DELETE FROM usergroup WHERE id = ?")
- or die $dbh->errstr;
-
- foreach (@dups) {
- $sth->execute($_) or die $sth->errstr;
- }
-
-}
-
-
-sub usage {
- die "Usage:\n\n freeside-sqlradius-dedup-group user [ exportnum|exporttype ]\n";
-}
-
-=head1 NAME
-
-freeside-sqlradius-dedup-group - Command line tool to eliminate duplicate usergroup entries from radius tables
-
-=head1 SYNOPSIS
-
- freeside-sqlradius-dedup-group user [ exportnum|exporttype ]
-
-=head1 DESCRIPTION
-
- Removes all but one username groupname pair when duplicate entries exist
- for the specified export (selected by exportnum or exporttype) or all
- exports if none are specified.
-
-=head1 SEE ALSO
-
-L<freeside-reexport>, L<freeside-sqlradius-reset>, L<FS::part_export>
-
-=cut
-
diff --git a/FS/bin/freeside-sqlradius-radacctd b/FS/bin/freeside-sqlradius-radacctd
deleted file mode 100644
index 83fd4bfd1..000000000
--- a/FS/bin/freeside-sqlradius-radacctd
+++ /dev/null
@@ -1,150 +0,0 @@
-#!/usr/bin/perl -w
-
-use strict;
-use vars qw( @part_export );
-use subs qw(myshutdown);
-use POSIX qw(:sys_wait_h);
-#use IO::File;
-use FS::Daemon qw(daemonize1 drop_root logfile daemonize2 sigint sigterm);
-use FS::UID qw(adminsuidsetup); #forksuidsetup driver_name dbh myconnect);
-use FS::Record qw(qsearch); # qsearchs);
-use FS::part_export;
-#use FS::svc_acct;
-#use FS::cust_svc;
-
-my $user = shift or die &usage;
-
-#daemonize1('freeside-sqlradius-radacctd', $user); #keep unique pid files w/multi installs
-daemonize1('freeside-sqlradius-radacctd');
-
-drop_root();
-
-#$ENV{HOME} = (getpwuid($>))[7]; #for ssh
-
-adminsuidsetup $user;
-
-logfile( "%%%FREESIDE_LOG%%%/sqlradius-radacctd-log.". $FS::UID::datasrc );
-
-daemonize2();
-
-#--
-
-#don't just look for ->can('usage_sessions'), we're sqlradius-specific
-# (radiator is supposed to be setup with a radacct table)
-
-@part_export =
- qsearch('part_export', { 'exporttype' => 'sqlradius' } );
-push @part_export,
- qsearch('part_export', { 'exporttype' => 'sqlradius_withdomain' } );
-push @part_export,
- qsearch('part_export', { 'exporttype' => 'radiator' } );
-
-@part_export = grep { ! $_->option('ignore_accounting') } @part_export;
-
-die "no sqlradius, sqlradius_withdomain or radiator exports without".
- " ignore_accounting"
- unless @part_export;
-
-while (1) {
-
- #fork off one kid per export (machine)
- # _>{'_radacct_kid'} is an evil kludge
- foreach my $part_export ( grep ! $_->{'_radacct_kid'}, @part_export ) {
-
- defined( my $pid = fork ) or do {
- warn "WARNING: can't fork to spawn child for ". $part_export->machine;
- next;
- };
-
- if ( $pid ) {
- $part_export->{'_radacct_kid'} = $pid;
- warn "child $pid spawned for ". $part_export->machine;
- } else { #kid time
-
- adminsuidsetup($user); #get our own db handle
-
- until ( sigint || sigterm ) {
- $part_export->update_svc_acct();
- sleep 1;
- }
-
- warn "child for ". $part_export->machine. " done";
- exit;
-
- } #eo kid
-
- }
-
- #reap up any kids that died...
- &reap_kids;
-
- myshutdown() if sigterm() || sigint();
-
- sleep 5;
-}
-
-#--
-
-sub myshutdown {
- &reap_kids;
-
- #kill all the kids
- kill 'TERM', $_ foreach grep $_, map $_->{'_radacct_kid'}, @part_export;
-
- my $wait = 12; #wait up to 1 minute
- while ( ( grep $_->{'_radacct_kid'}, @part_export ) && $wait-- ) {
- warn "waiting for children to terminate";
- sleep 5;
- &reap_kids;
- }
- warn "abandoning children" if grep $_->{'_radacct_kid'}, @part_export;
- die "exiting";
-}
-
-sub reap_kids {
- #warn "reaping kids\n";
- foreach my $part_export ( grep $_->{'_radacct_kid'}, @part_export ) {
- my $pid = $part_export->{'_radacct_kid'};
- my $kid = waitpid($pid, WNOHANG);
- if ( $kid > 0 ) {
- $part_export->{'_radacct_kid'} = '';
- }
- }
- #warn "done reaping\n";
-}
-
-sub usage {
- die "Usage:\n\n freeside-sqlradius-radacctd user\n";
-}
-
-=head1 NAME
-
-freeside-sqlradius-radacctd - Real-time radacct import daemon
-
-=head1 SYNOPSIS
-
- freeside-sqlradius-radacctd username
-
-=head1 DESCRIPTION
-
-Imports records from an the SQL radacct tables of all sqlradius,
-sqlradius_withdomain and radiator exports (except those with the
-ignore_accounting flag) and updates the svc_acct.seconds for each account.
-Runs as a daemon and updates the database in real-time.
-
-B<username> is a username added by freeside-adduser.
-
-=head1 RADIUS DATABASE CHANGES
-
-ALTER TABLE radacct ADD COLUMN FreesideStatus varchar(32) NULL;
-
-If you want to ignore the existing accountg records, also do:
-
-UPDATE radacct SET FreesideStatus = 'done' WHERE FreesideStatus IS NULL;
-
-=head1 SEE ALSO
-
-=cut
-
-1;
-
diff --git a/FS/bin/freeside-sqlradius-reset b/FS/bin/freeside-sqlradius-reset
deleted file mode 100755
index 94fa68a06..000000000
--- a/FS/bin/freeside-sqlradius-reset
+++ /dev/null
@@ -1,104 +0,0 @@
-#!/usr/bin/perl -w
-
-use strict;
-use vars qw( $opt_n );
-use Getopt::Std;
-use FS::UID qw(adminsuidsetup);
-use FS::Record qw(qsearch qsearchs);
-use FS::part_export;
-use FS::svc_acct;
-use FS::cust_svc;
-
-getopts("n");
-
-my $user = shift or die &usage;
-adminsuidsetup $user;
-
-#my $machine = shift or die &usage;
-
-my @exports = ();
-if ( @ARGV ) {
- foreach my $exportnum ( @ARGV ) {
- foreach my $exporttype (qw( sqlradius sqlradius_withdomain )) {
- push @exports, qsearch('part_export', { exportnum => $exportnum,
- exporttype => $exporttype, } );
- }
- }
- } else {
- @exports = qsearch('part_export', { exporttype=>'sqlradius' } );
- push @exports, qsearch('part_export', { exporttype=>'sqlradius_withdomain' } );
-}
-
-unless ( $opt_n ) {
- foreach my $export ( @exports ) {
- my $icradius_dbh = DBI->connect(
- map { $export->option($_) } qw( datasrc username password )
- ) or die $DBI::errstr;
- for my $table (qw( radcheck radreply usergroup )) {
- my $sth = $icradius_dbh->prepare("DELETE FROM $table");
- $sth->execute or die "Can't reset $table table: ". $sth->errstr;
- }
- $icradius_dbh->disconnect;
- }
-}
-
-foreach my $export ( @exports ) {
-
- #my @svcparts = map { $_->svcpart } $export->export_svc;
- my $overlimit_groups = $export->option('overlimit_groups');
-
- my @svc_acct =
- map { qsearchs('svc_acct', { 'svcnum' => $_->svcnum } ) }
- map { qsearch('cust_svc', { 'svcpart' => $_->svcpart } ) }
- grep { qsearch('cust_svc', { 'svcpart' => $_->svcpart } ) }
- $export->export_svc;
-
- foreach my $svc_acct ( @svc_acct ) {
-
- $svc_acct->check; #set any fixed usergroup so it'll export even if all
- #svc_acct records don't have the group yet
-
- if ($overlimit_groups && $svc_acct->overlimit) {
- $svc_acct->usergroup( &{ $svc_acct->_fieldhandlers->{'usergroup'} }
- ($svc_acct, $overlimit_groups)
- );
- }
-
- #false laziness with FS::svc_acct::insert (like it matters)
- my $error = $export->export_insert($svc_acct);
- die $error if $error;
-
- }
-}
-
-sub usage {
- die "Usage:\n\n freeside-sqlradius-reset user [ exportnum, ... ]\n";
-}
-
-=head1 NAME
-
-freeside-sqlradius-reset - Command line interface to reset and recreate RADIUS SQL tables
-
-=head1 SYNOPSIS
-
- freeside-sqlradius-reset [ -n ] username [ EXPORTNUM, ... ]
-
-=head1 DESCRIPTION
-
-Deletes the radcheck, radreply and usergroup tables and repopulates them from
-the Freeside database, for the specified exports, or, if no exports are
-specified, for all sqlradius and sqlradius_withdomain exports.
-
-B<username> is a username added by freeside-adduser.
-
-The B<-n> option, if supplied, supresses the deletion of the existing data in
-the tables.
-
-=head1 SEE ALSO
-
-L<freeside-reexport>, L<FS::part_export>, L<FS::part_export::sqlradius>
-
-=cut
-
-
-
diff --git a/FS/bin/freeside-sqlradius-seconds b/FS/bin/freeside-sqlradius-seconds
deleted file mode 100644
index 9999cbbf3..000000000
--- a/FS/bin/freeside-sqlradius-seconds
+++ /dev/null
@@ -1,58 +0,0 @@
-#!/usr/bin/perl -Tw
-
-use strict;
-use Date::Parse;
-use FS::UID qw(adminsuidsetup);
-use FS::Record qw(qsearchs);
-use FS::svc_acct;
-
-my $fs_user = shift or die &usage;
-adminsuidsetup( $fs_user );
-
-my $target_user = shift or die &usage;
-my $start = shift or die &usage;
-$start = str2time($start);
-my $stop = scalar(@ARGV) ? str2time(shift) : time;
-
-my $svc_acct = qsearchs( 'svc_acct', { 'username' => $target_user } );
-die "username $target_user not found\n" unless $svc_acct;
-
-print $svc_acct->seconds_since_sqlradacct( $start, $stop ). "\n";
-
-sub usage {
- die "Usage:\n\n freeside-sqlradius-seconds freeside_username target_username start_date stop_date\n";
-}
-
-
-=head1 NAME
-
-freeside-sqlradius-seconds - Command line time-online tool
-
-=head1 SYNOPSIS
-
- freeside-sqlradius-seconds freeside_username target_username start_date [ stop_date ]
-
-=head1 DESCRIPTION
-
-Returns the number of seconds the specified username has been online between
-start_date (inclusive) and stop_date (exclusive).
-See L<FS::svc_acct/seconds_since_sqlradacct>
-
-B<freeside_username> is a username added by freeside-adduser.
-B<target_username> is the username of the user account to query.
-B<start_date> and B<stop_date> are in any format Date::Parse is happy with.
-B<stop_date> defaults to now if not specified.
-
-=head1 BUGS
-
-Selection of the account in question is rather simplistic in that
-B<target_username> doesn't necessarily identify a unique account (and wouldn't
-even if a domain was specified), and no sqlradius export is checked for.
-
-=head1 SEE ALSO
-
-L<FS::svc_acct/seconds_since_sqlradacct>
-
-=cut
-
-1;
diff --git a/FS/bin/freeside-sqlradius-set-lastlog b/FS/bin/freeside-sqlradius-set-lastlog
deleted file mode 100755
index ad8563076..000000000
--- a/FS/bin/freeside-sqlradius-set-lastlog
+++ /dev/null
@@ -1,102 +0,0 @@
-#!/usr/bin/perl -w
-
-use strict;
-use Getopt::Std;
-use FS::UID qw(adminsuidsetup);
-use FS::Record qw(qsearch qsearchs str2time_sql);
-use FS::Conf;
-use FS::part_export;
-use FS::svc_acct;
-
-my %allowed_types = map { $_ => 1 } qw ( sqlradius sqlradius_withdomain );
-my $conf = new FS::Conf;
-
-my $user = shift or die &usage;
-adminsuidsetup $user;
-
-my $export_x = shift;
-my @part_export;
-if ( !defined($export_x) ) {
- @part_export = qsearch('part_export', {} );
-} elsif ( $export_x =~ /^(\d+)$/ ) {
- @part_export = qsearchs('part_export', { exportnum=>$1 } )
- or die "exportnum $export_x not found\n";
-} else {
- @part_export = qsearch('part_export', { exporttype=>$export_x } )
- or die "no exports of type $export_x found\n";
-}
-
-# gross almost false laziness with FS::part_export::sqlradius::update_svc_acct
-@part_export = grep { ! $_->option('ignore_accounting') }
- grep { $allowed_types{$_->exporttype} }
- @part_export
- or die "No sqlradius exports specified.";
-
-
-foreach my $part_export ( @part_export ) {
- my $dbh = DBI->connect( map $part_export->option($_),
- qw ( datasrc username password ) );
-
- my $str2time = str2time_sql( $dbh->{Driver}->{Name} );
- my $group = "UserName";
- $group .= ",Realm"
- if ( ref($part_export) =~ /withdomain/ );
-
- my $sth = $dbh->prepare("SELECT UserName, Realm,
- $str2time max(AcctStartTime)),
- $str2time max(AcctStopTime))
- FROM radacct
- WHERE AcctStartTime != 0 AND AcctStopTime != 0
- GROUP BY $group")
- or die $dbh->errstr;
- $sth->execute() or die $sth->errstr;
-
- while (my $row = $sth->fetchrow_arrayref ) {
- my ($username, $realm, $start, $stop) = @$row;
-
- $username = lc($username) unless $conf->exists('username-uppercase');
- my $extra_sql = '';
- if ( ref($part_export) =~ /withdomain/ ) {
- $extra_sql = " And '$realm' = ( SELECT domain FROM svc_domain
- WHERE svc_domain.svcnum = svc_acct.domsvc ) ";
- }
-
- my $svc_acct = qsearchs( 'svc_acct',
- { 'username' => $username },
- '',
- $extra_sql,
- );
- if ($svc_acct) {
- $svc_acct->last_login($start)
- if $start && (!$svc_acct->last_login || $start > $svc_acct->last_login);
- $svc_acct->last_logout($stop)
- if $stop && (!$svc_acct->last_logout || $stop > $svc_acct->last_logout);
- }
- }
-}
-
-
-sub usage {
- die "Usage:\n\n freeside-sqlradius-set_lastlog user [ exportnum|exporttype ]\n";
-}
-
-=head1 NAME
-
-freeside-sqlradius-set-lastlog - Command line tool to set last_login and last_logout values from radius tables
-
-=head1 SYNOPSIS
-
- freeside-sqlradius-set-lastlog user [ exportnum|exporttype ]
-
-=head1 DESCRIPTION
-
- Sets the last_login and last_logout columns of each svc_acct based on
- data in the radacct table for the specified export (selected by exportnum
- or exporttype) or all exports if none are specified.
-
-=head1 SEE ALSO
-
-L<freeside-sqlradius-radacctd>, L<FS::part_export>
-
-=cut
-
diff --git a/FS/bin/freeside-upgrade b/FS/bin/freeside-upgrade
deleted file mode 100755
index d143d9206..000000000
--- a/FS/bin/freeside-upgrade
+++ /dev/null
@@ -1,175 +0,0 @@
-#!/usr/bin/perl -w
-
-use strict;
-use vars qw($opt_d $opt_q $opt_v);
-use vars qw($DEBUG $DRY_RUN);
-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 FS::Misc::prune qw(prune_applications);
-use FS::Conf;
-use FS::Record qw(qsearch);
-use FS::Upgrade qw(upgrade);
-
-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;
-$FS::UID::callback_hack = 1;
-my $dbh = adminsuidsetup($user);
-$FS::UID::callback_hack = 0;
-
-#needs to match FS::Schema...
-my $dbdef_file = "%%%FREESIDE_CONF%%%/dbdef.". datasrc;
-
-dbdef_create($dbh, $dbdef_file);
-
-delete $FS::Schema::dbdef_cache{$dbdef_file}; #force an actual reload
-reload_dbdef($dbdef_file);
-
-$DBIx::DBSchema::DEBUG = $DEBUG;
-$DBIx::DBSchema::Table::DEBUG = $DEBUG;
-$DBIx::DBSchema::Index::DEBUG = $DEBUG;
-
-my @bugfix = ();
-
-if (dbdef->table('cust_main')->column('agent_custid')) {
- push @bugfix,
- "UPDATE cust_main SET agent_custid = NULL where agent_custid = ''";
-
- push @bugfix,
- "UPDATE h_cust_main SET agent_custid = NULL where agent_custid = ''"
- if (dbdef->table('h_cust_main'));
-}
-
-#you should have run fs-migrate-part_svc ages ago, when you upgraded
-#from 1.3 to 1.4... if not, it needs to be hooked into -upgrade here or
-#you'll lose all the part_svc settings it migrates to part_svc_column
-
-if ( $DRY_RUN ) {
- print
- join(";\n", @bugfix, dbdef->sql_update_schema( dbdef_dist(datasrc), $dbh ) ). ";\n";
- exit;
-} else {
- foreach my $statement ( @bugfix ) {
- $dbh->do( $statement )
- or die "Error: ". $dbh->errstr. "\n executing: $statement";
- }
-
- dbdef->update_schema( dbdef_dist(datasrc), $dbh );
-}
-
-my $hashref = {};
-$hashref->{dry_run} = 1 if $DRY_RUN;
-$hashref->{debug} = 1 if $DEBUG;
-print join "\n", prune_applications($hashref);
-print "\n" if $DRY_RUN;
-
-if ( $dbh->{Driver}->{Name} =~ /^mysql/i ) {
-
- my $sth = $dbh->prepare(
- "SELECT COUNT(*) FROM duplicate_lock WHERE lockname = 'svc_acct'"
- ) or die $dbh->errstr;
-
- $sth->execute or die $sth->errstr;
-
- unless ( $sth->fetchrow_arrayref->[0] ) {
-
- $sth = $dbh->prepare(
- "INSERT INTO duplicate_lock ( lockname ) VALUES ( 'svc_acct' )"
- ) or die $dbh->errstr;
-
- $sth->execute or die $sth->errstr;
-
- }
-}
-
-$dbh->commit or die $dbh->errstr;
-
-dbdef_create($dbh, $dbdef_file);
-
-$dbh->disconnect or die $dbh->errstr;
-
-delete $FS::Schema::dbdef_cache{$dbdef_file}; #force an actual reload
-$FS::UID::AutoCommit = 0;
-$FS::UID::callback_hack = 1;
-$dbh = adminsuidsetup($user);
-$FS::UID::callback_hack = 0;
-unless ( $DRY_RUN ) {
- my $dir = "%%%FREESIDE_CONF%%%/conf.". datasrc;
- if (!scalar(qsearch('conf', {}))) {
- my $error = FS::Conf::init_config($dir);
- if ($error) {
- warn "CONFIGURATION UPGRADE FAILED\n";
- $dbh->rollback or die $dbh->errstr;
- die $error;
- }
- }
-}
-$dbh->commit or die $dbh->errstr;
-$dbh->disconnect or die $dbh->errstr;
-
-$dbh = adminsuidsetup($user);
-
-upgrade()
- unless $DRY_RUN;
-
-$dbh->commit or die $dbh->errstr;
-$dbh->disconnect or die $dbh->errstr;
-
-###
-
-sub dbdef_create { # reverse engineer the schema from the DB and save to file
- my( $dbh, $file ) = @_;
- my $dbdef = new_native DBIx::DBSchema $dbh;
- $dbdef->save($file);
-}
-
-sub usage {
- die "Usage:\n freeside-upgrade [ -d ] [ -q | -v ] user\n";
-}
-
-=head1 NAME
-
-freeside-upgrade - Upgrades database schema for new freeside verisons.
-
-=head1 SYNOPSIS
-
- freeside-upgrade [ -d ] [ -q | -v ]
-
-=head1 DESCRIPTION
-
-Reads your existing database schema and updates it to match the current schema,
-adding any columns or tables necessary.
-
-Also performs other upgrade functions:
-
-=over 4
-
-=item Calls FS:: Misc::prune::prune_applications (probably unnecessary every upgrade, but simply won't find any records to change)
-
-=item If necessary, moves your configuration information from the filesystem in /usr/local/etc/freeside/conf.<datasrc> to the database.
-
-=back
-
- [ -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
-