X-Git-Url: http://git.freeside.biz/gitweb/?p=freeside.git;a=blobdiff_plain;f=FS%2Fbin%2Ffreeside-selfservice-server;h=c10623c9688edb58e1683af50e226686cbe5eba1;hp=fc04ee91ec9f1e9e243a975eeffa4078a6413022;hb=aed8ec35ccb9cdeb7ea0cb6ff2946f9d83d582f6;hpb=7422aa77086326ba1e6032150ce5704d1003ea6f diff --git a/FS/bin/freeside-selfservice-server b/FS/bin/freeside-selfservice-server index fc04ee91e..c10623c96 100644 --- a/FS/bin/freeside-selfservice-server +++ b/FS/bin/freeside-selfservice-server @@ -1,6 +1,7 @@ #!/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); @@ -12,13 +13,16 @@ 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 qw( load_clientapi_modules ); +use FS::ClientAPI_SessionCache; +use FS::Record qw( qsearch qsearchs ); use FS::Conf; -use FS::cust_bill; -use FS::cust_pkg; +use FS::cust_svc; +use FS::agent; -$FREESIDE_CONF = "%%%FREESIDE_CONF%%%"; +$FREESIDE_LOG = "%%%FREESIDE_LOG%%%"; +$FREESIDE_LOCK = "%%%FREESIDE_LOCK%%%"; $Debug = 1; # 2 will turn on more logging # 3 will log packet contents, including passwords @@ -31,8 +35,7 @@ my $user = shift or die &usage; my $machine = shift or die &usage; my $tag = scalar(@ARGV) ? shift : ''; -my $lock_file = "/usr/local/etc/freeside/selfservice.$machine.writelock"; - +my $lock_file = "$FREESIDE_LOCK/selfservice.$machine.writelock"; # to keep pid files unique w/multi machines (and installs!) # $FS::UID::datasrc not posible @@ -49,14 +52,34 @@ drop_root(); $ENV{HOME} = (getpwuid($>))[7]; #for ssh +load_clientapi_modules; + adminsuidsetup $user; #logfile("/usr/local/etc/freeside/selfservice.". $FS::UID::datasrc); #MACHINE -logfile("$FREESIDE_SERVER/selfservice.$machine.log"); +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'); + +#and also clear the selfservice skin info cache, for the same reason +my $ss_cache = new FS::ClientAPI_SessionCache( { + 'namespace' => 'FS::ClientAPI::MyAccount', +} ); +$ss_cache->remove($_) + foreach grep /^skin_info_cache_agent/, $ss_cache->get_keys(); my $clientd = "/usr/local/sbin/freeside-selfservice-clientd"; #better name? @@ -85,7 +108,31 @@ while (1) { if ( $keepalives && $keepalive_count++ > 10 ) { $keepalive_count = 0; lock_write; + nstore_fd( { _token => '_keepalive' }, $writer ); + +#commenting izoom stuff out until we can move it to a branch (or just remove) +# foreach my $agent ( qsearch( 'agent', { disabled => '' } ) ) { +# my $config = qsearchs( 'conf', { name => 'selfservice-bulk_ftp_dir', +# agentnum => $agent->agentnum, +# } ) +# or next; +# +# my $session = +# FS::ClientAPI->dispatch( 'Agent/agent_login', +# { username => $agent->username, +# password => $agent->_password, +# } +# ); +# +# nstore_fd( { _token => '_ftp_scan', +# dir => $config->value, +# session_id => $session->{session_id}, +# }, +# $writer +# ); +# } + unlock_write; } next;