X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=fs_signup%2FFS-SignupClient%2Ffs_signupd;h=85bd68a2f5ed63fd4a9b9a168a9151ca9ba0713a;hb=f9911ed31df63ac52ccc5b119388ea5b2dc24e58;hp=f22ab15d4978a4571d16858b6181fff734f4432d;hpb=5e39e2d7963d6f8304e5afb5d8b5f50aa6eaaf14;p=freeside.git diff --git a/fs_signup/FS-SignupClient/fs_signupd b/fs_signup/FS-SignupClient/fs_signupd index f22ab15d4..85bd68a2f 100755 --- a/fs_signup/FS-SignupClient/fs_signupd +++ b/fs_signup/FS-SignupClient/fs_signupd @@ -3,16 +3,18 @@ # fs_signupd # # This is run REMOTELY over ssh by fs_signup_server. -# use strict; use Socket; +use Storable qw(nstore_fd fd_retrieve); +use IO::Handle; use vars qw( $Debug ); -$Debug = 0; +$Debug = 1; -my($fs_signupd_socket)="/usr/local/freeside/fs_signupd_socket"; +my $fs_signupd_socket = "/usr/local/freeside/fs_signupd_socket"; +my $pid_file = "$fs_signupd_socket.pid"; $ENV{'PATH'} ='/usr/local/bin:/usr/bin:/usr/ucb:/bin'; $ENV{'SHELL'} = '/bin/sh'; @@ -23,50 +25,8 @@ $ENV{'BASH_ENV'} = ''; $|=1; -warn "[fs_signupd] Reading locales...\n" if $Debug; -chomp( my $n_cust_main_county = ); -my @cust_main_county = map { - chomp( my $taxnum = ); - chomp( my $state = ); - chomp( my $county = ); - chomp( my $country = ); - { - 'taxnum' => $taxnum, - 'state' => $state, - 'county' => $county, - 'country' => $country, - }; -} ( 1 .. $n_cust_main_county ); - -warn "[fs_signupd] Reading package definitions...\n" if $Debug; -chomp( my $n_part_pkg = ); -my @part_pkg = map { - chomp( my $pkgpart = ); - chomp( my $pkg = ); - { - 'pkgpart' => $pkgpart, - 'pkg' => $pkg, - }; -} ( 1 .. $n_part_pkg ); - -warn "[fs_signupd] Reading POPs...\n" if $Debug; -chomp( my $n_svc_acct_pop = ); -my @svc_acct_pop = map { - chomp( my $popnum = ); - chomp( my $city = ); - chomp( my $state = ); - chomp( my $ac = ); - chomp( my $exch = ); - chomp( my $loc = ); - { - 'popnum' => $popnum, - 'city' => $city, - 'state' => $state, - 'ac' => $ac, - 'exch' => $exch, - 'loc' => $loc, - }; -} ( 1 .. $n_svc_acct_pop ); +warn "[fs_signupd] Reading init data...\n" if $Debug; +my $init_data = fd_retrieve(\*STDIN); warn "[fs_signupd] Creating $fs_signupd_socket\n" if $Debug; my $uaddr = sockaddr_un($fs_signupd_socket); @@ -76,6 +36,18 @@ unlink($fs_signupd_socket); bind(Server, $uaddr) or die "bind: $!"; listen(Server,SOMAXCONN) or die "listen: $!"; +if ( -e $pid_file ) { + open(PIDFILE,"<$pid_file"); + #chomp( my $old_pid = ); + my $old_pid = ; + close PIDFILE; + $old_pid =~ /^(\d+)$/; + kill 'TERM', $1; +} +open(PIDFILE,">$pid_file"); +print PIDFILE "$$\n"; +close PIDFILE; + warn "[fs_signupd] Entering main loop...\n" if $Debug; my $paddr; for ( ; $paddr = accept(Client,Server); close Client) { @@ -83,56 +55,28 @@ for ( ; $paddr = accept(Client,Server); close Client) { chop( my $command = ); if ( $command eq "signup_info" ) { + warn "[fs_signupd] sending signup info...\n" if $Debug; - print Client join("\n", $n_cust_main_county, - map { - $_->{taxnum}, - $_->{state}, - $_->{county}, - $_->{country}, - } @cust_main_county - ), "\n"; - - print Client join("\n", $n_part_pkg, - map { - $_->{pkgpart}, - $_->{pkg}, - } @part_pkg - ), "\n"; - - print Client join("\n", $n_svc_acct_pop, - map { - $_->{popnum}, - $_->{city}, - $_->{state}, - $_->{ac}, - $_->{exch}, - $_->{loc}, - } @svc_acct_pop - ), "\n"; + nstore_fd($init_data, \*Client) or die "can't send init data: $!"; + Client->flush; } elsif ( $command eq "new_customer" ) { + + #inefficient... + warn "[fs_signupd] reading customer signup...\n" if $Debug; - my( - $first, $last, $ss, $company, $address1, $address2, $city, $county, - $state, $zip, $country, $daytime, $night, $fax, $payby, $payinfo, - $paydate, $payname, $invoicing_list, $pkgpart, $username, $password, - $popnum, - ) = map { scalar() } ( 1 .. 23 ); + my $signup_data = fd_retrieve(\*Client); warn "[fs_signupd] sending customer data to remote server...\n" if $Debug; - print - $first, $last, $ss, $company, $address1, $address2, $city, $county, - $state, $zip, $country, $daytime, $night, $fax, $payby, $payinfo, - $paydate, $payname, $invoicing_list, $pkgpart, $username, $password, - $popnum, - ; + nstore_fd($signup_data, \*STDOUT) or die "can't send signup data: $!"; + STDOUT->flush; warn "[fs_signupd] reading error from remote server...\n" if $Debug; my $error = ; warn "[fs_signupd] sending error to local client...\n" if $Debug; print Client $error; + Client->flush; } else { die "unexpected command from client: $command";