work around missing id, RT#83146
[freeside.git] / FS / bin / freeside-selfservice-server
old mode 100644 (file)
new mode 100755 (executable)
index 1c2086e..4272cae
@@ -1,5 +1,11 @@
 #!/usr/bin/perl -w
 
+=head1 NAME
+
+freeside-selfservice-server
+
+=cut
+
 use strict;
 use vars qw( $FREESIDE_LOG $FREESIDE_LOCK );
 use vars qw( $Debug %kids $kids $max_kids $ssh_pid %old_ssh_pid $keepalives );
@@ -16,6 +22,7 @@ use FS::UID qw(adminsuidsetup forksuidsetup);
 use FS::ClientAPI qw( load_clientapi_modules );
 use FS::ClientAPI_SessionCache;
 use FS::Record qw( qsearch qsearchs );
+use FS::TicketSystem;
 
 use FS::Conf;
 use FS::cust_svc;
@@ -62,10 +69,15 @@ logfile("$FREESIDE_LOG/selfservice.$machine.log");
 daemonize2();
 
 my $conf = new FS::Conf;
+my $ticket_system = $conf->config('ticket_system');
 if ( $conf->exists('selfservice-ignore_quantity') ) {
   $FS::cust_svc::ignore_quantity = 1;
   $FS::cust_svc::ignore_quantity = 1; #now it is used twice.
 }
+if ( $conf->exists('selfservice-db_profile') ) {
+  eval "use DBIx::Profile";
+  warn $@ if $@;
+}
 
 #clear the signup info cache so an "/etc/init.d/freeside restart" will pick
 #up new info... (better as a callback in Signup.pm?)
@@ -108,28 +120,7 @@ while (1) {
       if ( $keepalives && $keepalive_count++ > 10 ) {
         $keepalive_count = 0;
         lock_write;
-
         nstore_fd( { _token => '_keepalive' }, $writer );
-        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;
@@ -178,12 +169,10 @@ while (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);
+      FS::TicketSystem->init() if $ticket_system;
 
       my $type = $packet->{_packet};
       warn "calling $type handler\n" if $Debug;