#!/usr/bin/perl -Tw # # fs_signupd # # This is run REMOTELY over ssh by fs_signup_server. # use strict; use Socket; use vars qw( $Debug ); $Debug = 0; my($fs_signupd_socket)="/usr/local/freeside/fs_signupd_socket"; $ENV{'PATH'} ='/usr/local/bin:/usr/bin:/usr/ucb:/bin'; $ENV{'SHELL'} = '/bin/sh'; $ENV{'IFS'} = " \t\n"; $ENV{'CDPATH'} = ''; $ENV{'ENV'} = ''; $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] Creating $fs_signupd_socket\n" if $Debug; my $uaddr = sockaddr_un($fs_signupd_socket); my $proto = getprotobyname('tcp'); socket(Server,PF_UNIX,SOCK_STREAM,0) or die "socket: $!"; unlink($fs_signupd_socket); bind(Server, $uaddr) or die "bind: $!"; listen(Server,SOMAXCONN) or die "listen: $!"; warn "[fs_signupd] Entering main loop...\n" if $Debug; my $paddr; 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"; } elsif ( $command eq "new_customer" ) { 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 ); 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, ; 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; } else { die "unexpected command from client: $command"; } }