From c86ea4bb46792a5f175e9887c2e60d9bd3612056 Mon Sep 17 00:00:00 2001 From: ivan Date: Wed, 3 Jun 1998 07:22:52 +0000 Subject: Initial revision --- bin/dbdef-create | 85 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 85 insertions(+) create mode 100755 bin/dbdef-create (limited to 'bin') diff --git a/bin/dbdef-create b/bin/dbdef-create new file mode 100755 index 000000000..eb62c77e3 --- /dev/null +++ b/bin/dbdef-create @@ -0,0 +1,85 @@ +#!/usr/bin/perl -Tw +# +# create dbdef file for existing mySQL database (needs SHOW|DESCRIBE command +# not in Pg) based on fs-setup +# +# ivan@sisd.com 98-jun-2 + +use strict; +use DBI; +use FS::dbdef; +use FS::UID qw(adminsuidsetup datasrc); + +#needs to match FS::Record +my($dbdef_file) = "/var/spool/freeside/dbdef.". datasrc; + +my($dbh)=adminsuidsetup; + +my($tables_sth)=$dbh->prepare("SHOW TABLES"); +my($tables_rv)=$tables_sth->execute; + +my(@tables); +foreach ( @{$tables_sth->fetchall_arrayref} ) { + my($table)=${$_}[0]; + #print "TABLE\t$table\n"; + + my($index_sth)=$dbh->prepare("SHOW INDEX FROM $table"); + my($primary_key)=''; + my(%index,%unique); + for ( 1 .. $index_sth->execute ) { + my($row)=$index_sth->fetchrow_hashref; + if ( ${$row}{'Key_name'} eq "PRIMARY" ) { + $primary_key=${$row}{'Column_name'}; + next; + } + if ( ${$row}{'Non_unique'} ) { #index + push @{$index{${$row}{'Key_name'}}}, ${$row}{'Column_name'}; + } else { #unique + push @{$unique{${$row}{'Key_name'}}}, ${$row}{'Column_name'}; + } + } + + my(@index)=values %index; + my(@unique)=values %unique; + #print "\tPRIMARY KEY $primary_key\n"; + foreach (@index) { + #print "\tINDEX\t", join(', ', @{$_}), "\n"; + } + foreach (@unique) { + #print "\tUNIQUE\t", join(', ', @{$_}), "\n"; + } + + my($columns_sth)=$dbh->prepare("SHOW COLUMNS FROM $table"); + my(@columns); + for ( 1 .. $columns_sth->execute ) { + my($row)=$columns_sth->fetchrow_hashref; + #print "\t", ${$row}{'Field'}, "\n"; + ${$row}{'Type'} =~ /^(\w+)\(?([\d\,]+)?\)?( unsigned)?$/ + or die "Illegal type ${$row}{'Type'}\n"; + my($type,$length)=($1,$2); + my($null)=${$row}{'Null'}; + $null =~ s/YES/NULL/; + push @columns, new FS::dbdef_column ( + ${$row}{'Field'}, + $type, + $null, + $length, + ); + } + + #print "\n"; + push @tables, new FS::dbdef_table ( + $table, + $primary_key, + new FS::dbdef_unique (\@unique), + new FS::dbdef_index (\@index), + @columns, + ); + +} + +my($dbdef) = new FS::dbdef ( @tables ); + +#important +$dbdef->save($dbdef_file); + -- cgit v1.2.1 From 127b2e52cd2d6a9fd918be8ca7202b560d669e0a Mon Sep 17 00:00:00 2001 From: ivan Date: Fri, 17 Jul 1998 07:43:57 +0000 Subject: Initial revision --- bin/svc_acct_sm.import | 252 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 252 insertions(+) create mode 100755 bin/svc_acct_sm.import (limited to 'bin') diff --git a/bin/svc_acct_sm.import b/bin/svc_acct_sm.import new file mode 100755 index 000000000..10d7e4c20 --- /dev/null +++ b/bin/svc_acct_sm.import @@ -0,0 +1,252 @@ +#!/usr/bin/perl -Tw +# +# ivan@sisd.com 98-mar-9 +# +# generalized svcparts ivan@sisd.com 98-mar-23 + +# You really need to enable ssh into a shell machine as this needs to rename +# .qmail-extension files. +# +# now an interactive script ivan@sisd.com 98-jun-30 +# +# has an (untested) section for sendmail, s/warn/die/g and generates a program +# to run on your mail machine _later_ instead of ssh'ing for each user +# ivan@sisd.com 98-jul-13 + +use strict; +use vars qw(%d_part_svc %m_part_svc); +use FS::SSH qw(iscp); +use FS::UID qw(adminsuidsetup); +use FS::Record qw(qsearch qsearchs); +use FS::svc_acct_sm; +use FS::svc_domain; + +adminsuidsetup; + +#my($spooldir)="/var/spool/freeside/export"; +my($spooldir)="unix"; + +my(%mta) = ( + 1 => "qmail", + 2 => "sendmail", +); + +### + +%d_part_svc = + map { $_->svcpart, $_ } qsearch('part_svc',{'svcdb'=>'svc_domain'}); +%m_part_svc = + map { $_->svcpart, $_ } qsearch('part_svc',{'svcdb'=>'svc_acct_sm'}); + +print "\n\n", + ( join "\n", map "$_: ".$d_part_svc{$_}->svc, sort keys %d_part_svc ), + "\n\nEnter part number for domains: "; +my($domain_svcpart)=&getvalue; + +print "\n\n", + ( join "\n", map "$_: ".$m_part_svc{$_}->svc, sort keys %m_part_svc ), + "\n\nEnter part number for mail aliases: "; +my($mailalias_svcpart)=&getvalue; + +print "\n\n", <); + chop $x; + $x; +} + +print "\n\n"; + +### + +$FS::svc_domain::whois_hack=1; +$FS::svc_acct_sm::nossh_hack=1; + +if ( $mta{$mta} eq "qmail" ) { + open(RCPTHOSTS,"<$spooldir/rcpthosts.import") + or die "Can't open $spooldir/rcpthosts.import: $!"; +} elsif ( $mta{$mta} eq "sendmail" ) { + open(RCPTHOSTS,"<$spooldir/sendmail.cw.import") + or die "Can't open $spooldir/sendmail.cw.import: $!"; +} else { + die "Unknown MTA!\n"; +} + +my(%svcnum); + +while () { + next if /^(#|$)/; + /^\.?([\w\-\.]+)$/ + #or do { warn "Strange rcpthosts/sendmail.cw line: $_"; next; }; + or die "Strange rcpthosts/sendmail.cw line: $_"; + my $domain = $1; + my($svc_domain); + unless ( $svc_domain = qsearchs('svc_domain', {'domain'=>$domain} ) ) { + $svc_domain = create FS::svc_domain ({ + 'domain' => $domain, + 'svcpart' => $domain_svcpart, + 'action' => 'N', + }); + my $error = $svc_domain->insert; + #warn $error if $error; + die $error if $error; + } + $svcnum{$domain}=$svc_domain->svcnum; +} +close RCPTHOSTS; + +#these two loops have enough similar parts they should probably be merged +if ( $mta{$mta} eq "qmail" ) { + + open(VD_FIX,">$spooldir/virtualdomains.FIX"); + print VD_FIX "#!/usr/bin/perl\n"; + + open(VIRTUALDOMAINS,"<$spooldir/virtualdomains.import") + or die "Can't open $spooldir/virtualdomains.import: $!"; + while () { + next if /^#/; + /^\.?([\w\-\.]+):(\w+)(\-([\w\-\.]+))?$/ + #or do { warn "Strange virtualdomains line: $_"; next; }; + or die "Strange virtualdomains line: $_"; + my($domain,$username,$dash_ext,$extension)=($1,$2,$3,$4); + $dash_ext ||= ''; + $extension ||= ''; + my($svc_acct)=qsearchs('svc_acct',{'username'=>$username}); + unless ( $svc_acct ) { + #warn "Unknown user $username in virtualdomains; skipping\n"; + #die "Unknown user $username in virtualdomains; skipping\n"; + next; + } + if ( $domain ne $extension ) { + #warn "virtualdomains line $domain:$username$dash_ext changed to $domain:$username-$domain\n"; + my($dir)=$svc_acct->dir; + my($qdomain)=$domain; + $qdomain =~ s/\./:/g; #see manpage for 'dot-qmail': EXTENSION ADDRESSES + #example to move .qmail files for virtual domains to their new location + #dry run + #issh("root\@$shellmachine",'perl -e \'foreach $a (<'. $dir. '/.qmail'. $dash_ext. '-*>) { $old=$a; $a =~ s/\\.qmail'. $dash_ext. '\\-/\\.qmail\\-'. $qdomain. '\\-/; print " $old -> $a\n"; }\''); + #the real thing + #issh("root\@$shellmachine",'perl -e \'foreach $a (<'. $dir. '/.qmail'. $dash_ext. '-*>) { $old=$a; $a =~ s/\\.qmail'. $dash_ext. '\\-/\\.qmail\\-'. $qdomain. '\\-/; rename $old, $a; }\''); + print VD_FIX <) { + \$old = \$file; + \$file =~ s/\.qmail$dash_ext\-/\.qmail\-$qdomain\-/; + rename \$old, \$file; +} +END + } + + unless ( exists $svcnum{$domain} ) { + my($svc_domain) = create FS::svc_domain ({ + 'domain' => $domain, + 'svcpart' => $domain_svcpart, + 'action' => 'N', + }); + my $error = $svc_domain->insert; + #warn $error if $error; + die $error if $error; + $svcnum{$domain}=$svc_domain->svcnum; + } + + my($svc_acct_sm)=create FS::svc_acct_sm ({ + 'domsvc' => $svcnum{$domain}, + 'domuid' => $svc_acct->uid, + 'domuser' => '*', + 'svcpart' => $mailalias_svcpart, + }); + my($error)=''; + $error=$svc_acct_sm->insert; + #warn $error if $error; + die $error, ", domain $domain" if $error; + } + close VIRTUALDOMAINS; + close VD_FIX; + +} elsif ( $mta{$mta} eq "sendmail" ) { + + open(VIRTUSERTABLE,"<$spooldir/virtusertable.import") + or die "Can't open $spooldir/virtusertable.import: $!"; + while () { + next if /^#/; #comments? + /^([\w\-\.]+)?\@([\w\-\.]+)\t([\w\-\.]+)$/ + #or do { warn "Strange virtusertable line: $_"; next; }; + or die "Strange virtusertable line: $_"; + my($domuser,$domain,$username)=($1,$2,$3); + my($svc_acct)=qsearchs('svc_acct',{'username'=>$username}); + unless ( $svc_acct ) { + #warn "Unknown user $username in virtusertable"; + die "Unknown user $username in virtusertable"; + next; + } + my($svc_acct_sm)=create FS::svc_acct_sm ({ + 'domsvc' => $svcnum{$domain}, + 'domuid' => $svc_acct->uid, + 'domuser' => $domuser || '*', + 'svcpart' => $mailalias_svcpart, + }); + my($error)=''; + $error=$svc_acct_sm->insert; + #warn $error if $error; + die $error if $error; + } + close VIRTUSERTABLE; + +} else { + die "Unknown MTA!\n"; +} + +#open(RECIPIENTMAP,"<$spooldir/recipientmap.import"); +#close RECIPIENTMAP; + +print "\n\n", < Date: Fri, 14 Aug 1998 22:11:55 +0000 Subject: Initial revision --- bin/svc_acct_sm.export | 221 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 221 insertions(+) create mode 100755 bin/svc_acct_sm.export (limited to 'bin') diff --git a/bin/svc_acct_sm.export b/bin/svc_acct_sm.export new file mode 100755 index 000000000..c2ec1e53f --- /dev/null +++ b/bin/svc_acct_sm.export @@ -0,0 +1,221 @@ +#!/usr/bin/perl -Tw +# +# Create and export VoiceNet_quasar.m4 +# +# ivan@voicenet.com late oct 96 +# +# change priority (after copies) to 19, not 10 +# ivan@voicenet.com 97-feb-5 +# +# put file in different place and run different script, as per matt and +# mohamed +# ivan@voicenet.com 97-mar-10 +# +# added exit if stuff is already locked ivan@voicenet.com 97-apr-15 +# +# removed mail2 +# ivan@voicenet.com 97-jul-10 +# +# rewrote lots of the bits, now exports qmail "virtualdomain", +# "recipientmap" and "rcpthosts" files as well +# +# ivan@voicenet.com 97-sep-4 +# +# adds ".extra" files +# +# ivan@voicenet.com 97-sep-29 +# +# added ".pp" files, ugh. +# +# ivan@voicenet.com 97-oct-1 +# +# rewrite ivan@sisd.com 98-mar-9 +# +# now can create .qmail-default files ivan@sisd.com 98-mar-10 +# +# put example $my_domain declaration in ivan@sisd.com 98-mar-23 +# +# /var/spool/freeside/conf and sendmail updates ivan@sisd.com 98-aug-14 + +use strict; +use Fcntl qw(:flock); +use FS::SSH qw(ssh scp); +use FS::UID qw(adminsuidsetup); +use FS::Record qw(qsearch qsearchs); + +my($conf_shellm)="/var/spool/freeside/conf/shellmachine"; +my($fqmailmachines)="/var/spool/freeside/conf/qmailmachines"; +my($shellmachine); +my(@qmailmachines); +if ( -e $fqmailmachines ) { + open(SHELLMACHINE,$conf_shellm) or die "Can't open $conf_shellm: $!"; + =~ /^([\w\.\-]+)$/ or die "Illegal $conf_shellm"; + $shellmachine = $1; + close SHELLMACHINE; + open(QMAILMACHINES,$fqmailmachines); + @qmailmachines=map { + /^(.*)$/ or die "Illegal line in conf/qmailmachines"; #we trust the file + $1; + } grep $_ !~ /^(#|$)/, ; + close QMAILMACHINES; +} + +my($fsendmailmachines)="/var/spool/freeside/conf/sendmailmachines"; +my(@sendmailmachines); +if ( -e $fsendmailmachines ) { + open(SENDMAILMACHINES,$fsendmailmachines); + @sendmailmachines=map { + /^(.*)$/ or die "Illegal line in conf/sendmailmachines"; #we trust the file + $1; + } grep $_ !~ /^(#|$)/, ; + close SENDMAILMACHINES; +} + +my($conf_domain)="/var/spool/freeside/conf/domain"; +open(DOMAIN,$conf_domain) or die "Can't open $conf_domain: $!"; +my($mydomain)=map { + /^(.*)$/ or die "Illegal line in $conf_domain!"; #yes, we trust the file + $1 +} grep $_ !~ /^(#|$)/, ; +close DOMAIN; + +my($spooldir)="/var/spool/freeside/export"; +my($spoollock)="/var/spool/freeside/svc_acct_sm.export.lock"; + +adminsuidsetup; +umask 066; + +open(EXPORT,"+>>$spoollock") or die "Can't open $spoollock: $!"; +select(EXPORT); $|=1; select(STDOUT); +unless ( flock(EXPORT,LOCK_EX|LOCK_NB) ) { + seek(EXPORT,0,0); + my($pid)=; + chop($pid); + #no reason to start locks of blocking processes + die "Is another export process running under pid $pid?\n"; +} +seek(EXPORT,0,0); +print EXPORT $$,"\n"; + +my(@svc_acct_sm)=qsearch('svc_acct_sm',{}); + +( open(RCPTHOSTS,">$spooldir/rcpthosts") + and flock(RCPTHOSTS,LOCK_EX|LOCK_NB) +) or die "Can't open $spooldir/rcpthosts: $!"; +( open(RECIPIENTMAP,">$spooldir/recipientmap") + and flock(RECIPIENTMAP,LOCK_EX|LOCK_NB) +) or die "Can't open $spooldir/recipientmap: $!"; +( open(VIRTUALDOMAINS,">$spooldir/virtualdomains") + and flock(VIRTUALDOMAINS,LOCK_EX|LOCK_NB) +) or die "Can't open $spooldir/virtualdomains: $!"; +( open(VIRTUSERTABLE,">$spooldir/virtusertable") + and flock(VIRTUSERTABLE,LOCK_EX|LOCK_NB) +) or die "Can't open $spooldir/virtusertable: $!"; +( open(SENDMAIL_CW,">$spooldir/sendmail.cw") + and flock(SENDMAIL_CW,LOCK_EX|LOCK_NB) +) or die "Can't open $spooldir/sendmail.cw: $!"; + +setpriority(0,0,10); + +my($svc_domain,%domain); +foreach $svc_domain ( qsearch('svc_domain',{}) ) { + my($domain)=$svc_domain->domain; + $domain{$svc_domain->svcnum}=$domain; + print RCPTHOSTS "$domain\n.$domain\n"; + print SENDMAIL_CW "$domain\n"; +} + +my(@sendmail); + +my($svc_acct_sm); +foreach $svc_acct_sm ( qsearch('svc_acct_sm') ) { + my($domsvc,$domuid,$domuser)=( + $svc_acct_sm->domsvc, + $svc_acct_sm->domuid, + $svc_acct_sm->domuser, + ); + my($domain)=$domain{$domsvc}; + my($svc_acct)=qsearchs('svc_acct',{'uid'=>$domuid}); + my($username,$dir,$uid,$gid)=( + $svc_acct->username, + $svc_acct->dir, + $svc_acct->uid, + $svc_acct->gid, + ); + next unless $username && $domain && $domuser; + + if ($domuser eq '*') { + push @sendmail, "\@$domain\t$username\n"; + print VIRTUALDOMAINS "$domain:$username-$domain\n", + ".$domain:$username-$domain\n", + ; + ### + # qmail + ssh("root\@$shellmachine", + "[ -e $dir/.qmail-default ] || { touch $dir/.qmail-default; chown $uid:$gid $dir/.qmail-default; }" + ) if ( $shellmachine && $dir && $uid ); + + } else { + print VIRTUSERTABLE "$domuser\@$domain\t$username\n"; + print RECIPIENTMAP "$domuser\@$domain:$username\@$mydomain\n"; + } + + print VIRTUSERTABLE @sendmail; + +} + +chmod 0644, "$spooldir/sendmail.cw", + "$spooldir/virtusertable", + "$spooldir/rcpthosts", + "$spooldir/recipientmap", + "$spooldir/virtualdomains", +; + +flock(SENDMAIL_CW,LOCK_UN); +flock(VIRTUSERTABLE,LOCK_UN); +flock(RCPTHOSTS,LOCK_UN); +flock(RECIPIENTMAP,LOCK_UN); +flock(VIRTUALDOMAINS,LOCK_UN); + +close SENDMAIL_CW; +close VIRTUSERTABLE; +close RCPTHOSTS; +close RECIPIENTMAP; +close VIRTUALDOMAINS; + +### +# export stuff +# + +my($sendmailmachine); +foreach $sendmailmachine (@sendmailmachines) { + scp("$spooldir/sendmail.cw","root\@$sendmailmachine:/etc/sendmail.cw.new") + == 0 or die "scp error: $!"; + scp("$spooldir/virtusertable","root\@$sendmailmachine:/etc/virtusertable.new") + == 0 or die "scp error: $!"; + ssh("root\@$sendmailmachine", + "( ". + "mv /etc/sendmail.cw.new /etc/sendmail.cw; ". + "mv /etc/virtusertable.new /etc/virtusertable; ". + #"/etc/init.d/sendmail restart; ". + " )" + ) + == 0 or die "ssh error: $!"; +} + +my($qmailmachine); +foreach $qmailmachine (@qmailmachines) { + scp("$spooldir/recipientmap","root\@$qmailmachine:/var/qmail/control/recipientmap") + == 0 or die "scp error: $!"; + scp("$spooldir/virtualdomains","root\@$qmailmachine:/var/qmail/control/virtualdomains") + == 0 or die "scp error: $!"; + scp("$spooldir/rcpthosts","root\@$qmailmachine:/var/qmail/control/rcpthosts") + == 0 or die "scp error: $!"; + #ssh("root\@$qmailmachine","/etc/init.d/qmail restart") + # == 0 or die "ssh error: $!"; +} + +unlink $spoollock; +flock(EXPORT,LOCK_UN); +close EXPORT; + -- cgit v1.2.1 From e08286e81d6b3fd588c71103138e6f3218e21bc4 Mon Sep 17 00:00:00 2001 From: ivan Date: Sun, 16 Aug 1998 21:02:44 +0000 Subject: Initial revision --- bin/svc_acct.import | 227 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 227 insertions(+) create mode 100755 bin/svc_acct.import (limited to 'bin') diff --git a/bin/svc_acct.import b/bin/svc_acct.import new file mode 100755 index 000000000..c4b8c5ec5 --- /dev/null +++ b/bin/svc_acct.import @@ -0,0 +1,227 @@ +#!/usr/bin/perl -Tw +# +# ivan@sisd.com 98-mar-9 +# +# changed 'password' field to '_password' because PgSQL 6.3 reserves this word +# bmccane@maxbaud.net 98-Apr-3 +# +# generalized svcparts (still needs radius import) ivan@sisd.com 98-mar-23 +# +# radius import, now an interactive script. still needs erpcd import? +# ivan@sisd.com 98-jun-24 +# +# arbitrary radius attributes ivan@sisd.com 98-aug-9 +# +# don't import /var/spool/freeside/conf/shells! ivan@sisd.com 98-aug-13 + +use strict; +use vars qw(%part_svc); +use Date::Parse; +use FS::SSH qw(iscp); +use FS::UID qw(adminsuidsetup); +use FS::Record qw(qsearch); +use FS::svc_acct; + +adminsuidsetup; + +#my($spooldir)="/var/spool/freeside/export"; +my($spooldir)="unix/"; + +$FS::svc_acct::nossh_hack = 1; + +### + +%part_svc=map { $_->svcpart, $_ } qsearch('part_svc',{'svcdb'=>'svc_acct'}); + +print "\n\n", &menu_svc, "\n", <= 2) +END +my($oisdn_svcpart)=&getpart; + +print "\n\n", &menu_svc, "\n", <svc, sort keys %part_svc ). "\n"; +} +sub getpart { + print "Enter part number, or 0 for none: "; + &getvalue; +} +sub getvalue { + my($x)=scalar(); + chop $x; + $x; +} + +print "\n\n"; + +### + +open(PASSWD,"<$spooldir/passwd.import"); +open(SHADOW,"<$spooldir/shadow.import"); +open(USERS,"<$spooldir/users.import"); + +my(%upassword,%ip,%allparam); +my(%param,$username); +while () { + chop; + next if /^$/; + if ( /^\S/ ) { + /^(\w+)\s+Password\s+=\s+"([^"]+)"(,\s+Expiration\s+=\s+"([^"]*")\s*)?$/ + or die "1Unexpected line in users.import: $_"; + my($password,$expiration); + ($username,$password,$expiration)=(lc($1),$2,$4); + $upassword{$username}=$password; + undef %param; + } else { + die "2Unexpected line in users.import: $_"; + } + while () { + chop; + if ( /^\s*$/ ) { + $ip{$username}=$param{'radius_Framed_IP_Address'}||'0e0'; + delete $param{'radius_Framed_IP_Address'}; + $allparam{$username}={ %param }; + last; + } elsif ( /^\s+([\w\-]+)\s=\s"?([\w\.\-\s]+)"?,?\s*$/ ) { + my($attribute,$value)=($1,$2); + $attribute =~ s/\-/_/g; + $param{'radius_'.$attribute}=$value; + } else { + die "3Unexpected line in users.import: $_"; + } + } +} +#? incase there isn't a terminating blank line ? +$ip{$username}=$param{'radius_Framed_IP_Address'}||'0e0'; +delete $param{'radius_Framed_IP_Address'}; +$allparam{$username}={ %param }; + +my(%password); +while () { + chop; + my($username,$password)=split(/:/); + $password{$username}=$password; +} + +while () { + chop; + my($username,$x,$uid,$gid,$finger,$dir,$shell)=split(/:/); + my($password)=$upassword{$username} || $password{$username}; + + my($maxb)=${$allparam{$username}}{'radius_Port_Limit'}; + my($svcpart); + if ( exists $upassword{$username} ) { + if ( $maxb >= 2 ) { + $svcpart = $isdn_svcpart + } elsif ( ! $maxb || $maxb == 1 ) { + $svcpart = $ppp_svcpart + } else { + die "Illegal Port-Limit in users ($username)!\n"; + } + } elsif ( $shell eq $pop_shell ) { + $svcpart = $popmail_svcpart; + } else { + $svcpart = $shell_svcpart; + } + + my($svc_acct) = create FS::svc_acct ({ + 'svcpart' => $svcpart, + 'username' => $username, + 'password' => $password, + 'uid' => $uid, + 'gid' => $gid, + 'finger' => $finger, + 'dir' => $dir, + 'shell' => $shell, + 'slipip' => $ip{$username}, + %{$allparam{$username}}, + }); + my($error); + $error=$svc_acct->insert; + die $error if $error; + + delete $allparam{$username}; + delete $upassword{$username}; +} + +#my($username); +foreach $username ( keys %upassword ) { + my($password)=$upassword{$username}; + + my($maxb)=${$allparam{$username}}{'radius_Port_Limit'} || 0; + my($svcpart); + if ( $maxb == 2 ) { + $svcpart = $oisdn_svcpart + } elsif ( ! $maxb || $maxb == 1 ) { + $svcpart = $oppp_svcpart + } else { + die "Illegal Port-Limit in users!\n"; + } + + my($svc_acct) = create FS::svc_acct ({ + 'svcpart' => $svcpart, + 'username' => $username, + 'password' => $password, + 'slipip' => $ip{$username}, + %{$allparam{$username}}, + }); + my($error); + $error=$svc_acct->insert; + die $error, if $error; + + delete $allparam{$username}; + delete $upassword{$username}; +} + -- cgit v1.2.1 From cc60ec75f2f7ddbe0dca9292126adfc53e7b4e37 Mon Sep 17 00:00:00 2001 From: ivan Date: Mon, 24 Aug 1998 02:01:19 +0000 Subject: Initial revision --- bin/bill | 188 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 188 insertions(+) create mode 100755 bin/bill (limited to 'bin') diff --git a/bin/bill b/bin/bill new file mode 100755 index 000000000..5c5be703d --- /dev/null +++ b/bin/bill @@ -0,0 +1,188 @@ +#!/usr/local/bin/perl -Tw +# +# bill: Bill customer(s) +# +# Usage: bill [ -c [ i ] ] [ -d 'date' ] [ -b ] +# +# Bills all customers. +# +# Adds record to /dbin/cust_bill and /dbin/cust_pay (if payment made - +# CARD & COMP), prints invoice / charges card etc. +# +# -c: Turn on collecting (you probably want this). +# +# -i: real-time billing (as opposed to batch billing). only relevant +# for credit cards. +# +# -d: Pretent it's 'date'. Date is in any format Date::Parse is happy with, +# but be careful. +# +# ## n/a ## -b: send batch when done billing +# +# ivan@voicenet.com sep/oct 96 +# +# separated billing and collections, cleaned up code. +# ivan@voicenet.com 96-nov-11 +# +# added -d option +# ivan@voicenet.com 96-nov-13 +# +# added -v option and started to implement it, added 'd:' to getopts call +# (oops!) +# ivan@voicenet.com 97-jan-2 +# +# added more debug messages, moved some searches to fssearch.pl library (for +# speed) +# rewrote "all customer" finder to know about bill dates, for speed. +# ivan@voicenet.com 97-jan-8 +# +# thought about it a while, and removed passing of the -d option to collect...? +# ivan@voicenet.com 97-jan-14 +# +# make all -v stuff STDERR +# ivan@voicenet.com 97-feb-4 +# +# added pkgnum as argument to program from /db/part_pkg, with kludge for the +# "/bin/echo XX" 's already there. +# ivan@voicenet.com 97-feb-23 +# +# - general cleanup +# - customers who are suspended can still be billed for the setup fee +# - cust_pkg record is re-read after the package setup fee program is run. +# this way, +# that program can modify the record (for example, to start accounts off +# suspended) +# (best to think four or five times before modifying anything else!) +# ivan@voicenet.com 97-feb-26 +# +# don't bill recurring fee if its not time! (was removed) +# ivan@voicenet.com 97-mar-6 +# +# added -b option, send batch when done billing. +# ivan@voicenet.com 97-apr-4 +# +#insecure dependency on line 179ish below needs to be fixed before bill is +#used setuid +# ivan@voicenet.com 97-jun-2 +# +# removed running of setup program (depriciated) +# ivan@voicenet.com 97-jul-21 +# +# rewrote for new API, removed option to specify custnums (use FS::Bill +# instead), removed -v option (?) +# ivan@voicenet.com 97-jul-22 - 23 - 25 -28 +# (need to add back in email stuff, look in /home/ivan/old/dbin/collect) +# +# s/suidsetup/adminsuidsetup/, s/FS::Search/FS::Record/, added some batch +# exporting stuff (which still needs to be generalized) and removed &idiot +# ivan@sisd.com 98-may-27 + +# setup + +use strict; +use Fcntl qw(:flock); +use Date::Parse; +use Getopt::Std; +use FS::UID qw(adminsuidsetup swapuid); +use FS::Record qw(qsearch qsearchs); +use FS::Bill; + +my($batchfile)="/var/spool/freeside/batch"; +my($batchlock)="/var/spool/freeside/batch.lock"; + +adminsuidsetup; + +&untaint_argv; #what it sounds like (eww) +use vars qw($opt_b $opt_c $opt_i $opt_d); +getopts("bcid:"); #switches + +#we're at now now (and later). +my($time)= $main::opt_d ? str2time($main::opt_d) : $^T; + +# find packages w/ bill < time && cancel != '', and create corresponding +# customer objects + +my($cust_main,%saw); +foreach $cust_main ( + map { + if ( ( $_->getfield('bill') || 0 ) <= $time && + !$saw{ $_->getfield('custnum') }++ ) { + qsearchs('cust_main',{'custnum'=> $_->getfield('custnum') } ); + } else { + (); + } + } qsearch('cust_pkg',{'cancel'=>''}) +) { + + # and bill them + + print "Billing customer #" . $cust_main->getfield('custnum') . "\n"; + + bless($cust_main,"FS::Bill"); + + my($error); + + $error=$cust_main->bill('time'=>$time); + warn "Error billing, customer #" . $cust_main->getfield('custnum') . + ":" . $error if $error; + + if ($main::opt_c) { + $error=$cust_main->collect('invoice_time'=>$time, + 'batch_card' => $main::opt_i ? 'no' : 'yes', + ); + warn "Error collecting customer #" . $cust_main->getfield('custnum') . + ":" . $error if $error; + + #sleep 1; + + } + +} + +#if ($main::opt_b) { +# +# die "Batch still waiting for reply? ($batchlock exists)\n" if -e $batchlock; +# open(BATCHLOCK,"+>>$batchlock") or die "Can't open $batchlock: $!"; +# select(BATCHLOCK); $|=1; select(STDOUT); +# unless ( flock(BATCHLOCK,,LOCK_EX|LOCK_NB) ) { +# seek(BATCHLOCK,0,0); +# my($pid)=; +# chop($pid); +# die "Is a batch running? (pid $pid)\n"; +# } +# seek(BATCHLOCK,0,0); +# print BATCHLOCK $$,"\n"; +# +# ( open(BATCH,">$batchfile") +# and flock(BATCH,LOCK_EX|LOCK_NB) +# ) or die "Can't open $batchfile: $!"; +# +# my($cust_pay_batch); +# foreach $cust_pay_batch (qsearch('cust_pay_batch',{})) { +# print BATCH join(':', +# $_->getfield('cardnum'), +# $_->getfield('exp'), +# $_->getfield('amount'), +# $_->getfield('payname') +# || $_->getfield('first'). ' '. $_->getfield('last'), +# "Description", +# $_->getfield('zip'), +# ),"\n"; +# } +# +# flock(BATCH,LOCK_UN); +# close BATCH; +# +# flock(BATCHLOCK,LOCK_UN); +# close BATCHLOCK; +#} + +# subroutines + +sub untaint_argv { + foreach $_ ( $[ .. $#ARGV ) { #untaint @ARGV + $ARGV[$_] =~ /^([\w\-\/]*)$/ || die "Illegal arguement \"$ARGV[$_]\""; + $ARGV[$_]=$1; + } +} + -- cgit v1.2.1 From ab21af64cd80035d8f713e4704919f3b9733a936 Mon Sep 17 00:00:00 2001 From: ivan Date: Fri, 18 Sep 1998 05:43:42 +0000 Subject: Initial revision --- bin/svc_acct.export | 351 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 351 insertions(+) create mode 100755 bin/svc_acct.export (limited to 'bin') diff --git a/bin/svc_acct.export b/bin/svc_acct.export new file mode 100755 index 000000000..3f65a08ba --- /dev/null +++ b/bin/svc_acct.export @@ -0,0 +1,351 @@ +#!/usr/bin/perl -Tw +# +# Create and export password files: passwd, passwd.adjunct, shadow, +# acp_passwd, acp_userinfo, acp_dialup, users +# +# ivan@voicenet.com late august/september 96 +# (the password encryption bits were from melody) +# +# use a temporary copy of svc_acct to minimize lock time on the real file, +# and skip blank entries. +# +# ivan@voicenet.com 96-Oct-6 +# +# change users / acp_dialup file formats +# ivan@voicenet.com 97-jan-28-31 +# +# change priority (after copies) to 19, not 10 +# ivan@voicenet.com 97-feb-5 +# +# added exit if stuff is already locked 97-apr-15 +# +# rewrite ivan@sisd.com 98-mar-9 +# +# Changed 'password' to '_password' because Pg6.3 reserves this word +# Added code to create a FreeBSD style master.passwd file +# bmccane@maxbaud.net 98-Apr-3 +# +# don't export non-root 0 UID's, even if they get put in the database +# ivan@sisd.com 98-jul-14 +# +# Uses Idle_Timeout, Port_Limit, Framed_Netmask and Framed_Route if they +# exist; need some way to support arbitrary radius fields. also +# /var/spool/freeside/conf/ ivan@sisd.com 98-jul-26, aug-9 +# +# OOPS! added arbitrary radius fields (pry 98-aug-16) but forgot to say so. +# ivan@sisd.com 98-sep-18 + +use strict; +use Fcntl qw(:flock); +use FS::SSH qw(scp ssh); +use FS::UID qw(adminsuidsetup); +use FS::Record qw(qsearch fields); + +my($fshellmachines)="/var/spool/freeside/conf/shellmachines"; +my(@shellmachines); +if ( -e $fshellmachines ) { + open(SHELLMACHINES,$fshellmachines); + @shellmachines=map { + /^(.*)$/ or die "Illegal line in conf/shellmachines"; #we trust the file + $1; + } grep $_ !~ /^(#|$)/, ; + close SHELLMACHINES; +} + +my($fbsdshellmachines)="/var/spool/freeside/conf/bsdshellmachines"; +my(@bsdshellmachines); +if ( -e $fbsdshellmachines ) { + open(BSDSHELLMACHINES,$fbsdshellmachines); + @bsdshellmachines=map { + /^(.*)$/ or die "Illegal line in conf/bsdshellmachines"; #we trust the file + $1; + } grep $_ !~ /^(#|$)/, ; + close BSDSHELLMACHINES; +} + +my($fnismachines)="/var/spool/freeside/conf/nismachines"; +my(@nismachines); +if ( -e $fnismachines ) { + open(NISMACHINES,$fnismachines); + @nismachines=map { + /^(.*)$/ or die "Illegal line in conf/nismachines"; #we trust the file + $1; + } grep $_ !~ /^(#|$)/, ; + close NISMACHINES; +} + +my($ferpcdmachines)="/var/spool/freeside/conf/erpcdmachines"; +my(@erpcdmachines); +if ( -e $ferpcdmachines ) { + open(ERPCDMACHINES,$ferpcdmachines); + @erpcdmachines=map { + /^(.*)$/ or die "Illegal line in conf/erpcdmachines"; #we trust the file + $1; + } grep $_ !~ /^(#|$)/, ; + close ERPCDMACHINES; +} + +my($fradiusmachines)="/var/spool/freeside/conf/radiusmachines"; +my(@radiusmachines); +if ( -e $fradiusmachines ) { + open(RADIUSMACHINES,$fradiusmachines); + @radiusmachines=map { + /^(.*)$/ or die "Illegal line in conf/radiusmachines"; #we trust the file + $1; + } grep $_ !~ /^(#|$)/, ; + close RADIUSMACHINES; +} + +my($spooldir)="/var/spool/freeside/export"; +my($spoollock)="/var/spool/freeside/svc_acct.export.lock"; + +adminsuidsetup; + +my(@saltset)= ( 'a'..'z' , 'A'..'Z' , '0'..'9' , '.' , '/' ); +srand(time|$$); + +open(EXPORT,"+>>$spoollock") or die "Can't open $spoollock: $!"; +select(EXPORT); $|=1; select(STDOUT); +unless ( flock(EXPORT,LOCK_EX|LOCK_NB) ) { + seek(EXPORT,0,0); + my($pid)=; + chop($pid); + #no reason to start loct of blocking processes + die "Is another export process running under pid $pid?\n"; +} +seek(EXPORT,0,0); +print EXPORT $$,"\n"; + +my(@svc_acct)=qsearch('svc_acct',{}); + +( open(MASTER,">$spooldir/master.passwd") + and flock(MASTER,LOCK_EX|LOCK_NB) +) or die "Can't open $spooldir/master.passwd: $!"; +( open(PASSWD,">$spooldir/passwd") + and flock(PASSWD,LOCK_EX|LOCK_NB) +) or die "Can't open $spooldir/passwd: $!"; +( open(SHADOW,">$spooldir/shadow") + and flock(SHADOW,LOCK_EX|LOCK_NB) +) or die "Can't open $spooldir/shadow: $!"; +( open(ACP_PASSWD,">$spooldir/acp_passwd") + and flock (ACP_PASSWD,LOCK_EX|LOCK_NB) +) or die "Can't open $spooldir/acp_passwd: $!"; +( open (ACP_DIALUP,">$spooldir/acp_dialup") + and flock(ACP_DIALUP,LOCK_EX|LOCK_NB) +) or die "Can't open $spooldir/acp_dialup: $!"; +( open (USERS,">$spooldir/users") + and flock(USERS,LOCK_EX|LOCK_NB) +) or die "Can't open $spooldir/users: $!"; + +chmod 0644, "$spooldir/passwd", + "$spooldir/acp_dialup", +; +chmod 0600, "$spooldir/master.passwd", + "$spooldir/acp_passwd", + "$spooldir/shadow", + "$spooldir/users", +; + +setpriority(0,0,10); + +my($svc_acct); +foreach $svc_acct (@svc_acct) { + + my($password)=$svc_acct->getfield('_password'); + my($cpassword,$rpassword); + if ( ( length($password) <= 8 ) + && ( $password ne '*' ) + && ( $password ne '' ) + ) { + $cpassword=crypt($password, + $saltset[int(rand(64))].$saltset[int(rand(64))] + ); + $rpassword=$password; + } else { + $cpassword=$password; + $rpassword='UNIX'; + } + + if ( $svc_acct->uid =~ /^(\d+)$/ ) { + + die "Non-root user ". $svc_acct->username. " has 0 UID!" + if $svc_acct->uid == 0 && $svc_acct->username ne 'root'; + + ### + # FORMAT OF FreeBSD MASTER PASSWD FILE HERE + print MASTER join(":", + $svc_acct->username, # User name + $cpassword, # Encrypted password + $svc_acct->uid, # User ID + $svc_acct->gid, # Group ID + "", # Login Class + "0", # Password Change Time + "0", # Password Expiration Time + $svc_acct->finger, # Users name + $svc_acct->dir, # Users home directory + $svc_acct->shell, # shell + ), "\n" ; + + ### + # FORMAT OF THE PASSWD FILE HERE + print PASSWD join(":", + $svc_acct->username, + 'x', # "##". $svc_acct->$username, + $svc_acct->uid, + $svc_acct->gid, + $svc_acct->finger, + $svc_acct->dir, + $svc_acct->shell, + ), "\n"; + + ### + # FORMAT OF THE SHADOW FILE HERE + print SHADOW join(":", + $svc_acct->username, + $cpassword, + '', + '', + '', + '', + '', + '', + '', + ), "\n"; + + } + + if ( $svc_acct->slipip ne '' ) { + + ### + # FORMAT OF THE ACP_* FILES HERE + print ACP_PASSWD join(":", + $svc_acct->username, + $cpassword, + "0", + "0", + "", + "", + "", + ), "\n"; + + my($ip)=$svc_acct->slipip; + + unless ( $ip eq '0.0.0.0' || $svc_acct->slipip eq '0e0' ) { + print ACP_DIALUP $svc_acct->username, "\t*\t", $svc_acct->slipip, "\n"; + } + + ### + # FORMAT OF THE USERS FILE HERE + print USERS + $svc_acct->username, qq(\tPassword = "$rpassword"\n\t), + + join ",\n\t", + map { + /^(radius_(.*))$/; + my($field,$attrib)=($1,$2); + $attrib =~ s/_/\-/g; + "$attrib = \"". $svc_acct->getfield($field). "\""; + } grep /^radius_/ && $svc_acct->getfield($_), fields('svc_acct') + ; + if ( $ip && $ip ne '0e0' ) { + print USERS qq(,\n\tFramed-Address = "$ip"\n\n); + } else { + print USERS qq(\n\n); + } + + } + +} + +flock(MASTER,LOCK_UN); +flock(PASSWD,LOCK_UN); +flock(SHADOW,LOCK_UN); +flock(ACP_DIALUP,LOCK_UN); +flock(ACP_PASSWD,LOCK_UN); +flock(USERS,LOCK_UN); + +close MASTER; +close PASSWD; +close SHADOW; +close ACP_DIALUP; +close ACP_PASSWD; +close USERS; + +### +# export stuff +# + +my($shellmachine); +foreach $shellmachine (@shellmachines) { + scp("$spooldir/passwd","root\@$shellmachine:/etc/passwd.new") + == 0 or die "scp error: $!"; + scp("$spooldir/shadow","root\@$shellmachine:/etc/shadow.new") + == 0 or die "scp error: $!"; + ssh("root\@$shellmachine", + "( ". + "mv /etc/passwd.new /etc/passwd; ". + "mv /etc/shadow.new /etc/shadow; ". + " )" + ) + == 0 or die "ssh error: $!"; +} + +my($bsdshellmachine); +foreach $bsdshellmachine (@bsdshellmachines) { + scp("$spooldir/passwd","root\@$bsdshellmachine:/etc/passwd.new") + == 0 or die "scp error: $!"; + scp("$spooldir/master.passwd","root\@$bsdshellmachine:/etc/master.passwd.new") + == 0 or die "scp error: $!"; + ssh("root\@$bsdshellmachine", + "( ". + "mv /etc/passwd.new /etc/passwd; ". + "mv /etc/master.passwd.new /etc/master.passwd; ". + " )" + ) + == 0 or die "ssh error: $!"; +} + +my($nismachine); +foreach $nismachine (@nismachines) { + scp("$spooldir/passwd","root\@$nismachine:/etc/global/passwd") + == 0 or die "scp error: $!"; + scp("$spooldir/shadow","root\@$nismachine:/etc/global/shadow") + == 0 or die "scp error: $!"; + ssh("root\@$nismachine", + "( ". + "cd /var/yp; make; ". + " )" + ) + == 0 or die "ssh error: $!"; +} + +my($erpcdmachine); +foreach $erpcdmachine (@erpcdmachines) { + scp("$spooldir/acp_passwd","root\@$erpcdmachine:/usr/annex/acp_passwd") + == 0 or die "scp error: $!"; + scp("$spooldir/acp_dialup","root\@$erpcdmachine:/usr/annex/acp_dialup") + == 0 or die "scp error: $!"; + ssh("root\@$erpcdmachine", + "( ". + "kill -USR1 \`cat /usr/annex/erpcd.pid\'". + " )" + ) + == 0 or die "ssh error: $!"; +} + +my($radiusmachine); +foreach $radiusmachine (@radiusmachines) { + scp("$spooldir/users","root\@$radiusmachine:/etc/raddb/users") + == 0 or die "scp error: $!"; + ssh("root\@$erpcdmachine", + "( ". + "builddbm". + " )" + ) + == 0 or die "ssh error: $!"; +} + +unlink $spoollock; +flock(EXPORT,LOCK_UN); +close EXPORT; + -- cgit v1.2.1 From 08f52e31c5f777963d565085d077c9d8d9734e17 Mon Sep 17 00:00:00 2001 From: ivan Date: Fri, 25 Sep 1998 08:52:48 +0000 Subject: Initial revision --- bin/pod2x | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100755 bin/pod2x (limited to 'bin') diff --git a/bin/pod2x b/bin/pod2x new file mode 100755 index 000000000..1edb1c41e --- /dev/null +++ b/bin/pod2x @@ -0,0 +1,23 @@ +#!/usr/bin/perl + +#use Pod::Text; +#$Pod::Text::termcap=1; + +my $site_perl = "./site_perl"; +#my $catman = "./catman"; +my $catman = "./htdocs/docs/man"; +#my $html = "./htdocs/docs/man"; + +$|=1; + +die "Can't find $site_perl and $catman" + unless [ -d $site_perl ] && [ -d $catman ] && [ -d $html ]; + +foreach my $file (glob("$site_perl/*.pm")) { + $file =~ /\/([\w\-]+)\.pm$/ or die "oops file $file"; + my $name = $1; + print "$name\n"; + system "pod2text $file >$catman/$name.txt"; +# system "pod2html --podpath=$site_perl $file >$html/$name.html"; +# system "pod2html $file >$html/$name.html"; +} -- cgit v1.2.1 From cad4eadf964cb65841d7cb6f0bcf804f1d39ae2c Mon Sep 17 00:00:00 2001 From: ivan Date: Mon, 12 Oct 1998 07:03:09 +0000 Subject: Initial revision --- bin/fs-setup | 542 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 542 insertions(+) create mode 100755 bin/fs-setup (limited to 'bin') diff --git a/bin/fs-setup b/bin/fs-setup new file mode 100755 index 000000000..45332d85c --- /dev/null +++ b/bin/fs-setup @@ -0,0 +1,542 @@ +#!/usr/bin/perl -Tw +# +# create database and necessary tables, etc. DBI version. +# +# ivan@sisd.com 97-nov-8,9 +# +# agent_type and type_pkgs added. +# (index need to be declared, & primary keys shoudln't have mysql syntax) +# ivan@sisd.com 97-nov-13 +# +# pulled modified version back out of register.cgi ivan@sisd.com 98-feb-21 +# +# removed extraneous sample data ivan@sisd.com 98-mar-23 +# +# gained the big hash from dbdef.pm, dbdef.pm usage rewrite ivan@sisd.com +# 98-apr-19 - 98-may-11 plus +# +# finished up ivan@sisd.com 98-jun-1 +# +# part_svc fields are all forced NULL, not the opposite +# hmm: also are forced varchar($char_d) as fixed '0' for things like +# uid is Not Good. will this break anything else? +# ivan@sisd.com 98-jun-29 +# +# ss is 11 chars ivan@sisd.com 98-jul-20 +# +# setup of arbitrary radius fields ivan@sisd.com 98-aug-9 +# +# ouch, removed index on company name that wasn't supposed to be there +# ivan@sisd.com 98-sep-4 +# +# fix radius attributes ivan@sisd.com 98-sep-27 + +#to delay loading dbdef until we're ready +BEGIN { $FS::Record::setup_hack = 1; } + +use strict; +use DBI; +use FS::dbdef; +use FS::UID qw(adminsuidsetup datasrc); +use FS::Record; +use FS::cust_main_county; + +#needs to match FS::Record +my($dbdef_file) = "/var/spool/freeside/dbdef.". datasrc; + +### + +print "\nEnter the maximum username length: "; +my($username_len)=&getvalue; + +print "\n\n", <); + chop $x; + $x; +} + +### + +my($char_d) = 80; #default maxlength for text fields + +#my(@date_type) = ( 'timestamp', '', '' ); +my(@date_type) = ( 'int', 'NULL', '' ); +my(@perl_type) = ( 'long varchar', 'NULL', '' ); +my(@money_type); +if (datasrc =~ m/Pg/) { #Pg can't do decimal(10,2) + @money_type = ( 'money', '', '' ); +} else { + @money_type = ( 'decimal', '', '10,2' ); +} + +### +# create a dbdef object from the old data structure +### + +my(%tables)=&tables_hash_hack; + +#turn it into objects +my($dbdef) = new FS::dbdef ( map { + my(@columns); + while (@{$tables{$_}{'columns'}}) { + my($name,$type,$null,$length)=splice @{$tables{$_}{'columns'}}, 0, 4; + push @columns, new FS::dbdef_column ( $name,$type,$null,$length ); + } + FS::dbdef_table->new( + $_, + $tables{$_}{'primary_key'}, + #FS::dbdef_unique->new(@{$tables{$_}{'unique'}}), + #FS::dbdef_index->new(@{$tables{$_}{'index'}}), + FS::dbdef_unique->new($tables{$_}{'unique'}), + FS::dbdef_index->new($tables{$_}{'index'}), + @columns, + ); +} (keys %tables) ); + +#add radius attributes to svc_acct + +my($svc_acct)=$dbdef->table('svc_acct'); + +my($attribute); +foreach $attribute (@attributes) { + $svc_acct->addcolumn ( new FS::dbdef_column ( + 'radius_'. $attribute, + 'varchar', + 'NULL', + $char_d, + )); +} + +#make part_svc table (but now as object) + +my($part_svc)=$dbdef->table('part_svc'); + +#because of svc_acct_pop +#foreach (grep /^svc_/, $dbdef->tables) { +#foreach (qw(svc_acct svc_acct_sm svc_charge svc_domain svc_wo)) { +foreach (qw(svc_acct svc_acct_sm svc_domain)) { + my($table)=$dbdef->table($_); + my($col); + foreach $col ( $table->columns ) { + next if $col =~ /^svcnum$/; + $part_svc->addcolumn( new FS::dbdef_column ( + $table->name. '__' . $table->column($col)->name, + 'varchar', #$table->column($col)->type, + 'NULL', + $char_d, #$table->column($col)->length, + )); + $part_svc->addcolumn ( new FS::dbdef_column ( + $table->name. '__'. $table->column($col)->name . "_flag", + 'char', + 'NULL', + 1, + )); + } +} + +#important +$dbdef->save($dbdef_file); +FS::Record::reload_dbdef; + +### +# create 'em +### + +my($dbh)=adminsuidsetup; + +#create tables +$|=1; + +my($table); +foreach ($dbdef->tables) { + my($table)=$dbdef->table($_); + print "Creating $_..."; + + my($statement); + + #create table + foreach $statement ($table->sql_create_table(datasrc)) { + #print $statement, "\n"; + $dbh->do( $statement ) + or die "CREATE error: ",$dbh->errstr, "\ndoing statement: $statement"; + } + + print "\n"; +} + +#not really sample data (and shouldn't default to US) + +#cust_main_county +foreach ( qw( +AL AK AS AZ AR CA CO CT DC DE FM FL GA GU HI ID IL IN IA KS KY LA +ME MH MD MA MI MN MS MO MT NC ND NE NH NJ NM NV NY MP OH OK OR PA PW PR RI +SC SD TN TX TT UT VT VI VA WA WV WI WY AE AA AP +) ) { + my($cust_main_county)=create FS::cust_main_county({ + 'state' => $_, + 'tax' => 0, + }); + my($error); + $error=$cust_main_county->insert; + die $error if $error; +} + +$dbh->disconnect or die $dbh->errstr; + +### +# Now it becomes an object. much better. +### +sub tables_hash_hack { + + #note that s/(date|change)/_$1/; to avoid keyword conflict. + #put a kludge in FS::Record to catch this or? (pry need some date-handling + #stuff anyway also) + + my(%tables)=( #yech.} + + 'agent' => { + 'columns' => [ + 'agentnum', 'int', '', '', + 'agent', 'varchar', '', $char_d, + 'typenum', 'int', '', '', + 'freq', 'smallint', 'NULL', '', + 'prog', @perl_type, + ], + 'primary_key' => 'agentnum', + 'unique' => [ [] ], + 'index' => [ ['typenum'] ], + }, + + 'agent_type' => { + 'columns' => [ + 'typenum', 'int', '', '', + 'atype', 'varchar', '', $char_d, + ], + 'primary_key' => 'typenum', + 'unique' => [ [] ], + 'index' => [ [] ], + }, + + 'type_pkgs' => { + 'columns' => [ + 'typenum', 'int', '', '', + 'pkgpart', 'int', '', '', + ], + 'primary_key' => '', + 'unique' => [ ['typenum', 'pkgpart'] ], + 'index' => [ ['typenum'] ], + }, + + 'cust_bill' => { + 'columns' => [ + 'invnum', 'int', '', '', + 'custnum', 'int', '', '', + '_date', @date_type, + 'charged', @money_type, + 'owed', @money_type, + 'printed', 'int', '', '', + ], + 'primary_key' => 'invnum', + 'unique' => [ [] ], + 'index' => [ ['custnum'] ], + }, + + 'cust_bill_pkg' => { + 'columns' => [ + 'pkgnum', 'int', '', '', + 'invnum', 'int', '', '', + 'setup', @money_type, + 'recur', @money_type, + 'sdate', @date_type, + 'edate', @date_type, + ], + 'primary_key' => '', + 'unique' => [ ['pkgnum', 'invnum'] ], + 'index' => [ ['invnum'] ], + }, + + 'cust_credit' => { + 'columns' => [ + 'crednum', 'int', '', '', + 'custnum', 'int', '', '', + '_date', @date_type, + 'amount', @money_type, + 'credited', @money_type, + 'otaker', 'varchar', '', 8, + 'reason', 'varchar', '', 255, + ], + 'primary_key' => 'crednum', + 'unique' => [ [] ], + 'index' => [ ['custnum'] ], + }, + + 'cust_main' => { + 'columns' => [ + 'custnum', 'int', '', '', + 'agentnum', 'int', '', '', + 'last', 'varchar', '', $char_d, + 'first', 'varchar', '', $char_d, + 'ss', 'char', 'NULL', 11, + 'company', 'varchar', 'NULL', $char_d, + 'address1', 'varchar', '', $char_d, + 'address2', 'varchar', 'NULL', $char_d, + 'city', 'varchar', '', $char_d, + 'county', 'varchar', 'NULL', $char_d, + 'state', 'char', '', 2, + 'zip', 'varchar', '', 10, + 'country', 'char', '', 2, + 'daytime', 'varchar', 'NULL', 20, + 'night', 'varchar', 'NULL', 20, + 'fax', 'varchar', 'NULL', 12, + 'payby', 'char', '', 4, + 'payinfo', 'varchar', 'NULL', 16, + 'paydate', @date_type, + 'payname', 'varchar', 'NULL', $char_d, + 'tax', 'char', 'NULL', 1, + 'otaker', 'varchar', '', 8, + 'refnum', 'int', '', '', + ], + 'primary_key' => 'custnum', + 'unique' => [ [] ], + #'index' => [ ['last'], ['company'] ], + 'index' => [ ['last'], ], + }, + + 'cust_main_county' => { #county+state are checked off the cust_main_county + #table for validation and to provide a tax rate. + #add country? + 'columns' => [ + 'taxnum', 'int', '', '', + 'state', 'char', '', 2, #two letters max in US... elsewhere? + 'county', 'varchar', '', $char_d, + 'tax', 'real', '', '', #tax % + ], + 'primary_key' => 'taxnum', + 'unique' => [ [] ], + # 'unique' => [ ['taxnum'], ['state', 'county'] ], + 'index' => [ [] ], + }, + + 'cust_pay' => { + 'columns' => [ + 'paynum', 'int', '', '', + 'invnum', 'int', '', '', + 'paid', @money_type, + '_date', @date_type, + 'payby', 'char', '', 4, # CARD/BILL/COMP, should be index into + # payment type table. + 'payinfo', 'varchar', 'NULL', 16, #see cust_main above + 'paybatch', 'varchar', 'NULL', $char_d, #for auditing purposes. + ], + 'primary_key' => 'paynum', + 'unique' => [ [] ], + 'index' => [ ['invnum'] ], + }, + + 'cust_pay_batch' => { #what's this used for again? list of customers + #in current CARD batch? (necessarily CARD?) + 'columns' => [ + 'invnum', 'int', '', '', + 'custnum', 'int', '', '', + 'last', 'varchar', '', $char_d, + 'first', 'varchar', '', $char_d, + 'address1', 'varchar', '', $char_d, + 'address2', 'varchar', 'NULL', $char_d, + 'city', 'varchar', '', $char_d, + 'state', 'char', '', 2, + 'zip', 'varchar', '', 10, + 'country', 'char', '', 2, + 'trancode', 'TINYINT', '', '', + 'cardnum', 'varchar', '', 16, + 'exp', @date_type, + 'payname', 'varchar', 'NULL', $char_d, + 'amount', @money_type, + ], + 'primary_key' => '', + 'unique' => [ [] ], + 'index' => [ ['invnum'], ['custnum'] ], + }, + + 'cust_pkg' => { + 'columns' => [ + 'pkgnum', 'int', '', '', + 'custnum', 'int', '', '', + 'pkgpart', 'int', '', '', + 'otaker', 'varchar', '', 8, + 'setup', @date_type, + 'bill', @date_type, + 'susp', @date_type, + 'cancel', @date_type, + 'expire', @date_type, + ], + 'primary_key' => 'pkgnum', + 'unique' => [ [] ], + 'index' => [ ['custnum'] ], + }, + + 'cust_refund' => { + 'columns' => [ + 'refundnum', 'int', '', '', + 'crednum', 'int', '', '', + '_date', @date_type, + 'refund', @money_type, + 'otaker', 'varchar', '', 8, + 'reason', 'varchar', '', $char_d, + 'payby', 'char', '', 4, # CARD/BILL/COMP, should be index + # into payment type table. + 'payinfo', 'varchar', 'NULL', 16, #see cust_main above + ], + 'primary_key' => 'refundnum', + 'unique' => [ [] ], + 'index' => [ ['crednum'] ], + }, + + 'cust_svc' => { + 'columns' => [ + 'svcnum', 'int', '', '', + 'pkgnum', 'int', '', '', + 'svcpart', 'int', '', '', + ], + 'primary_key' => 'svcnum', + 'unique' => [ [] ], + 'index' => [ ['svcnum'], ['pkgnum'], ['svcpart'] ], + }, + + 'part_pkg' => { + 'columns' => [ + 'pkgpart', 'int', '', '', + 'pkg', 'varchar', '', $char_d, + 'comment', 'varchar', '', $char_d, + 'setup', @perl_type, + 'freq', 'smallint', '', '', #billing frequency (months) + 'recur', @perl_type, + ], + 'primary_key' => 'pkgpart', + 'unique' => [ [] ], + 'index' => [ [] ], + }, + + 'pkg_svc' => { + 'columns' => [ + 'pkgpart', 'int', '', '', + 'svcpart', 'int', '', '', + 'quantity', 'int', '', '', + ], + 'primary_key' => '', + 'unique' => [ ['pkgpart', 'svcpart'] ], + 'index' => [ ['pkgpart'] ], + }, + + 'part_referral' => { + 'columns' => [ + 'refnum', 'int', '', '', + 'referral', 'varchar', '', $char_d, + ], + 'primary_key' => 'refnum', + 'unique' => [ [] ], + 'index' => [ [] ], + }, + + 'part_svc' => { + 'columns' => [ + 'svcpart', 'int', '', '', + 'svc', 'varchar', '', $char_d, + 'svcdb', 'varchar', '', $char_d, + ], + 'primary_key' => 'svcpart', + 'unique' => [ [] ], + 'index' => [ [] ], + }, + + #(this should be renamed to part_pop) + 'svc_acct_pop' => { + 'columns' => [ + 'popnum', 'int', '', '', + 'city', 'varchar', '', $char_d, + 'state', 'char', '', 2, + 'ac', 'char', '', 3, + 'exch', 'char', '', 3, + #rest o' number? + ], + 'primary_key' => 'popnum', + 'unique' => [ [] ], + 'index' => [ [] ], + }, + + 'svc_acct' => { + 'columns' => [ + 'svcnum', 'int', '', '', + 'username', 'varchar', '', $username_len, #unique (& remove dup code) + '_password', 'varchar', '', 25, #13 for encryped pw's plus ' *SUSPENDED* + 'popnum', 'int', 'NULL', '', + 'uid', 'bigint', 'NULL', '', + 'gid', 'bigint', 'NULL', '', + 'finger', 'varchar', 'NULL', $char_d, + 'dir', 'varchar', 'NULL', $char_d, + 'shell', 'varchar', 'NULL', $char_d, + 'quota', 'varchar', 'NULL', $char_d, + 'slipip', 'varchar', 'NULL', 15, #four TINYINTs, bah. + ], + 'primary_key' => 'svcnum', + 'unique' => [ [] ], + 'index' => [ ['username'] ], + }, + + 'svc_acct_sm' => { + 'columns' => [ + 'svcnum', 'int', '', '', + 'domsvc', 'int', '', '', + 'domuid', 'bigint', '', '', + 'domuser', 'varchar', '', $char_d, + ], + 'primary_key' => 'svcnum', + 'unique' => [ [] ], + 'index' => [ ['domsvc'], ['domuid'] ], + }, + + #'svc_charge' => { + # 'columns' => [ + # 'svcnum', 'int', '', '', + # 'amount', @money_type, + # ], + # 'primary_key' => 'svcnum', + # 'unique' => [ [] ], + # 'index' => [ [] ], + #}, + + 'svc_domain' => { + 'columns' => [ + 'svcnum', 'int', '', '', + 'domain', 'varchar', '', $char_d, + ], + 'primary_key' => 'svcnum', + 'unique' => [ ['domain'] ], + 'index' => [ [] ], + }, + + #'svc_wo' => { + # 'columns' => [ + # 'svcnum', 'int', '', '', + # 'svcnum', 'int', '', '', + # 'svcnum', 'int', '', '', + # 'worker', 'varchar', '', $char_d, + # '_date', @date_type, + # ], + # 'primary_key' => 'svcnum', + # 'unique' => [ [] ], + # 'index' => [ [] ], + #}, + + ); + + %tables; + +} + -- cgit v1.2.1 From d4e9b3b0b80a25992fa7194464efa06deb484185 Mon Sep 17 00:00:00 2001 From: ivan Date: Tue, 13 Oct 1998 12:07:51 +0000 Subject: Assigns password from the shadow file for RADIUS password "UNIX" --- bin/svc_acct.import | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'bin') diff --git a/bin/svc_acct.import b/bin/svc_acct.import index c4b8c5ec5..60deac539 100755 --- a/bin/svc_acct.import +++ b/bin/svc_acct.import @@ -1,5 +1,7 @@ #!/usr/bin/perl -Tw # +# $Id: svc_acct.import,v 1.2 1998-10-13 12:07:51 ivan Exp $ +# # ivan@sisd.com 98-mar-9 # # changed 'password' field to '_password' because PgSQL 6.3 reserves this word @@ -13,6 +15,11 @@ # arbitrary radius attributes ivan@sisd.com 98-aug-9 # # don't import /var/spool/freeside/conf/shells! ivan@sisd.com 98-aug-13 +# +# $Log: svc_acct.import,v $ +# Revision 1.2 1998-10-13 12:07:51 ivan +# Assigns password from the shadow file for RADIUS password "UNIX" +# use strict; use vars qw(%part_svc); @@ -122,6 +129,7 @@ while () { or die "1Unexpected line in users.import: $_"; my($password,$expiration); ($username,$password,$expiration)=(lc($1),$2,$4); + $password = '' if $password eq 'UNIX'; $upassword{$username}=$password; undef %param; } else { -- cgit v1.2.1 From d914c9c9f2e73f58c3bd9b70738747d2c7e6c05b Mon Sep 17 00:00:00 2001 From: ivan Date: Wed, 14 Oct 1998 07:05:06 +0000 Subject: 1.1.4 release, fix postgresql --- bin/fs-setup | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'bin') diff --git a/bin/fs-setup b/bin/fs-setup index 45332d85c..22891ec0f 100755 --- a/bin/fs-setup +++ b/bin/fs-setup @@ -68,7 +68,7 @@ my($char_d) = 80; #default maxlength for text fields #my(@date_type) = ( 'timestamp', '', '' ); my(@date_type) = ( 'int', 'NULL', '' ); -my(@perl_type) = ( 'long varchar', 'NULL', '' ); +my(@perl_type) = ( 'varchar', 'NULL', '' ); my(@money_type); if (datasrc =~ m/Pg/) { #Pg can't do decimal(10,2) @money_type = ( 'money', '', '' ); @@ -315,7 +315,7 @@ sub tables_hash_hack { 'columns' => [ 'taxnum', 'int', '', '', 'state', 'char', '', 2, #two letters max in US... elsewhere? - 'county', 'varchar', '', $char_d, + 'county', 'varchar', 'NULL', $char_d, 'tax', 'real', '', '', #tax % ], 'primary_key' => 'taxnum', @@ -353,7 +353,7 @@ sub tables_hash_hack { 'state', 'char', '', 2, 'zip', 'varchar', '', 10, 'country', 'char', '', 2, - 'trancode', 'TINYINT', '', '', + 'trancode', 'int', '', '', 'cardnum', 'varchar', '', 16, 'exp', @date_type, 'payname', 'varchar', 'NULL', $char_d, @@ -476,8 +476,8 @@ sub tables_hash_hack { 'username', 'varchar', '', $username_len, #unique (& remove dup code) '_password', 'varchar', '', 25, #13 for encryped pw's plus ' *SUSPENDED* 'popnum', 'int', 'NULL', '', - 'uid', 'bigint', 'NULL', '', - 'gid', 'bigint', 'NULL', '', + 'uid', 'int', 'NULL', '', + 'gid', 'int', 'NULL', '', 'finger', 'varchar', 'NULL', $char_d, 'dir', 'varchar', 'NULL', $char_d, 'shell', 'varchar', 'NULL', $char_d, @@ -493,7 +493,7 @@ sub tables_hash_hack { 'columns' => [ 'svcnum', 'int', '', '', 'domsvc', 'int', '', '', - 'domuid', 'bigint', '', '', + 'domuid', 'int', '', '', 'domuser', 'varchar', '', $char_d, ], 'primary_key' => 'svcnum', -- cgit v1.2.1 From b8f8d9c3a07d4cb18ab6ec49fcd5ee0620c04a24 Mon Sep 17 00:00:00 2001 From: ivan Date: Thu, 22 Oct 1998 15:46:28 +0000 Subject: now smallint is illegal, so remove that too. --- bin/fs-setup | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'bin') diff --git a/bin/fs-setup b/bin/fs-setup index 22891ec0f..dc732e5ed 100755 --- a/bin/fs-setup +++ b/bin/fs-setup @@ -30,6 +30,11 @@ # ivan@sisd.com 98-sep-4 # # fix radius attributes ivan@sisd.com 98-sep-27 +# +# $Log: fs-setup,v $ +# Revision 1.3 1998-10-22 15:46:28 ivan +# now smallint is illegal, so remove that too. +# #to delay loading dbdef until we're ready BEGIN { $FS::Record::setup_hack = 1; } @@ -206,7 +211,7 @@ sub tables_hash_hack { 'agentnum', 'int', '', '', 'agent', 'varchar', '', $char_d, 'typenum', 'int', '', '', - 'freq', 'smallint', 'NULL', '', + 'freq', 'int', 'NULL', '', 'prog', @perl_type, ], 'primary_key' => 'agentnum', @@ -415,7 +420,7 @@ sub tables_hash_hack { 'pkg', 'varchar', '', $char_d, 'comment', 'varchar', '', $char_d, 'setup', @perl_type, - 'freq', 'smallint', '', '', #billing frequency (months) + 'freq', 'int', '', '', #billing frequency (months) 'recur', @perl_type, ], 'primary_key' => 'pkgpart', -- cgit v1.2.1 From 9061feef2e36c8a58a612be0e4e80853715bacb2 Mon Sep 17 00:00:00 2001 From: ivan Date: Thu, 22 Oct 1998 15:51:23 +0000 Subject: also varchar with no length specified - postgresql fix broke mysql. --- bin/fs-setup | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'bin') diff --git a/bin/fs-setup b/bin/fs-setup index dc732e5ed..98e754261 100755 --- a/bin/fs-setup +++ b/bin/fs-setup @@ -32,7 +32,10 @@ # fix radius attributes ivan@sisd.com 98-sep-27 # # $Log: fs-setup,v $ -# Revision 1.3 1998-10-22 15:46:28 ivan +# Revision 1.4 1998-10-22 15:51:23 ivan +# also varchar with no length specified - postgresql fix broke mysql. +# +# Revision 1.3 1998/10/22 15:46:28 ivan # now smallint is illegal, so remove that too. # @@ -73,7 +76,7 @@ my($char_d) = 80; #default maxlength for text fields #my(@date_type) = ( 'timestamp', '', '' ); my(@date_type) = ( 'int', 'NULL', '' ); -my(@perl_type) = ( 'varchar', 'NULL', '' ); +my(@perl_type) = ( 'varchar', 'NULL', 255 ); my(@money_type); if (datasrc =~ m/Pg/) { #Pg can't do decimal(10,2) @money_type = ( 'money', '', '' ); -- cgit v1.2.1 From 79556e1cfa147d8c9b2fc8142ed03ff067360030 Mon Sep 17 00:00:00 2001 From: ivan Date: Sat, 7 Nov 1998 08:08:12 +0000 Subject: Removed depriciated FS::Bill (now in FS::cust_main) --- bin/bill | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'bin') diff --git a/bin/bill b/bin/bill index 5c5be703d..ef321002b 100755 --- a/bin/bill +++ b/bin/bill @@ -76,6 +76,12 @@ # s/suidsetup/adminsuidsetup/, s/FS::Search/FS::Record/, added some batch # exporting stuff (which still needs to be generalized) and removed &idiot # ivan@sisd.com 98-may-27 +# +# $Log: bill,v $ +# Revision 1.2 1998-11-07 08:08:12 ivan +# +# Removed depriciated FS::Bill (now in FS::cust_main) +# # setup @@ -85,7 +91,6 @@ use Date::Parse; use Getopt::Std; use FS::UID qw(adminsuidsetup swapuid); use FS::Record qw(qsearch qsearchs); -use FS::Bill; my($batchfile)="/var/spool/freeside/batch"; my($batchlock)="/var/spool/freeside/batch.lock"; @@ -118,8 +123,6 @@ foreach $cust_main ( print "Billing customer #" . $cust_main->getfield('custnum') . "\n"; - bless($cust_main,"FS::Bill"); - my($error); $error=$cust_main->bill('time'=>$time); -- cgit v1.2.1 From e4ad777a6ffa5b2cc28bf26681bcfa56f83df7e9 Mon Sep 17 00:00:00 2001 From: ivan Date: Sat, 7 Nov 1998 08:19:21 +0000 Subject: still need to bless into FS::cust_main (for now) --- bin/bill | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'bin') diff --git a/bin/bill b/bin/bill index ef321002b..7b1e162c2 100755 --- a/bin/bill +++ b/bin/bill @@ -78,9 +78,9 @@ # ivan@sisd.com 98-may-27 # # $Log: bill,v $ -# Revision 1.2 1998-11-07 08:08:12 ivan +# Revision 1.3 1998-11-07 08:19:21 ivan # -# Removed depriciated FS::Bill (now in FS::cust_main) +# still need to bless into FS::cust_main (for now) # # setup @@ -123,6 +123,8 @@ foreach $cust_main ( print "Billing customer #" . $cust_main->getfield('custnum') . "\n"; + bless($cust_main,"FS::cust_main"); + my($error); $error=$cust_main->bill('time'=>$time); -- cgit v1.2.1 From de5bd53fdf4d115a26c1b51fefa83a114735f9bc Mon Sep 17 00:00:00 2001 From: ivan Date: Sat, 7 Nov 1998 08:21:26 +0000 Subject: missing use --- bin/bill | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'bin') diff --git a/bin/bill b/bin/bill index 7b1e162c2..3bc995d35 100755 --- a/bin/bill +++ b/bin/bill @@ -78,9 +78,8 @@ # ivan@sisd.com 98-may-27 # # $Log: bill,v $ -# Revision 1.3 1998-11-07 08:19:21 ivan -# -# still need to bless into FS::cust_main (for now) +# Revision 1.4 1998-11-07 08:21:26 ivan +# missing use # # setup @@ -91,6 +90,7 @@ use Date::Parse; use Getopt::Std; use FS::UID qw(adminsuidsetup swapuid); use FS::Record qw(qsearch qsearchs); +use FS::cust_main; my($batchfile)="/var/spool/freeside/batch"; my($batchlock)="/var/spool/freeside/batch.lock"; -- cgit v1.2.1 From 99296e2d2de4162acdd6d607fdbb2e8f6688930e Mon Sep 17 00:00:00 2001 From: ivan Date: Sun, 15 Nov 1998 02:51:21 +0000 Subject: adminsuidsetup needs user, pod, cleanup --- bin/bill | 237 ++++++++++++++++++++++++++++----------------------------------- 1 file changed, 107 insertions(+), 130 deletions(-) (limited to 'bin') diff --git a/bin/bill b/bin/bill index 3bc995d35..b74f26abd 100755 --- a/bin/bill +++ b/bin/bill @@ -1,88 +1,4 @@ -#!/usr/local/bin/perl -Tw -# -# bill: Bill customer(s) -# -# Usage: bill [ -c [ i ] ] [ -d 'date' ] [ -b ] -# -# Bills all customers. -# -# Adds record to /dbin/cust_bill and /dbin/cust_pay (if payment made - -# CARD & COMP), prints invoice / charges card etc. -# -# -c: Turn on collecting (you probably want this). -# -# -i: real-time billing (as opposed to batch billing). only relevant -# for credit cards. -# -# -d: Pretent it's 'date'. Date is in any format Date::Parse is happy with, -# but be careful. -# -# ## n/a ## -b: send batch when done billing -# -# ivan@voicenet.com sep/oct 96 -# -# separated billing and collections, cleaned up code. -# ivan@voicenet.com 96-nov-11 -# -# added -d option -# ivan@voicenet.com 96-nov-13 -# -# added -v option and started to implement it, added 'd:' to getopts call -# (oops!) -# ivan@voicenet.com 97-jan-2 -# -# added more debug messages, moved some searches to fssearch.pl library (for -# speed) -# rewrote "all customer" finder to know about bill dates, for speed. -# ivan@voicenet.com 97-jan-8 -# -# thought about it a while, and removed passing of the -d option to collect...? -# ivan@voicenet.com 97-jan-14 -# -# make all -v stuff STDERR -# ivan@voicenet.com 97-feb-4 -# -# added pkgnum as argument to program from /db/part_pkg, with kludge for the -# "/bin/echo XX" 's already there. -# ivan@voicenet.com 97-feb-23 -# -# - general cleanup -# - customers who are suspended can still be billed for the setup fee -# - cust_pkg record is re-read after the package setup fee program is run. -# this way, -# that program can modify the record (for example, to start accounts off -# suspended) -# (best to think four or five times before modifying anything else!) -# ivan@voicenet.com 97-feb-26 -# -# don't bill recurring fee if its not time! (was removed) -# ivan@voicenet.com 97-mar-6 -# -# added -b option, send batch when done billing. -# ivan@voicenet.com 97-apr-4 -# -#insecure dependency on line 179ish below needs to be fixed before bill is -#used setuid -# ivan@voicenet.com 97-jun-2 -# -# removed running of setup program (depriciated) -# ivan@voicenet.com 97-jul-21 -# -# rewrote for new API, removed option to specify custnums (use FS::Bill -# instead), removed -v option (?) -# ivan@voicenet.com 97-jul-22 - 23 - 25 -28 -# (need to add back in email stuff, look in /home/ivan/old/dbin/collect) -# -# s/suidsetup/adminsuidsetup/, s/FS::Search/FS::Record/, added some batch -# exporting stuff (which still needs to be generalized) and removed &idiot -# ivan@sisd.com 98-may-27 -# -# $Log: bill,v $ -# Revision 1.4 1998-11-07 08:21:26 ivan -# missing use -# - -# setup +#!/usr/bin/perl -Tw use strict; use Fcntl qw(:flock); @@ -92,14 +8,12 @@ use FS::UID qw(adminsuidsetup swapuid); use FS::Record qw(qsearch qsearchs); use FS::cust_main; -my($batchfile)="/var/spool/freeside/batch"; -my($batchlock)="/var/spool/freeside/batch.lock"; - -adminsuidsetup; - &untaint_argv; #what it sounds like (eww) use vars qw($opt_b $opt_c $opt_i $opt_d); getopts("bcid:"); #switches +my $user = shift or die &usage; + +adminsuidsetup $user; #we're at now now (and later). my($time)= $main::opt_d ? str2time($main::opt_d) : $^T; @@ -123,8 +37,6 @@ foreach $cust_main ( print "Billing customer #" . $cust_main->getfield('custnum') . "\n"; - bless($cust_main,"FS::cust_main"); - my($error); $error=$cust_main->bill('time'=>$time); @@ -144,44 +56,6 @@ foreach $cust_main ( } -#if ($main::opt_b) { -# -# die "Batch still waiting for reply? ($batchlock exists)\n" if -e $batchlock; -# open(BATCHLOCK,"+>>$batchlock") or die "Can't open $batchlock: $!"; -# select(BATCHLOCK); $|=1; select(STDOUT); -# unless ( flock(BATCHLOCK,,LOCK_EX|LOCK_NB) ) { -# seek(BATCHLOCK,0,0); -# my($pid)=; -# chop($pid); -# die "Is a batch running? (pid $pid)\n"; -# } -# seek(BATCHLOCK,0,0); -# print BATCHLOCK $$,"\n"; -# -# ( open(BATCH,">$batchfile") -# and flock(BATCH,LOCK_EX|LOCK_NB) -# ) or die "Can't open $batchfile: $!"; -# -# my($cust_pay_batch); -# foreach $cust_pay_batch (qsearch('cust_pay_batch',{})) { -# print BATCH join(':', -# $_->getfield('cardnum'), -# $_->getfield('exp'), -# $_->getfield('amount'), -# $_->getfield('payname') -# || $_->getfield('first'). ' '. $_->getfield('last'), -# "Description", -# $_->getfield('zip'), -# ),"\n"; -# } -# -# flock(BATCH,LOCK_UN); -# close BATCH; -# -# flock(BATCHLOCK,LOCK_UN); -# close BATCHLOCK; -#} - # subroutines sub untaint_argv { @@ -191,3 +65,106 @@ sub untaint_argv { } } +sub usage { + die "Usage:\n\n bill [ -c [ i ] ] [ -d 'date' ] [ -b ] user\n"; +} + +=head1 NAME + +bill - Command line (crontab, script) interface to customer billing. + +=head1 SYNOPSIS + + bill [ -c [ i ] ] [ -d 'date' ] user + +=head1 DESCRIPTION + +Bills all customers. Searches for customers who are due for billing and calls +the bill and collect methods of a cust_main object. See L. + +-c: Turn on collecting (you probably want this). + +-i: real-time billing (as opposed to batch billing). only relevant + for credit cards. + +-d: Pretent it's 'date'. Date is in any format Date::Parse is happy with, + but be careful. + +user: From the mapsecrets file - see config.html from the base documentation + +=head1 BUGS + +=head1 SEE ALSO + +L, config.html from the base documentation + +=head1 HISTORY + +ivan@voicenet.com sep/oct 96 + +separated billing and collections, cleaned up code. +ivan@voicenet.com 96-nov-11 + +added -d option +ivan@voicenet.com 96-nov-13 + +added -v option and started to implement it, added 'd:' to getopts call + (oops!) +ivan@voicenet.com 97-jan-2 + +added more debug messages, moved some searches to fssearch.pl library (for +speed) +rewrote "all customer" finder to know about bill dates, for speed. +ivan@voicenet.com 97-jan-8 + +thought about it a while, and removed passing of the -d option to collect...? +ivan@voicenet.com 97-jan-14 + +make all -v stuff STDERR +ivan@voicenet.com 97-feb-4 + +added pkgnum as argument to program from /db/part_pkg, with kludge for the +"/bin/echo XX" 's already there. +ivan@voicenet.com 97-feb-23 + +- general cleanup +- customers who are suspended can still be billed for the setup fee +- cust_pkg record is re-read after the package setup fee program is run. + this way, + that program can modify the record (for example, to start accounts off + suspended) + (best to think four or five times before modifying anything else!) +ivan@voicenet.com 97-feb-26 + +don't bill recurring fee if its not time! (was removed) +ivan@voicenet.com 97-mar-6 + +added -b option, send batch when done billing. +ivan@voicenet.com 97-apr-4 + +insecure dependency on line 179ish below needs to be fixed before bill is +used setuid +ivan@voicenet.com 97-jun-2 + +removed running of setup program (depriciated) +ivan@voicenet.com 97-jul-21 + +rewrote for new API, removed option to specify custnums (use FS::Bill +instead), removed -v option (?) +ivan@voicenet.com 97-jul-22 - 23 - 25 -28 +(need to add back in email stuff, look in /home/ivan/old/dbin/collect) + +s/suidsetup/adminsuidsetup/, s/FS::Search/FS::Record/, added some batch +exporting stuff (which still needs to be generalized) and removed &idiot +ivan@sisd.com 98-may-27 + +$Log: bill,v $ +Revision 1.5 1998-11-15 02:51:21 ivan +adminsuidsetup needs user, pod, cleanup + +Revision 1.4 1998/11/07 08:21:26 ivan +missing use + +=cut + + -- cgit v1.2.1 From 1dad506b145956736a8f200ee35786b640b40e3f Mon Sep 17 00:00:00 2001 From: ivan Date: Sun, 15 Nov 1998 02:53:00 +0000 Subject: afterthought --- bin/bill | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'bin') diff --git a/bin/bill b/bin/bill index b74f26abd..9553af966 100755 --- a/bin/bill +++ b/bin/bill @@ -30,7 +30,9 @@ foreach $cust_main ( } else { (); } - } qsearch('cust_pkg',{'cancel'=>''}) + } ( qsearch('cust_pkg', { 'cancel' => '' }), + qsearch('cust_pkg', { 'cancel' => 0 }), + ) ) { # and bill them @@ -92,6 +94,10 @@ the bill and collect methods of a cust_main object. See L. user: From the mapsecrets file - see config.html from the base documentation +=head1 VERSION + +$Id: bill,v 1.6 1998-11-15 02:53:00 ivan Exp $ + =head1 BUGS =head1 SEE ALSO @@ -159,8 +165,8 @@ exporting stuff (which still needs to be generalized) and removed &idiot ivan@sisd.com 98-may-27 $Log: bill,v $ -Revision 1.5 1998-11-15 02:51:21 ivan -adminsuidsetup needs user, pod, cleanup +Revision 1.6 1998-11-15 02:53:00 ivan +afterthought Revision 1.4 1998/11/07 08:21:26 ivan missing use -- cgit v1.2.1 From 60b5717194d18401d8532ca8b09376edeea535d7 Mon Sep 17 00:00:00 2001 From: ivan Date: Sun, 15 Nov 1998 09:43:03 +0000 Subject: update for new config file syntax, new adminsuidsetup --- bin/fs-setup | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) (limited to 'bin') diff --git a/bin/fs-setup b/bin/fs-setup index 98e754261..4e64f1bdf 100755 --- a/bin/fs-setup +++ b/bin/fs-setup @@ -32,7 +32,10 @@ # fix radius attributes ivan@sisd.com 98-sep-27 # # $Log: fs-setup,v $ -# Revision 1.4 1998-10-22 15:51:23 ivan +# Revision 1.5 1998-11-15 09:43:03 ivan +# update for new config file syntax, new adminsuidsetup +# +# Revision 1.4 1998/10/22 15:51:23 ivan # also varchar with no length specified - postgresql fix broke mysql. # # Revision 1.3 1998/10/22 15:46:28 ivan @@ -49,8 +52,11 @@ use FS::UID qw(adminsuidsetup datasrc); use FS::Record; use FS::cust_main_county; +my $user = shift or die &usage; +FS::UID::getsecrets $user; + #needs to match FS::Record -my($dbdef_file) = "/var/spool/freeside/dbdef.". datasrc; +my($dbdef_file) = "/usr/local/etc/freeside/dbdef.". datasrc; ### @@ -151,13 +157,14 @@ foreach (qw(svc_acct svc_acct_sm svc_domain)) { #important $dbdef->save($dbdef_file); -FS::Record::reload_dbdef; +FS::Record::reload_dbdef($dbdef_file); ### # create 'em ### -my($dbh)=adminsuidsetup; +my($dbh)=adminsuidsetup $user; +warn $dbh; #create tables $|=1; @@ -198,6 +205,10 @@ SC SD TN TX TT UT VT VI VA WA WV WI WY AE AA AP $dbh->disconnect or die $dbh->errstr; +sub usage { + die "Usage:\n fs-setup user\n"; +} + ### # Now it becomes an object. much better. ### -- cgit v1.2.1 From c48cfd422976aa77e9f10b5324bfbd71952e5333 Mon Sep 17 00:00:00 2001 From: ivan Date: Sun, 15 Nov 1998 13:18:02 +0000 Subject: remove debugging --- bin/fs-setup | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'bin') diff --git a/bin/fs-setup b/bin/fs-setup index 4e64f1bdf..aab24b7e1 100755 --- a/bin/fs-setup +++ b/bin/fs-setup @@ -32,7 +32,10 @@ # fix radius attributes ivan@sisd.com 98-sep-27 # # $Log: fs-setup,v $ -# Revision 1.5 1998-11-15 09:43:03 ivan +# Revision 1.6 1998-11-15 13:18:02 ivan +# remove debugging +# +# Revision 1.5 1998/11/15 09:43:03 ivan # update for new config file syntax, new adminsuidsetup # # Revision 1.4 1998/10/22 15:51:23 ivan @@ -164,7 +167,6 @@ FS::Record::reload_dbdef($dbdef_file); ### my($dbh)=adminsuidsetup $user; -warn $dbh; #create tables $|=1; -- cgit v1.2.1 From ef834d58bfd2ce38c8bea73262c8091a5d88388f Mon Sep 17 00:00:00 2001 From: ivan Date: Wed, 18 Nov 1998 09:01:44 +0000 Subject: i18n! i18n! --- bin/fs-setup | 53 +++++++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 47 insertions(+), 6 deletions(-) (limited to 'bin') diff --git a/bin/fs-setup b/bin/fs-setup index aab24b7e1..b3fc5c5a0 100755 --- a/bin/fs-setup +++ b/bin/fs-setup @@ -32,7 +32,10 @@ # fix radius attributes ivan@sisd.com 98-sep-27 # # $Log: fs-setup,v $ -# Revision 1.6 1998-11-15 13:18:02 ivan +# Revision 1.7 1998-11-18 09:01:31 ivan +# i18n! i18n! +# +# Revision 1.6 1998/11/15 13:18:02 ivan # remove debugging # # Revision 1.5 1998/11/15 09:43:03 ivan @@ -191,6 +194,8 @@ foreach ($dbdef->tables) { #not really sample data (and shouldn't default to US) #cust_main_county + +#USPS state codes foreach ( qw( AL AK AS AZ AR CA CO CT DC DE FM FL GA GU HI ID IL IN IA KS KY LA ME MH MD MA MI MN MS MO MT NC ND NE NH NJ NM NV NY MP OH OK OR PA PW PR RI @@ -199,6 +204,29 @@ SC SD TN TX TT UT VT VI VA WA WV WI WY AE AA AP my($cust_main_county)=create FS::cust_main_county({ 'state' => $_, 'tax' => 0, + 'country' => 'US', + }); + my($error); + $error=$cust_main_county->insert; + die $error if $error; +} + +#ISO 2-letter country codes (same as country TLDs) except US +foreach ( qw( +AF AL DZ AS AD AO AI AQ AG AR AM AW AU AT AZ BS BH BD BB BY BE BZ BJ BM BT BO +BA BW BV BR IO BN BG BF BI KH CM CA CV KY CF TD CL CN CX CC CO KM CG CK CR CI +HR CU CY CZ DK DJ DM DO TP EC EG SV GQ ER EE ET FK FO FJ FI FR FX GF PF TF GA +GM GE DE GH GI GR GL GD GP GU GT GN GW GY HT HM HN HK HU IS IN ID IR IQ IE IL +IT JM JP JO KZ KE KI KP KR KW KG LA LV LB LS LR LY LI LT LU MO MK MG MW MY MV +ML MT MH MQ MR MU YT MX FM MD MC MN MS MA MZ MM NA NR NP NL AN NC NZ NI NE NG +NU NF MP NO OM PK PW PA PG PY PE PH PN PL PT PR QA RE RO RU RW KN LC VC WS SM +ST SA SN SC SL SG SK SI SB SO ZA GS ES LK SH PM SD SR SJ SZ SE CH SY TW TJ TZ +TH TG TK TO TT TN TR TM TC TV UG UA AE GB UM UY UZ VU VA VE VN VG VI WF EH +YE YU ZR ZM ZW +) ) { + my($cust_main_county)=create FS::cust_main_county({ + 'tax' => 0, + 'country' => $_, }); my($error); $error=$cust_main_county->insert; @@ -302,7 +330,9 @@ sub tables_hash_hack { 'columns' => [ 'custnum', 'int', '', '', 'agentnum', 'int', '', '', + 'titlenum', 'int', 'NULL', '', 'last', 'varchar', '', $char_d, + 'middle', 'varchar', 'NULL', $char_d, 'first', 'varchar', '', $char_d, 'ss', 'char', 'NULL', 11, 'company', 'varchar', 'NULL', $char_d, @@ -310,7 +340,7 @@ sub tables_hash_hack { 'address2', 'varchar', 'NULL', $char_d, 'city', 'varchar', '', $char_d, 'county', 'varchar', 'NULL', $char_d, - 'state', 'char', '', 2, + 'state', 'varchar', '', $char_d, 'zip', 'varchar', '', 10, 'country', 'char', '', 2, 'daytime', 'varchar', 'NULL', 20, @@ -330,13 +360,14 @@ sub tables_hash_hack { 'index' => [ ['last'], ], }, - 'cust_main_county' => { #county+state are checked off the cust_main_county - #table for validation and to provide a tax rate. - #add country? + 'cust_main_county' => { #county+state+country are checked off the + #cust_main_county for validation and to provide + # a tax rate. 'columns' => [ 'taxnum', 'int', '', '', - 'state', 'char', '', 2, #two letters max in US... elsewhere? + 'state', 'char', 'NULL', $char_d, 'county', 'varchar', 'NULL', $char_d, + 'country', 'char', '', 2, 'tax', 'real', '', '', #tax % ], 'primary_key' => 'taxnum', @@ -444,6 +475,16 @@ sub tables_hash_hack { 'index' => [ [] ], }, + 'part_title' => { + 'columns' => [ + 'titlenum', 'int', '', '', + 'title', 'varchar', '', $char_d, + ], + 'primary_key' => 'titlenum', + 'unique' => [ [] ], + 'index' => [ [] ], + }, + 'pkg_svc' => { 'columns' => [ 'pkgpart', 'int', '', '', -- cgit v1.2.1 From 8935cf3566726a2757c3b8f988acfcc0b7ac9352 Mon Sep 17 00:00:00 2001 From: ivan Date: Thu, 19 Nov 1998 11:17:44 +0000 Subject: adminsuidsetup requires argument --- bin/dbdef-create | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) (limited to 'bin') diff --git a/bin/dbdef-create b/bin/dbdef-create index eb62c77e3..fe7475bec 100755 --- a/bin/dbdef-create +++ b/bin/dbdef-create @@ -1,19 +1,28 @@ #!/usr/bin/perl -Tw # +# $Id: dbdef-create,v 1.2 1998-11-19 11:17:44 ivan Exp $ +# # create dbdef file for existing mySQL database (needs SHOW|DESCRIBE command # not in Pg) based on fs-setup # # ivan@sisd.com 98-jun-2 +# +# $Log: dbdef-create,v $ +# Revision 1.2 1998-11-19 11:17:44 ivan +# adminsuidsetup requires argument +# use strict; use DBI; use FS::dbdef; use FS::UID qw(adminsuidsetup datasrc); -#needs to match FS::Record -my($dbdef_file) = "/var/spool/freeside/dbdef.". datasrc; +my $user = shift or die &usage; -my($dbh)=adminsuidsetup; +my($dbh)=adminsuidsetup $user; + +#needs to match FS::Record +my($dbdef_file) = "/usr/local/etc/freeside/dbdef.". datasrc; my($tables_sth)=$dbh->prepare("SHOW TABLES"); my($tables_rv)=$tables_sth->execute; @@ -83,3 +92,6 @@ my($dbdef) = new FS::dbdef ( @tables ); #important $dbdef->save($dbdef_file); +sub usage { + die "Usage:\n dbdef-create user\n"; +} -- cgit v1.2.1 From 7559cc8cb8e2ad57806462d22eedb1fb101816f0 Mon Sep 17 00:00:00 2001 From: ivan Date: Thu, 10 Dec 1998 07:23:18 +0000 Subject: use FS::Conf, need user (for datasrc) --- bin/svc_acct.export | 89 +++++++++++++++++++------------------------------- bin/svc_acct.import | 22 +++++++++---- bin/svc_acct_sm.export | 69 +++++++++++++++++++------------------- bin/svc_acct_sm.import | 23 ++++++++++--- 4 files changed, 103 insertions(+), 100 deletions(-) (limited to 'bin') diff --git a/bin/svc_acct.export b/bin/svc_acct.export index 3f65a08ba..d4ebe6bdc 100755 --- a/bin/svc_acct.export +++ b/bin/svc_acct.export @@ -1,5 +1,7 @@ #!/usr/bin/perl -Tw # +# $Id: svc_acct.export,v 1.2 1998-12-10 07:23:15 ivan Exp $ +# # Create and export password files: passwd, passwd.adjunct, shadow, # acp_passwd, acp_userinfo, acp_dialup, users # @@ -34,75 +36,46 @@ # # OOPS! added arbitrary radius fields (pry 98-aug-16) but forgot to say so. # ivan@sisd.com 98-sep-18 +# +# $Log: svc_acct.export,v $ +# Revision 1.2 1998-12-10 07:23:15 ivan +# use FS::Conf, need user (for datasrc) +# use strict; +use vars qw($conf); use Fcntl qw(:flock); +use FS::Conf; use FS::SSH qw(scp ssh); -use FS::UID qw(adminsuidsetup); +use FS::UID qw(adminsuidsetup datasrc); use FS::Record qw(qsearch fields); +use FS::svc_acct; -my($fshellmachines)="/var/spool/freeside/conf/shellmachines"; -my(@shellmachines); -if ( -e $fshellmachines ) { - open(SHELLMACHINES,$fshellmachines); - @shellmachines=map { - /^(.*)$/ or die "Illegal line in conf/shellmachines"; #we trust the file - $1; - } grep $_ !~ /^(#|$)/, ; - close SHELLMACHINES; -} +my $user = shift or die &usage; +adminsuidsetup $user; -my($fbsdshellmachines)="/var/spool/freeside/conf/bsdshellmachines"; -my(@bsdshellmachines); -if ( -e $fbsdshellmachines ) { - open(BSDSHELLMACHINES,$fbsdshellmachines); - @bsdshellmachines=map { - /^(.*)$/ or die "Illegal line in conf/bsdshellmachines"; #we trust the file - $1; - } grep $_ !~ /^(#|$)/, ; - close BSDSHELLMACHINES; -} +$conf = new FS::Conf; -my($fnismachines)="/var/spool/freeside/conf/nismachines"; -my(@nismachines); -if ( -e $fnismachines ) { - open(NISMACHINES,$fnismachines); - @nismachines=map { - /^(.*)$/ or die "Illegal line in conf/nismachines"; #we trust the file - $1; - } grep $_ !~ /^(#|$)/, ; - close NISMACHINES; -} +my @shellmachines = $conf->config('shellmachines') + if $conf->exists('shellmachines'); -my($ferpcdmachines)="/var/spool/freeside/conf/erpcdmachines"; -my(@erpcdmachines); -if ( -e $ferpcdmachines ) { - open(ERPCDMACHINES,$ferpcdmachines); - @erpcdmachines=map { - /^(.*)$/ or die "Illegal line in conf/erpcdmachines"; #we trust the file - $1; - } grep $_ !~ /^(#|$)/, ; - close ERPCDMACHINES; -} +my @bsdshellmachines = $conf->config('bsdshellmachines') + if $conf->exists('bsdshellmachines'); -my($fradiusmachines)="/var/spool/freeside/conf/radiusmachines"; -my(@radiusmachines); -if ( -e $fradiusmachines ) { - open(RADIUSMACHINES,$fradiusmachines); - @radiusmachines=map { - /^(.*)$/ or die "Illegal line in conf/radiusmachines"; #we trust the file - $1; - } grep $_ !~ /^(#|$)/, ; - close RADIUSMACHINES; -} +my @nismachines = $conf->config('nismachines') + if $conf->exists('nismachines'); -my($spooldir)="/var/spool/freeside/export"; -my($spoollock)="/var/spool/freeside/svc_acct.export.lock"; +my @erpcdmachines = $conf->config('erpcdmachines') + if $conf->exists('erpcdmachines'); -adminsuidsetup; +my @radiusmachines = $conf->config('radiusmachines') + if $conf->exists('radiusmachines'); my(@saltset)= ( 'a'..'z' , 'A'..'Z' , '0'..'9' , '.' , '/' ); -srand(time|$$); +require 5.004; #srand(time|$$); + +my $spooldir = "/usr/local/etc/freeside/export.". datasrc; +my $spoollock = "/usr/local/etc/freeside/svc_acct.export.lock.". datasrc; open(EXPORT,"+>>$spoollock") or die "Can't open $spoollock: $!"; select(EXPORT); $|=1; select(STDOUT); @@ -349,3 +322,9 @@ unlink $spoollock; flock(EXPORT,LOCK_UN); close EXPORT; +# + +sub usage { + die "Usage:\n\n svc_acct.export user\n"; +} + diff --git a/bin/svc_acct.import b/bin/svc_acct.import index 60deac539..8343ce867 100755 --- a/bin/svc_acct.import +++ b/bin/svc_acct.import @@ -1,6 +1,6 @@ #!/usr/bin/perl -Tw # -# $Id: svc_acct.import,v 1.2 1998-10-13 12:07:51 ivan Exp $ +# $Id: svc_acct.import,v 1.3 1998-12-10 07:23:16 ivan Exp $ # # ivan@sisd.com 98-mar-9 # @@ -17,7 +17,10 @@ # don't import /var/spool/freeside/conf/shells! ivan@sisd.com 98-aug-13 # # $Log: svc_acct.import,v $ -# Revision 1.2 1998-10-13 12:07:51 ivan +# Revision 1.3 1998-12-10 07:23:16 ivan +# use FS::Conf, need user (for datasrc) +# +# Revision 1.2 1998/10/13 12:07:51 ivan # Assigns password from the shadow file for RADIUS password "UNIX" # @@ -25,14 +28,15 @@ use strict; use vars qw(%part_svc); use Date::Parse; use FS::SSH qw(iscp); -use FS::UID qw(adminsuidsetup); +use FS::UID qw(adminsuidsetup datasrc); use FS::Record qw(qsearch); use FS::svc_acct; +use FS::part_svc; -adminsuidsetup; +my $user = shift or die &usage; +adminsuidsetup $user; -#my($spooldir)="/var/spool/freeside/export"; -my($spooldir)="unix/"; +my($spooldir)="/usr/local/etc/freeside/export.". datasrc; $FS::svc_acct::nossh_hack = 1; @@ -233,3 +237,9 @@ foreach $username ( keys %upassword ) { delete $upassword{$username}; } +# + +sub usage { + die "Usage:\n\n svc_acct.export user\n"; +} + diff --git a/bin/svc_acct_sm.export b/bin/svc_acct_sm.export index c2ec1e53f..ce4900733 100755 --- a/bin/svc_acct_sm.export +++ b/bin/svc_acct_sm.export @@ -1,6 +1,10 @@ #!/usr/bin/perl -Tw # -# Create and export VoiceNet_quasar.m4 +# $Id: svc_acct_sm.export,v 1.2 1998-12-10 07:23:17 ivan Exp $ +# +# Create and export config files for sendmail, qmail +# +# (used to) Create and export VoiceNet_quasar.m4 # # ivan@voicenet.com late oct 96 # @@ -36,53 +40,42 @@ # put example $my_domain declaration in ivan@sisd.com 98-mar-23 # # /var/spool/freeside/conf and sendmail updates ivan@sisd.com 98-aug-14 +# +# $Log: svc_acct_sm.export,v $ +# Revision 1.2 1998-12-10 07:23:17 ivan +# use FS::Conf, need user (for datasrc) +# use strict; +use vars qw($conf); use Fcntl qw(:flock); use FS::SSH qw(ssh scp); -use FS::UID qw(adminsuidsetup); +use FS::UID qw(adminsuidsetup datasrc); use FS::Record qw(qsearch qsearchs); +use FS::svc_acct; +use FS::svc_acct_sm; +use FS::svc_domain; + +my $user = shift or die &usage; +adminsuidsetup $user; + +$conf = new FS::Conf; -my($conf_shellm)="/var/spool/freeside/conf/shellmachine"; -my($fqmailmachines)="/var/spool/freeside/conf/qmailmachines"; my($shellmachine); my(@qmailmachines); -if ( -e $fqmailmachines ) { - open(SHELLMACHINE,$conf_shellm) or die "Can't open $conf_shellm: $!"; - =~ /^([\w\.\-]+)$/ or die "Illegal $conf_shellm"; - $shellmachine = $1; - close SHELLMACHINE; - open(QMAILMACHINES,$fqmailmachines); - @qmailmachines=map { - /^(.*)$/ or die "Illegal line in conf/qmailmachines"; #we trust the file - $1; - } grep $_ !~ /^(#|$)/, ; - close QMAILMACHINES; +if ( $conf->exists('qmailmachines') ) { + $shellmachine = $conf->config('shellmachine'); + @qmailmachines = $conf->config('qmailmachines'); } -my($fsendmailmachines)="/var/spool/freeside/conf/sendmailmachines"; -my(@sendmailmachines); -if ( -e $fsendmailmachines ) { - open(SENDMAILMACHINES,$fsendmailmachines); - @sendmailmachines=map { - /^(.*)$/ or die "Illegal line in conf/sendmailmachines"; #we trust the file - $1; - } grep $_ !~ /^(#|$)/, ; - close SENDMAILMACHINES; -} +my @sendmailmachines = $conf->config('sendmailmachines') + if $conf->exists('sendmailmachines'); -my($conf_domain)="/var/spool/freeside/conf/domain"; -open(DOMAIN,$conf_domain) or die "Can't open $conf_domain: $!"; -my($mydomain)=map { - /^(.*)$/ or die "Illegal line in $conf_domain!"; #yes, we trust the file - $1 -} grep $_ !~ /^(#|$)/, ; -close DOMAIN; +my $mydomain = $conf->config('domain'); -my($spooldir)="/var/spool/freeside/export"; -my($spoollock)="/var/spool/freeside/svc_acct_sm.export.lock"; +my $spooldir = "/usr/local/etc/freeside/export.". datasrc; +my $spoollock = "/usr/local/etc/freeside/svc_acct_sm.export.lock.". datasrc; -adminsuidsetup; umask 066; open(EXPORT,"+>>$spoollock") or die "Can't open $spoollock: $!"; @@ -219,3 +212,9 @@ unlink $spoollock; flock(EXPORT,LOCK_UN); close EXPORT; +# + +sub usage { + die "Usage:\n\n svc_acct.export user\n"; +} + diff --git a/bin/svc_acct_sm.import b/bin/svc_acct_sm.import index 10d7e4c20..f94bda637 100755 --- a/bin/svc_acct_sm.import +++ b/bin/svc_acct_sm.import @@ -1,5 +1,7 @@ #!/usr/bin/perl -Tw # +# $Id: svc_acct_sm.import,v 1.2 1998-12-10 07:23:18 ivan Exp $ +# # ivan@sisd.com 98-mar-9 # # generalized svcparts ivan@sisd.com 98-mar-23 @@ -12,19 +14,26 @@ # has an (untested) section for sendmail, s/warn/die/g and generates a program # to run on your mail machine _later_ instead of ssh'ing for each user # ivan@sisd.com 98-jul-13 +# +# $Log: svc_acct_sm.import,v $ +# Revision 1.2 1998-12-10 07:23:18 ivan +# use FS::Conf, need user (for datasrc) +# use strict; use vars qw(%d_part_svc %m_part_svc); use FS::SSH qw(iscp); -use FS::UID qw(adminsuidsetup); +use FS::UID qw(adminsuidsetup datasrc); use FS::Record qw(qsearch qsearchs); use FS::svc_acct_sm; use FS::svc_domain; +use FS::svc_acct; +use FS::part_svc; -adminsuidsetup; +my $user = shift or die &usage; +adminsuidsetup $user; -#my($spooldir)="/var/spool/freeside/export"; -my($spooldir)="unix"; +my($spooldir)="/usr/local/etc/freeside/export.". datasrc; my(%mta) = ( 1 => "qmail", @@ -250,3 +259,9 @@ Don\'t forget to run $spooldir/virtualdomains.FIX before using $spooldir/virtualdomains ! END +# + +sub usage { + die "Usage:\n\n svc_acct_sm.export user\n"; +} + -- cgit v1.2.1 From 0057d8bd24476fc9a50c82a94f39b168f46b0a28 Mon Sep 17 00:00:00 2001 From: ivan Date: Tue, 15 Dec 1998 04:33:27 +0000 Subject: dies if it isn't running as the freeside user --- bin/fs-setup | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'bin') diff --git a/bin/fs-setup b/bin/fs-setup index b3fc5c5a0..621c426c4 100755 --- a/bin/fs-setup +++ b/bin/fs-setup @@ -1,6 +1,6 @@ #!/usr/bin/perl -Tw # -# create database and necessary tables, etc. DBI version. +# $Id: fs-setup,v 1.8 1998-12-15 04:33:27 ivan Exp $ # # ivan@sisd.com 97-nov-8,9 # @@ -32,7 +32,10 @@ # fix radius attributes ivan@sisd.com 98-sep-27 # # $Log: fs-setup,v $ -# Revision 1.7 1998-11-18 09:01:31 ivan +# Revision 1.8 1998-12-15 04:33:27 ivan +# dies if it isn't running as the freeside user +# +# Revision 1.7 1998/11/18 09:01:31 ivan # i18n! i18n! # # Revision 1.6 1998/11/15 13:18:02 ivan @@ -54,10 +57,12 @@ BEGIN { $FS::Record::setup_hack = 1; } use strict; use DBI; use FS::dbdef; -use FS::UID qw(adminsuidsetup datasrc); +use FS::UID qw(adminsuidsetup datasrc checkeuid); use FS::Record; use FS::cust_main_county; +croak "Not running uid freeside!" unless checkeuid(); + my $user = shift or die &usage; FS::UID::getsecrets $user; -- cgit v1.2.1 From 5633a7534d0319ce016092523d4ad7ff453a9726 Mon Sep 17 00:00:00 2001 From: ivan Date: Tue, 15 Dec 1998 04:36:29 +0000 Subject: s/croak/die/; #oops --- bin/fs-setup | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'bin') diff --git a/bin/fs-setup b/bin/fs-setup index 621c426c4..19ac53377 100755 --- a/bin/fs-setup +++ b/bin/fs-setup @@ -1,6 +1,6 @@ #!/usr/bin/perl -Tw # -# $Id: fs-setup,v 1.8 1998-12-15 04:33:27 ivan Exp $ +# $Id: fs-setup,v 1.9 1998-12-15 04:36:29 ivan Exp $ # # ivan@sisd.com 97-nov-8,9 # @@ -32,7 +32,10 @@ # fix radius attributes ivan@sisd.com 98-sep-27 # # $Log: fs-setup,v $ -# Revision 1.8 1998-12-15 04:33:27 ivan +# Revision 1.9 1998-12-15 04:36:29 ivan +# s/croak/die/; #oops +# +# Revision 1.8 1998/12/15 04:33:27 ivan # dies if it isn't running as the freeside user # # Revision 1.7 1998/11/18 09:01:31 ivan @@ -61,7 +64,7 @@ use FS::UID qw(adminsuidsetup datasrc checkeuid); use FS::Record; use FS::cust_main_county; -croak "Not running uid freeside!" unless checkeuid(); +die "Not running uid freeside!" unless checkeuid(); my $user = shift or die &usage; FS::UID::getsecrets $user; -- cgit v1.2.1 From 56b98dd1587282585a92a93dbac5781da58154f1 Mon Sep 17 00:00:00 2001 From: ivan Date: Wed, 16 Dec 1998 06:05:40 +0000 Subject: add table cust_main_invoice --- bin/fs-setup | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) (limited to 'bin') diff --git a/bin/fs-setup b/bin/fs-setup index 19ac53377..9f8740093 100755 --- a/bin/fs-setup +++ b/bin/fs-setup @@ -1,6 +1,6 @@ #!/usr/bin/perl -Tw # -# $Id: fs-setup,v 1.9 1998-12-15 04:36:29 ivan Exp $ +# $Id: fs-setup,v 1.10 1998-12-16 06:05:38 ivan Exp $ # # ivan@sisd.com 97-nov-8,9 # @@ -32,7 +32,10 @@ # fix radius attributes ivan@sisd.com 98-sep-27 # # $Log: fs-setup,v $ -# Revision 1.9 1998-12-15 04:36:29 ivan +# Revision 1.10 1998-12-16 06:05:38 ivan +# add table cust_main_invoice +# +# Revision 1.9 1998/12/15 04:36:29 ivan # s/croak/die/; #oops # # Revision 1.8 1998/12/15 04:33:27 ivan @@ -368,6 +371,17 @@ sub tables_hash_hack { 'index' => [ ['last'], ], }, + 'cust_main_invoice' => { + 'columns' => [ + 'destnum', 'int', '', '', + 'custnum', 'int', '', '', + 'dest', 'varchar', '', $char_d, + ], + 'primary_key' => 'destnum', + 'unique' => [ [] ], + 'index' => [ ['custnum'], ], + }, + 'cust_main_county' => { #county+state+country are checked off the #cust_main_county for validation and to provide # a tax rate. -- cgit v1.2.1 From 228a29352a267bd457ce372e7ee933c9b07e11fd Mon Sep 17 00:00:00 2001 From: ivan Date: Sun, 17 Jan 1999 03:11:52 +0000 Subject: remove preliminary completehost changes --- bin/fs-setup | 29 ++++++++++++++++------------- 1 file changed, 16 insertions(+), 13 deletions(-) (limited to 'bin') diff --git a/bin/fs-setup b/bin/fs-setup index 9f8740093..222ce1611 100755 --- a/bin/fs-setup +++ b/bin/fs-setup @@ -1,6 +1,6 @@ #!/usr/bin/perl -Tw # -# $Id: fs-setup,v 1.10 1998-12-16 06:05:38 ivan Exp $ +# $Id: fs-setup,v 1.11 1999-01-17 03:11:52 ivan Exp $ # # ivan@sisd.com 97-nov-8,9 # @@ -32,7 +32,10 @@ # fix radius attributes ivan@sisd.com 98-sep-27 # # $Log: fs-setup,v $ -# Revision 1.10 1998-12-16 06:05:38 ivan +# Revision 1.11 1999-01-17 03:11:52 ivan +# remove preliminary completehost changes +# +# Revision 1.10 1998/12/16 06:05:38 ivan # add table cust_main_invoice # # Revision 1.9 1998/12/15 04:36:29 ivan @@ -341,9 +344,9 @@ sub tables_hash_hack { 'columns' => [ 'custnum', 'int', '', '', 'agentnum', 'int', '', '', - 'titlenum', 'int', 'NULL', '', +# 'titlenum', 'int', 'NULL', '', 'last', 'varchar', '', $char_d, - 'middle', 'varchar', 'NULL', $char_d, +# 'middle', 'varchar', 'NULL', $char_d, 'first', 'varchar', '', $char_d, 'ss', 'char', 'NULL', 11, 'company', 'varchar', 'NULL', $char_d, @@ -497,15 +500,15 @@ sub tables_hash_hack { 'index' => [ [] ], }, - 'part_title' => { - 'columns' => [ - 'titlenum', 'int', '', '', - 'title', 'varchar', '', $char_d, - ], - 'primary_key' => 'titlenum', - 'unique' => [ [] ], - 'index' => [ [] ], - }, +# 'part_title' => { +# 'columns' => [ +# 'titlenum', 'int', '', '', +# 'title', 'varchar', '', $char_d, +# ], +# 'primary_key' => 'titlenum', +# 'unique' => [ [] ], +# 'index' => [ [] ], +# }, 'pkg_svc' => { 'columns' => [ -- cgit v1.2.1 From 4757f810e753160f874de68190df5dabc43488d5 Mon Sep 17 00:00:00 2001 From: ivan Date: Wed, 3 Feb 1999 10:42:27 +0000 Subject: *** empty log message *** --- bin/fs-setup | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'bin') diff --git a/bin/fs-setup b/bin/fs-setup index 222ce1611..2c425df39 100755 --- a/bin/fs-setup +++ b/bin/fs-setup @@ -1,6 +1,6 @@ #!/usr/bin/perl -Tw # -# $Id: fs-setup,v 1.11 1999-01-17 03:11:52 ivan Exp $ +# $Id: fs-setup,v 1.12 1999-02-03 10:42:27 ivan Exp $ # # ivan@sisd.com 97-nov-8,9 # @@ -32,7 +32,10 @@ # fix radius attributes ivan@sisd.com 98-sep-27 # # $Log: fs-setup,v $ -# Revision 1.11 1999-01-17 03:11:52 ivan +# Revision 1.12 1999-02-03 10:42:27 ivan +# *** empty log message *** +# +# Revision 1.11 1999/01/17 03:11:52 ivan # remove preliminary completehost changes # # Revision 1.10 1998/12/16 06:05:38 ivan @@ -177,7 +180,7 @@ foreach (qw(svc_acct svc_acct_sm svc_domain)) { #important $dbdef->save($dbdef_file); -FS::Record::reload_dbdef($dbdef_file); +&FS::Record::reload_dbdef($dbdef_file); ### # create 'em -- cgit v1.2.1 From 3e38c8e98073ab22c443de245846008a9db98000 Mon Sep 17 00:00:00 2001 From: ivan Date: Thu, 4 Feb 1999 06:09:23 +0000 Subject: add AU provences --- bin/fs-setup | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) (limited to 'bin') diff --git a/bin/fs-setup b/bin/fs-setup index 2c425df39..2683e98ad 100755 --- a/bin/fs-setup +++ b/bin/fs-setup @@ -1,6 +1,6 @@ #!/usr/bin/perl -Tw # -# $Id: fs-setup,v 1.12 1999-02-03 10:42:27 ivan Exp $ +# $Id: fs-setup,v 1.13 1999-02-04 06:09:23 ivan Exp $ # # ivan@sisd.com 97-nov-8,9 # @@ -32,7 +32,10 @@ # fix radius attributes ivan@sisd.com 98-sep-27 # # $Log: fs-setup,v $ -# Revision 1.12 1999-02-03 10:42:27 ivan +# Revision 1.13 1999-02-04 06:09:23 ivan +# add AU provences +# +# Revision 1.12 1999/02/03 10:42:27 ivan # *** empty log message *** # # Revision 1.11 1999/01/17 03:11:52 ivan @@ -228,9 +231,23 @@ SC SD TN TX TT UT VT VI VA WA WV WI WY AE AA AP die $error if $error; } -#ISO 2-letter country codes (same as country TLDs) except US +#AU "offical" state codes ala mark.williamson@ebbs.com.au (Mark Williamson) +foreach ( qw( +VIC NSW NT QLD TAS ACT WA SA +) ) { + my($cust_main_county)=create FS::cust_main_county({ + 'state' => $_, + 'tax' => 0, + 'country' => 'AU', + }); + my($error); + $error=$cust_main_county->insert; + die $error if $error; +} + +#ISO 2-letter country codes (same as country TLDs) except US and AU foreach ( qw( -AF AL DZ AS AD AO AI AQ AG AR AM AW AU AT AZ BS BH BD BB BY BE BZ BJ BM BT BO +AF AL DZ AS AD AO AI AQ AG AR AM AW AT AZ BS BH BD BB BY BE BZ BJ BM BT BO BA BW BV BR IO BN BG BF BI KH CM CA CV KY CF TD CL CN CX CC CO KM CG CK CR CI HR CU CY CZ DK DJ DM DO TP EC EG SV GQ ER EE ET FK FO FJ FI FR FX GF PF TF GA GM GE DE GH GI GR GL GD GP GU GT GN GW GY HT HM HN HK HU IS IN ID IR IQ IE IL -- cgit v1.2.1 From e0da34d97b1463b55a334e8dae10cd55796e2312 Mon Sep 17 00:00:00 2001 From: ivan Date: Sun, 7 Feb 1999 09:59:44 +0000 Subject: more mod_perl fixes, and bugfixes Peter Wemm sent via email --- bin/fs-setup | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) (limited to 'bin') diff --git a/bin/fs-setup b/bin/fs-setup index 2683e98ad..f028c6e1d 100755 --- a/bin/fs-setup +++ b/bin/fs-setup @@ -1,6 +1,6 @@ #!/usr/bin/perl -Tw # -# $Id: fs-setup,v 1.13 1999-02-04 06:09:23 ivan Exp $ +# $Id: fs-setup,v 1.14 1999-02-07 09:59:14 ivan Exp $ # # ivan@sisd.com 97-nov-8,9 # @@ -32,7 +32,10 @@ # fix radius attributes ivan@sisd.com 98-sep-27 # # $Log: fs-setup,v $ -# Revision 1.13 1999-02-04 06:09:23 ivan +# Revision 1.14 1999-02-07 09:59:14 ivan +# more mod_perl fixes, and bugfixes Peter Wemm sent via email +# +# Revision 1.13 1999/02/04 06:09:23 ivan # add AU provences # # Revision 1.12 1999/02/03 10:42:27 ivan @@ -374,7 +377,7 @@ sub tables_hash_hack { 'address2', 'varchar', 'NULL', $char_d, 'city', 'varchar', '', $char_d, 'county', 'varchar', 'NULL', $char_d, - 'state', 'varchar', '', $char_d, + 'state', 'varchar', 'NULL', $char_d, 'zip', 'varchar', '', 10, 'country', 'char', '', 2, 'daytime', 'varchar', 'NULL', 20, @@ -410,7 +413,7 @@ sub tables_hash_hack { # a tax rate. 'columns' => [ 'taxnum', 'int', '', '', - 'state', 'char', 'NULL', $char_d, + 'state', 'varchar', 'NULL', $char_d, 'county', 'varchar', 'NULL', $char_d, 'country', 'char', '', 2, 'tax', 'real', '', '', #tax % @@ -447,7 +450,7 @@ sub tables_hash_hack { 'address1', 'varchar', '', $char_d, 'address2', 'varchar', 'NULL', $char_d, 'city', 'varchar', '', $char_d, - 'state', 'char', '', 2, + 'state', 'varchar', '', $char_d, 'zip', 'varchar', '', 10, 'country', 'char', '', 2, 'trancode', 'int', '', '', @@ -567,7 +570,7 @@ sub tables_hash_hack { 'columns' => [ 'popnum', 'int', '', '', 'city', 'varchar', '', $char_d, - 'state', 'char', '', 2, + 'state', 'varchar', '', $char_d, 'ac', 'char', '', 3, 'exch', 'char', '', 3, #rest o' number? -- cgit v1.2.1 From 532db8ddd43eae7f09200ad25fbc542524f2093d Mon Sep 17 00:00:00 2001 From: ivan Date: Sat, 27 Feb 1999 21:06:48 +0000 Subject: cust_main.paydate should be varchar(10), not @date_type ; problem reported by Ben Leibig --- bin/fs-setup | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'bin') diff --git a/bin/fs-setup b/bin/fs-setup index f028c6e1d..7a5403b01 100755 --- a/bin/fs-setup +++ b/bin/fs-setup @@ -1,6 +1,6 @@ #!/usr/bin/perl -Tw # -# $Id: fs-setup,v 1.14 1999-02-07 09:59:14 ivan Exp $ +# $Id: fs-setup,v 1.15 1999-02-27 21:06:21 ivan Exp $ # # ivan@sisd.com 97-nov-8,9 # @@ -32,7 +32,11 @@ # fix radius attributes ivan@sisd.com 98-sep-27 # # $Log: fs-setup,v $ -# Revision 1.14 1999-02-07 09:59:14 ivan +# Revision 1.15 1999-02-27 21:06:21 ivan +# cust_main.paydate should be varchar(10), not @date_type ; problem reported +# by Ben Leibig +# +# Revision 1.14 1999/02/07 09:59:14 ivan # more mod_perl fixes, and bugfixes Peter Wemm sent via email # # Revision 1.13 1999/02/04 06:09:23 ivan @@ -385,7 +389,8 @@ sub tables_hash_hack { 'fax', 'varchar', 'NULL', 12, 'payby', 'char', '', 4, 'payinfo', 'varchar', 'NULL', 16, - 'paydate', @date_type, + #'paydate', @date_type, + 'paydate', 'varchar', 'NULL', 10, 'payname', 'varchar', 'NULL', $char_d, 'tax', 'char', 'NULL', 1, 'otaker', 'varchar', '', 8, -- cgit v1.2.1 From b295ca59242c863db3f6f79295625392680e144b Mon Sep 17 00:00:00 2001 From: ivan Date: Sun, 28 Feb 1999 19:44:16 +0000 Subject: constructors s/create/new/ pointed out by "Bao C. Ha" --- bin/fs-setup | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'bin') diff --git a/bin/fs-setup b/bin/fs-setup index 7a5403b01..b7d4a1889 100755 --- a/bin/fs-setup +++ b/bin/fs-setup @@ -1,6 +1,6 @@ #!/usr/bin/perl -Tw # -# $Id: fs-setup,v 1.15 1999-02-27 21:06:21 ivan Exp $ +# $Id: fs-setup,v 1.16 1999-02-28 19:44:16 ivan Exp $ # # ivan@sisd.com 97-nov-8,9 # @@ -32,7 +32,10 @@ # fix radius attributes ivan@sisd.com 98-sep-27 # # $Log: fs-setup,v $ -# Revision 1.15 1999-02-27 21:06:21 ivan +# Revision 1.16 1999-02-28 19:44:16 ivan +# constructors s/create/new/ pointed out by "Bao C. Ha" +# +# Revision 1.15 1999/02/27 21:06:21 ivan # cust_main.paydate should be varchar(10), not @date_type ; problem reported # by Ben Leibig # @@ -228,7 +231,7 @@ AL AK AS AZ AR CA CO CT DC DE FM FL GA GU HI ID IL IN IA KS KY LA ME MH MD MA MI MN MS MO MT NC ND NE NH NJ NM NV NY MP OH OK OR PA PW PR RI SC SD TN TX TT UT VT VI VA WA WV WI WY AE AA AP ) ) { - my($cust_main_county)=create FS::cust_main_county({ + my($cust_main_county)=new FS::cust_main_county({ 'state' => $_, 'tax' => 0, 'country' => 'US', @@ -242,7 +245,7 @@ SC SD TN TX TT UT VT VI VA WA WV WI WY AE AA AP foreach ( qw( VIC NSW NT QLD TAS ACT WA SA ) ) { - my($cust_main_county)=create FS::cust_main_county({ + my($cust_main_county)=new FS::cust_main_county({ 'state' => $_, 'tax' => 0, 'country' => 'AU', @@ -265,7 +268,7 @@ ST SA SN SC SL SG SK SI SB SO ZA GS ES LK SH PM SD SR SJ SZ SE CH SY TW TJ TZ TH TG TK TO TT TN TR TM TC TV UG UA AE GB UM UY UZ VU VA VE VN VG VI WF EH YE YU ZR ZM ZW ) ) { - my($cust_main_county)=create FS::cust_main_county({ + my($cust_main_county)=new FS::cust_main_county({ 'tax' => 0, 'country' => $_, }); -- cgit v1.2.1 From beea3b3e0c801ceeb05eee672957d318930a9a2d Mon Sep 17 00:00:00 2001 From: ivan Date: Wed, 24 Mar 1999 00:43:38 +0000 Subject: die if no relevant services --- bin/svc_acct.import | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'bin') diff --git a/bin/svc_acct.import b/bin/svc_acct.import index 8343ce867..c22cb0d15 100755 --- a/bin/svc_acct.import +++ b/bin/svc_acct.import @@ -1,6 +1,6 @@ #!/usr/bin/perl -Tw # -# $Id: svc_acct.import,v 1.3 1998-12-10 07:23:16 ivan Exp $ +# $Id: svc_acct.import,v 1.4 1999-03-24 00:43:38 ivan Exp $ # # ivan@sisd.com 98-mar-9 # @@ -17,7 +17,10 @@ # don't import /var/spool/freeside/conf/shells! ivan@sisd.com 98-aug-13 # # $Log: svc_acct.import,v $ -# Revision 1.3 1998-12-10 07:23:16 ivan +# Revision 1.4 1999-03-24 00:43:38 ivan +# die if no relevant services +# +# Revision 1.3 1998/12/10 07:23:16 ivan # use FS::Conf, need user (for datasrc) # # Revision 1.2 1998/10/13 12:07:51 ivan @@ -44,6 +47,8 @@ $FS::svc_acct::nossh_hack = 1; %part_svc=map { $_->svcpart, $_ } qsearch('part_svc',{'svcdb'=>'svc_acct'}); +die "No services with svcdb svc_acct!\n" unless %part_svc; + print "\n\n", &menu_svc, "\n", < Date: Wed, 24 Mar 1999 00:51:55 +0000 Subject: die if no relevant services... cvspain --- bin/svc_acct_sm.import | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'bin') diff --git a/bin/svc_acct_sm.import b/bin/svc_acct_sm.import index f94bda637..647e5c2ee 100755 --- a/bin/svc_acct_sm.import +++ b/bin/svc_acct_sm.import @@ -1,6 +1,6 @@ #!/usr/bin/perl -Tw # -# $Id: svc_acct_sm.import,v 1.2 1998-12-10 07:23:18 ivan Exp $ +# $Id: svc_acct_sm.import,v 1.3 1999-03-24 00:51:55 ivan Exp $ # # ivan@sisd.com 98-mar-9 # @@ -16,7 +16,10 @@ # ivan@sisd.com 98-jul-13 # # $Log: svc_acct_sm.import,v $ -# Revision 1.2 1998-12-10 07:23:18 ivan +# Revision 1.3 1999-03-24 00:51:55 ivan +# die if no relevant services... cvspain +# +# Revision 1.2 1998/12/10 07:23:18 ivan # use FS::Conf, need user (for datasrc) # @@ -47,6 +50,9 @@ my(%mta) = ( %m_part_svc = map { $_->svcpart, $_ } qsearch('part_svc',{'svcdb'=>'svc_acct_sm'}); +die "No services with svcdb svc_domain!\n" unless %d_part_svc; +die "No services with svcdb svc_svc_acct_sm!\n" unless %m_part_svc; + print "\n\n", ( join "\n", map "$_: ".$d_part_svc{$_}->svc, sort keys %d_part_svc ), "\n\nEnter part number for domains: "; -- cgit v1.2.1 From 93ced168cd4e1e23d36094a919576fc646b4df28 Mon Sep 17 00:00:00 2001 From: ivan Date: Thu, 25 Mar 1999 08:42:20 +0000 Subject: import stuff uses Term::Query and spits out (some kinds of) nonsensical input --- bin/svc_acct.import | 36 +++++++++++++++++----------------- bin/svc_acct_sm.import | 52 ++++++++++++++++++++++++++++++-------------------- 2 files changed, 50 insertions(+), 38 deletions(-) (limited to 'bin') diff --git a/bin/svc_acct.import b/bin/svc_acct.import index c22cb0d15..512572251 100755 --- a/bin/svc_acct.import +++ b/bin/svc_acct.import @@ -1,6 +1,6 @@ #!/usr/bin/perl -Tw # -# $Id: svc_acct.import,v 1.4 1999-03-24 00:43:38 ivan Exp $ +# $Id: svc_acct.import,v 1.5 1999-03-25 08:42:19 ivan Exp $ # # ivan@sisd.com 98-mar-9 # @@ -17,7 +17,10 @@ # don't import /var/spool/freeside/conf/shells! ivan@sisd.com 98-aug-13 # # $Log: svc_acct.import,v $ -# Revision 1.4 1999-03-24 00:43:38 ivan +# Revision 1.5 1999-03-25 08:42:19 ivan +# import stuff uses Term::Query and spits out (some kinds of) nonsensical input +# +# Revision 1.4 1999/03/24 00:43:38 ivan # die if no relevant services # # Revision 1.3 1998/12/10 07:23:16 ivan @@ -30,6 +33,7 @@ use strict; use vars qw(%part_svc); use Date::Parse; +use Term::Query qw(query); use FS::SSH qw(iscp); use FS::UID qw(adminsuidsetup datasrc); use FS::Record qw(qsearch); @@ -74,8 +78,7 @@ my($oisdn_svcpart)=&getpart; print "\n\n", &menu_svc, "\n", <svc, sort keys %part_svc ). "\n"; } sub getpart { - print "Enter part number, or 0 for none: "; - &getvalue; + $^W=0; # Term::Query isn't -w-safe + query "Enter part number:", 'irk', [ keys %part_svc ]; + $^W=1; } sub getvalue { - my($x)=scalar(); - chop $x; - $x; + my $prompt = shift; + $^W=0; # Term::Query isn't -w-safe + query $prompt, ''; + $^W=1; } print "\n\n"; @@ -193,7 +195,7 @@ while () { $svcpart = $shell_svcpart; } - my($svc_acct) = create FS::svc_acct ({ + my($svc_acct) = new FS::svc_acct ({ 'svcpart' => $svcpart, 'username' => $username, 'password' => $password, @@ -227,7 +229,7 @@ foreach $username ( keys %upassword ) { die "Illegal Port-Limit in users!\n"; } - my($svc_acct) = create FS::svc_acct ({ + my($svc_acct) = new FS::svc_acct ({ 'svcpart' => $svcpart, 'username' => $username, 'password' => $password, diff --git a/bin/svc_acct_sm.import b/bin/svc_acct_sm.import index 647e5c2ee..bda9762e1 100755 --- a/bin/svc_acct_sm.import +++ b/bin/svc_acct_sm.import @@ -1,6 +1,6 @@ #!/usr/bin/perl -Tw # -# $Id: svc_acct_sm.import,v 1.3 1999-03-24 00:51:55 ivan Exp $ +# $Id: svc_acct_sm.import,v 1.4 1999-03-25 08:42:20 ivan Exp $ # # ivan@sisd.com 98-mar-9 # @@ -16,7 +16,10 @@ # ivan@sisd.com 98-jul-13 # # $Log: svc_acct_sm.import,v $ -# Revision 1.3 1999-03-24 00:51:55 ivan +# Revision 1.4 1999-03-25 08:42:20 ivan +# import stuff uses Term::Query and spits out (some kinds of) nonsensical input +# +# Revision 1.3 1999/03/24 00:51:55 ivan # die if no relevant services... cvspain # # Revision 1.2 1998/12/10 07:23:18 ivan @@ -25,6 +28,7 @@ use strict; use vars qw(%d_part_svc %m_part_svc); +use Term::Query qw(query); use FS::SSH qw(iscp); use FS::UID qw(adminsuidsetup datasrc); use FS::Record qw(qsearch qsearchs); @@ -55,20 +59,28 @@ die "No services with svcdb svc_svc_acct_sm!\n" unless %m_part_svc; print "\n\n", ( join "\n", map "$_: ".$d_part_svc{$_}->svc, sort keys %d_part_svc ), - "\n\nEnter part number for domains: "; -my($domain_svcpart)=&getvalue; + "\n\n"; +$^W=0; #Term::Query isn't -w-safe +my $domain_svcpart = + query "Enter part number for domains: ", 'irk', [ keys %d_part_svc ]; +$^W=1; print "\n\n", ( join "\n", map "$_: ".$m_part_svc{$_}->svc, sort keys %m_part_svc ), - "\n\nEnter part number for mail aliases: "; -my($mailalias_svcpart)=&getvalue; + "\n\n"; +$^W=0; #Term::Query isn't -w-safe +my $mailalias_svcpart = + query "Enter part number for mail aliases: ", 'irk', [ keys %m_part_svc ]; +$^W=1; print "\n\n", <); - chop $x; - $x; + my $prompt = shift; + $^W=0; #Term::Query isn't -w-safe + query $prompt, ''; + $^W=1; } print "\n\n"; @@ -144,7 +154,7 @@ while () { my $domain = $1; my($svc_domain); unless ( $svc_domain = qsearchs('svc_domain', {'domain'=>$domain} ) ) { - $svc_domain = create FS::svc_domain ({ + $svc_domain = new FS::svc_domain ({ 'domain' => $domain, 'svcpart' => $domain_svcpart, 'action' => 'N', @@ -199,7 +209,7 @@ END } unless ( exists $svcnum{$domain} ) { - my($svc_domain) = create FS::svc_domain ({ + my($svc_domain) = new FS::svc_domain ({ 'domain' => $domain, 'svcpart' => $domain_svcpart, 'action' => 'N', @@ -210,7 +220,7 @@ END $svcnum{$domain}=$svc_domain->svcnum; } - my($svc_acct_sm)=create FS::svc_acct_sm ({ + my($svc_acct_sm)=new FS::svc_acct_sm ({ 'domsvc' => $svcnum{$domain}, 'domuid' => $svc_acct->uid, 'domuser' => '*', @@ -240,7 +250,7 @@ END die "Unknown user $username in virtusertable"; next; } - my($svc_acct_sm)=create FS::svc_acct_sm ({ + my($svc_acct_sm)=new FS::svc_acct_sm ({ 'domsvc' => $svcnum{$domain}, 'domuid' => $svc_acct->uid, 'domuser' => $domuser || '*', -- cgit v1.2.1 From ce11defad5298448b5c62c7e40fa1d0351f2af8a Mon Sep 17 00:00:00 2001 From: ivan Date: Wed, 14 Apr 1999 07:58:39 +0000 Subject: export getsecrets from FS::UID instead of calling it explicitly --- bin/fs-setup | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'bin') diff --git a/bin/fs-setup b/bin/fs-setup index b7d4a1889..d21b41d3d 100755 --- a/bin/fs-setup +++ b/bin/fs-setup @@ -1,6 +1,6 @@ #!/usr/bin/perl -Tw # -# $Id: fs-setup,v 1.16 1999-02-28 19:44:16 ivan Exp $ +# $Id: fs-setup,v 1.17 1999-04-14 07:58:39 ivan Exp $ # # ivan@sisd.com 97-nov-8,9 # @@ -32,7 +32,10 @@ # fix radius attributes ivan@sisd.com 98-sep-27 # # $Log: fs-setup,v $ -# Revision 1.16 1999-02-28 19:44:16 ivan +# Revision 1.17 1999-04-14 07:58:39 ivan +# export getsecrets from FS::UID instead of calling it explicitly +# +# Revision 1.16 1999/02/28 19:44:16 ivan # constructors s/create/new/ pointed out by "Bao C. Ha" # # Revision 1.15 1999/02/27 21:06:21 ivan @@ -82,14 +85,14 @@ BEGIN { $FS::Record::setup_hack = 1; } use strict; use DBI; use FS::dbdef; -use FS::UID qw(adminsuidsetup datasrc checkeuid); +use FS::UID qw(adminsuidsetup datasrc checkeuid getsecrets); use FS::Record; use FS::cust_main_county; die "Not running uid freeside!" unless checkeuid(); my $user = shift or die &usage; -FS::UID::getsecrets $user; +getsecrets($user); #needs to match FS::Record my($dbdef_file) = "/usr/local/etc/freeside/dbdef.". datasrc; -- cgit v1.2.1 From a39a2158c87c105f4cf04d68a02bc44557b5a85a Mon Sep 17 00:00:00 2001 From: ivan Date: Thu, 15 Apr 1999 22:46:30 +0000 Subject: TT isn't a state! --- bin/fs-setup | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'bin') diff --git a/bin/fs-setup b/bin/fs-setup index d21b41d3d..ca5e82211 100755 --- a/bin/fs-setup +++ b/bin/fs-setup @@ -1,6 +1,6 @@ #!/usr/bin/perl -Tw # -# $Id: fs-setup,v 1.17 1999-04-14 07:58:39 ivan Exp $ +# $Id: fs-setup,v 1.18 1999-04-15 22:46:30 ivan Exp $ # # ivan@sisd.com 97-nov-8,9 # @@ -32,7 +32,10 @@ # fix radius attributes ivan@sisd.com 98-sep-27 # # $Log: fs-setup,v $ -# Revision 1.17 1999-04-14 07:58:39 ivan +# Revision 1.18 1999-04-15 22:46:30 ivan +# TT isn't a state! +# +# Revision 1.17 1999/04/14 07:58:39 ivan # export getsecrets from FS::UID instead of calling it explicitly # # Revision 1.16 1999/02/28 19:44:16 ivan @@ -232,7 +235,7 @@ foreach ($dbdef->tables) { foreach ( qw( AL AK AS AZ AR CA CO CT DC DE FM FL GA GU HI ID IL IN IA KS KY LA ME MH MD MA MI MN MS MO MT NC ND NE NH NJ NM NV NY MP OH OK OR PA PW PR RI -SC SD TN TX TT UT VT VI VA WA WV WI WY AE AA AP +SC SD TN TX UT VT VI VA WA WV WI WY AE AA AP ) ) { my($cust_main_county)=new FS::cust_main_county({ 'state' => $_, -- cgit v1.2.1 From fe1fe9e3c076c7e4f45a810d6cd07c9008cb2e5b Mon Sep 17 00:00:00 2001 From: ivan Date: Thu, 8 Jul 1999 01:49:00 +0000 Subject: updates to avoid -w warnings from Joel Griffiths --- bin/svc_acct.import | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) (limited to 'bin') diff --git a/bin/svc_acct.import b/bin/svc_acct.import index 512572251..85bc2f5eb 100755 --- a/bin/svc_acct.import +++ b/bin/svc_acct.import @@ -1,6 +1,6 @@ #!/usr/bin/perl -Tw # -# $Id: svc_acct.import,v 1.5 1999-03-25 08:42:19 ivan Exp $ +# $Id: svc_acct.import,v 1.6 1999-07-08 01:49:00 ivan Exp $ # # ivan@sisd.com 98-mar-9 # @@ -17,7 +17,10 @@ # don't import /var/spool/freeside/conf/shells! ivan@sisd.com 98-aug-13 # # $Log: svc_acct.import,v $ -# Revision 1.5 1999-03-25 08:42:19 ivan +# Revision 1.6 1999-07-08 01:49:00 ivan +# updates to avoid -w warnings from Joel Griffiths +# +# Revision 1.5 1999/03/25 08:42:19 ivan # import stuff uses Term::Query and spits out (some kinds of) nonsensical input # # Revision 1.4 1999/03/24 00:43:38 ivan @@ -149,8 +152,12 @@ while () { while () { chop; if ( /^\s*$/ ) { - $ip{$username}=$param{'radius_Framed_IP_Address'}||'0e0'; - delete $param{'radius_Framed_IP_Address'}; + if ( defined $param{'radius_Framed_IP_Address'} ) { + $ip{$username} = $param{'radius_Framed_IP_Address'}; + delete $param{'radius_Framed_IP_Address'}; + } else { + $ip{$username} = '0e0'; + } $allparam{$username}={ %param }; last; } elsif ( /^\s+([\w\-]+)\s=\s"?([\w\.\-\s]+)"?,?\s*$/ ) { @@ -163,8 +170,12 @@ while () { } } #? incase there isn't a terminating blank line ? -$ip{$username}=$param{'radius_Framed_IP_Address'}||'0e0'; -delete $param{'radius_Framed_IP_Address'}; +if ( defined $param{'radius_Framed_IP_Address'} ) { + $ip{$username} = $param{'radius_Framed_IP_Address'}; + delete $param{'radius_Framed_IP_Address'}; +} else { + $ip{$username} = '0e0'; +} $allparam{$username}={ %param }; my(%password); -- cgit v1.2.1 From eb815cc14f3fea0a8d68b22b2fbf282eae09a92a Mon Sep 17 00:00:00 2001 From: ivan Date: Thu, 8 Jul 1999 02:32:26 +0000 Subject: import fix, noticed by Ben Leibig and Joel Griffiths --- bin/svc_acct.import | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'bin') diff --git a/bin/svc_acct.import b/bin/svc_acct.import index 85bc2f5eb..6541a9fd4 100755 --- a/bin/svc_acct.import +++ b/bin/svc_acct.import @@ -1,6 +1,6 @@ #!/usr/bin/perl -Tw # -# $Id: svc_acct.import,v 1.6 1999-07-08 01:49:00 ivan Exp $ +# $Id: svc_acct.import,v 1.7 1999-07-08 02:32:26 ivan Exp $ # # ivan@sisd.com 98-mar-9 # @@ -17,7 +17,10 @@ # don't import /var/spool/freeside/conf/shells! ivan@sisd.com 98-aug-13 # # $Log: svc_acct.import,v $ -# Revision 1.6 1999-07-08 01:49:00 ivan +# Revision 1.7 1999-07-08 02:32:26 ivan +# import fix, noticed by Ben Leibig and Joel Griffiths +# +# Revision 1.6 1999/07/08 01:49:00 ivan # updates to avoid -w warnings from Joel Griffiths # # Revision 1.5 1999/03/25 08:42:19 ivan @@ -115,14 +118,16 @@ sub menu_svc { } sub getpart { $^W=0; # Term::Query isn't -w-safe - query "Enter part number:", 'irk', [ keys %part_svc ]; + my $return = query "Enter part number:", 'irk', [ keys %part_svc ]; $^W=1; + $return; } sub getvalue { my $prompt = shift; $^W=0; # Term::Query isn't -w-safe - query $prompt, ''; + my $return = query $prompt, ''; $^W=1; + $return; } print "\n\n"; -- cgit v1.2.1 From 196b3d878b3526995fd25592168fefd624d757ac Mon Sep 17 00:00:00 2001 From: ivan Date: Thu, 29 Jul 1999 08:50:35 +0000 Subject: wrong type for cust_pay_batch.exp --- bin/fs-setup | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'bin') diff --git a/bin/fs-setup b/bin/fs-setup index ca5e82211..aae9c5739 100755 --- a/bin/fs-setup +++ b/bin/fs-setup @@ -1,6 +1,6 @@ #!/usr/bin/perl -Tw # -# $Id: fs-setup,v 1.18 1999-04-15 22:46:30 ivan Exp $ +# $Id: fs-setup,v 1.19 1999-07-29 08:50:35 ivan Exp $ # # ivan@sisd.com 97-nov-8,9 # @@ -32,7 +32,10 @@ # fix radius attributes ivan@sisd.com 98-sep-27 # # $Log: fs-setup,v $ -# Revision 1.18 1999-04-15 22:46:30 ivan +# Revision 1.19 1999-07-29 08:50:35 ivan +# wrong type for cust_pay_batch.exp +# +# Revision 1.18 1999/04/15 22:46:30 ivan # TT isn't a state! # # Revision 1.17 1999/04/14 07:58:39 ivan @@ -469,7 +472,8 @@ sub tables_hash_hack { 'country', 'char', '', 2, 'trancode', 'int', '', '', 'cardnum', 'varchar', '', 16, - 'exp', @date_type, + #'exp', @date_type, + 'exp', 'varchar', '', 11, 'payname', 'varchar', 'NULL', $char_d, 'amount', @money_type, ], -- cgit v1.2.1 From 32794e9defaeb5ebc84afabf3ef5b360f5533d08 Mon Sep 17 00:00:00 2001 From: ivan Date: Wed, 4 Aug 1999 12:42:19 +0000 Subject: new, kludgy-but-working html generator --- bin/pod2x | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) (limited to 'bin') diff --git a/bin/pod2x b/bin/pod2x index 1edb1c41e..2c10a30d0 100755 --- a/bin/pod2x +++ b/bin/pod2x @@ -3,21 +3,27 @@ #use Pod::Text; #$Pod::Text::termcap=1; -my $site_perl = "./site_perl"; +my $site_perl = "./FS"; #my $catman = "./catman"; -my $catman = "./htdocs/docs/man"; -#my $html = "./htdocs/docs/man"; +#my $catman = "./htdocs/docs/man"; +my $html = "./htdocs/docs/man"; $|=1; die "Can't find $site_perl and $catman" unless [ -d $site_perl ] && [ -d $catman ] && [ -d $html ]; -foreach my $file (glob("$site_perl/*.pm")) { - $file =~ /\/([\w\-]+)\.pm$/ or die "oops file $file"; +foreach my $file ( + glob("$site_perl/*.pm"), + glob("$site_perl/*/*.pm"), + glob("$site_perl/*/*/*.pm") +) { + #$file =~ /\/([\w\-]+)\.pm$/ or die "oops file $file"; + $file =~ /$site_perl\/(.*)\.pm$/ or die "oops file $file"; my $name = $1; - print "$name\n"; - system "pod2text $file >$catman/$name.txt"; -# system "pod2html --podpath=$site_perl $file >$html/$name.html"; + print "$name\n"; + my $htmlroot = join('/', map '..',1..(scalar($file =~ tr/\///)-2)) || '.'; +# system "pod2text $file >$catman/$name.txt"; + system "pod2html --podroot=$site_perl --podpath=./FS:./FS/UI:. --norecurse --htmlroot=$htmlroot $file >$html/$name.html"; # system "pod2html $file >$html/$name.html"; } -- cgit v1.2.1 From 6178bdb5a08527e9c64deb05fab6b836af869695 Mon Sep 17 00:00:00 2001 From: ivan Date: Wed, 11 Aug 1999 14:42:57 +0000 Subject: *** empty log message *** --- bin/backup-freeside | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 bin/backup-freeside (limited to 'bin') diff --git a/bin/backup-freeside b/bin/backup-freeside new file mode 100644 index 000000000..a39b04692 --- /dev/null +++ b/bin/backup-freeside @@ -0,0 +1,6 @@ +#!/bin/sh +/etc/init.d/apache stop +/etc/init.d/mysql stop +tar czvf var-lib-mysql-`date +%y%m%d%H%M%S`.tar.gz /var/lib/mysql +/etc/init.d/mysql start +/etc/init.d/apache start -- cgit v1.2.1 From 0b1f40cc85eee025f01dd14e155cc65837e3f9e5 Mon Sep 17 00:00:00 2001 From: ivan Date: Wed, 11 Aug 1999 20:41:28 +0000 Subject: new bill script, --- bin/bill | 176 --------------------------------------------------------------- 1 file changed, 176 deletions(-) delete mode 100755 bin/bill (limited to 'bin') diff --git a/bin/bill b/bin/bill deleted file mode 100755 index 9553af966..000000000 --- a/bin/bill +++ /dev/null @@ -1,176 +0,0 @@ -#!/usr/bin/perl -Tw - -use strict; -use Fcntl qw(:flock); -use Date::Parse; -use Getopt::Std; -use FS::UID qw(adminsuidsetup swapuid); -use FS::Record qw(qsearch qsearchs); -use FS::cust_main; - -&untaint_argv; #what it sounds like (eww) -use vars qw($opt_b $opt_c $opt_i $opt_d); -getopts("bcid:"); #switches -my $user = shift or die &usage; - -adminsuidsetup $user; - -#we're at now now (and later). -my($time)= $main::opt_d ? str2time($main::opt_d) : $^T; - -# find packages w/ bill < time && cancel != '', and create corresponding -# customer objects - -my($cust_main,%saw); -foreach $cust_main ( - map { - if ( ( $_->getfield('bill') || 0 ) <= $time && - !$saw{ $_->getfield('custnum') }++ ) { - qsearchs('cust_main',{'custnum'=> $_->getfield('custnum') } ); - } else { - (); - } - } ( qsearch('cust_pkg', { 'cancel' => '' }), - qsearch('cust_pkg', { 'cancel' => 0 }), - ) -) { - - # and bill them - - print "Billing customer #" . $cust_main->getfield('custnum') . "\n"; - - my($error); - - $error=$cust_main->bill('time'=>$time); - warn "Error billing, customer #" . $cust_main->getfield('custnum') . - ":" . $error if $error; - - if ($main::opt_c) { - $error=$cust_main->collect('invoice_time'=>$time, - 'batch_card' => $main::opt_i ? 'no' : 'yes', - ); - warn "Error collecting customer #" . $cust_main->getfield('custnum') . - ":" . $error if $error; - - #sleep 1; - - } - -} - -# subroutines - -sub untaint_argv { - foreach $_ ( $[ .. $#ARGV ) { #untaint @ARGV - $ARGV[$_] =~ /^([\w\-\/]*)$/ || die "Illegal arguement \"$ARGV[$_]\""; - $ARGV[$_]=$1; - } -} - -sub usage { - die "Usage:\n\n bill [ -c [ i ] ] [ -d 'date' ] [ -b ] user\n"; -} - -=head1 NAME - -bill - Command line (crontab, script) interface to customer billing. - -=head1 SYNOPSIS - - bill [ -c [ i ] ] [ -d 'date' ] user - -=head1 DESCRIPTION - -Bills all customers. Searches for customers who are due for billing and calls -the bill and collect methods of a cust_main object. See L. - --c: Turn on collecting (you probably want this). - --i: real-time billing (as opposed to batch billing). only relevant - for credit cards. - --d: Pretent it's 'date'. Date is in any format Date::Parse is happy with, - but be careful. - -user: From the mapsecrets file - see config.html from the base documentation - -=head1 VERSION - -$Id: bill,v 1.6 1998-11-15 02:53:00 ivan Exp $ - -=head1 BUGS - -=head1 SEE ALSO - -L, config.html from the base documentation - -=head1 HISTORY - -ivan@voicenet.com sep/oct 96 - -separated billing and collections, cleaned up code. -ivan@voicenet.com 96-nov-11 - -added -d option -ivan@voicenet.com 96-nov-13 - -added -v option and started to implement it, added 'd:' to getopts call - (oops!) -ivan@voicenet.com 97-jan-2 - -added more debug messages, moved some searches to fssearch.pl library (for -speed) -rewrote "all customer" finder to know about bill dates, for speed. -ivan@voicenet.com 97-jan-8 - -thought about it a while, and removed passing of the -d option to collect...? -ivan@voicenet.com 97-jan-14 - -make all -v stuff STDERR -ivan@voicenet.com 97-feb-4 - -added pkgnum as argument to program from /db/part_pkg, with kludge for the -"/bin/echo XX" 's already there. -ivan@voicenet.com 97-feb-23 - -- general cleanup -- customers who are suspended can still be billed for the setup fee -- cust_pkg record is re-read after the package setup fee program is run. - this way, - that program can modify the record (for example, to start accounts off - suspended) - (best to think four or five times before modifying anything else!) -ivan@voicenet.com 97-feb-26 - -don't bill recurring fee if its not time! (was removed) -ivan@voicenet.com 97-mar-6 - -added -b option, send batch when done billing. -ivan@voicenet.com 97-apr-4 - -insecure dependency on line 179ish below needs to be fixed before bill is -used setuid -ivan@voicenet.com 97-jun-2 - -removed running of setup program (depriciated) -ivan@voicenet.com 97-jul-21 - -rewrote for new API, removed option to specify custnums (use FS::Bill -instead), removed -v option (?) -ivan@voicenet.com 97-jul-22 - 23 - 25 -28 -(need to add back in email stuff, look in /home/ivan/old/dbin/collect) - -s/suidsetup/adminsuidsetup/, s/FS::Search/FS::Record/, added some batch -exporting stuff (which still needs to be generalized) and removed &idiot -ivan@sisd.com 98-may-27 - -$Log: bill,v $ -Revision 1.6 1998-11-15 02:53:00 ivan -afterthought - -Revision 1.4 1998/11/07 08:21:26 ivan -missing use - -=cut - - -- cgit v1.2.1 From 9a34cb208f355e2046580232eb731b00deac4b89 Mon Sep 17 00:00:00 2001 From: ivan Date: Fri, 28 Jan 2000 22:56:13 +0000 Subject: track full phone number --- bin/fs-setup | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'bin') diff --git a/bin/fs-setup b/bin/fs-setup index aae9c5739..6ba07e897 100755 --- a/bin/fs-setup +++ b/bin/fs-setup @@ -1,6 +1,6 @@ #!/usr/bin/perl -Tw # -# $Id: fs-setup,v 1.19 1999-07-29 08:50:35 ivan Exp $ +# $Id: fs-setup,v 1.20 2000-01-28 22:53:33 ivan Exp $ # # ivan@sisd.com 97-nov-8,9 # @@ -32,7 +32,10 @@ # fix radius attributes ivan@sisd.com 98-sep-27 # # $Log: fs-setup,v $ -# Revision 1.19 1999-07-29 08:50:35 ivan +# Revision 1.20 2000-01-28 22:53:33 ivan +# track full phone number +# +# Revision 1.19 1999/07/29 08:50:35 ivan # wrong type for cust_pay_batch.exp # # Revision 1.18 1999/04/15 22:46:30 ivan @@ -591,7 +594,7 @@ sub tables_hash_hack { 'state', 'varchar', '', $char_d, 'ac', 'char', '', 3, 'exch', 'char', '', 3, - #rest o' number? + 'loc', 'char', 'NULL', 4, #NULL for legacy purposes ], 'primary_key' => 'popnum', 'unique' => [ [] ], -- cgit v1.2.1 From 8f685842fce6c912568c215f645b01b7fc73c647 Mon Sep 17 00:00:00 2001 From: ivan Date: Sun, 30 Jan 2000 06:05:07 +0000 Subject: postgres 6.5 finally supports decimal(10,2) --- bin/fs-setup | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) (limited to 'bin') diff --git a/bin/fs-setup b/bin/fs-setup index 6ba07e897..f1dd3a8b4 100755 --- a/bin/fs-setup +++ b/bin/fs-setup @@ -1,6 +1,6 @@ #!/usr/bin/perl -Tw # -# $Id: fs-setup,v 1.20 2000-01-28 22:53:33 ivan Exp $ +# $Id: fs-setup,v 1.21 2000-01-30 06:03:26 ivan Exp $ # # ivan@sisd.com 97-nov-8,9 # @@ -32,7 +32,10 @@ # fix radius attributes ivan@sisd.com 98-sep-27 # # $Log: fs-setup,v $ -# Revision 1.20 2000-01-28 22:53:33 ivan +# Revision 1.21 2000-01-30 06:03:26 ivan +# postgres 6.5 finally supports decimal(10,2) +# +# Revision 1.20 2000/01/28 22:53:33 ivan # track full phone number # # Revision 1.19 1999/07/29 08:50:35 ivan @@ -131,12 +134,7 @@ my($char_d) = 80; #default maxlength for text fields #my(@date_type) = ( 'timestamp', '', '' ); my(@date_type) = ( 'int', 'NULL', '' ); my(@perl_type) = ( 'varchar', 'NULL', 255 ); -my(@money_type); -if (datasrc =~ m/Pg/) { #Pg can't do decimal(10,2) - @money_type = ( 'money', '', '' ); -} else { - @money_type = ( 'decimal', '', '10,2' ); -} +my @money_type = ( 'decimal', '', '10,2' ); ### # create a dbdef object from the old data structure -- cgit v1.2.1 From 959663cd4d4885295f44de43ac005e55d054102f Mon Sep 17 00:00:00 2001 From: ivan Date: Mon, 31 Jan 2000 05:22:23 +0000 Subject: prepaid "internet cards" --- bin/fs-setup | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) (limited to 'bin') diff --git a/bin/fs-setup b/bin/fs-setup index f1dd3a8b4..dcaccdf1c 100755 --- a/bin/fs-setup +++ b/bin/fs-setup @@ -1,6 +1,6 @@ #!/usr/bin/perl -Tw # -# $Id: fs-setup,v 1.21 2000-01-30 06:03:26 ivan Exp $ +# $Id: fs-setup,v 1.22 2000-01-31 05:22:23 ivan Exp $ # # ivan@sisd.com 97-nov-8,9 # @@ -32,7 +32,10 @@ # fix radius attributes ivan@sisd.com 98-sep-27 # # $Log: fs-setup,v $ -# Revision 1.21 2000-01-30 06:03:26 ivan +# Revision 1.22 2000-01-31 05:22:23 ivan +# prepaid "internet cards" +# +# Revision 1.21 2000/01/30 06:03:26 ivan # postgres 6.5 finally supports decimal(10,2) # # Revision 1.20 2000/01/28 22:53:33 ivan @@ -663,6 +666,17 @@ sub tables_hash_hack { # 'index' => [ [] ], #}, + 'prepay_credit' => { + 'columns' => [ + 'prepaynum', 'int', '', '', + 'identifier', 'varchar', '', $char_d, + 'amount', @money_type, + ], + 'primary_key' => 'prepaynum', + 'unique' => [ ['identifier'] ], + 'index => [ [] ], + }, + ); %tables; -- cgit v1.2.1 From 3bfec7cf75a1a4eb4da1cdf8c64003bd6babcd81 Mon Sep 17 00:00:00 2001 From: ivan Date: Wed, 2 Feb 2000 20:22:18 +0000 Subject: bugfix prepayment in signup server --- bin/generate-prepay | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100755 bin/generate-prepay (limited to 'bin') diff --git a/bin/generate-prepay b/bin/generate-prepay new file mode 100755 index 000000000..6fb615ab1 --- /dev/null +++ b/bin/generate-prepay @@ -0,0 +1,32 @@ +#!/usr/bin/perl -w + +use strict; +use FS::UID qw(adminsuidsetup); +use FS::prepay_credit; + +require 5.004; #srand(time|$$); + +my $user = shift or die &usage; +&adminsuidsetup( $user ); + +my $amount = shift or die &usage; + +my $num_digits = shift or die &usage; + +my $num_entries = shift or die &usage; + +for ( 1 .. $num_entries ) { + my $identifier = join( '', map int(rand(10)), ( 1 .. $num_digits ) ); + my $prepay_credit = new FS::prepay_credit { + 'identifier' => $identifier, + 'amount' => $amount, + }; + my $error = $prepay_credit->insert; + die $error if $error; + print "$identifier\n"; +} + +sub usage { + die "Usage:\n\n generate-prepay user amount num_digits num_entries"; +} + -- cgit v1.2.1 From 5bd5f206a77cf975515d955119d4dff7764a2d8c Mon Sep 17 00:00:00 2001 From: ivan Date: Thu, 3 Feb 2000 05:17:39 +0000 Subject: beginning of DNS and Apache support --- bin/fs-setup | 34 +++++++++++++++++-- bin/svc_acct.import | 9 +++-- bin/svc_acct_sm.import | 9 +++-- bin/svc_domain.import | 92 ++++++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 135 insertions(+), 9 deletions(-) create mode 100644 bin/svc_domain.import (limited to 'bin') diff --git a/bin/fs-setup b/bin/fs-setup index dcaccdf1c..b75058d55 100755 --- a/bin/fs-setup +++ b/bin/fs-setup @@ -1,6 +1,6 @@ #!/usr/bin/perl -Tw # -# $Id: fs-setup,v 1.22 2000-01-31 05:22:23 ivan Exp $ +# $Id: fs-setup,v 1.23 2000-02-03 05:16:52 ivan Exp $ # # ivan@sisd.com 97-nov-8,9 # @@ -32,7 +32,10 @@ # fix radius attributes ivan@sisd.com 98-sep-27 # # $Log: fs-setup,v $ -# Revision 1.22 2000-01-31 05:22:23 ivan +# Revision 1.23 2000-02-03 05:16:52 ivan +# beginning of DNS and Apache support +# +# Revision 1.22 2000/01/31 05:22:23 ivan # prepaid "internet cards" # # Revision 1.21 2000/01/30 06:03:26 ivan @@ -184,7 +187,7 @@ my($part_svc)=$dbdef->table('part_svc'); #because of svc_acct_pop #foreach (grep /^svc_/, $dbdef->tables) { #foreach (qw(svc_acct svc_acct_sm svc_charge svc_domain svc_wo)) { -foreach (qw(svc_acct svc_acct_sm svc_domain)) { +foreach (qw(svc_acct svc_acct_sm svc_domain svc_www)) { my($table)=$dbdef->table($_); my($col); foreach $col ( $table->columns ) { @@ -653,6 +656,31 @@ sub tables_hash_hack { 'index' => [ [] ], }, + 'domain_record' => { + 'columns' => [ + 'recnum', 'int', '', '', + 'svcnum', 'int', '', '', + 'reczone', 'varchar', '', $char_d, + 'recaf', 'char', '', 2, + 'rectype', 'char', '', 5, + 'recdata', 'varchar', '', $char_d, + ], + 'primary_key' => 'recnum', + 'unique' => [ [] ], + 'index' => [ ['svcnum'] ], + }, + + 'svc_www' => { + 'columns' => [ + 'svcnum', 'int', '', '', + 'recnum', 'int', '', '', + 'usersvc', 'int', '', '', + ], + 'primary_key' => 'svcnum', + 'unique' => [ [] ], + 'index' => [ [] ], + }, + #'svc_wo' => { # 'columns' => [ # 'svcnum', 'int', '', '', diff --git a/bin/svc_acct.import b/bin/svc_acct.import index 6541a9fd4..893a8298a 100755 --- a/bin/svc_acct.import +++ b/bin/svc_acct.import @@ -1,6 +1,6 @@ #!/usr/bin/perl -Tw # -# $Id: svc_acct.import,v 1.7 1999-07-08 02:32:26 ivan Exp $ +# $Id: svc_acct.import,v 1.8 2000-02-03 05:16:52 ivan Exp $ # # ivan@sisd.com 98-mar-9 # @@ -17,7 +17,10 @@ # don't import /var/spool/freeside/conf/shells! ivan@sisd.com 98-aug-13 # # $Log: svc_acct.import,v $ -# Revision 1.7 1999-07-08 02:32:26 ivan +# Revision 1.8 2000-02-03 05:16:52 ivan +# beginning of DNS and Apache support +# +# Revision 1.7 1999/07/08 02:32:26 ivan # import fix, noticed by Ben Leibig and Joel Griffiths # # Revision 1.6 1999/07/08 01:49:00 ivan @@ -263,6 +266,6 @@ foreach $username ( keys %upassword ) { # sub usage { - die "Usage:\n\n svc_acct.export user\n"; + die "Usage:\n\n svc_acct.import user\n"; } diff --git a/bin/svc_acct_sm.import b/bin/svc_acct_sm.import index bda9762e1..50b0f6702 100755 --- a/bin/svc_acct_sm.import +++ b/bin/svc_acct_sm.import @@ -1,6 +1,6 @@ #!/usr/bin/perl -Tw # -# $Id: svc_acct_sm.import,v 1.4 1999-03-25 08:42:20 ivan Exp $ +# $Id: svc_acct_sm.import,v 1.5 2000-02-03 05:16:52 ivan Exp $ # # ivan@sisd.com 98-mar-9 # @@ -16,7 +16,10 @@ # ivan@sisd.com 98-jul-13 # # $Log: svc_acct_sm.import,v $ -# Revision 1.4 1999-03-25 08:42:20 ivan +# Revision 1.5 2000-02-03 05:16:52 ivan +# beginning of DNS and Apache support +# +# Revision 1.4 1999/03/25 08:42:20 ivan # import stuff uses Term::Query and spits out (some kinds of) nonsensical input # # Revision 1.3 1999/03/24 00:51:55 ivan @@ -278,6 +281,6 @@ END # sub usage { - die "Usage:\n\n svc_acct_sm.export user\n"; + die "Usage:\n\n svc_acct_sm.import user\n"; } diff --git a/bin/svc_domain.import b/bin/svc_domain.import new file mode 100644 index 000000000..329465ca1 --- /dev/null +++ b/bin/svc_domain.import @@ -0,0 +1,92 @@ +#!/usr/bin/perl -w +# +# $Id: svc_domain.import,v 1.1 2000-02-03 05:17:39 ivan Exp $ + +use strict; +use vars qw( %d_part_svc ); +use Term::Query qw(query); +use FS::SSH qw(iscp); +use FS::UID qw(adminsuidsetup datasrc); +#use FS::Record qw(qsearch qsearchs); +#use FS::svc_acct_sm; +use FS::svc_domain; +use FS::domain_record; +#use FS::svc_acct; +#use FS::part_svc; + +my $user = shift or die &usage; +adminsuidsetup $user; + +my($spooldir)="/usr/local/etc/freeside/export.". datasrc; + +%d_part_svc = + map { $_->svcpart, $_ } qsearch('part_svc',{'svcdb'=>'svc_domain'}); + +print "\n\n", + ( join "\n", map "$_: ".$d_part_svc{$_}->svc, sort keys %d_part_svc ), + "\n\n"; +$^W=0; #Term::Query isn't -w-safe +my $domain_svcpart = + query "Enter part number for domains: ", 'irk', [ keys %d_part_svc ]; +$^W=1; + + print "\n\n", <) { + next unless /^\s*options/; +} +my $directory; +while () { + last if /^\s*directory\s+\"([\/\w+]+)\";/; +} +$directory = $1 or die "can't locate directory in named.conf!"; +whlie () { + next unless /^\s*zone\s+\"([\w\.\-]+)\"\s+\{/; + my $zone = $1; + while () { + my $type; + if ( /^\s*type\s+(master|slave)\s*\;/ ) { + $type = $1; + } + if ( /^\s*file\s+\"([\w\.\-]+)\"\s*\;/ && $type eq 'master' ) { + + # + # (add svc_domain) + my $file = $1; + iscp("root\@$named_machine:$directory/$file","$spooldir/$file.import"); + open(ZONE,"<$spooldir/$file.import") + or die "Can't open $spooldir/$file.import: $!"; + while () { + # (add domain_record) + } + + # + + } + + last if /^\s*\}\s*\;/; + } +} + +## + +sub usage { + die "Usage:\n\n svc_domain.import user\n"; +} + -- cgit v1.2.1 From b2aed426363c22c3dc4cbad5e899028f8f96a4da Mon Sep 17 00:00:00 2001 From: ivan Date: Thu, 2 Mar 2000 07:44:07 +0000 Subject: typo forgot closing ' --- bin/fs-setup | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'bin') diff --git a/bin/fs-setup b/bin/fs-setup index b75058d55..3dde038b2 100755 --- a/bin/fs-setup +++ b/bin/fs-setup @@ -1,6 +1,6 @@ #!/usr/bin/perl -Tw # -# $Id: fs-setup,v 1.23 2000-02-03 05:16:52 ivan Exp $ +# $Id: fs-setup,v 1.24 2000-03-02 07:44:07 ivan Exp $ # # ivan@sisd.com 97-nov-8,9 # @@ -32,7 +32,10 @@ # fix radius attributes ivan@sisd.com 98-sep-27 # # $Log: fs-setup,v $ -# Revision 1.23 2000-02-03 05:16:52 ivan +# Revision 1.24 2000-03-02 07:44:07 ivan +# typo forgot closing ' +# +# Revision 1.23 2000/02/03 05:16:52 ivan # beginning of DNS and Apache support # # Revision 1.22 2000/01/31 05:22:23 ivan @@ -702,7 +705,7 @@ sub tables_hash_hack { ], 'primary_key' => 'prepaynum', 'unique' => [ ['identifier'] ], - 'index => [ [] ], + 'index' => [ [] ], }, ); -- cgit v1.2.1 From 236d0a0f93ffa2f7609f930c8af2c507741060ad Mon Sep 17 00:00:00 2001 From: ivan Date: Mon, 6 Mar 2000 14:12:57 +0000 Subject: ICRADIUS export support --- bin/svc_acct.export | 56 +++++++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 52 insertions(+), 4 deletions(-) (limited to 'bin') diff --git a/bin/svc_acct.export b/bin/svc_acct.export index d4ebe6bdc..8cdccda1f 100755 --- a/bin/svc_acct.export +++ b/bin/svc_acct.export @@ -1,6 +1,6 @@ #!/usr/bin/perl -Tw # -# $Id: svc_acct.export,v 1.2 1998-12-10 07:23:15 ivan Exp $ +# $Id: svc_acct.export,v 1.3 2000-03-06 14:12:57 ivan Exp $ # # Create and export password files: passwd, passwd.adjunct, shadow, # acp_passwd, acp_userinfo, acp_dialup, users @@ -38,16 +38,20 @@ # ivan@sisd.com 98-sep-18 # # $Log: svc_acct.export,v $ -# Revision 1.2 1998-12-10 07:23:15 ivan +# Revision 1.3 2000-03-06 14:12:57 ivan +# ICRADIUS export support +# +# Revision 1.2 1998/12/10 07:23:15 ivan # use FS::Conf, need user (for datasrc) # use strict; use vars qw($conf); use Fcntl qw(:flock); +use IO::Handle; use FS::Conf; -use FS::SSH qw(scp ssh); -use FS::UID qw(adminsuidsetup datasrc); +use FS::SSH qw(scp ssh sshopen2); +use FS::UID qw(adminsuidsetup datasrc dbh); use FS::Record qw(qsearch fields); use FS::svc_acct; @@ -71,6 +75,17 @@ my @erpcdmachines = $conf->config('erpcdmachines') my @radiusmachines = $conf->config('radiusmachines') if $conf->exists('radiusmachines'); +my $icradiusmachines = $conf->exists('icradiusmachines'); +my @icradiusmachines = $conf->config('icradiusmachines') if $icradiusmachines; +my $icradius_mysqldest = + $conf->config('icradius_mysqldest') || "/usr/local/var/radius" + if $icradiusmachines; +my $icradius_mysqlsource = + $conf->config('icradius_mysqlsource') || "/usr/local/var/freeside" + if $icradiusmachines; +my $icradius_dbh = dbh; #could eventually get it from a config file if you're + #not running MySQL for your Freeside database + my(@saltset)= ( 'a'..'z' , 'A'..'Z' , '0'..'9' , '.' , '/' ); require 5.004; #srand(time|$$); @@ -119,6 +134,11 @@ chmod 0600, "$spooldir/master.passwd", "$spooldir/users", ; +if ( $icradiusmachines ) { + my $sth = $icradius_dbh->prepare("DELETE FROM radcheck"); + $sth->execute or die "Can't reset radcheck table: ". $sth->errstr; +} + setpriority(0,0,10); my($svc_acct); @@ -226,6 +246,21 @@ foreach $svc_acct (@svc_acct) { print USERS qq(\n\n); } + ### + # ICRADIUS export + if ( $icradiusmachines ) { + my $sth = $icradius_dbh->prepare( + "INSERT INTO radcheck ( id, UserName, Attribute, Value ) VALUES ( ". + join(", ", map { $icradius_dbh->quote( $_ ) } qw ( + $svc_acct->svcnum + $svc_acct->username + "Password" + $svc_acct->_password + ) ). " )" + ); + $sth->execute or die "Can't insert into radcheck table: ". $sth->errstr; + } + } } @@ -318,6 +353,19 @@ foreach $radiusmachine (@radiusmachines) { == 0 or die "ssh error: $!"; } +foreach my $icradiusmachine ( @icradiusmachines ) { + my( $machine, $db, $user, $pass ) = split(/\s+/, $icradiusmachine); + chdir $icradius_mysqlsource or die "Can't cd $icradius_mysqlsource: $!"; + my($reader,$writer)=(new IO::Handle, new IO::Handle); + sshopen2("root\@$machine", $reader, $writer, "mysql --user=$user -p $db"); + print $writer "$pass\nLOCK TABLES radcheck WRITE;\n"; + foreach my $file ( glob("radcheck.*") ) { + scp($file,"root\@$icradiusmachine:$icradius_mysqldest/$file"); + } + close $writer; + close $reader; +} + unlink $spoollock; flock(EXPORT,LOCK_UN); close EXPORT; -- cgit v1.2.1 From b70cf8e6aaeeef34baae4542f389ceab20f4f37d Mon Sep 17 00:00:00 2001 From: ivan Date: Mon, 6 Mar 2000 14:19:15 +0000 Subject: ICRADIUS export bugfix --- bin/svc_acct.export | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'bin') diff --git a/bin/svc_acct.export b/bin/svc_acct.export index 8cdccda1f..8bec4aa79 100755 --- a/bin/svc_acct.export +++ b/bin/svc_acct.export @@ -1,6 +1,6 @@ #!/usr/bin/perl -Tw # -# $Id: svc_acct.export,v 1.3 2000-03-06 14:12:57 ivan Exp $ +# $Id: svc_acct.export,v 1.4 2000-03-06 14:19:15 ivan Exp $ # # Create and export password files: passwd, passwd.adjunct, shadow, # acp_passwd, acp_userinfo, acp_dialup, users @@ -38,8 +38,8 @@ # ivan@sisd.com 98-sep-18 # # $Log: svc_acct.export,v $ -# Revision 1.3 2000-03-06 14:12:57 ivan -# ICRADIUS export support +# Revision 1.4 2000-03-06 14:19:15 ivan +# ICRADIUS export bugfix # # Revision 1.2 1998/12/10 07:23:15 ivan # use FS::Conf, need user (for datasrc) @@ -360,7 +360,7 @@ foreach my $icradiusmachine ( @icradiusmachines ) { sshopen2("root\@$machine", $reader, $writer, "mysql --user=$user -p $db"); print $writer "$pass\nLOCK TABLES radcheck WRITE;\n"; foreach my $file ( glob("radcheck.*") ) { - scp($file,"root\@$icradiusmachine:$icradius_mysqldest/$file"); + scp($file,"root\@$icradiusmachine:$icradius_mysqldest/$db/$file"); } close $writer; close $reader; -- cgit v1.2.1 From b5fa754313f4c98d50071a747046ee48fde0ef44 Mon Sep 17 00:00:00 2001 From: ivan Date: Mon, 6 Mar 2000 14:46:41 +0000 Subject: not setuid or run by malicious user - no -T necessary --- bin/svc_acct.export | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'bin') diff --git a/bin/svc_acct.export b/bin/svc_acct.export index 8bec4aa79..725504690 100755 --- a/bin/svc_acct.export +++ b/bin/svc_acct.export @@ -1,6 +1,6 @@ -#!/usr/bin/perl -Tw +#!/usr/bin/perl -w # -# $Id: svc_acct.export,v 1.4 2000-03-06 14:19:15 ivan Exp $ +# $Id: svc_acct.export,v 1.5 2000-03-06 14:46:41 ivan Exp $ # # Create and export password files: passwd, passwd.adjunct, shadow, # acp_passwd, acp_userinfo, acp_dialup, users @@ -38,8 +38,8 @@ # ivan@sisd.com 98-sep-18 # # $Log: svc_acct.export,v $ -# Revision 1.4 2000-03-06 14:19:15 ivan -# ICRADIUS export bugfix +# Revision 1.5 2000-03-06 14:46:41 ivan +# not setuid or run by malicious user - no -T necessary # # Revision 1.2 1998/12/10 07:23:15 ivan # use FS::Conf, need user (for datasrc) -- cgit v1.2.1 From cd2eb2ec0256884b5e06fae6b7a9d9fb9dc7e2c3 Mon Sep 17 00:00:00 2001 From: ivan Date: Mon, 6 Mar 2000 14:48:29 +0000 Subject: s/icradiusmachine/machine/ --- bin/svc_acct.export | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'bin') diff --git a/bin/svc_acct.export b/bin/svc_acct.export index 725504690..a638a3261 100755 --- a/bin/svc_acct.export +++ b/bin/svc_acct.export @@ -1,6 +1,6 @@ #!/usr/bin/perl -w # -# $Id: svc_acct.export,v 1.5 2000-03-06 14:46:41 ivan Exp $ +# $Id: svc_acct.export,v 1.6 2000-03-06 14:48:29 ivan Exp $ # # Create and export password files: passwd, passwd.adjunct, shadow, # acp_passwd, acp_userinfo, acp_dialup, users @@ -38,8 +38,8 @@ # ivan@sisd.com 98-sep-18 # # $Log: svc_acct.export,v $ -# Revision 1.5 2000-03-06 14:46:41 ivan -# not setuid or run by malicious user - no -T necessary +# Revision 1.6 2000-03-06 14:48:29 ivan +# s/icradiusmachine/machine/ # # Revision 1.2 1998/12/10 07:23:15 ivan # use FS::Conf, need user (for datasrc) @@ -360,7 +360,7 @@ foreach my $icradiusmachine ( @icradiusmachines ) { sshopen2("root\@$machine", $reader, $writer, "mysql --user=$user -p $db"); print $writer "$pass\nLOCK TABLES radcheck WRITE;\n"; foreach my $file ( glob("radcheck.*") ) { - scp($file,"root\@$icradiusmachine:$icradius_mysqldest/$db/$file"); + scp($file,"root\@$machine:$icradius_mysqldest/$db/$file"); } close $writer; close $reader; -- cgit v1.2.1 From a19e9126e3bd79719e1bddd7f77381c613a157f4 Mon Sep 17 00:00:00 2001 From: ivan Date: Mon, 6 Mar 2000 14:50:15 +0000 Subject: oop --- bin/svc_acct.export | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'bin') diff --git a/bin/svc_acct.export b/bin/svc_acct.export index a638a3261..ef3edc2e2 100755 --- a/bin/svc_acct.export +++ b/bin/svc_acct.export @@ -1,6 +1,6 @@ #!/usr/bin/perl -w # -# $Id: svc_acct.export,v 1.6 2000-03-06 14:48:29 ivan Exp $ +# $Id: svc_acct.export,v 1.7 2000-03-06 14:50:15 ivan Exp $ # # Create and export password files: passwd, passwd.adjunct, shadow, # acp_passwd, acp_userinfo, acp_dialup, users @@ -38,8 +38,8 @@ # ivan@sisd.com 98-sep-18 # # $Log: svc_acct.export,v $ -# Revision 1.6 2000-03-06 14:48:29 ivan -# s/icradiusmachine/machine/ +# Revision 1.7 2000-03-06 14:50:15 ivan +# oop # # Revision 1.2 1998/12/10 07:23:15 ivan # use FS::Conf, need user (for datasrc) @@ -78,7 +78,7 @@ my @radiusmachines = $conf->config('radiusmachines') my $icradiusmachines = $conf->exists('icradiusmachines'); my @icradiusmachines = $conf->config('icradiusmachines') if $icradiusmachines; my $icradius_mysqldest = - $conf->config('icradius_mysqldest') || "/usr/local/var/radius" + $conf->config('icradius_mysqldest') || "/usr/local/var/" if $icradiusmachines; my $icradius_mysqlsource = $conf->config('icradius_mysqlsource') || "/usr/local/var/freeside" -- cgit v1.2.1 From 2cc9708011a232237189440f254aea31d4ac2022 Mon Sep 17 00:00:00 2001 From: ivan Date: Mon, 6 Mar 2000 14:51:27 +0000 Subject: eek --- bin/svc_acct.export | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'bin') diff --git a/bin/svc_acct.export b/bin/svc_acct.export index ef3edc2e2..d2f746c0e 100755 --- a/bin/svc_acct.export +++ b/bin/svc_acct.export @@ -1,6 +1,6 @@ #!/usr/bin/perl -w # -# $Id: svc_acct.export,v 1.7 2000-03-06 14:50:15 ivan Exp $ +# $Id: svc_acct.export,v 1.8 2000-03-06 14:51:27 ivan Exp $ # # Create and export password files: passwd, passwd.adjunct, shadow, # acp_passwd, acp_userinfo, acp_dialup, users @@ -38,8 +38,8 @@ # ivan@sisd.com 98-sep-18 # # $Log: svc_acct.export,v $ -# Revision 1.7 2000-03-06 14:50:15 ivan -# oop +# Revision 1.8 2000-03-06 14:51:27 ivan +# eek # # Revision 1.2 1998/12/10 07:23:15 ivan # use FS::Conf, need user (for datasrc) @@ -251,11 +251,11 @@ foreach $svc_acct (@svc_acct) { if ( $icradiusmachines ) { my $sth = $icradius_dbh->prepare( "INSERT INTO radcheck ( id, UserName, Attribute, Value ) VALUES ( ". - join(", ", map { $icradius_dbh->quote( $_ ) } qw ( - $svc_acct->svcnum - $svc_acct->username - "Password" - $svc_acct->_password + join(", ", map { $icradius_dbh->quote( $_ ) } ( + $svc_acct->svcnum, + $svc_acct->username, + "Password", + $svc_acct->_password, ) ). " )" ); $sth->execute or die "Can't insert into radcheck table: ". $sth->errstr; -- cgit v1.2.1 From c3f5321527ad8783f81c65f39cbb1f3612cec2e5 Mon Sep 17 00:00:00 2001 From: ivan Date: Mon, 6 Mar 2000 14:59:06 +0000 Subject: s/sshopen2/sshopen3/ to prevent spurious mysql "Enter password: " dialog from showing up in cron/terminal --- bin/svc_acct.export | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) (limited to 'bin') diff --git a/bin/svc_acct.export b/bin/svc_acct.export index d2f746c0e..303c6d28a 100755 --- a/bin/svc_acct.export +++ b/bin/svc_acct.export @@ -1,6 +1,6 @@ #!/usr/bin/perl -w # -# $Id: svc_acct.export,v 1.8 2000-03-06 14:51:27 ivan Exp $ +# $Id: svc_acct.export,v 1.9 2000-03-06 14:59:06 ivan Exp $ # # Create and export password files: passwd, passwd.adjunct, shadow, # acp_passwd, acp_userinfo, acp_dialup, users @@ -38,8 +38,9 @@ # ivan@sisd.com 98-sep-18 # # $Log: svc_acct.export,v $ -# Revision 1.8 2000-03-06 14:51:27 ivan -# eek +# Revision 1.9 2000-03-06 14:59:06 ivan +# s/sshopen2/sshopen3/ to prevent spurious mysql "Enter password: " dialog from +# showing up in cron/terminal # # Revision 1.2 1998/12/10 07:23:15 ivan # use FS::Conf, need user (for datasrc) @@ -50,7 +51,7 @@ use vars qw($conf); use Fcntl qw(:flock); use IO::Handle; use FS::Conf; -use FS::SSH qw(scp ssh sshopen2); +use FS::SSH qw(scp ssh sshopen3); use FS::UID qw(adminsuidsetup datasrc dbh); use FS::Record qw(qsearch fields); use FS::svc_acct; @@ -356,14 +357,17 @@ foreach $radiusmachine (@radiusmachines) { foreach my $icradiusmachine ( @icradiusmachines ) { my( $machine, $db, $user, $pass ) = split(/\s+/, $icradiusmachine); chdir $icradius_mysqlsource or die "Can't cd $icradius_mysqlsource: $!"; - my($reader,$writer)=(new IO::Handle, new IO::Handle); - sshopen2("root\@$machine", $reader, $writer, "mysql --user=$user -p $db"); + my($reader,$writer,$error)=(new IO::Handle, new IO::Handle, new IO::Handle); + sshopen3("root\@$machine", $reader, $writer, $error, + "mysql --user=$user -p $db" + ); print $writer "$pass\nLOCK TABLES radcheck WRITE;\n"; foreach my $file ( glob("radcheck.*") ) { scp($file,"root\@$machine:$icradius_mysqldest/$db/$file"); } close $writer; close $reader; + close $error; } unlink $spoollock; -- cgit v1.2.1 From 18439f1f53ba238bf9fba7580fce34d844827109 Mon Sep 17 00:00:00 2001 From: ivan Date: Mon, 6 Mar 2000 15:59:19 +0000 Subject: finally get MySQL locking working for ICRADIUS export --- bin/svc_acct.export | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) (limited to 'bin') diff --git a/bin/svc_acct.export b/bin/svc_acct.export index 303c6d28a..1e1a16318 100755 --- a/bin/svc_acct.export +++ b/bin/svc_acct.export @@ -1,6 +1,6 @@ #!/usr/bin/perl -w # -# $Id: svc_acct.export,v 1.9 2000-03-06 14:59:06 ivan Exp $ +# $Id: svc_acct.export,v 1.10 2000-03-06 15:59:19 ivan Exp $ # # Create and export password files: passwd, passwd.adjunct, shadow, # acp_passwd, acp_userinfo, acp_dialup, users @@ -38,9 +38,8 @@ # ivan@sisd.com 98-sep-18 # # $Log: svc_acct.export,v $ -# Revision 1.9 2000-03-06 14:59:06 ivan -# s/sshopen2/sshopen3/ to prevent spurious mysql "Enter password: " dialog from -# showing up in cron/terminal +# Revision 1.10 2000-03-06 15:59:19 ivan +# finally get MySQL locking working for ICRADIUS export # # Revision 1.2 1998/12/10 07:23:15 ivan # use FS::Conf, need user (for datasrc) @@ -358,16 +357,13 @@ foreach my $icradiusmachine ( @icradiusmachines ) { my( $machine, $db, $user, $pass ) = split(/\s+/, $icradiusmachine); chdir $icradius_mysqlsource or die "Can't cd $icradius_mysqlsource: $!"; my($reader,$writer,$error)=(new IO::Handle, new IO::Handle, new IO::Handle); - sshopen3("root\@$machine", $reader, $writer, $error, - "mysql --user=$user -p $db" - ); - print $writer "$pass\nLOCK TABLES radcheck WRITE;\n"; + open(WRITER,"|ssh root\@$machine mysql -v --user=$user -p $db"); + my $oldfh = select WRITER; $|=1; select $oldfh; + print WRITER "$pass\n"; sleep 2; print WRITER "LOCK TABLES radcheck WRITE;\n"; foreach my $file ( glob("radcheck.*") ) { scp($file,"root\@$machine:$icradius_mysqldest/$db/$file"); } - close $writer; - close $reader; - close $error; + close WRITER; } unlink $spoollock; -- cgit v1.2.1 From 4ac60147a2fe3734530149c1f72788e1d555abbd Mon Sep 17 00:00:00 2001 From: ivan Date: Mon, 6 Mar 2000 16:00:39 +0000 Subject: sync up with working versoin --- bin/svc_acct.export | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'bin') diff --git a/bin/svc_acct.export b/bin/svc_acct.export index 1e1a16318..47df3d169 100755 --- a/bin/svc_acct.export +++ b/bin/svc_acct.export @@ -1,6 +1,6 @@ #!/usr/bin/perl -w # -# $Id: svc_acct.export,v 1.10 2000-03-06 15:59:19 ivan Exp $ +# $Id: svc_acct.export,v 1.11 2000-03-06 16:00:39 ivan Exp $ # # Create and export password files: passwd, passwd.adjunct, shadow, # acp_passwd, acp_userinfo, acp_dialup, users @@ -38,8 +38,8 @@ # ivan@sisd.com 98-sep-18 # # $Log: svc_acct.export,v $ -# Revision 1.10 2000-03-06 15:59:19 ivan -# finally get MySQL locking working for ICRADIUS export +# Revision 1.11 2000-03-06 16:00:39 ivan +# sync up with working versoin # # Revision 1.2 1998/12/10 07:23:15 ivan # use FS::Conf, need user (for datasrc) @@ -50,7 +50,7 @@ use vars qw($conf); use Fcntl qw(:flock); use IO::Handle; use FS::Conf; -use FS::SSH qw(scp ssh sshopen3); +use FS::SSH qw(scp ssh); use FS::UID qw(adminsuidsetup datasrc dbh); use FS::Record qw(qsearch fields); use FS::svc_acct; @@ -356,7 +356,6 @@ foreach $radiusmachine (@radiusmachines) { foreach my $icradiusmachine ( @icradiusmachines ) { my( $machine, $db, $user, $pass ) = split(/\s+/, $icradiusmachine); chdir $icradius_mysqlsource or die "Can't cd $icradius_mysqlsource: $!"; - my($reader,$writer,$error)=(new IO::Handle, new IO::Handle, new IO::Handle); open(WRITER,"|ssh root\@$machine mysql -v --user=$user -p $db"); my $oldfh = select WRITER; $|=1; select $oldfh; print WRITER "$pass\n"; sleep 2; print WRITER "LOCK TABLES radcheck WRITE;\n"; -- cgit v1.2.1 From 26077e96836f95cd1b62aef3fff450913982f6da Mon Sep 17 00:00:00 2001 From: ivan Date: Mon, 12 Jun 2000 08:37:56 +0000 Subject: sendmail fix from Jeff Finucane --- bin/svc_acct_sm.export | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'bin') diff --git a/bin/svc_acct_sm.export b/bin/svc_acct_sm.export index ce4900733..380a52eff 100755 --- a/bin/svc_acct_sm.export +++ b/bin/svc_acct_sm.export @@ -1,6 +1,6 @@ #!/usr/bin/perl -Tw # -# $Id: svc_acct_sm.export,v 1.2 1998-12-10 07:23:17 ivan Exp $ +# $Id: svc_acct_sm.export,v 1.3 2000-06-12 08:37:56 ivan Exp $ # # Create and export config files for sendmail, qmail # @@ -42,7 +42,10 @@ # /var/spool/freeside/conf and sendmail updates ivan@sisd.com 98-aug-14 # # $Log: svc_acct_sm.export,v $ -# Revision 1.2 1998-12-10 07:23:17 ivan +# Revision 1.3 2000-06-12 08:37:56 ivan +# sendmail fix from Jeff Finucane +# +# Revision 1.2 1998/12/10 07:23:17 ivan # use FS::Conf, need user (for datasrc) # @@ -90,8 +93,6 @@ unless ( flock(EXPORT,LOCK_EX|LOCK_NB) ) { seek(EXPORT,0,0); print EXPORT $$,"\n"; -my(@svc_acct_sm)=qsearch('svc_acct_sm',{}); - ( open(RCPTHOSTS,">$spooldir/rcpthosts") and flock(RCPTHOSTS,LOCK_EX|LOCK_NB) ) or die "Can't open $spooldir/rcpthosts: $!"; @@ -153,10 +154,10 @@ foreach $svc_acct_sm ( qsearch('svc_acct_sm') ) { print RECIPIENTMAP "$domuser\@$domain:$username\@$mydomain\n"; } - print VIRTUSERTABLE @sendmail; - } +print VIRTUSERTABLE @sendmail; + chmod 0644, "$spooldir/sendmail.cw", "$spooldir/virtusertable", "$spooldir/rcpthosts", -- cgit v1.2.1 From 6ef8eaebaef9d8c278f5cae6f48ffee8c2359565 Mon Sep 17 00:00:00 2001 From: ivan Date: Thu, 15 Jun 2000 14:07:02 +0000 Subject: added ICRADIUS radreply table support, courtesy of Kenny Elliott --- bin/svc_acct.export | 47 +++++++++++++++++++++++++++++++++-------------- 1 file changed, 33 insertions(+), 14 deletions(-) (limited to 'bin') diff --git a/bin/svc_acct.export b/bin/svc_acct.export index 47df3d169..598a6df80 100755 --- a/bin/svc_acct.export +++ b/bin/svc_acct.export @@ -1,6 +1,6 @@ #!/usr/bin/perl -w # -# $Id: svc_acct.export,v 1.11 2000-03-06 16:00:39 ivan Exp $ +# $Id: svc_acct.export,v 1.12 2000-06-15 14:07:02 ivan Exp $ # # Create and export password files: passwd, passwd.adjunct, shadow, # acp_passwd, acp_userinfo, acp_dialup, users @@ -38,7 +38,10 @@ # ivan@sisd.com 98-sep-18 # # $Log: svc_acct.export,v $ -# Revision 1.11 2000-03-06 16:00:39 ivan +# Revision 1.12 2000-06-15 14:07:02 ivan +# added ICRADIUS radreply table support, courtesy of Kenny Elliott +# +# Revision 1.11 2000/03/06 16:00:39 ivan # sync up with working versoin # # Revision 1.2 1998/12/10 07:23:15 ivan @@ -137,6 +140,8 @@ chmod 0600, "$spooldir/master.passwd", if ( $icradiusmachines ) { my $sth = $icradius_dbh->prepare("DELETE FROM radcheck"); $sth->execute or die "Can't reset radcheck table: ". $sth->errstr; + my $sth2 = $icradius_dbh->prepare("DELETE FROM radreply"); + $sth2->execute or die "Can't reset radreply table: ". $sth2->errstr; } setpriority(0,0,10); @@ -227,19 +232,14 @@ foreach $svc_acct (@svc_acct) { print ACP_DIALUP $svc_acct->username, "\t*\t", $svc_acct->slipip, "\n"; } + my %radius = $svc_acct->radius; + ### # FORMAT OF THE USERS FILE HERE print USERS $svc_acct->username, qq(\tPassword = "$rpassword"\n\t), - - join ",\n\t", - map { - /^(radius_(.*))$/; - my($field,$attrib)=($1,$2); - $attrib =~ s/_/\-/g; - "$attrib = \"". $svc_acct->getfield($field). "\""; - } grep /^radius_/ && $svc_acct->getfield($_), fields('svc_acct') - ; + join ",\n\t", map { qq($_ = "$radius{$_}") } keys %radius; + if ( $ip && $ip ne '0e0' ) { print USERS qq(,\n\tFramed-Address = "$ip"\n\n); } else { @@ -252,14 +252,28 @@ foreach $svc_acct (@svc_acct) { my $sth = $icradius_dbh->prepare( "INSERT INTO radcheck ( id, UserName, Attribute, Value ) VALUES ( ". join(", ", map { $icradius_dbh->quote( $_ ) } ( - $svc_acct->svcnum, + '', $svc_acct->username, "Password", $svc_acct->_password, ) ). " )" ); $sth->execute or die "Can't insert into radcheck table: ". $sth->errstr; - } + + foreach my $attribute ( keys %radius ) { + my $sth = $icradius_dbh->prepare( + "INSERT INTO radreply (id, UserName, Attribute, Value) VALUES ( ". + join(", ", map { $icradius_dbh->quote( $_ ) } ( + '', + $svc_acct->username, + $attribute, + $radius{$attribute}, + ) ). " )" + ); + $sth->execute or die "Can't insert into radreply table: ". $sth->errstr; + } + + } } @@ -358,10 +372,15 @@ foreach my $icradiusmachine ( @icradiusmachines ) { chdir $icradius_mysqlsource or die "Can't cd $icradius_mysqlsource: $!"; open(WRITER,"|ssh root\@$machine mysql -v --user=$user -p $db"); my $oldfh = select WRITER; $|=1; select $oldfh; - print WRITER "$pass\n"; sleep 2; print WRITER "LOCK TABLES radcheck WRITE;\n"; + print WRITER "$pass\n"; + sleep 2; + print WRITER "LOCK TABLES radcheck WRITE, radreply WRITE;\n"; foreach my $file ( glob("radcheck.*") ) { scp($file,"root\@$machine:$icradius_mysqldest/$db/$file"); } + foreach my $file ( glob("radreply.*") ) { + scp($file,"root\@$machine:$icradius_mysqldest/$db/$file"); + } close WRITER; } -- cgit v1.2.1 From 2a9820d9b4dd0c6e26761a28ff6db2b582218278 Mon Sep 17 00:00:00 2001 From: ivan Date: Wed, 28 Jun 2000 10:48:42 +0000 Subject: quick hack to add RADIUS attributes --- bin/fs-radius-add | 53 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100755 bin/fs-radius-add (limited to 'bin') diff --git a/bin/fs-radius-add b/bin/fs-radius-add new file mode 100755 index 000000000..376b7a7a4 --- /dev/null +++ b/bin/fs-radius-add @@ -0,0 +1,53 @@ +#!/usr/bin/perl -Tw + +# quick'n'dirty hack of fs-setup to add radius attributes + +use strict; +use DBI; +use FS::UID qw(adminsuidsetup checkeuid); +die "Not running uid freeside!" unless checkeuid(); + +my $user = shift or die &usage; +getsecrets($user); + +my $dbh = adminsuidsetup $user; + +### + +print "\n\n", <); + chop $x; + $x; +} + +### + +my($char_d) = 80; #default maxlength for text fields + +### + +foreach my $attribute ( @attributes ) { + foreach my $statement ( + "ALTER TABLE svc_acct ADD radius_$attribute varchar($char_d) NULL", + "ALTER TABLE svc_acct ADD radius_$attribute varchar($char_d) NULL", + "ALTER TABLE part_svc ADD svc_acct__radius_$attribute varchar($char_d) NULL;", + "ALTER TABLE part_svc ADD svc_acct__radius_${attribute}_flag char(1) NULL;", + ) { + $dbh->do( $statement ) or warn "Error executing $statement: ". $dbh->errstr; } +} + +$dbh->disconnect or die $dbh->errstr; + +print "\n\n", "Now you must run dbdef-create.\n\n"; + +sub usage { + die "Usage:\n fs-radius-add user\n"; +} + + -- cgit v1.2.1 From ca1e62b0e38c8784e4b4b5d365fc0f6f42079db8 Mon Sep 17 00:00:00 2001 From: ivan Date: Wed, 28 Jun 2000 10:51:19 +0000 Subject: forgot to import a sub --- bin/fs-radius-add | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'bin') diff --git a/bin/fs-radius-add b/bin/fs-radius-add index 376b7a7a4..707926677 100755 --- a/bin/fs-radius-add +++ b/bin/fs-radius-add @@ -4,7 +4,7 @@ use strict; use DBI; -use FS::UID qw(adminsuidsetup checkeuid); +use FS::UID qw(adminsuidsetup checkeuid getsecrets); die "Not running uid freeside!" unless checkeuid(); my $user = shift or die &usage; -- cgit v1.2.1 From 7a503c0ec805aa1a428ee094660f8146efee4653 Mon Sep 17 00:00:00 2001 From: ivan Date: Wed, 28 Jun 2000 12:03:53 +0000 Subject: make svc_acct more forgiving about RADIUS users files --- bin/svc_acct.import | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'bin') diff --git a/bin/svc_acct.import b/bin/svc_acct.import index 893a8298a..c2ef4fd7f 100755 --- a/bin/svc_acct.import +++ b/bin/svc_acct.import @@ -1,6 +1,6 @@ #!/usr/bin/perl -Tw # -# $Id: svc_acct.import,v 1.8 2000-02-03 05:16:52 ivan Exp $ +# $Id: svc_acct.import,v 1.9 2000-06-28 12:03:53 ivan Exp $ # # ivan@sisd.com 98-mar-9 # @@ -17,7 +17,10 @@ # don't import /var/spool/freeside/conf/shells! ivan@sisd.com 98-aug-13 # # $Log: svc_acct.import,v $ -# Revision 1.8 2000-02-03 05:16:52 ivan +# Revision 1.9 2000-06-28 12:03:53 ivan +# make svc_acct more forgiving about RADIUS users files +# +# Revision 1.8 2000/02/03 05:16:52 ivan # beginning of DNS and Apache support # # Revision 1.7 1999/07/08 02:32:26 ivan @@ -145,7 +148,8 @@ my(%upassword,%ip,%allparam); my(%param,$username); while () { chop; - next if /^$/; + next if /^\s*$/; + next if /^\s*#/; if ( /^\S/ ) { /^(\w+)\s+Password\s+=\s+"([^"]+)"(,\s+Expiration\s+=\s+"([^"]*")\s*)?$/ or die "1Unexpected line in users.import: $_"; -- cgit v1.2.1 From 88e029c6fab66a6596153b0f3d1f86e110f149ed Mon Sep 17 00:00:00 2001 From: ivan Date: Wed, 28 Jun 2000 12:32:30 +0000 Subject: allow RADIUS lines with "Auth-Type = Local" too --- bin/svc_acct.import | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'bin') diff --git a/bin/svc_acct.import b/bin/svc_acct.import index c2ef4fd7f..691798b09 100755 --- a/bin/svc_acct.import +++ b/bin/svc_acct.import @@ -1,6 +1,6 @@ #!/usr/bin/perl -Tw # -# $Id: svc_acct.import,v 1.9 2000-06-28 12:03:53 ivan Exp $ +# $Id: svc_acct.import,v 1.10 2000-06-28 12:32:30 ivan Exp $ # # ivan@sisd.com 98-mar-9 # @@ -17,8 +17,8 @@ # don't import /var/spool/freeside/conf/shells! ivan@sisd.com 98-aug-13 # # $Log: svc_acct.import,v $ -# Revision 1.9 2000-06-28 12:03:53 ivan -# make svc_acct more forgiving about RADIUS users files +# Revision 1.10 2000-06-28 12:32:30 ivan +# allow RADIUS lines with "Auth-Type = Local" too # # Revision 1.8 2000/02/03 05:16:52 ivan # beginning of DNS and Apache support @@ -151,10 +151,10 @@ while () { next if /^\s*$/; next if /^\s*#/; if ( /^\S/ ) { - /^(\w+)\s+Password\s+=\s+"([^"]+)"(,\s+Expiration\s+=\s+"([^"]*")\s*)?$/ + /^(\w+)\s+(Auth-Type\s+=\s+Local,\s+)Password\s+=\s+"([^"]+)"(,\s+Expiration\s+=\s+"([^"]*")\s*)?$/ or die "1Unexpected line in users.import: $_"; my($password,$expiration); - ($username,$password,$expiration)=(lc($1),$2,$4); + ($username,$password,$expiration)=(lc($1),$3,$5); $password = '' if $password eq 'UNIX'; $upassword{$username}=$password; undef %param; -- cgit v1.2.1 From cb61ec822bf114015e4044868c5c7f3c3000ab0d Mon Sep 17 00:00:00 2001 From: ivan Date: Wed, 28 Jun 2000 12:37:28 +0000 Subject: add support for config option textradiusprepend --- bin/svc_acct.export | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'bin') diff --git a/bin/svc_acct.export b/bin/svc_acct.export index 598a6df80..f7ee571de 100755 --- a/bin/svc_acct.export +++ b/bin/svc_acct.export @@ -1,6 +1,6 @@ #!/usr/bin/perl -w # -# $Id: svc_acct.export,v 1.12 2000-06-15 14:07:02 ivan Exp $ +# $Id: svc_acct.export,v 1.13 2000-06-28 12:37:28 ivan Exp $ # # Create and export password files: passwd, passwd.adjunct, shadow, # acp_passwd, acp_userinfo, acp_dialup, users @@ -38,7 +38,10 @@ # ivan@sisd.com 98-sep-18 # # $Log: svc_acct.export,v $ -# Revision 1.12 2000-06-15 14:07:02 ivan +# Revision 1.13 2000-06-28 12:37:28 ivan +# add support for config option textradiusprepend +# +# Revision 1.12 2000/06/15 14:07:02 ivan # added ICRADIUS radreply table support, courtesy of Kenny Elliott # # Revision 1.11 2000/03/06 16:00:39 ivan @@ -89,6 +92,8 @@ my $icradius_mysqlsource = my $icradius_dbh = dbh; #could eventually get it from a config file if you're #not running MySQL for your Freeside database +my $textradiusprepend = $conf->config('textradiusprepend'); + my(@saltset)= ( 'a'..'z' , 'A'..'Z' , '0'..'9' , '.' , '/' ); require 5.004; #srand(time|$$); @@ -237,7 +242,7 @@ foreach $svc_acct (@svc_acct) { ### # FORMAT OF THE USERS FILE HERE print USERS - $svc_acct->username, qq(\tPassword = "$rpassword"\n\t), + $svc_acct->username, qq(\t${textradiusprepend}Password = "$rpassword"\n\t), join ",\n\t", map { qq($_ = "$radius{$_}") } keys %radius; if ( $ip && $ip ne '0e0' ) { -- cgit v1.2.1 From 958222ad6b9e290ef4db7e0ab3f1ead6bd3fcb7f Mon Sep 17 00:00:00 2001 From: ivan Date: Thu, 29 Jun 2000 10:48:25 +0000 Subject: make svc_acct_sm skip blank lines in sendmail import --- bin/svc_acct_sm.import | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'bin') diff --git a/bin/svc_acct_sm.import b/bin/svc_acct_sm.import index 50b0f6702..8777abe7e 100755 --- a/bin/svc_acct_sm.import +++ b/bin/svc_acct_sm.import @@ -1,6 +1,6 @@ #!/usr/bin/perl -Tw # -# $Id: svc_acct_sm.import,v 1.5 2000-02-03 05:16:52 ivan Exp $ +# $Id: svc_acct_sm.import,v 1.6 2000-06-29 10:48:25 ivan Exp $ # # ivan@sisd.com 98-mar-9 # @@ -16,7 +16,10 @@ # ivan@sisd.com 98-jul-13 # # $Log: svc_acct_sm.import,v $ -# Revision 1.5 2000-02-03 05:16:52 ivan +# Revision 1.6 2000-06-29 10:48:25 ivan +# make svc_acct_sm skip blank lines in sendmail import +# +# Revision 1.5 2000/02/03 05:16:52 ivan # beginning of DNS and Apache support # # Revision 1.4 1999/03/25 08:42:20 ivan @@ -151,6 +154,7 @@ my(%svcnum); while () { next if /^(#|$)/; + next if $mta{$mta} eq 'sendmail' && /^\s*$/; #blank lines /^\.?([\w\-\.]+)$/ #or do { warn "Strange rcpthosts/sendmail.cw line: $_"; next; }; or die "Strange rcpthosts/sendmail.cw line: $_"; @@ -243,6 +247,7 @@ END or die "Can't open $spooldir/virtusertable.import: $!"; while () { next if /^#/; #comments? + next if /^\s*$/; #blank lines /^([\w\-\.]+)?\@([\w\-\.]+)\t([\w\-\.]+)$/ #or do { warn "Strange virtusertable line: $_"; next; }; or die "Strange virtusertable line: $_"; -- cgit v1.2.1 From 543ac5d57838319516d325dbeac898f111065bc3 Mon Sep 17 00:00:00 2001 From: ivan Date: Thu, 29 Jun 2000 10:51:52 +0000 Subject: oops, silly mistake --- bin/svc_acct_sm.import | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'bin') diff --git a/bin/svc_acct_sm.import b/bin/svc_acct_sm.import index 8777abe7e..349c4f26c 100755 --- a/bin/svc_acct_sm.import +++ b/bin/svc_acct_sm.import @@ -1,6 +1,6 @@ #!/usr/bin/perl -Tw # -# $Id: svc_acct_sm.import,v 1.6 2000-06-29 10:48:25 ivan Exp $ +# $Id: svc_acct_sm.import,v 1.7 2000-06-29 10:51:52 ivan Exp $ # # ivan@sisd.com 98-mar-9 # @@ -16,7 +16,10 @@ # ivan@sisd.com 98-jul-13 # # $Log: svc_acct_sm.import,v $ -# Revision 1.6 2000-06-29 10:48:25 ivan +# Revision 1.7 2000-06-29 10:51:52 ivan +# oops, silly mistake +# +# Revision 1.6 2000/06/29 10:48:25 ivan # make svc_acct_sm skip blank lines in sendmail import # # Revision 1.5 2000/02/03 05:16:52 ivan @@ -129,8 +132,9 @@ END sub getvalue { my $prompt = shift; $^W=0; #Term::Query isn't -w-safe - query $prompt, ''; + my $data = query $prompt, ''; $^W=1; + $data; } print "\n\n"; -- cgit v1.2.1 From e446c1f657b37034e1867e82857a1741572da07f Mon Sep 17 00:00:00 2001 From: ivan Date: Thu, 29 Jun 2000 12:00:49 +0000 Subject: support for pre-encrypted md5 passwords. --- bin/fs-setup | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'bin') diff --git a/bin/fs-setup b/bin/fs-setup index 3dde038b2..002a4ed4c 100755 --- a/bin/fs-setup +++ b/bin/fs-setup @@ -1,6 +1,6 @@ #!/usr/bin/perl -Tw # -# $Id: fs-setup,v 1.24 2000-03-02 07:44:07 ivan Exp $ +# $Id: fs-setup,v 1.25 2000-06-29 12:00:49 ivan Exp $ # # ivan@sisd.com 97-nov-8,9 # @@ -32,7 +32,10 @@ # fix radius attributes ivan@sisd.com 98-sep-27 # # $Log: fs-setup,v $ -# Revision 1.24 2000-03-02 07:44:07 ivan +# Revision 1.25 2000-06-29 12:00:49 ivan +# support for pre-encrypted md5 passwords. +# +# Revision 1.24 2000/03/02 07:44:07 ivan # typo forgot closing ' # # Revision 1.23 2000/02/03 05:16:52 ivan @@ -612,7 +615,7 @@ sub tables_hash_hack { 'columns' => [ 'svcnum', 'int', '', '', 'username', 'varchar', '', $username_len, #unique (& remove dup code) - '_password', 'varchar', '', 25, #13 for encryped pw's plus ' *SUSPENDED* + '_password', 'varchar', '', 50, #13 for encryped pw's plus ' *SUSPENDED* (mp5 passwords can be 34) 'popnum', 'int', 'NULL', '', 'uid', 'int', 'NULL', '', 'gid', 'int', 'NULL', '', -- cgit v1.2.1 From 6e05f9c154f3cac80969c9a8f266b3d5b041b463 Mon Sep 17 00:00:00 2001 From: ivan Date: Thu, 29 Jun 2000 12:27:01 +0000 Subject: s/password/_password/ for PostgreSQL wasn't done in the import. --- bin/svc_acct.import | 33 ++++++++++++++++++--------------- 1 file changed, 18 insertions(+), 15 deletions(-) (limited to 'bin') diff --git a/bin/svc_acct.import b/bin/svc_acct.import index 691798b09..795b853c0 100755 --- a/bin/svc_acct.import +++ b/bin/svc_acct.import @@ -1,6 +1,6 @@ #!/usr/bin/perl -Tw # -# $Id: svc_acct.import,v 1.10 2000-06-28 12:32:30 ivan Exp $ +# $Id: svc_acct.import,v 1.11 2000-06-29 12:27:01 ivan Exp $ # # ivan@sisd.com 98-mar-9 # @@ -17,7 +17,10 @@ # don't import /var/spool/freeside/conf/shells! ivan@sisd.com 98-aug-13 # # $Log: svc_acct.import,v $ -# Revision 1.10 2000-06-28 12:32:30 ivan +# Revision 1.11 2000-06-29 12:27:01 ivan +# s/password/_password/ for PostgreSQL wasn't done in the import. +# +# Revision 1.10 2000/06/28 12:32:30 ivan # allow RADIUS lines with "Auth-Type = Local" too # # Revision 1.8 2000/02/03 05:16:52 ivan @@ -219,15 +222,15 @@ while () { } my($svc_acct) = new FS::svc_acct ({ - 'svcpart' => $svcpart, - 'username' => $username, - 'password' => $password, - 'uid' => $uid, - 'gid' => $gid, - 'finger' => $finger, - 'dir' => $dir, - 'shell' => $shell, - 'slipip' => $ip{$username}, + 'svcpart' => $svcpart, + 'username' => $username, + '_password' => $password, + 'uid' => $uid, + 'gid' => $gid, + 'finger' => $finger, + 'dir' => $dir, + 'shell' => $shell, + 'slipip' => $ip{$username}, %{$allparam{$username}}, }); my($error); @@ -253,10 +256,10 @@ foreach $username ( keys %upassword ) { } my($svc_acct) = new FS::svc_acct ({ - 'svcpart' => $svcpart, - 'username' => $username, - 'password' => $password, - 'slipip' => $ip{$username}, + 'svcpart' => $svcpart, + 'username' => $username, + '_password' => $password, + 'slipip' => $ip{$username}, %{$allparam{$username}}, }); my($error); -- cgit v1.2.1 From f30825464928625a2980e9286a28ea7ab91dad64 Mon Sep 17 00:00:00 2001 From: ivan Date: Thu, 29 Jun 2000 14:02:29 +0000 Subject: add sendmailrestart configuration file --- bin/svc_acct_sm.export | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'bin') diff --git a/bin/svc_acct_sm.export b/bin/svc_acct_sm.export index 380a52eff..8a38f5d54 100755 --- a/bin/svc_acct_sm.export +++ b/bin/svc_acct_sm.export @@ -1,6 +1,6 @@ #!/usr/bin/perl -Tw # -# $Id: svc_acct_sm.export,v 1.3 2000-06-12 08:37:56 ivan Exp $ +# $Id: svc_acct_sm.export,v 1.4 2000-06-29 14:02:29 ivan Exp $ # # Create and export config files for sendmail, qmail # @@ -42,7 +42,10 @@ # /var/spool/freeside/conf and sendmail updates ivan@sisd.com 98-aug-14 # # $Log: svc_acct_sm.export,v $ -# Revision 1.3 2000-06-12 08:37:56 ivan +# Revision 1.4 2000-06-29 14:02:29 ivan +# add sendmailrestart configuration file +# +# Revision 1.3 2000/06/12 08:37:56 ivan # sendmail fix from Jeff Finucane # # Revision 1.2 1998/12/10 07:23:17 ivan @@ -195,6 +198,10 @@ foreach $sendmailmachine (@sendmailmachines) { " )" ) == 0 or die "ssh error: $!"; + if ( $conf->config('sendmailrestart') ) { + ssh("root\@$sendmailmachine", $conf->config('sendmailrestart') ) + == 0 or die "ssh error: $!"; + } } my($qmailmachine); -- cgit v1.2.1 From ba0e7c68fa1a7dd9beff5084ac1a846960f3a477 Mon Sep 17 00:00:00 2001 From: ivan Date: Thu, 29 Jun 2000 15:01:25 +0000 Subject: another silly typo in svc_acct.export --- bin/svc_acct.export | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'bin') diff --git a/bin/svc_acct.export b/bin/svc_acct.export index f7ee571de..53fd1f0c7 100755 --- a/bin/svc_acct.export +++ b/bin/svc_acct.export @@ -1,6 +1,6 @@ #!/usr/bin/perl -w # -# $Id: svc_acct.export,v 1.13 2000-06-28 12:37:28 ivan Exp $ +# $Id: svc_acct.export,v 1.14 2000-06-29 15:01:25 ivan Exp $ # # Create and export password files: passwd, passwd.adjunct, shadow, # acp_passwd, acp_userinfo, acp_dialup, users @@ -38,7 +38,10 @@ # ivan@sisd.com 98-sep-18 # # $Log: svc_acct.export,v $ -# Revision 1.13 2000-06-28 12:37:28 ivan +# Revision 1.14 2000-06-29 15:01:25 ivan +# another silly typo in svc_acct.export +# +# Revision 1.13 2000/06/28 12:37:28 ivan # add support for config option textradiusprepend # # Revision 1.12 2000/06/15 14:07:02 ivan @@ -364,7 +367,7 @@ my($radiusmachine); foreach $radiusmachine (@radiusmachines) { scp("$spooldir/users","root\@$radiusmachine:/etc/raddb/users") == 0 or die "scp error: $!"; - ssh("root\@$erpcdmachine", + ssh("root\@$radiusmachine", "( ". "builddbm". " )" -- cgit v1.2.1 From bd26886dfcdb71027f0a3393993df383e72475b5 Mon Sep 17 00:00:00 2001 From: ivan Date: Mon, 3 Jul 2000 09:03:14 +0000 Subject: added sendmailrestart and sendmailconfigpath config files --- bin/svc_acct_sm.export | 28 +++++++++++++++++----------- 1 file changed, 17 insertions(+), 11 deletions(-) (limited to 'bin') diff --git a/bin/svc_acct_sm.export b/bin/svc_acct_sm.export index 8a38f5d54..0893c94df 100755 --- a/bin/svc_acct_sm.export +++ b/bin/svc_acct_sm.export @@ -1,6 +1,6 @@ #!/usr/bin/perl -Tw # -# $Id: svc_acct_sm.export,v 1.4 2000-06-29 14:02:29 ivan Exp $ +# $Id: svc_acct_sm.export,v 1.5 2000-07-03 09:03:14 ivan Exp $ # # Create and export config files for sendmail, qmail # @@ -42,7 +42,10 @@ # /var/spool/freeside/conf and sendmail updates ivan@sisd.com 98-aug-14 # # $Log: svc_acct_sm.export,v $ -# Revision 1.4 2000-06-29 14:02:29 ivan +# Revision 1.5 2000-07-03 09:03:14 ivan +# added sendmailrestart and sendmailconfigpath config files +# +# Revision 1.4 2000/06/29 14:02:29 ivan # add sendmailrestart configuration file # # Revision 1.3 2000/06/12 08:37:56 ivan @@ -67,15 +70,18 @@ adminsuidsetup $user; $conf = new FS::Conf; -my($shellmachine); -my(@qmailmachines); +my($shellmachine, @qmailmachines); if ( $conf->exists('qmailmachines') ) { $shellmachine = $conf->config('shellmachine'); @qmailmachines = $conf->config('qmailmachines'); } -my @sendmailmachines = $conf->config('sendmailmachines') - if $conf->exists('sendmailmachines'); +my(@sendmailmachines, $sendmailconfigpath, $sendmailrestart); +if $conf->exists('sendmailmachines') { + @sendmailmachines = $conf->config('sendmailmachines'); + $sendmailconfigpath = $conf->config('sendmailconfigpath') || '/etc'; + $sendmailrestart = $conf->config('sendmailrestart'); +} my $mydomain = $conf->config('domain'); @@ -186,15 +192,15 @@ close VIRTUALDOMAINS; my($sendmailmachine); foreach $sendmailmachine (@sendmailmachines) { - scp("$spooldir/sendmail.cw","root\@$sendmailmachine:/etc/sendmail.cw.new") + scp("$spooldir/sendmail.cw","root\@$sendmailmachine:$sendmailconfigpath/sendmail.cw.new") == 0 or die "scp error: $!"; - scp("$spooldir/virtusertable","root\@$sendmailmachine:/etc/virtusertable.new") + scp("$spooldir/virtusertable","root\@$sendmailmachine:$sendmailconfigpath/virtusertable.new") == 0 or die "scp error: $!"; ssh("root\@$sendmailmachine", "( ". - "mv /etc/sendmail.cw.new /etc/sendmail.cw; ". - "mv /etc/virtusertable.new /etc/virtusertable; ". - #"/etc/init.d/sendmail restart; ". + "mv $sendmailconfigpath/sendmail.cw.new $sendmailconfigpath/sendmail.cw; ". + "mv $sendmailconfigpath/virtusertable.new $sendmailconfigpath/virtusertable; ". + $sendmailrestart. " )" ) == 0 or die "ssh error: $!"; -- cgit v1.2.1 From 755e9d4966f0c09d846ad1b96f5a549ff6cd915a Mon Sep 17 00:00:00 2001 From: ivan Date: Mon, 3 Jul 2000 09:09:14 +0000 Subject: typo --- bin/svc_acct_sm.export | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'bin') diff --git a/bin/svc_acct_sm.export b/bin/svc_acct_sm.export index 0893c94df..2627496c3 100755 --- a/bin/svc_acct_sm.export +++ b/bin/svc_acct_sm.export @@ -1,6 +1,6 @@ #!/usr/bin/perl -Tw # -# $Id: svc_acct_sm.export,v 1.5 2000-07-03 09:03:14 ivan Exp $ +# $Id: svc_acct_sm.export,v 1.6 2000-07-03 09:09:14 ivan Exp $ # # Create and export config files for sendmail, qmail # @@ -42,7 +42,10 @@ # /var/spool/freeside/conf and sendmail updates ivan@sisd.com 98-aug-14 # # $Log: svc_acct_sm.export,v $ -# Revision 1.5 2000-07-03 09:03:14 ivan +# Revision 1.6 2000-07-03 09:09:14 ivan +# typo +# +# Revision 1.5 2000/07/03 09:03:14 ivan # added sendmailrestart and sendmailconfigpath config files # # Revision 1.4 2000/06/29 14:02:29 ivan @@ -77,7 +80,7 @@ if ( $conf->exists('qmailmachines') ) { } my(@sendmailmachines, $sendmailconfigpath, $sendmailrestart); -if $conf->exists('sendmailmachines') { +if ( $conf->exists('sendmailmachines') ) { @sendmailmachines = $conf->config('sendmailmachines'); $sendmailconfigpath = $conf->config('sendmailconfigpath') || '/etc'; $sendmailrestart = $conf->config('sendmailrestart'); -- cgit v1.2.1 From 3b998c1d6a308992f368d32c5dd5c901f262fed8 Mon Sep 17 00:00:00 2001 From: ivan Date: Mon, 3 Jul 2000 09:13:10 +0000 Subject: get rid of double sendmailrestart invocation; no need for multiple sessions --- bin/svc_acct_sm.export | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) (limited to 'bin') diff --git a/bin/svc_acct_sm.export b/bin/svc_acct_sm.export index 2627496c3..56c6115a6 100755 --- a/bin/svc_acct_sm.export +++ b/bin/svc_acct_sm.export @@ -1,6 +1,6 @@ #!/usr/bin/perl -Tw # -# $Id: svc_acct_sm.export,v 1.6 2000-07-03 09:09:14 ivan Exp $ +# $Id: svc_acct_sm.export,v 1.7 2000-07-03 09:13:10 ivan Exp $ # # Create and export config files for sendmail, qmail # @@ -42,7 +42,10 @@ # /var/spool/freeside/conf and sendmail updates ivan@sisd.com 98-aug-14 # # $Log: svc_acct_sm.export,v $ -# Revision 1.6 2000-07-03 09:09:14 ivan +# Revision 1.7 2000-07-03 09:13:10 ivan +# get rid of double sendmailrestart invocation; no need for multiple sessions +# +# Revision 1.6 2000/07/03 09:09:14 ivan # typo # # Revision 1.5 2000/07/03 09:03:14 ivan @@ -207,10 +210,6 @@ foreach $sendmailmachine (@sendmailmachines) { " )" ) == 0 or die "ssh error: $!"; - if ( $conf->config('sendmailrestart') ) { - ssh("root\@$sendmailmachine", $conf->config('sendmailrestart') ) - == 0 or die "ssh error: $!"; - } } my($qmailmachine); -- cgit v1.2.1 From ab67932df5b5999bcc0a94b3020bba7f57dd4980 Mon Sep 17 00:00:00 2001 From: ivan Date: Thu, 6 Jul 2000 03:37:24 +0000 Subject: don't error out on invalid svc_acct_sm.domuid's that can't be matched in svc_acct.uid - just warn. --- bin/svc_acct_sm.export | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'bin') diff --git a/bin/svc_acct_sm.export b/bin/svc_acct_sm.export index 56c6115a6..bda17e332 100755 --- a/bin/svc_acct_sm.export +++ b/bin/svc_acct_sm.export @@ -1,6 +1,6 @@ #!/usr/bin/perl -Tw # -# $Id: svc_acct_sm.export,v 1.7 2000-07-03 09:13:10 ivan Exp $ +# $Id: svc_acct_sm.export,v 1.8 2000-07-06 03:37:24 ivan Exp $ # # Create and export config files for sendmail, qmail # @@ -42,7 +42,11 @@ # /var/spool/freeside/conf and sendmail updates ivan@sisd.com 98-aug-14 # # $Log: svc_acct_sm.export,v $ -# Revision 1.7 2000-07-03 09:13:10 ivan +# Revision 1.8 2000-07-06 03:37:24 ivan +# don't error out on invalid svc_acct_sm.domuid's that can't be matched in +# svc_acct.uid - just warn. +# +# Revision 1.7 2000/07/03 09:13:10 ivan # get rid of double sendmailrestart invocation; no need for multiple sessions # # Revision 1.6 2000/07/03 09:09:14 ivan @@ -145,6 +149,11 @@ foreach $svc_acct_sm ( qsearch('svc_acct_sm') ) { ); my($domain)=$domain{$domsvc}; my($svc_acct)=qsearchs('svc_acct',{'uid'=>$domuid}); + unless ( $svc_acct ) { + warn "WARNING: couldn't find svc_acct.uid $domuid (svc_acct_sm.svcnum ". + $svc_acct_sm->svcnum. ") - corruped database?\n"; + next; + } my($username,$dir,$uid,$gid)=( $svc_acct->username, $svc_acct->dir, -- cgit v1.2.1 From 61fc4e61c6644d2e0abdffe8cbdfafd4b092e84b Mon Sep 17 00:00:00 2001 From: ivan Date: Thu, 6 Jul 2000 08:57:28 +0000 Subject: support for radius check attributes (except importing). poorly documented. --- bin/fs-radius-add | 53 ------------------------------------------------- bin/fs-radius-add-check | 53 +++++++++++++++++++++++++++++++++++++++++++++++++ bin/fs-radius-add-reply | 53 +++++++++++++++++++++++++++++++++++++++++++++++++ bin/fs-setup | 29 ++++++++++++++++++++++----- bin/svc_acct.export | 41 ++++++++++++++++++++++++++++++-------- 5 files changed, 163 insertions(+), 66 deletions(-) delete mode 100755 bin/fs-radius-add create mode 100755 bin/fs-radius-add-check create mode 100755 bin/fs-radius-add-reply (limited to 'bin') diff --git a/bin/fs-radius-add b/bin/fs-radius-add deleted file mode 100755 index 707926677..000000000 --- a/bin/fs-radius-add +++ /dev/null @@ -1,53 +0,0 @@ -#!/usr/bin/perl -Tw - -# quick'n'dirty hack of fs-setup to add radius attributes - -use strict; -use DBI; -use FS::UID qw(adminsuidsetup checkeuid getsecrets); -die "Not running uid freeside!" unless checkeuid(); - -my $user = shift or die &usage; -getsecrets($user); - -my $dbh = adminsuidsetup $user; - -### - -print "\n\n", <); - chop $x; - $x; -} - -### - -my($char_d) = 80; #default maxlength for text fields - -### - -foreach my $attribute ( @attributes ) { - foreach my $statement ( - "ALTER TABLE svc_acct ADD radius_$attribute varchar($char_d) NULL", - "ALTER TABLE svc_acct ADD radius_$attribute varchar($char_d) NULL", - "ALTER TABLE part_svc ADD svc_acct__radius_$attribute varchar($char_d) NULL;", - "ALTER TABLE part_svc ADD svc_acct__radius_${attribute}_flag char(1) NULL;", - ) { - $dbh->do( $statement ) or warn "Error executing $statement: ". $dbh->errstr; } -} - -$dbh->disconnect or die $dbh->errstr; - -print "\n\n", "Now you must run dbdef-create.\n\n"; - -sub usage { - die "Usage:\n fs-radius-add user\n"; -} - - diff --git a/bin/fs-radius-add-check b/bin/fs-radius-add-check new file mode 100755 index 000000000..435f3e88a --- /dev/null +++ b/bin/fs-radius-add-check @@ -0,0 +1,53 @@ +#!/usr/bin/perl -Tw + +# quick'n'dirty hack of fs-setup to add radius attributes + +use strict; +use DBI; +use FS::UID qw(adminsuidsetup checkeuid getsecrets); +die "Not running uid freeside!" unless checkeuid(); + +my $user = shift or die &usage; +getsecrets($user); + +my $dbh = adminsuidsetup $user; + +### + +print "\n\n", <); + chop $x; + $x; +} + +### + +my($char_d) = 80; #default maxlength for text fields + +### + +foreach my $attribute ( @attributes ) { + foreach my $statement ( + "ALTER TABLE svc_acct ADD rc_$attribute varchar($char_d) NULL", + "ALTER TABLE svc_acct ADD rc_$attribute varchar($char_d) NULL", + "ALTER TABLE part_svc ADD svc_acct__rc_$attribute varchar($char_d) NULL;", + "ALTER TABLE part_svc ADD svc_acct__rc_${attribute}_flag char(1) NULL;", + ) { + $dbh->do( $statement ) or warn "Error executing $statement: ". $dbh->errstr; } +} + +$dbh->disconnect or die $dbh->errstr; + +print "\n\n", "Now you must run dbdef-create.\n\n"; + +sub usage { + die "Usage:\n fs-radius-add user\n"; +} + + diff --git a/bin/fs-radius-add-reply b/bin/fs-radius-add-reply new file mode 100755 index 000000000..23a8d78a3 --- /dev/null +++ b/bin/fs-radius-add-reply @@ -0,0 +1,53 @@ +#!/usr/bin/perl -Tw + +# quick'n'dirty hack of fs-setup to add radius attributes + +use strict; +use DBI; +use FS::UID qw(adminsuidsetup checkeuid getsecrets); +die "Not running uid freeside!" unless checkeuid(); + +my $user = shift or die &usage; +getsecrets($user); + +my $dbh = adminsuidsetup $user; + +### + +print "\n\n", <); + chop $x; + $x; +} + +### + +my($char_d) = 80; #default maxlength for text fields + +### + +foreach my $attribute ( @attributes ) { + foreach my $statement ( + "ALTER TABLE svc_acct ADD radius_$attribute varchar($char_d) NULL", + "ALTER TABLE svc_acct ADD radius_$attribute varchar($char_d) NULL", + "ALTER TABLE part_svc ADD svc_acct__radius_$attribute varchar($char_d) NULL;", + "ALTER TABLE part_svc ADD svc_acct__radius_${attribute}_flag char(1) NULL;", + ) { + $dbh->do( $statement ) or warn "Error executing $statement: ". $dbh->errstr; } +} + +$dbh->disconnect or die $dbh->errstr; + +print "\n\n", "Now you must run dbdef-create.\n\n"; + +sub usage { + die "Usage:\n fs-radius-add user\n"; +} + + diff --git a/bin/fs-setup b/bin/fs-setup index 002a4ed4c..ac8ff5eb7 100755 --- a/bin/fs-setup +++ b/bin/fs-setup @@ -1,6 +1,6 @@ #!/usr/bin/perl -Tw # -# $Id: fs-setup,v 1.25 2000-06-29 12:00:49 ivan Exp $ +# $Id: fs-setup,v 1.26 2000-07-06 08:57:27 ivan Exp $ # # ivan@sisd.com 97-nov-8,9 # @@ -32,7 +32,10 @@ # fix radius attributes ivan@sisd.com 98-sep-27 # # $Log: fs-setup,v $ -# Revision 1.25 2000-06-29 12:00:49 ivan +# Revision 1.26 2000-07-06 08:57:27 ivan +# support for radius check attributes (except importing). poorly documented. +# +# Revision 1.25 2000/06/29 12:00:49 ivan # support for pre-encrypted md5 passwords. # # Revision 1.24 2000/03/02 07:44:07 ivan @@ -127,9 +130,16 @@ print "\nEnter the maximum username length: "; my($username_len)=&getvalue; print "\n\n", <addcolumn( new FS::dbdef_column ( + 'rc_'. $attribute, + 'varchar', + 'NULL', + $char_d, + )); +} + #make part_svc table (but now as object) my($part_svc)=$dbdef->table('part_svc'); diff --git a/bin/svc_acct.export b/bin/svc_acct.export index 53fd1f0c7..57be2ddb7 100755 --- a/bin/svc_acct.export +++ b/bin/svc_acct.export @@ -1,6 +1,6 @@ #!/usr/bin/perl -w # -# $Id: svc_acct.export,v 1.14 2000-06-29 15:01:25 ivan Exp $ +# $Id: svc_acct.export,v 1.15 2000-07-06 08:57:28 ivan Exp $ # # Create and export password files: passwd, passwd.adjunct, shadow, # acp_passwd, acp_userinfo, acp_dialup, users @@ -38,7 +38,10 @@ # ivan@sisd.com 98-sep-18 # # $Log: svc_acct.export,v $ -# Revision 1.14 2000-06-29 15:01:25 ivan +# Revision 1.15 2000-07-06 08:57:28 ivan +# support for radius check attributes (except importing). poorly documented. +# +# Revision 1.14 2000/06/29 15:01:25 ivan # another silly typo in svc_acct.export # # Revision 1.13 2000/06/28 12:37:28 ivan @@ -240,16 +243,24 @@ foreach $svc_acct (@svc_acct) { print ACP_DIALUP $svc_acct->username, "\t*\t", $svc_acct->slipip, "\n"; } - my %radius = $svc_acct->radius; + my %radreply = $svc_acct->radius_reply; + my %radcheck = $svc_acct->radius_check; + + my $radcheck = join ", ", map { qq($_ = "$radcheck{$_}") } keys %radcheck; + $radcheck .= ", " if $radcheck; ### # FORMAT OF THE USERS FILE HERE print USERS - $svc_acct->username, qq(\t${textradiusprepend}Password = "$rpassword"\n\t), - join ",\n\t", map { qq($_ = "$radius{$_}") } keys %radius; + $svc_acct->username, + qq(\t${textradiusprepend}), + $radcheck, + qq(Password = "$rpassword"\n\t), + join ",\n\t", map { qq($_ = "$radreply{$_}") } keys %radreply; if ( $ip && $ip ne '0e0' ) { - print USERS qq(,\n\tFramed-Address = "$ip"\n\n); + #print USERS qq(,\n\tFramed-Address = "$ip"\n\n); + print USERS qq(,\n\tFramed-IP-Address = "$ip"\n\n); } else { print USERS qq(\n\n); } @@ -257,6 +268,7 @@ foreach $svc_acct (@svc_acct) { ### # ICRADIUS export if ( $icradiusmachines ) { + my $sth = $icradius_dbh->prepare( "INSERT INTO radcheck ( id, UserName, Attribute, Value ) VALUES ( ". join(", ", map { $icradius_dbh->quote( $_ ) } ( @@ -268,14 +280,27 @@ foreach $svc_acct (@svc_acct) { ); $sth->execute or die "Can't insert into radcheck table: ". $sth->errstr; - foreach my $attribute ( keys %radius ) { + foreach my $attribute ( keys %radcheck ) { + my $sth = $icradius_dbh->prepare( + "INSERT INTO radcheck ( id, UserName, Attribute, Value ) VALUES ( ". + join(", ", map { $icradius_dbh->quote( $_ ) } ( + '', + $svc_acct->username, + $attribute + $radcheck{$attribute}, + ) ). " )" + ); + $sth->execute or die "Can't insert into radcheck table: ". $sth->errstr; + } + + foreach my $attribute ( keys %radreply ) { my $sth = $icradius_dbh->prepare( "INSERT INTO radreply (id, UserName, Attribute, Value) VALUES ( ". join(", ", map { $icradius_dbh->quote( $_ ) } ( '', $svc_acct->username, $attribute, - $radius{$attribute}, + $radreply{$attribute}, ) ). " )" ); $sth->execute or die "Can't insert into radreply table: ". $sth->errstr; -- cgit v1.2.1 From df3db34511853d9404a4910c20dcedf0563f02f2 Mon Sep 17 00:00:00 2001 From: ivan Date: Thu, 6 Jul 2000 13:19:18 +0000 Subject: remove duplicate sql statement causing spurious errors --- bin/fs-radius-add-check | 1 - bin/fs-radius-add-reply | 1 - 2 files changed, 2 deletions(-) (limited to 'bin') diff --git a/bin/fs-radius-add-check b/bin/fs-radius-add-check index 435f3e88a..92523eb95 100755 --- a/bin/fs-radius-add-check +++ b/bin/fs-radius-add-check @@ -34,7 +34,6 @@ my($char_d) = 80; #default maxlength for text fields foreach my $attribute ( @attributes ) { foreach my $statement ( - "ALTER TABLE svc_acct ADD rc_$attribute varchar($char_d) NULL", "ALTER TABLE svc_acct ADD rc_$attribute varchar($char_d) NULL", "ALTER TABLE part_svc ADD svc_acct__rc_$attribute varchar($char_d) NULL;", "ALTER TABLE part_svc ADD svc_acct__rc_${attribute}_flag char(1) NULL;", diff --git a/bin/fs-radius-add-reply b/bin/fs-radius-add-reply index 23a8d78a3..7938feac6 100755 --- a/bin/fs-radius-add-reply +++ b/bin/fs-radius-add-reply @@ -34,7 +34,6 @@ my($char_d) = 80; #default maxlength for text fields foreach my $attribute ( @attributes ) { foreach my $statement ( - "ALTER TABLE svc_acct ADD radius_$attribute varchar($char_d) NULL", "ALTER TABLE svc_acct ADD radius_$attribute varchar($char_d) NULL", "ALTER TABLE part_svc ADD svc_acct__radius_$attribute varchar($char_d) NULL;", "ALTER TABLE part_svc ADD svc_acct__radius_${attribute}_flag char(1) NULL;", -- cgit v1.2.1 From e5d8fd10937c98ef6bfe06ee745cba36d33a9dc5 Mon Sep 17 00:00:00 2001 From: ivan Date: Thu, 6 Jul 2000 13:23:29 +0000 Subject: tyop --- bin/svc_acct.export | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'bin') diff --git a/bin/svc_acct.export b/bin/svc_acct.export index 57be2ddb7..636921a40 100755 --- a/bin/svc_acct.export +++ b/bin/svc_acct.export @@ -1,6 +1,6 @@ #!/usr/bin/perl -w # -# $Id: svc_acct.export,v 1.15 2000-07-06 08:57:28 ivan Exp $ +# $Id: svc_acct.export,v 1.16 2000-07-06 13:23:29 ivan Exp $ # # Create and export password files: passwd, passwd.adjunct, shadow, # acp_passwd, acp_userinfo, acp_dialup, users @@ -38,7 +38,10 @@ # ivan@sisd.com 98-sep-18 # # $Log: svc_acct.export,v $ -# Revision 1.15 2000-07-06 08:57:28 ivan +# Revision 1.16 2000-07-06 13:23:29 ivan +# tyop +# +# Revision 1.15 2000/07/06 08:57:28 ivan # support for radius check attributes (except importing). poorly documented. # # Revision 1.14 2000/06/29 15:01:25 ivan @@ -286,7 +289,7 @@ foreach $svc_acct (@svc_acct) { join(", ", map { $icradius_dbh->quote( $_ ) } ( '', $svc_acct->username, - $attribute + $attribute, $radcheck{$attribute}, ) ). " )" ); -- cgit v1.2.1 From 52b07e8abd3946578a6c2701ec9e5195ec6b17e6 Mon Sep 17 00:00:00 2001 From: ivan Date: Fri, 27 Oct 2000 20:15:50 +0000 Subject: session monitor --- bin/fs-setup | 50 ++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 48 insertions(+), 2 deletions(-) (limited to 'bin') diff --git a/bin/fs-setup b/bin/fs-setup index ac8ff5eb7..cabeb2859 100755 --- a/bin/fs-setup +++ b/bin/fs-setup @@ -1,6 +1,6 @@ #!/usr/bin/perl -Tw # -# $Id: fs-setup,v 1.26 2000-07-06 08:57:27 ivan Exp $ +# $Id: fs-setup,v 1.27 2000-10-27 20:15:50 ivan Exp $ # # ivan@sisd.com 97-nov-8,9 # @@ -32,7 +32,10 @@ # fix radius attributes ivan@sisd.com 98-sep-27 # # $Log: fs-setup,v $ -# Revision 1.26 2000-07-06 08:57:27 ivan +# Revision 1.27 2000-10-27 20:15:50 ivan +# session monitor +# +# Revision 1.26 2000/07/06 08:57:27 ivan # support for radius check attributes (except importing). poorly documented. # # Revision 1.25 2000/06/29 12:00:49 ivan @@ -730,6 +733,49 @@ sub tables_hash_hack { 'index' => [ [] ], }, + 'port' => { + 'columns' => [ + 'portnum', 'int', '', '', + 'ip', 'varchar', NULL, 15, + 'nasport' 'int', NULL, '', + 'nasnum', 'int', '', '', + ], + 'primary_key' => 'portnum', + 'unique' => [], + 'index' => [], + }, + + 'nas' => { + 'columns' => [ + 'nasnum', 'int', '', '', + 'nas', 'varchar', '', $char_d, + 'nasip', 'varchar', '', 15, + 'nasfqdn', 'varchar', '', $char_d, +# 'last', 'timestamp', NULL, '', +#change to above when move to DBIx::DBSchema!!! + 'last', 'datetime', NULL, '', + ], + 'primary_key' => 'nasnum', + 'unique' => [ [ 'nas' ], [ 'nasip' ] ], + 'index' => [ [ 'last' ] ], + }, + + 'session' => { + 'columns' => [ + 'sessionnum', 'int', '', '', + 'portnum', 'int', '', '', + 'svcnum', 'int', '', '', +# 'login', 'timestamp', '', '', +# 'logout', 'timestamp', '', '', +#change to above when move to DBIx::DBSchema!!! + 'login', 'datetime', '', '', + 'logout', 'datetime', NULL, '', + ], + 'primary_key' => 'sessionnum', + 'unique' => [], + 'index' => [ [ 'portnum' ] ], + }, + ); %tables; -- cgit v1.2.1 From b31966d5d1f9d8629bd28ff1c2ff37a5c84965c1 Mon Sep 17 00:00:00 2001 From: ivan Date: Mon, 30 Oct 2000 10:47:26 +0000 Subject: nas.last can't be defined NULL if indexed --- bin/fs-setup | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'bin') diff --git a/bin/fs-setup b/bin/fs-setup index cabeb2859..b0f47610f 100755 --- a/bin/fs-setup +++ b/bin/fs-setup @@ -1,6 +1,6 @@ #!/usr/bin/perl -Tw # -# $Id: fs-setup,v 1.27 2000-10-27 20:15:50 ivan Exp $ +# $Id: fs-setup,v 1.28 2000-10-30 10:47:26 ivan Exp $ # # ivan@sisd.com 97-nov-8,9 # @@ -32,8 +32,8 @@ # fix radius attributes ivan@sisd.com 98-sep-27 # # $Log: fs-setup,v $ -# Revision 1.27 2000-10-27 20:15:50 ivan -# session monitor +# Revision 1.28 2000-10-30 10:47:26 ivan +# nas.last can't be defined NULL if indexed # # Revision 1.26 2000/07/06 08:57:27 ivan # support for radius check attributes (except importing). poorly documented. @@ -751,9 +751,9 @@ sub tables_hash_hack { 'nas', 'varchar', '', $char_d, 'nasip', 'varchar', '', 15, 'nasfqdn', 'varchar', '', $char_d, -# 'last', 'timestamp', NULL, '', +# 'last', 'timestamp', '', '', #change to above when move to DBIx::DBSchema!!! - 'last', 'datetime', NULL, '', + 'last', 'datetime', '', '', ], 'primary_key' => 'nasnum', 'unique' => [ [ 'nas' ], [ 'nasip' ] ], -- cgit v1.2.1 From 7f07089722bfcabe3bf42619bb2bdb81fd8d44e1 Mon Sep 17 00:00:00 2001 From: ivan Date: Tue, 7 Nov 2000 15:00:37 +0000 Subject: session monitor --- bin/fs-setup | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) (limited to 'bin') diff --git a/bin/fs-setup b/bin/fs-setup index b0f47610f..602dc7274 100755 --- a/bin/fs-setup +++ b/bin/fs-setup @@ -1,6 +1,6 @@ #!/usr/bin/perl -Tw # -# $Id: fs-setup,v 1.28 2000-10-30 10:47:26 ivan Exp $ +# $Id: fs-setup,v 1.29 2000-11-07 15:00:37 ivan Exp $ # # ivan@sisd.com 97-nov-8,9 # @@ -32,7 +32,10 @@ # fix radius attributes ivan@sisd.com 98-sep-27 # # $Log: fs-setup,v $ -# Revision 1.28 2000-10-30 10:47:26 ivan +# Revision 1.29 2000-11-07 15:00:37 ivan +# session monitor +# +# Revision 1.28 2000/10/30 10:47:26 ivan # nas.last can't be defined NULL if indexed # # Revision 1.26 2000/07/06 08:57:27 ivan @@ -751,9 +754,7 @@ sub tables_hash_hack { 'nas', 'varchar', '', $char_d, 'nasip', 'varchar', '', 15, 'nasfqdn', 'varchar', '', $char_d, -# 'last', 'timestamp', '', '', -#change to above when move to DBIx::DBSchema!!! - 'last', 'datetime', '', '', + 'last', @date_type, ], 'primary_key' => 'nasnum', 'unique' => [ [ 'nas' ], [ 'nasip' ] ], @@ -765,11 +766,8 @@ sub tables_hash_hack { 'sessionnum', 'int', '', '', 'portnum', 'int', '', '', 'svcnum', 'int', '', '', -# 'login', 'timestamp', '', '', -# 'logout', 'timestamp', '', '', -#change to above when move to DBIx::DBSchema!!! - 'login', 'datetime', '', '', - 'logout', 'datetime', NULL, '', + 'login', @date_type, + 'logout', @date_type, ], 'primary_key' => 'sessionnum', 'unique' => [], -- cgit v1.2.1 From ae2f662a52a739ce966cdc0e74faef7bab1f8cb7 Mon Sep 17 00:00:00 2001 From: ivan Date: Fri, 1 Dec 2000 18:33:32 +0000 Subject: tyop --- bin/fs-setup | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'bin') diff --git a/bin/fs-setup b/bin/fs-setup index 602dc7274..b2000a53b 100755 --- a/bin/fs-setup +++ b/bin/fs-setup @@ -1,6 +1,6 @@ #!/usr/bin/perl -Tw # -# $Id: fs-setup,v 1.29 2000-11-07 15:00:37 ivan Exp $ +# $Id: fs-setup,v 1.30 2000-12-01 18:33:32 ivan Exp $ # # ivan@sisd.com 97-nov-8,9 # @@ -32,7 +32,10 @@ # fix radius attributes ivan@sisd.com 98-sep-27 # # $Log: fs-setup,v $ -# Revision 1.29 2000-11-07 15:00:37 ivan +# Revision 1.30 2000-12-01 18:33:32 ivan +# tyop +# +# Revision 1.29 2000/11/07 15:00:37 ivan # session monitor # # Revision 1.28 2000/10/30 10:47:26 ivan @@ -740,7 +743,7 @@ sub tables_hash_hack { 'columns' => [ 'portnum', 'int', '', '', 'ip', 'varchar', NULL, 15, - 'nasport' 'int', NULL, '', + 'nasport', 'int', NULL, '', 'nasnum', 'int', '', '', ], 'primary_key' => 'portnum', -- cgit v1.2.1 From 61495019b4ef4079c771c37933d0fe0f38164f1a Mon Sep 17 00:00:00 2001 From: ivan Date: Fri, 1 Dec 2000 18:34:53 +0000 Subject: another tyop --- bin/fs-setup | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'bin') diff --git a/bin/fs-setup b/bin/fs-setup index b2000a53b..4cdcb1b2c 100755 --- a/bin/fs-setup +++ b/bin/fs-setup @@ -1,6 +1,6 @@ #!/usr/bin/perl -Tw # -# $Id: fs-setup,v 1.30 2000-12-01 18:33:32 ivan Exp $ +# $Id: fs-setup,v 1.31 2000-12-01 18:34:53 ivan Exp $ # # ivan@sisd.com 97-nov-8,9 # @@ -32,7 +32,10 @@ # fix radius attributes ivan@sisd.com 98-sep-27 # # $Log: fs-setup,v $ -# Revision 1.30 2000-12-01 18:33:32 ivan +# Revision 1.31 2000-12-01 18:34:53 ivan +# another tyop +# +# Revision 1.30 2000/12/01 18:33:32 ivan # tyop # # Revision 1.29 2000/11/07 15:00:37 ivan @@ -742,8 +745,8 @@ sub tables_hash_hack { 'port' => { 'columns' => [ 'portnum', 'int', '', '', - 'ip', 'varchar', NULL, 15, - 'nasport', 'int', NULL, '', + 'ip', 'varchar', 'NULL', 15, + 'nasport', 'int', 'NULL', '', 'nasnum', 'int', '', '', ], 'primary_key' => 'portnum', -- cgit v1.2.1 From 3a95cc316da367ffd248ba29ac594f3efbc9db61 Mon Sep 17 00:00:00 2001 From: ivan Date: Sun, 3 Dec 2000 15:14:00 +0000 Subject: bugfixes from Jeff Finucane , thanks! --- bin/svc_acct_sm.import | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'bin') diff --git a/bin/svc_acct_sm.import b/bin/svc_acct_sm.import index 349c4f26c..0714af3f1 100755 --- a/bin/svc_acct_sm.import +++ b/bin/svc_acct_sm.import @@ -1,6 +1,6 @@ #!/usr/bin/perl -Tw # -# $Id: svc_acct_sm.import,v 1.7 2000-06-29 10:51:52 ivan Exp $ +# $Id: svc_acct_sm.import,v 1.8 2000-12-03 15:14:00 ivan Exp $ # # ivan@sisd.com 98-mar-9 # @@ -16,7 +16,10 @@ # ivan@sisd.com 98-jul-13 # # $Log: svc_acct_sm.import,v $ -# Revision 1.7 2000-06-29 10:51:52 ivan +# Revision 1.8 2000-12-03 15:14:00 ivan +# bugfixes from Jeff Finucane , thanks! +# +# Revision 1.7 2000/06/29 10:51:52 ivan # oops, silly mistake # # Revision 1.6 2000/06/29 10:48:25 ivan @@ -252,7 +255,7 @@ END while () { next if /^#/; #comments? next if /^\s*$/; #blank lines - /^([\w\-\.]+)?\@([\w\-\.]+)\t([\w\-\.]+)$/ + /^([\w\-\.]+)?\@([\w\-\.]+)\t+([\w\-\.]+)$/ #or do { warn "Strange virtusertable line: $_"; next; }; or die "Strange virtusertable line: $_"; my($domuser,$domain,$username)=($1,$2,$3); -- cgit v1.2.1 From f16bab33441eb8bb4475f4bf3a64310e7786f0fc Mon Sep 17 00:00:00 2001 From: ivan Date: Mon, 4 Dec 2000 00:13:02 +0000 Subject: fix nas.last type --- bin/fs-setup | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'bin') diff --git a/bin/fs-setup b/bin/fs-setup index 4cdcb1b2c..2c31ff667 100755 --- a/bin/fs-setup +++ b/bin/fs-setup @@ -1,6 +1,6 @@ #!/usr/bin/perl -Tw # -# $Id: fs-setup,v 1.31 2000-12-01 18:34:53 ivan Exp $ +# $Id: fs-setup,v 1.32 2000-12-04 00:13:02 ivan Exp $ # # ivan@sisd.com 97-nov-8,9 # @@ -32,7 +32,10 @@ # fix radius attributes ivan@sisd.com 98-sep-27 # # $Log: fs-setup,v $ -# Revision 1.31 2000-12-01 18:34:53 ivan +# Revision 1.32 2000-12-04 00:13:02 ivan +# fix nas.last type +# +# Revision 1.31 2000/12/01 18:34:53 ivan # another tyop # # Revision 1.30 2000/12/01 18:33:32 ivan @@ -760,7 +763,7 @@ sub tables_hash_hack { 'nas', 'varchar', '', $char_d, 'nasip', 'varchar', '', 15, 'nasfqdn', 'varchar', '', $char_d, - 'last', @date_type, + 'last', 'int', '', '', ], 'primary_key' => 'nasnum', 'unique' => [ [ 'nas' ], [ 'nasip' ] ], -- cgit v1.2.1 From d220c8a4bfa1aee8f17ed71c2dba655160dd3595 Mon Sep 17 00:00:00 2001 From: ivan Date: Sat, 3 Feb 2001 14:03:50 +0000 Subject: time-based prepaid cards, session monitor. woop! --- bin/fs-setup | 9 +++++++-- bin/generate-prepay | 5 ++++- 2 files changed, 11 insertions(+), 3 deletions(-) (limited to 'bin') diff --git a/bin/fs-setup b/bin/fs-setup index 2c31ff667..1df46d342 100755 --- a/bin/fs-setup +++ b/bin/fs-setup @@ -1,6 +1,6 @@ #!/usr/bin/perl -Tw # -# $Id: fs-setup,v 1.32 2000-12-04 00:13:02 ivan Exp $ +# $Id: fs-setup,v 1.33 2001-02-03 14:03:50 ivan Exp $ # # ivan@sisd.com 97-nov-8,9 # @@ -32,7 +32,10 @@ # fix radius attributes ivan@sisd.com 98-sep-27 # # $Log: fs-setup,v $ -# Revision 1.32 2000-12-04 00:13:02 ivan +# Revision 1.33 2001-02-03 14:03:50 ivan +# time-based prepaid cards, session monitor. woop! +# +# Revision 1.32 2000/12/04 00:13:02 ivan # fix nas.last type # # Revision 1.31 2000/12/01 18:34:53 ivan @@ -658,6 +661,7 @@ sub tables_hash_hack { 'shell', 'varchar', 'NULL', $char_d, 'quota', 'varchar', 'NULL', $char_d, 'slipip', 'varchar', 'NULL', 15, #four TINYINTs, bah. + 'seconds', 'int', 'NULL', '', #uhhhh ], 'primary_key' => 'svcnum', 'unique' => [ [] ], @@ -739,6 +743,7 @@ sub tables_hash_hack { 'prepaynum', 'int', '', '', 'identifier', 'varchar', '', $char_d, 'amount', @money_type, + 'seconds', 'int', 'NULL', '', ], 'primary_key' => 'prepaynum', 'unique' => [ ['identifier'] ], diff --git a/bin/generate-prepay b/bin/generate-prepay index 6fb615ab1..cb4ba7fc6 100755 --- a/bin/generate-prepay +++ b/bin/generate-prepay @@ -11,6 +11,8 @@ my $user = shift or die &usage; my $amount = shift or die &usage; +my $seconds = shift or die &usage; + my $num_digits = shift or die &usage; my $num_entries = shift or die &usage; @@ -20,6 +22,7 @@ for ( 1 .. $num_entries ) { my $prepay_credit = new FS::prepay_credit { 'identifier' => $identifier, 'amount' => $amount, + 'seconds' => $seconds, }; my $error = $prepay_credit->insert; die $error if $error; @@ -27,6 +30,6 @@ for ( 1 .. $num_entries ) { } sub usage { - die "Usage:\n\n generate-prepay user amount num_digits num_entries"; + die "Usage:\n\n generate-prepay user amount seconds num_digits num_entries"; } -- cgit v1.2.1 From 4930644974239211b217a6241781db91808a3778 Mon Sep 17 00:00:00 2001 From: ivan Date: Wed, 21 Feb 2001 23:48:19 +0000 Subject: add icradius_secrets config file to export to a non-Freeside MySQL database for ICRADIUS --- bin/svc_acct.export | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) (limited to 'bin') diff --git a/bin/svc_acct.export b/bin/svc_acct.export index 636921a40..3280904f6 100755 --- a/bin/svc_acct.export +++ b/bin/svc_acct.export @@ -1,6 +1,6 @@ #!/usr/bin/perl -w # -# $Id: svc_acct.export,v 1.16 2000-07-06 13:23:29 ivan Exp $ +# $Id: svc_acct.export,v 1.17 2001-02-21 23:48:19 ivan Exp $ # # Create and export password files: passwd, passwd.adjunct, shadow, # acp_passwd, acp_userinfo, acp_dialup, users @@ -38,7 +38,11 @@ # ivan@sisd.com 98-sep-18 # # $Log: svc_acct.export,v $ -# Revision 1.16 2000-07-06 13:23:29 ivan +# Revision 1.17 2001-02-21 23:48:19 ivan +# add icradius_secrets config file to export to a non-Freeside MySQL database for +# ICRADIUS +# +# Revision 1.16 2000/07/06 13:23:29 ivan # tyop # # Revision 1.15 2000/07/06 08:57:28 ivan @@ -64,6 +68,7 @@ use strict; use vars qw($conf); use Fcntl qw(:flock); use IO::Handle; +use DBI; use FS::Conf; use FS::SSH qw(scp ssh); use FS::UID qw(adminsuidsetup datasrc dbh); @@ -98,8 +103,13 @@ my $icradius_mysqldest = my $icradius_mysqlsource = $conf->config('icradius_mysqlsource') || "/usr/local/var/freeside" if $icradiusmachines; -my $icradius_dbh = dbh; #could eventually get it from a config file if you're - #not running MySQL for your Freeside database +my $icradius_dbh; +if ( $icradiusmachines && $conf->exists('icradius_secrets') ) { + $icradius_dbh = DBI->connect($conf->config('icradius_secrets')) + or die $DBI::errstr;; +} else { + $icradius_dbh = dbh; +} my $textradiusprepend = $conf->config('textradiusprepend'); -- cgit v1.2.1 From 15f65a0c56cbce6951d9cb4f71119725a2009f79 Mon Sep 17 00:00:00 2001 From: ivan Date: Mon, 9 Apr 2001 23:05:16 +0000 Subject: Transactions Part I!!! --- bin/fs-setup | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'bin') diff --git a/bin/fs-setup b/bin/fs-setup index 1df46d342..2a37fb8d7 100755 --- a/bin/fs-setup +++ b/bin/fs-setup @@ -1,6 +1,6 @@ #!/usr/bin/perl -Tw # -# $Id: fs-setup,v 1.33 2001-02-03 14:03:50 ivan Exp $ +# $Id: fs-setup,v 1.34 2001-04-09 23:05:16 ivan Exp $ # # ivan@sisd.com 97-nov-8,9 # @@ -32,7 +32,10 @@ # fix radius attributes ivan@sisd.com 98-sep-27 # # $Log: fs-setup,v $ -# Revision 1.33 2001-02-03 14:03:50 ivan +# Revision 1.34 2001-04-09 23:05:16 ivan +# Transactions Part I!!! +# +# Revision 1.33 2001/02/03 14:03:50 ivan # time-based prepaid cards, session monitor. woop! # # Revision 1.32 2000/12/04 00:13:02 ivan @@ -392,7 +395,6 @@ sub tables_hash_hack { 'custnum', 'int', '', '', '_date', @date_type, 'charged', @money_type, - 'owed', @money_type, 'printed', 'int', '', '', ], 'primary_key' => 'invnum', @@ -420,7 +422,6 @@ sub tables_hash_hack { 'custnum', 'int', '', '', '_date', @date_type, 'amount', @money_type, - 'credited', @money_type, 'otaker', 'varchar', '', 8, 'reason', 'varchar', '', 255, ], -- cgit v1.2.1 From 7dac9e5e79d089cfb23ab1cf9330473e698b12e8 Mon Sep 17 00:00:00 2001 From: ivan Date: Sun, 15 Apr 2001 09:36:43 +0000 Subject: http://www.sisd.com/freeside/list-archive/msg01450.html --- bin/fs-setup | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'bin') diff --git a/bin/fs-setup b/bin/fs-setup index 2a37fb8d7..b91633bf4 100755 --- a/bin/fs-setup +++ b/bin/fs-setup @@ -1,6 +1,6 @@ #!/usr/bin/perl -Tw # -# $Id: fs-setup,v 1.34 2001-04-09 23:05:16 ivan Exp $ +# $Id: fs-setup,v 1.35 2001-04-15 09:36:43 ivan Exp $ # # ivan@sisd.com 97-nov-8,9 # @@ -32,7 +32,10 @@ # fix radius attributes ivan@sisd.com 98-sep-27 # # $Log: fs-setup,v $ -# Revision 1.34 2001-04-09 23:05:16 ivan +# Revision 1.35 2001-04-15 09:36:43 ivan +# http://www.sisd.com/freeside/list-archive/msg01450.html +# +# Revision 1.34 2001/04/09 23:05:16 ivan # Transactions Part I!!! # # Revision 1.33 2001/02/03 14:03:50 ivan @@ -570,7 +573,7 @@ sub tables_hash_hack { 'cust_svc' => { 'columns' => [ 'svcnum', 'int', '', '', - 'pkgnum', 'int', '', '', + 'pkgnum', 'int', 'NULL', '', 'svcpart', 'int', '', '', ], 'primary_key' => 'svcnum', -- cgit v1.2.1 From 018f6678557506e68cc6b8643862143cc332f7da Mon Sep 17 00:00:00 2001 From: ivan Date: Sun, 15 Apr 2001 12:56:31 +0000 Subject: s/dbdef/DBIx::DBSchema/ --- bin/dbdef-create | 76 ++++++-------------------------------------------------- bin/fs-setup | 54 +++++++++++++++++++--------------------- 2 files changed, 33 insertions(+), 97 deletions(-) (limited to 'bin') diff --git a/bin/dbdef-create b/bin/dbdef-create index fe7475bec..902f7f145 100755 --- a/bin/dbdef-create +++ b/bin/dbdef-create @@ -1,6 +1,6 @@ #!/usr/bin/perl -Tw # -# $Id: dbdef-create,v 1.2 1998-11-19 11:17:44 ivan Exp $ +# $Id: dbdef-create,v 1.3 2001-04-15 12:56:31 ivan Exp $ # # create dbdef file for existing mySQL database (needs SHOW|DESCRIBE command # not in Pg) based on fs-setup @@ -8,14 +8,17 @@ # ivan@sisd.com 98-jun-2 # # $Log: dbdef-create,v $ -# Revision 1.2 1998-11-19 11:17:44 ivan +# Revision 1.3 2001-04-15 12:56:31 ivan +# s/dbdef/DBIx::DBSchema/ +# +# Revision 1.2 1998/11/19 11:17:44 ivan # adminsuidsetup requires argument # use strict; use DBI; -use FS::dbdef; -use FS::UID qw(adminsuidsetup datasrc); +use DBIx::DBSchema; +use FS::UID qw(adminsuidsetup datasrc driver_name); my $user = shift or die &usage; @@ -24,70 +27,7 @@ my($dbh)=adminsuidsetup $user; #needs to match FS::Record my($dbdef_file) = "/usr/local/etc/freeside/dbdef.". datasrc; -my($tables_sth)=$dbh->prepare("SHOW TABLES"); -my($tables_rv)=$tables_sth->execute; - -my(@tables); -foreach ( @{$tables_sth->fetchall_arrayref} ) { - my($table)=${$_}[0]; - #print "TABLE\t$table\n"; - - my($index_sth)=$dbh->prepare("SHOW INDEX FROM $table"); - my($primary_key)=''; - my(%index,%unique); - for ( 1 .. $index_sth->execute ) { - my($row)=$index_sth->fetchrow_hashref; - if ( ${$row}{'Key_name'} eq "PRIMARY" ) { - $primary_key=${$row}{'Column_name'}; - next; - } - if ( ${$row}{'Non_unique'} ) { #index - push @{$index{${$row}{'Key_name'}}}, ${$row}{'Column_name'}; - } else { #unique - push @{$unique{${$row}{'Key_name'}}}, ${$row}{'Column_name'}; - } - } - - my(@index)=values %index; - my(@unique)=values %unique; - #print "\tPRIMARY KEY $primary_key\n"; - foreach (@index) { - #print "\tINDEX\t", join(', ', @{$_}), "\n"; - } - foreach (@unique) { - #print "\tUNIQUE\t", join(', ', @{$_}), "\n"; - } - - my($columns_sth)=$dbh->prepare("SHOW COLUMNS FROM $table"); - my(@columns); - for ( 1 .. $columns_sth->execute ) { - my($row)=$columns_sth->fetchrow_hashref; - #print "\t", ${$row}{'Field'}, "\n"; - ${$row}{'Type'} =~ /^(\w+)\(?([\d\,]+)?\)?( unsigned)?$/ - or die "Illegal type ${$row}{'Type'}\n"; - my($type,$length)=($1,$2); - my($null)=${$row}{'Null'}; - $null =~ s/YES/NULL/; - push @columns, new FS::dbdef_column ( - ${$row}{'Field'}, - $type, - $null, - $length, - ); - } - - #print "\n"; - push @tables, new FS::dbdef_table ( - $table, - $primary_key, - new FS::dbdef_unique (\@unique), - new FS::dbdef_index (\@index), - @columns, - ); - -} - -my($dbdef) = new FS::dbdef ( @tables ); +my $dbdef = new_native DBIx::DBSchema $dbh; #important $dbdef->save($dbdef_file); diff --git a/bin/fs-setup b/bin/fs-setup index b91633bf4..545c6a4df 100755 --- a/bin/fs-setup +++ b/bin/fs-setup @@ -1,6 +1,6 @@ #!/usr/bin/perl -Tw # -# $Id: fs-setup,v 1.35 2001-04-15 09:36:43 ivan Exp $ +# $Id: fs-setup,v 1.36 2001-04-15 12:56:31 ivan Exp $ # # ivan@sisd.com 97-nov-8,9 # @@ -32,7 +32,10 @@ # fix radius attributes ivan@sisd.com 98-sep-27 # # $Log: fs-setup,v $ -# Revision 1.35 2001-04-15 09:36:43 ivan +# Revision 1.36 2001-04-15 12:56:31 ivan +# s/dbdef/DBIx::DBSchema/ +# +# Revision 1.35 2001/04/15 09:36:43 ivan # http://www.sisd.com/freeside/list-archive/msg01450.html # # Revision 1.34 2001/04/09 23:05:16 ivan @@ -135,7 +138,11 @@ BEGIN { $FS::Record::setup_hack = 1; } use strict; use DBI; -use FS::dbdef; +use DBIx::DBSchema; +use DBIx::DBSchema::Table; +use DBIx::DBSchema::Column; +use DBIx::DBSchema::ColGroup::Unique; +use DBIx::DBSchema::ColGroup::Index; use FS::UID qw(adminsuidsetup datasrc checkeuid getsecrets); use FS::Record; use FS::cust_main_county; @@ -189,19 +196,17 @@ my @money_type = ( 'decimal', '', '10,2' ); my(%tables)=&tables_hash_hack; #turn it into objects -my($dbdef) = new FS::dbdef ( map { +my($dbdef) = new DBIx::DBSchema ( map { my(@columns); while (@{$tables{$_}{'columns'}}) { my($name,$type,$null,$length)=splice @{$tables{$_}{'columns'}}, 0, 4; - push @columns, new FS::dbdef_column ( $name,$type,$null,$length ); + push @columns, new DBIx::DBSchema::Column ( $name,$type,$null,$length ); } - FS::dbdef_table->new( + DBIx::DBSchema::Table->new( $_, $tables{$_}{'primary_key'}, - #FS::dbdef_unique->new(@{$tables{$_}{'unique'}}), - #FS::dbdef_index->new(@{$tables{$_}{'index'}}), - FS::dbdef_unique->new($tables{$_}{'unique'}), - FS::dbdef_index->new($tables{$_}{'index'}), + DBIx::DBSchema::ColGroup::Unique->new($tables{$_}{'unique'}), + DBIx::DBSchema::ColGroup::Index->new($tables{$_}{'index'}), @columns, ); } (keys %tables) ); @@ -212,7 +217,7 @@ my($svc_acct)=$dbdef->table('svc_acct'); my($attribute); foreach $attribute (@attributes) { - $svc_acct->addcolumn ( new FS::dbdef_column ( + $svc_acct->addcolumn ( new DBIx::DBSchema::Column ( 'radius_'. $attribute, 'varchar', 'NULL', @@ -221,7 +226,7 @@ foreach $attribute (@attributes) { } foreach $attribute (@check_attributes) { - $svc_acct->addcolumn( new FS::dbdef_column ( + $svc_acct->addcolumn( new DBIx::DBSchema::Column ( 'rc_'. $attribute, 'varchar', 'NULL', @@ -241,13 +246,13 @@ foreach (qw(svc_acct svc_acct_sm svc_domain svc_www)) { my($col); foreach $col ( $table->columns ) { next if $col =~ /^svcnum$/; - $part_svc->addcolumn( new FS::dbdef_column ( + $part_svc->addcolumn( new DBIx::DBSchema::Column ( $table->name. '__' . $table->column($col)->name, 'varchar', #$table->column($col)->type, 'NULL', $char_d, #$table->column($col)->length, )); - $part_svc->addcolumn ( new FS::dbdef_column ( + $part_svc->addcolumn ( new DBIx::DBSchema::Column ( $table->name. '__'. $table->column($col)->name . "_flag", 'char', 'NULL', @@ -269,21 +274,10 @@ my($dbh)=adminsuidsetup $user; #create tables $|=1; -my($table); -foreach ($dbdef->tables) { - my($table)=$dbdef->table($_); - print "Creating $_..."; - - my($statement); - - #create table - foreach $statement ($table->sql_create_table(datasrc)) { - #print $statement, "\n"; - $dbh->do( $statement ) - or die "CREATE error: ",$dbh->errstr, "\ndoing statement: $statement"; - } - - print "\n"; +my @sql = $dbdef->sql($dbh); +foreach my $statement ( $dbdef->sql($dbh) ) { + $dbh->do( $statement ) + or die "CREATE error: ",$dbh->errstr, "\ndoing statement: $statement"; } #not really sample data (and shouldn't default to US) @@ -344,6 +338,8 @@ YE YU ZR ZM ZW $dbh->disconnect or die $dbh->errstr; +print "Freeside database initialized sucessfully\n"; + sub usage { die "Usage:\n fs-setup user\n"; } -- cgit v1.2.1 From 1c14b1faec0f3f07a6d4190cf535b3ddb45075ce Mon Sep 17 00:00:00 2001 From: ivan Date: Sun, 22 Apr 2001 01:56:15 +0000 Subject: get rid of FS::SSH.pm (became Net::SSH and Net::SCP on CPAN) --- bin/svc_acct.export | 10 +++++++--- bin/svc_acct.import | 9 ++++++--- bin/svc_acct_sm.export | 10 +++++++--- bin/svc_acct_sm.import | 9 ++++++--- bin/svc_domain.import | 4 ++-- 5 files changed, 28 insertions(+), 14 deletions(-) (limited to 'bin') diff --git a/bin/svc_acct.export b/bin/svc_acct.export index 3280904f6..073359587 100755 --- a/bin/svc_acct.export +++ b/bin/svc_acct.export @@ -1,6 +1,6 @@ #!/usr/bin/perl -w # -# $Id: svc_acct.export,v 1.17 2001-02-21 23:48:19 ivan Exp $ +# $Id: svc_acct.export,v 1.18 2001-04-22 01:56:15 ivan Exp $ # # Create and export password files: passwd, passwd.adjunct, shadow, # acp_passwd, acp_userinfo, acp_dialup, users @@ -38,7 +38,10 @@ # ivan@sisd.com 98-sep-18 # # $Log: svc_acct.export,v $ -# Revision 1.17 2001-02-21 23:48:19 ivan +# Revision 1.18 2001-04-22 01:56:15 ivan +# get rid of FS::SSH.pm (became Net::SSH and Net::SCP on CPAN) +# +# Revision 1.17 2001/02/21 23:48:19 ivan # add icradius_secrets config file to export to a non-Freeside MySQL database for # ICRADIUS # @@ -70,7 +73,8 @@ use Fcntl qw(:flock); use IO::Handle; use DBI; use FS::Conf; -use FS::SSH qw(scp ssh); +use Net::SSH qw(ssh); +use Net::SCP qw(scp); use FS::UID qw(adminsuidsetup datasrc dbh); use FS::Record qw(qsearch fields); use FS::svc_acct; diff --git a/bin/svc_acct.import b/bin/svc_acct.import index 795b853c0..0acd731c5 100755 --- a/bin/svc_acct.import +++ b/bin/svc_acct.import @@ -1,6 +1,6 @@ #!/usr/bin/perl -Tw # -# $Id: svc_acct.import,v 1.11 2000-06-29 12:27:01 ivan Exp $ +# $Id: svc_acct.import,v 1.12 2001-04-22 01:56:15 ivan Exp $ # # ivan@sisd.com 98-mar-9 # @@ -17,7 +17,10 @@ # don't import /var/spool/freeside/conf/shells! ivan@sisd.com 98-aug-13 # # $Log: svc_acct.import,v $ -# Revision 1.11 2000-06-29 12:27:01 ivan +# Revision 1.12 2001-04-22 01:56:15 ivan +# get rid of FS::SSH.pm (became Net::SSH and Net::SCP on CPAN) +# +# Revision 1.11 2000/06/29 12:27:01 ivan # s/password/_password/ for PostgreSQL wasn't done in the import. # # Revision 1.10 2000/06/28 12:32:30 ivan @@ -49,7 +52,7 @@ use strict; use vars qw(%part_svc); use Date::Parse; use Term::Query qw(query); -use FS::SSH qw(iscp); +use Net::SCP qw(iscp); use FS::UID qw(adminsuidsetup datasrc); use FS::Record qw(qsearch); use FS::svc_acct; diff --git a/bin/svc_acct_sm.export b/bin/svc_acct_sm.export index bda17e332..a0938caf2 100755 --- a/bin/svc_acct_sm.export +++ b/bin/svc_acct_sm.export @@ -1,6 +1,6 @@ #!/usr/bin/perl -Tw # -# $Id: svc_acct_sm.export,v 1.8 2000-07-06 03:37:24 ivan Exp $ +# $Id: svc_acct_sm.export,v 1.9 2001-04-22 01:56:15 ivan Exp $ # # Create and export config files for sendmail, qmail # @@ -42,7 +42,10 @@ # /var/spool/freeside/conf and sendmail updates ivan@sisd.com 98-aug-14 # # $Log: svc_acct_sm.export,v $ -# Revision 1.8 2000-07-06 03:37:24 ivan +# Revision 1.9 2001-04-22 01:56:15 ivan +# get rid of FS::SSH.pm (became Net::SSH and Net::SCP on CPAN) +# +# Revision 1.8 2000/07/06 03:37:24 ivan # don't error out on invalid svc_acct_sm.domuid's that can't be matched in # svc_acct.uid - just warn. # @@ -68,7 +71,8 @@ use strict; use vars qw($conf); use Fcntl qw(:flock); -use FS::SSH qw(ssh scp); +use Net::SSH qw(ssh); +use Net::SCP qw(scp); use FS::UID qw(adminsuidsetup datasrc); use FS::Record qw(qsearch qsearchs); use FS::svc_acct; diff --git a/bin/svc_acct_sm.import b/bin/svc_acct_sm.import index 0714af3f1..723fb029f 100755 --- a/bin/svc_acct_sm.import +++ b/bin/svc_acct_sm.import @@ -1,6 +1,6 @@ #!/usr/bin/perl -Tw # -# $Id: svc_acct_sm.import,v 1.8 2000-12-03 15:14:00 ivan Exp $ +# $Id: svc_acct_sm.import,v 1.9 2001-04-22 01:56:15 ivan Exp $ # # ivan@sisd.com 98-mar-9 # @@ -16,7 +16,10 @@ # ivan@sisd.com 98-jul-13 # # $Log: svc_acct_sm.import,v $ -# Revision 1.8 2000-12-03 15:14:00 ivan +# Revision 1.9 2001-04-22 01:56:15 ivan +# get rid of FS::SSH.pm (became Net::SSH and Net::SCP on CPAN) +# +# Revision 1.8 2000/12/03 15:14:00 ivan # bugfixes from Jeff Finucane , thanks! # # Revision 1.7 2000/06/29 10:51:52 ivan @@ -41,7 +44,7 @@ use strict; use vars qw(%d_part_svc %m_part_svc); use Term::Query qw(query); -use FS::SSH qw(iscp); +use Net::SCP qw(iscp); use FS::UID qw(adminsuidsetup datasrc); use FS::Record qw(qsearch qsearchs); use FS::svc_acct_sm; diff --git a/bin/svc_domain.import b/bin/svc_domain.import index 329465ca1..3d3be9da5 100644 --- a/bin/svc_domain.import +++ b/bin/svc_domain.import @@ -1,11 +1,11 @@ #!/usr/bin/perl -w # -# $Id: svc_domain.import,v 1.1 2000-02-03 05:17:39 ivan Exp $ +# $Id: svc_domain.import,v 1.2 2001-04-22 01:56:15 ivan Exp $ use strict; use vars qw( %d_part_svc ); use Term::Query qw(query); -use FS::SSH qw(iscp); +use Net::SCP qw(iscp); use FS::UID qw(adminsuidsetup datasrc); #use FS::Record qw(qsearch qsearchs); #use FS::svc_acct_sm; -- cgit v1.2.1 From fd337973c05b8cd15ecc8c4c9b913c7261e17ed6 Mon Sep 17 00:00:00 2001 From: ivan Date: Mon, 23 Apr 2001 12:44:06 +0000 Subject: session killer implemeting timed access --- bin/freeside-session-kill | 100 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 100 insertions(+) create mode 100755 bin/freeside-session-kill (limited to 'bin') diff --git a/bin/freeside-session-kill b/bin/freeside-session-kill new file mode 100755 index 000000000..9f11abd5b --- /dev/null +++ b/bin/freeside-session-kill @@ -0,0 +1,100 @@ +#!/usr/bin/perl -w + +use strict; +use vars qw($conf); +use Fcntl qw(:flock); +use FS::UID qw(adminsuidsetup datasrc dbh); +use FS::Record qw(dbdef qsearch fields); +use FS::session; +use FS::svc_acct; + +my $user = shift or die &usage; +adminsuidsetup $user; + +my $sessionlock = "/usr/local/etc/freeside/session-kill.lock.". datasrc; + +open(LOCK,"+>>$sessionlock") or die "Can't open $sessionlock: $!"; +select(LOCK); $|=1; select(STDOUT); +unless ( flock(LOCK,LOCK_EX|LOCK_NB) ) { + seek(LOCK,0,0); + my($pid)=; + chop($pid); + #no reason to start loct of blocking processes + die "Is another session kill process running under pid $pid?\n"; +} +seek(LOCK,0,0); +print LOCK $$,"\n"; + +$FS::UID::AutoCommit = 0; + +my $now = time; + +#uhhhhh + +use DBIx::DBSchema; +use DBIx::DBSchema::Table; #down this path lies madness +use DBIx::DBSchema::Column; + +my $dbdef = dbdef or die; +#warn $dbdef; +#warn $dbdef->{'tables'}; +#warn keys %{$dbdef->{'tables'}}; +my $session_table = $dbdef->table('session') or die; +my $svc_acct_table = $dbdef->table('svc_acct') or die; + +my $session_svc_acct = new DBIx::DBSchema::Table ( 'session,svc_acct', '', '', '', + map( DBIx::DBSchema::Column->new( "session.$_", + $session_table->column($_)->type, + $session_table->column($_)->null, + $session_table->column($_)->length, + ), $session_table->columns() ), + map( DBIx::DBSchema::Column->new( "svc_acct.$_", + $svc_acct_table->column($_)->type, + $svc_acct_table->column($_)->null, + $svc_acct_table->column($_)->length, + ), $svc_acct_table->columns ), +# map("svc_acct.$_", $svc_acct_table->columns), +); + +$dbdef->addtable($session_svc_acct); #madness, i tell you + +$FS::Record::DEBUG = 1; +my @session = qsearch('session,svc_acct', {}, '', ' WHERE '. join(' AND ', + 'svc_acct.svcnum = session.svcnum', + '( session.logout IS NULL OR session.logout = 0 )', + "( $now - session.login ) >= svc_acct.seconds" +). " FOR UPDATE" ); + +my $dbh = dbh; + +foreach my $join ( @session ) { + + my $session = new FS::session ( { + map { $_ => $join->{'Hash'}{"session.$_"} } fields('session') + } ); #see no evil + + my $svc_acct = new FS::svc_acct ( { + map { $_ => $join->{'Hash'}{"svc_acct.$_"} } fields('svc_acct') + } ); + + #false laziness w/ fs_session_server + my $nsession = new FS::session ( { $session->hash } ); + my $error = $nsession->replace($session); + if ( $error ) { + $dbh->rollback; + die $error; + } + my $time = $nsession->logout - $nsession->login; + my $new_svc_acct = new FS::svc_acct ( { $svc_acct->hash } ); + my $seconds = $new_svc_acct->seconds; + $seconds -= $time; + $seconds = 0 if $seconds < 0; + $new_svc_acct->seconds( $seconds ); + $error = $new_svc_acct->replace( $svc_acct ); + warn "can't debit time from ". $svc_acct->username. ": $error\n"; #don't want to rollback, though + #ssenizal eslaf + +} + +$dbh->commit or die $dbh->errstr; + -- cgit v1.2.1 From fafbffd5057b45c84afd30fbf664f37661ef1533 Mon Sep 17 00:00:00 2001 From: ivan Date: Sat, 5 May 2001 08:51:16 +0000 Subject: http://www.sisd.com/freeside/list-archive/msg01915.html --- bin/svc_acct.import | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'bin') diff --git a/bin/svc_acct.import b/bin/svc_acct.import index 0acd731c5..0f459483f 100755 --- a/bin/svc_acct.import +++ b/bin/svc_acct.import @@ -1,6 +1,6 @@ #!/usr/bin/perl -Tw # -# $Id: svc_acct.import,v 1.12 2001-04-22 01:56:15 ivan Exp $ +# $Id: svc_acct.import,v 1.13 2001-05-05 08:51:16 ivan Exp $ # # ivan@sisd.com 98-mar-9 # @@ -17,7 +17,10 @@ # don't import /var/spool/freeside/conf/shells! ivan@sisd.com 98-aug-13 # # $Log: svc_acct.import,v $ -# Revision 1.12 2001-04-22 01:56:15 ivan +# Revision 1.13 2001-05-05 08:51:16 ivan +# http://www.sisd.com/freeside/list-archive/msg01915.html +# +# Revision 1.12 2001/04/22 01:56:15 ivan # get rid of FS::SSH.pm (became Net::SSH and Net::SCP on CPAN) # # Revision 1.11 2000/06/29 12:27:01 ivan @@ -200,6 +203,7 @@ my(%password); while () { chop; my($username,$password)=split(/:/); + $password =~ s/\!+/\*SUSPENDED\* /; $password{$username}=$password; } -- cgit v1.2.1 From f50e19a81e4f15d8ec15376d1674dfe6caad3d82 Mon Sep 17 00:00:00 2001 From: ivan Date: Mon, 7 May 2001 15:24:15 +0000 Subject: s/!/*/ --- bin/svc_acct.import | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'bin') diff --git a/bin/svc_acct.import b/bin/svc_acct.import index 0f459483f..2e51a8b2c 100755 --- a/bin/svc_acct.import +++ b/bin/svc_acct.import @@ -1,6 +1,6 @@ #!/usr/bin/perl -Tw # -# $Id: svc_acct.import,v 1.13 2001-05-05 08:51:16 ivan Exp $ +# $Id: svc_acct.import,v 1.14 2001-05-07 15:24:15 ivan Exp $ # # ivan@sisd.com 98-mar-9 # @@ -17,7 +17,10 @@ # don't import /var/spool/freeside/conf/shells! ivan@sisd.com 98-aug-13 # # $Log: svc_acct.import,v $ -# Revision 1.13 2001-05-05 08:51:16 ivan +# Revision 1.14 2001-05-07 15:24:15 ivan +# s/!/*/ +# +# Revision 1.13 2001/05/05 08:51:16 ivan # http://www.sisd.com/freeside/list-archive/msg01915.html # # Revision 1.12 2001/04/22 01:56:15 ivan @@ -203,6 +206,7 @@ my(%password); while () { chop; my($username,$password)=split(/:/); + $password =~ s/^\!$/\*/; $password =~ s/\!+/\*SUSPENDED\* /; $password{$username}=$password; } -- cgit v1.2.1 From 365fdd1f1938f399113a5ce013a7c2daa431a5c2 Mon Sep 17 00:00:00 2001 From: ivan Date: Tue, 8 May 2001 10:44:17 +0000 Subject: fix for OO Net::SCP --- bin/svc_acct.export | 56 ++++++++++++++++++++++++++++++-------------------- bin/svc_acct_sm.export | 29 +++++++++++++++----------- 2 files changed, 51 insertions(+), 34 deletions(-) (limited to 'bin') diff --git a/bin/svc_acct.export b/bin/svc_acct.export index 073359587..1c3ffa243 100755 --- a/bin/svc_acct.export +++ b/bin/svc_acct.export @@ -1,6 +1,6 @@ #!/usr/bin/perl -w # -# $Id: svc_acct.export,v 1.18 2001-04-22 01:56:15 ivan Exp $ +# $Id: svc_acct.export,v 1.19 2001-05-08 10:44:17 ivan Exp $ # # Create and export password files: passwd, passwd.adjunct, shadow, # acp_passwd, acp_userinfo, acp_dialup, users @@ -38,7 +38,10 @@ # ivan@sisd.com 98-sep-18 # # $Log: svc_acct.export,v $ -# Revision 1.18 2001-04-22 01:56:15 ivan +# Revision 1.19 2001-05-08 10:44:17 ivan +# fix for OO Net::SCP +# +# Revision 1.18 2001/04/22 01:56:15 ivan # get rid of FS::SSH.pm (became Net::SSH and Net::SCP on CPAN) # # Revision 1.17 2001/02/21 23:48:19 ivan @@ -349,10 +352,11 @@ close USERS; my($shellmachine); foreach $shellmachine (@shellmachines) { - scp("$spooldir/passwd","root\@$shellmachine:/etc/passwd.new") - == 0 or die "scp error: $!"; - scp("$spooldir/shadow","root\@$shellmachine:/etc/shadow.new") - == 0 or die "scp error: $!"; + my $scp = new Net::SCP; + $scp->scp("$spooldir/passwd","root\@$shellmachine:/etc/passwd.new") + or die "scp error: ". $scp->{errstr}; + $scp->scp("$spooldir/shadow","root\@$shellmachine:/etc/shadow.new") + or die "scp error: ". $scp->{errstr}; ssh("root\@$shellmachine", "( ". "mv /etc/passwd.new /etc/passwd; ". @@ -364,10 +368,11 @@ foreach $shellmachine (@shellmachines) { my($bsdshellmachine); foreach $bsdshellmachine (@bsdshellmachines) { - scp("$spooldir/passwd","root\@$bsdshellmachine:/etc/passwd.new") - == 0 or die "scp error: $!"; - scp("$spooldir/master.passwd","root\@$bsdshellmachine:/etc/master.passwd.new") - == 0 or die "scp error: $!"; + my $scp = new Net::SCP; + $scp->scp("$spooldir/passwd","root\@$bsdshellmachine:/etc/passwd.new") + or die "scp error: ". $scp->{errstr}; + $scp->scp("$spooldir/master.passwd","root\@$bsdshellmachine:/etc/master.passwd.new") + or die "scp error: ". $scp->{errstr}; ssh("root\@$bsdshellmachine", "( ". "mv /etc/passwd.new /etc/passwd; ". @@ -379,10 +384,11 @@ foreach $bsdshellmachine (@bsdshellmachines) { my($nismachine); foreach $nismachine (@nismachines) { - scp("$spooldir/passwd","root\@$nismachine:/etc/global/passwd") - == 0 or die "scp error: $!"; - scp("$spooldir/shadow","root\@$nismachine:/etc/global/shadow") - == 0 or die "scp error: $!"; + my $scp = new Net::SCP; + $scp->scp("$spooldir/passwd","root\@$nismachine:/etc/global/passwd") + or die "scp error: ". $scp->{errstr}; + $scp->scp("$spooldir/shadow","root\@$nismachine:/etc/global/shadow") + or die "scp error: ". $scp->{errstr}; ssh("root\@$nismachine", "( ". "cd /var/yp; make; ". @@ -393,10 +399,11 @@ foreach $nismachine (@nismachines) { my($erpcdmachine); foreach $erpcdmachine (@erpcdmachines) { - scp("$spooldir/acp_passwd","root\@$erpcdmachine:/usr/annex/acp_passwd") - == 0 or die "scp error: $!"; - scp("$spooldir/acp_dialup","root\@$erpcdmachine:/usr/annex/acp_dialup") - == 0 or die "scp error: $!"; + my $scp = new Net::SCP; + $scp->scp("$spooldir/acp_passwd","root\@$erpcdmachine:/usr/annex/acp_passwd") + or die "scp error: ". $scp->{errstr}; + $scp->scp("$spooldir/acp_dialup","root\@$erpcdmachine:/usr/annex/acp_dialup") + or die "scp error: ". $scp->{errstr}; ssh("root\@$erpcdmachine", "( ". "kill -USR1 \`cat /usr/annex/erpcd.pid\'". @@ -407,8 +414,9 @@ foreach $erpcdmachine (@erpcdmachines) { my($radiusmachine); foreach $radiusmachine (@radiusmachines) { - scp("$spooldir/users","root\@$radiusmachine:/etc/raddb/users") - == 0 or die "scp error: $!"; + my $scp = new Net::SCP; + $scp->scp("$spooldir/users","root\@$radiusmachine:/etc/raddb/users") + or die "scp error: ". $scp->{errstr}; ssh("root\@$radiusmachine", "( ". "builddbm". @@ -426,10 +434,14 @@ foreach my $icradiusmachine ( @icradiusmachines ) { sleep 2; print WRITER "LOCK TABLES radcheck WRITE, radreply WRITE;\n"; foreach my $file ( glob("radcheck.*") ) { - scp($file,"root\@$machine:$icradius_mysqldest/$db/$file"); + my $scp = new Net::SCP; + $scp->scp($file,"root\@$machine:$icradius_mysqldest/$db/$file") + or die "scp error: ". $scp->{errstr}; } foreach my $file ( glob("radreply.*") ) { - scp($file,"root\@$machine:$icradius_mysqldest/$db/$file"); + my $scp = new Net::SCP; + $scp->scp($file,"root\@$machine:$icradius_mysqldest/$db/$file") + or die "scp error: ". $scp->{errstr}; } close WRITER; } diff --git a/bin/svc_acct_sm.export b/bin/svc_acct_sm.export index a0938caf2..d7a7840f1 100755 --- a/bin/svc_acct_sm.export +++ b/bin/svc_acct_sm.export @@ -1,6 +1,6 @@ #!/usr/bin/perl -Tw # -# $Id: svc_acct_sm.export,v 1.9 2001-04-22 01:56:15 ivan Exp $ +# $Id: svc_acct_sm.export,v 1.10 2001-05-08 10:44:17 ivan Exp $ # # Create and export config files for sendmail, qmail # @@ -42,7 +42,10 @@ # /var/spool/freeside/conf and sendmail updates ivan@sisd.com 98-aug-14 # # $Log: svc_acct_sm.export,v $ -# Revision 1.9 2001-04-22 01:56:15 ivan +# Revision 1.10 2001-05-08 10:44:17 ivan +# fix for OO Net::SCP +# +# Revision 1.9 2001/04/22 01:56:15 ivan # get rid of FS::SSH.pm (became Net::SSH and Net::SCP on CPAN) # # Revision 1.8 2000/07/06 03:37:24 ivan @@ -211,10 +214,11 @@ close VIRTUALDOMAINS; my($sendmailmachine); foreach $sendmailmachine (@sendmailmachines) { - scp("$spooldir/sendmail.cw","root\@$sendmailmachine:$sendmailconfigpath/sendmail.cw.new") - == 0 or die "scp error: $!"; - scp("$spooldir/virtusertable","root\@$sendmailmachine:$sendmailconfigpath/virtusertable.new") - == 0 or die "scp error: $!"; + my $scp = new Net::SCP; + $scp->scp("$spooldir/sendmail.cw","root\@$sendmailmachine:$sendmailconfigpath/sendmail.cw.new") + or die "scp error: ". $scp->{errstr}; + $scp->scp("$spooldir/virtusertable","root\@$sendmailmachine:$sendmailconfigpath/virtusertable.new") + or die "scp error: ". $scp->{errstr}; ssh("root\@$sendmailmachine", "( ". "mv $sendmailconfigpath/sendmail.cw.new $sendmailconfigpath/sendmail.cw; ". @@ -227,12 +231,13 @@ foreach $sendmailmachine (@sendmailmachines) { my($qmailmachine); foreach $qmailmachine (@qmailmachines) { - scp("$spooldir/recipientmap","root\@$qmailmachine:/var/qmail/control/recipientmap") - == 0 or die "scp error: $!"; - scp("$spooldir/virtualdomains","root\@$qmailmachine:/var/qmail/control/virtualdomains") - == 0 or die "scp error: $!"; - scp("$spooldir/rcpthosts","root\@$qmailmachine:/var/qmail/control/rcpthosts") - == 0 or die "scp error: $!"; + my $scp = new Net::SCP; + $scp->scp("$spooldir/recipientmap","root\@$qmailmachine:/var/qmail/control/recipientmap") + or die "scp error: ". $scp->{errstr}; + $scp->scp("$spooldir/virtualdomains","root\@$qmailmachine:/var/qmail/control/virtualdomains") + or die "scp error: ". $scp->{errstr}; + $scp->scp("$spooldir/rcpthosts","root\@$qmailmachine:/var/qmail/control/rcpthosts") + or die "scp error: ". $scp->{errstr}; #ssh("root\@$qmailmachine","/etc/init.d/qmail restart") # == 0 or die "ssh error: $!"; } -- cgit v1.2.1 From 42a5e04d9d5520be1fe22b8c0062a39d374a1c3e Mon Sep 17 00:00:00 2001 From: ivan Date: Sun, 3 Jun 2001 14:16:11 +0000 Subject: allow empty refund reasons --- bin/fs-setup | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'bin') diff --git a/bin/fs-setup b/bin/fs-setup index 545c6a4df..c1e87c8d6 100755 --- a/bin/fs-setup +++ b/bin/fs-setup @@ -1,6 +1,6 @@ #!/usr/bin/perl -Tw # -# $Id: fs-setup,v 1.36 2001-04-15 12:56:31 ivan Exp $ +# $Id: fs-setup,v 1.37 2001-06-03 14:16:11 ivan Exp $ # # ivan@sisd.com 97-nov-8,9 # @@ -32,7 +32,10 @@ # fix radius attributes ivan@sisd.com 98-sep-27 # # $Log: fs-setup,v $ -# Revision 1.36 2001-04-15 12:56:31 ivan +# Revision 1.37 2001-06-03 14:16:11 ivan +# allow empty refund reasons +# +# Revision 1.36 2001/04/15 12:56:31 ivan # s/dbdef/DBIx::DBSchema/ # # Revision 1.35 2001/04/15 09:36:43 ivan @@ -422,7 +425,7 @@ sub tables_hash_hack { '_date', @date_type, 'amount', @money_type, 'otaker', 'varchar', '', 8, - 'reason', 'varchar', '', 255, + 'reason', 'varchar', 'NULL', 255, ], 'primary_key' => 'crednum', 'unique' => [ [] ], -- cgit v1.2.1 From e1ac5ad82d0a77d9aee14b275950642ef588db54 Mon Sep 17 00:00:00 2001 From: ivan Date: Wed, 20 Jun 2001 08:33:42 +0000 Subject: > Use of uninitialized value in concatenation (.) at svc_acct.export line > 276. --- bin/svc_acct.export | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) (limited to 'bin') diff --git a/bin/svc_acct.export b/bin/svc_acct.export index 1c3ffa243..822f70a9d 100755 --- a/bin/svc_acct.export +++ b/bin/svc_acct.export @@ -1,6 +1,6 @@ #!/usr/bin/perl -w # -# $Id: svc_acct.export,v 1.19 2001-05-08 10:44:17 ivan Exp $ +# $Id: svc_acct.export,v 1.20 2001-06-20 08:33:42 ivan Exp $ # # Create and export password files: passwd, passwd.adjunct, shadow, # acp_passwd, acp_userinfo, acp_dialup, users @@ -38,7 +38,11 @@ # ivan@sisd.com 98-sep-18 # # $Log: svc_acct.export,v $ -# Revision 1.19 2001-05-08 10:44:17 ivan +# Revision 1.20 2001-06-20 08:33:42 ivan +# > Use of uninitialized value in concatenation (.) at svc_acct.export line +# > 276. +# +# Revision 1.19 2001/05/08 10:44:17 ivan # fix for OO Net::SCP # # Revision 1.18 2001/04/22 01:56:15 ivan @@ -118,7 +122,10 @@ if ( $icradiusmachines && $conf->exists('icradius_secrets') ) { $icradius_dbh = dbh; } -my $textradiusprepend = $conf->config('textradiusprepend'); +my $textradiusprepend = + $conf->exists('textradiusprepend') + ? $conf->config('textradiusprepend') + : ''; my(@saltset)= ( 'a'..'z' , 'A'..'Z' , '0'..'9' , '.' , '/' ); require 5.004; #srand(time|$$); -- cgit v1.2.1 From 6d49710a4eaaa51438b42059c2d97f1d99e7a243 Mon Sep 17 00:00:00 2001 From: ivan Date: Mon, 30 Jul 2001 06:07:47 +0000 Subject: allow !! for locked accounts instead of changing to *SUSPENDED* --- bin/svc_acct.export | 8 ++++++-- bin/svc_acct.import | 11 +++++++---- 2 files changed, 13 insertions(+), 6 deletions(-) (limited to 'bin') diff --git a/bin/svc_acct.export b/bin/svc_acct.export index 822f70a9d..7e92c61e8 100755 --- a/bin/svc_acct.export +++ b/bin/svc_acct.export @@ -1,6 +1,6 @@ #!/usr/bin/perl -w # -# $Id: svc_acct.export,v 1.20 2001-06-20 08:33:42 ivan Exp $ +# $Id: svc_acct.export,v 1.21 2001-07-30 06:07:46 ivan Exp $ # # Create and export password files: passwd, passwd.adjunct, shadow, # acp_passwd, acp_userinfo, acp_dialup, users @@ -38,7 +38,10 @@ # ivan@sisd.com 98-sep-18 # # $Log: svc_acct.export,v $ -# Revision 1.20 2001-06-20 08:33:42 ivan +# Revision 1.21 2001-07-30 06:07:46 ivan +# allow !! for locked accounts instead of changing to *SUSPENDED* +# +# Revision 1.20 2001/06/20 08:33:42 ivan # > Use of uninitialized value in concatenation (.) at svc_acct.export line # > 276. # @@ -191,6 +194,7 @@ foreach $svc_acct (@svc_acct) { my($cpassword,$rpassword); if ( ( length($password) <= 8 ) && ( $password ne '*' ) + && ( $password ne '!!' ) && ( $password ne '' ) ) { $cpassword=crypt($password, diff --git a/bin/svc_acct.import b/bin/svc_acct.import index 2e51a8b2c..eaf0c03c5 100755 --- a/bin/svc_acct.import +++ b/bin/svc_acct.import @@ -1,6 +1,6 @@ #!/usr/bin/perl -Tw # -# $Id: svc_acct.import,v 1.14 2001-05-07 15:24:15 ivan Exp $ +# $Id: svc_acct.import,v 1.15 2001-07-30 06:07:47 ivan Exp $ # # ivan@sisd.com 98-mar-9 # @@ -17,7 +17,10 @@ # don't import /var/spool/freeside/conf/shells! ivan@sisd.com 98-aug-13 # # $Log: svc_acct.import,v $ -# Revision 1.14 2001-05-07 15:24:15 ivan +# Revision 1.15 2001-07-30 06:07:47 ivan +# allow !! for locked accounts instead of changing to *SUSPENDED* +# +# Revision 1.14 2001/05/07 15:24:15 ivan # s/!/*/ # # Revision 1.13 2001/05/05 08:51:16 ivan @@ -206,8 +209,8 @@ my(%password); while () { chop; my($username,$password)=split(/:/); - $password =~ s/^\!$/\*/; - $password =~ s/\!+/\*SUSPENDED\* /; + #$password =~ s/^\!$/\*/; + #$password =~ s/\!+/\*SUSPENDED\* /; $password{$username}=$password; } -- cgit v1.2.1 From 51984ac3d3da3006809c6866fdecd4ad83610731 Mon Sep 17 00:00:00 2001 From: ivan Date: Mon, 30 Jul 2001 07:36:04 +0000 Subject: templates!!! --- bin/fs-setup | 39 +++++++++++++++++++++++++++++++-- bin/masonize | 70 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ bin/pod2x | 8 ++++--- 3 files changed, 112 insertions(+), 5 deletions(-) create mode 100755 bin/masonize (limited to 'bin') diff --git a/bin/fs-setup b/bin/fs-setup index c1e87c8d6..1113966f8 100755 --- a/bin/fs-setup +++ b/bin/fs-setup @@ -1,6 +1,6 @@ #!/usr/bin/perl -Tw # -# $Id: fs-setup,v 1.37 2001-06-03 14:16:11 ivan Exp $ +# $Id: fs-setup,v 1.38 2001-07-30 07:36:04 ivan Exp $ # # ivan@sisd.com 97-nov-8,9 # @@ -32,7 +32,10 @@ # fix radius attributes ivan@sisd.com 98-sep-27 # # $Log: fs-setup,v $ -# Revision 1.37 2001-06-03 14:16:11 ivan +# Revision 1.38 2001-07-30 07:36:04 ivan +# templates!!! +# +# Revision 1.37 2001/06/03 14:16:11 ivan # allow empty refund reasons # # Revision 1.36 2001/04/15 12:56:31 ivan @@ -177,12 +180,24 @@ separated by whitespace. END my @attributes = map { s/\-/_/g; $_; } split(" ",&getvalue); +print "\n\n", <); chop $x; $x; } +sub _yesno { + print " [y/N]:"; + my $x = scalar(); + $x =~ /^y/i; +} + ### my($char_d) = 80; #default maxlength for text fields @@ -214,6 +229,12 @@ my($dbdef) = new DBIx::DBSchema ( map { ); } (keys %tables) ); +#remove ship_ from cust_main +unless ($ship) { + my $cust_main = $dbdef->table('cust_main'); + $cust_main->delcolumn($_) foreach ( grep /^ship_/, $cust_main->columns ); +} + #add radius attributes to svc_acct my($svc_acct)=$dbdef->table('svc_acct'); @@ -452,6 +473,20 @@ sub tables_hash_hack { 'daytime', 'varchar', 'NULL', 20, 'night', 'varchar', 'NULL', 20, 'fax', 'varchar', 'NULL', 12, + 'ship_last', 'varchar', 'NULL', $char_d, +# 'ship_middle', 'varchar', 'NULL', $char_d, + 'ship_first', 'varchar', 'NULL', $char_d, + 'ship_company', 'varchar', 'NULL', $char_d, + 'ship_address1', 'varchar', 'NULL', $char_d, + 'ship_address2', 'varchar', 'NULL', $char_d, + 'ship_city', 'varchar', 'NULL', $char_d, + 'ship_county', 'varchar', 'NULL', $char_d, + 'ship_state', 'varchar', 'NULL', $char_d, + 'ship_zip', 'varchar', 'NULL', 10, + 'ship_country', 'char', 'NULL', 2, + 'ship_daytime', 'varchar', 'NULL', 20, + 'ship_night', 'varchar', 'NULL', 20, + 'ship_fax', 'varchar', 'NULL', 12, 'payby', 'char', '', 4, 'payinfo', 'varchar', 'NULL', 16, #'paydate', @date_type, diff --git a/bin/masonize b/bin/masonize new file mode 100755 index 000000000..475c9a6bf --- /dev/null +++ b/bin/masonize @@ -0,0 +1,70 @@ +#!/usr/bin/perl + +foreach $file ( split(/\n/, `find . -depth -print | grep cgi\$`) ) { + open(F,$file) or die "can't open $file for reading: $!"; + @file = ; + #print "$file ". scalar(@file). "\n"; + close $file; + system("chmod u+w $file"); + open(W,">$file") or die "can't open $file for writing: $!"; + select W; $| = 1; select STDOUT; + $all = join('',@file); + + $mode = 'html'; + while ( length($all) ) { + + if ( $mode eq 'html' ) { + + if ( $all =~ /^(.+?)(<%=?.*)$/s && $1 !~ /<%/s ) { + print W $1; + $all = $2; + next; + } elsif ( $all =~ /^<%=(.*)$/s ) { + print W '<%'; + $all = $1; + $mode = 'perlv'; + #die; + next; + } elsif ( $all =~ /^<%(.*)$/s ) { + print W "\n"; + $all = $1; + $mode = 'perlc'; + next; + } elsif ( $all !~ /<%/s ) { + print W $all; + last; + } else { + warn length($all); die; + } + die; + + } elsif ( $mode eq 'perlv' ) { + + if ( $all =~ /^(.*?%>)(.*)$/s ) { + print W $1; + $all=$2; + $mode = 'html'; + next; + } + die 'unterminated <%= ???'; + + } elsif ( $mode eq 'perlc' ) { + + if ( $all =~ /^([^\n]*?)%>(.*)$/s ) { + print W "%$1\n"; + $all=$2; + $mode='html'; + next; + } + if ( $all =~ /^([^\n]*)\n(.*)$/s ) { + print W "%$1\n"; + $all=$2; + next; + } + + } else { die }; + + } + + close W; +} diff --git a/bin/pod2x b/bin/pod2x index 2c10a30d0..8c020062c 100755 --- a/bin/pod2x +++ b/bin/pod2x @@ -6,12 +6,14 @@ my $site_perl = "./FS"; #my $catman = "./catman"; #my $catman = "./htdocs/docs/man"; -my $html = "./htdocs/docs/man"; +#my $html = "./htdocs/docs/man"; +my $html = "./httemplate/docs/man"; $|=1; -die "Can't find $site_perl and $catman" - unless [ -d $site_perl ] && [ -d $catman ] && [ -d $html ]; +die "Can't find $site_perl" unless -d $site_perl; +#die "Can't find $catman" unless -d $catman; +die "Can't find $html" unless -d $html; foreach my $file ( glob("$site_perl/*.pm"), -- cgit v1.2.1 From e8dd9b3bbf139e1a21180a1efc81129f01d2d18b Mon Sep 17 00:00:00 2001 From: ivan Date: Mon, 30 Jul 2001 07:42:39 +0000 Subject: need an DBIx::DBSchema with delcolumn --- bin/fs-setup | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'bin') diff --git a/bin/fs-setup b/bin/fs-setup index 1113966f8..9075ca2a9 100755 --- a/bin/fs-setup +++ b/bin/fs-setup @@ -1,6 +1,6 @@ #!/usr/bin/perl -Tw # -# $Id: fs-setup,v 1.38 2001-07-30 07:36:04 ivan Exp $ +# $Id: fs-setup,v 1.39 2001-07-30 07:42:39 ivan Exp $ # # ivan@sisd.com 97-nov-8,9 # @@ -32,7 +32,10 @@ # fix radius attributes ivan@sisd.com 98-sep-27 # # $Log: fs-setup,v $ -# Revision 1.38 2001-07-30 07:36:04 ivan +# Revision 1.39 2001-07-30 07:42:39 ivan +# need an DBIx::DBSchema with delcolumn +# +# Revision 1.38 2001/07/30 07:36:04 ivan # templates!!! # # Revision 1.37 2001/06/03 14:16:11 ivan @@ -144,7 +147,7 @@ BEGIN { $FS::Record::setup_hack = 1; } use strict; use DBI; -use DBIx::DBSchema; +use DBIx::DBSchema 0.18; use DBIx::DBSchema::Table; use DBIx::DBSchema::Column; use DBIx::DBSchema::ColGroup::Unique; -- cgit v1.2.1 From 1dd250b6ff2c32f0bb9b4db7606066f34721e7d9 Mon Sep 17 00:00:00 2001 From: ivan Date: Sat, 11 Aug 2001 05:54:45 +0000 Subject: add comments field --- bin/fs-setup | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'bin') diff --git a/bin/fs-setup b/bin/fs-setup index 9075ca2a9..314a7c234 100755 --- a/bin/fs-setup +++ b/bin/fs-setup @@ -1,6 +1,6 @@ #!/usr/bin/perl -Tw # -# $Id: fs-setup,v 1.39 2001-07-30 07:42:39 ivan Exp $ +# $Id: fs-setup,v 1.40 2001-08-11 05:53:42 ivan Exp $ # # ivan@sisd.com 97-nov-8,9 # @@ -32,7 +32,10 @@ # fix radius attributes ivan@sisd.com 98-sep-27 # # $Log: fs-setup,v $ -# Revision 1.39 2001-07-30 07:42:39 ivan +# Revision 1.40 2001-08-11 05:53:42 ivan +# add comments field +# +# Revision 1.39 2001/07/30 07:42:39 ivan # need an DBIx::DBSchema with delcolumn # # Revision 1.38 2001/07/30 07:36:04 ivan @@ -498,6 +501,7 @@ sub tables_hash_hack { 'tax', 'char', 'NULL', 1, 'otaker', 'varchar', '', 8, 'refnum', 'int', '', '', + 'comments', 'varchar', 'NULL', '', ], 'primary_key' => 'custnum', 'unique' => [ [] ], -- cgit v1.2.1 From 4d513ff5a17bd3b697502b54c9516577a0a8d3e4 Mon Sep 17 00:00:00 2001 From: jeff Date: Sun, 12 Aug 2001 19:41:26 +0000 Subject: merging vpopmail support branch --- bin/fs-migrate-svc_acct_sm | 242 +++++++++++++++++ bin/fs-setup | 25 +- bin/svc_acct.export | 654 ++++++++++++++++++++++++++++++--------------- bin/svc_acct_sm.export | 254 ------------------ 4 files changed, 702 insertions(+), 473 deletions(-) create mode 100755 bin/fs-migrate-svc_acct_sm delete mode 100755 bin/svc_acct_sm.export (limited to 'bin') diff --git a/bin/fs-migrate-svc_acct_sm b/bin/fs-migrate-svc_acct_sm new file mode 100755 index 000000000..d0d4a94b6 --- /dev/null +++ b/bin/fs-migrate-svc_acct_sm @@ -0,0 +1,242 @@ +#!/usr/bin/perl -Tw +# +# $Id: fs-migrate-svc_acct_sm,v 1.2 2001-08-12 19:41:25 jeff Exp $ +# +# jeff@cmh.net 01-Jul-20 +# +# $Log: fs-migrate-svc_acct_sm,v $ +# Revision 1.2 2001-08-12 19:41:25 jeff +# merging vpopmail support branch +# +# Revision 1.1.2.1 2001/08/08 17:45:35 jeff +# initial vpopmail support +# +# +# +# Initial vpopmail changes +# + +#to delay loading dbdef until we're ready +#BEGIN { $FS::Record::setup_hack = 1; } + +use strict; +use Term::Query qw(query); +#use DBI; +#use DBIx::DBSchema; +#use DBIx::DBSchema::Table; +#use DBIx::DBSchema::Column; +#use DBIx::DBSchema::ColGroup::Unique; +#use DBIx::DBSchema::ColGroup::Index; +use FS::Conf; +use FS::UID qw(adminsuidsetup datasrc checkeuid getsecrets); +use FS::Record qw(qsearch qsearchs); +use FS::svc_domain; +use FS::svc_forward; +use vars qw( $conf $old_default_domain %part_domain_svc %part_acct_svc %part_forward_svc $svc_acct $svc_acct_sm $error); + +die "Not running uid freeside!" unless checkeuid(); + +my $user = shift or die &usage; +getsecrets($user); + +$conf = new FS::Conf; +$old_default_domain = $conf->config('domain'); + +#needs to match FS::Record +#my($dbdef_file) = "/usr/local/etc/freeside/dbdef.". datasrc; + +### +# This section would be the appropriate place to manipulate +# the schema & tables. +### + +## we need to add the domsvc to svc_acct +## we must add a svc_forward record.... +## I am thinking that the fields svcnum (int), destsvc (int), and +## dest (varchar (80)) are appropriate, with destsvc/dest an either/or +## much in the spirit of cust_main_invoice + +### +# massage the data +### + +my($dbh)=adminsuidsetup $user; + +$|=1; + +$FS::svc_acct::nossh_hack = 1; +$FS::svc_forward::nossh_hack = 1; +$FS::svc_domain::whois_hack = 1; + +%part_domain_svc=map { $_->svcpart, $_ } qsearch('part_svc',{'svcdb'=>'svc_domain'}); +%part_acct_svc=map { $_->svcpart, $_ } qsearch('part_svc',{'svcdb'=>'svc_acct'}); +%part_forward_svc=map { $_->svcpart, $_ } qsearch('part_svc',{'svcdb'=>'svc_forward'}); + +die "No services with svcdb svc_domain!\n" unless %part_domain_svc; +die "No services with svcdb svc_acct!\n" unless %part_acct_svc; +die "No services with svcdb svc_forward!\n" unless %part_forward_svc; + +my($svc_domain) = qsearchs('svc_domain', { 'domain' => $old_default_domain }); +if (! $svc_domain || $svc_domain->domain != $old_default_domain) { + print <); + chop $response; + if ($response =~ /^[yY]/) { + print "\n\n", &menu_domain_svc, "\n", < $old_default_domain, + 'svcpart' => $domain_svcpart, + 'action' => 'M', + }; +# $error=$svc_domain->insert && die "Error adding domain $old_default_domain: $error"; + $error=$svc_domain->insert; + die "Error adding domain $old_default_domain: $error" if $error; + }else{ + print <svc, sort keys %part_domain_svc ). "\n"; +} +sub menu_acct_svc { + ( join "\n", map "$_: ".$part_acct_svc{$_}->svc, sort keys %part_acct_svc ). "\n"; +} +sub menu_forward_svc { + ( join "\n", map "$_: ".$part_forward_svc{$_}->svc, sort keys %part_forward_svc ). "\n"; +} +sub getdomainpart { + $^W=0; # Term::Query isn't -w-safe + my $return = query "Enter part number:", 'irk', [ keys %part_domain_svc ]; + $^W=1; + $return; +} +sub getacctpart { + $^W=0; # Term::Query isn't -w-safe + my $return = query "Enter part number:", 'irk', [ keys %part_acct_svc ]; + $^W=1; + $return; +} +sub getforwardpart { + $^W=0; # Term::Query isn't -w-safe + my $return = query "Enter part number:", 'irk', [ keys %part_forward_svc ]; + $^W=1; + $return; +} + + +#migrate data + +my(@svc_accts) = qsearch('svc_acct', {}); +foreach $svc_acct (@svc_accts) { + my(@svc_acct_sms) = qsearch('svc_acct_sm', { + domuid => $svc_acct->getfield('uid'), + } + ); + + # Ok.. we've got the svc_acct record, and an array of svc_acct_sm's + # What do we do from here? + + # The intuitive: + # plop the svc_acct into the 'default domain' + # and then represent the svc_acct_sm's with svc_forwards + # they can be gussied up manually, later + # + # Perhaps better: + # when no svc_acct_sm exists, place svc_acct in 'default domain' + # when one svc_acct_sm exists, place svc_acct in corresponding + # domain & possibly create a svc_forward in 'default domain' + # when multiple svc_acct_sm's exists (in different domains) we'd + # better use the 'intuitive' approach. + # + # Specific way: + # as 'perhaps better,' but we may be able to guess which domain + # is correct by comparing the svcnum of domains to the username + # of the svc_acct + # + + # The intuitive way: + + my $def_acct = new FS::svc_acct ( { $svc_acct->hash } ); + $def_acct->setfield('domsvc' => $svc_domain->getfield('svcnum')); + $error = $def_acct->replace($svc_acct); + die "Error replacing svc_acct for " . $def_acct->username . " : $error" if $error; + + foreach $svc_acct_sm (@svc_acct_sms) { + + my($domrec)=qsearchs('svc_domain', { + svcnum => $svc_acct_sm->getfield('domsvc'), + }) || die "svc_acct_sm references invalid domsvc $svc_acct_sm->getfield('domsvc')\n"; + + if ($svc_acct_sm->getfield('domuser') =~ /^\*$/) { + + my($newdom) = new FS::svc_domain ( { $domrec->hash } ); + $newdom->setfield('catchall', $svc_acct->svcnum); + $newdom->setfield('action', "M"); + $error = $newdom->replace($domrec); + die "Error replacing svc_domain for (anything)@" . $domrec->domain . " : $error" if $error; + + } else { + + my($newacct) = new FS::svc_acct { + 'svcpart' => $pop_svcpart, + 'username' => $svc_acct_sm->getfield('domuser'), + 'domsvc' => $svc_acct_sm->getfield('domsvc'), + 'dir' => '/dev/null', + }; + $error = $newacct->insert; + die "Error adding svc_acct for " . $newacct->username . " : $error" if $error; + + my($newforward) = new FS::svc_forward { + 'svcpart' => $forward_svcpart, + 'srcsvc' => $newacct->getfield('svcnum'), + 'dstsvc' => $def_acct->getfield('svcnum'), + }; + $error = $newforward->insert; + die "Error adding svc_forward for " . $newacct->username ." : $error" if $error; + } + + $error = $svc_acct_sm->delete; + die "Error deleting svc_acct_sm for " . $svc_acct_sm->domuser ." : $error" if $error; + + }; + +}; + + +$dbh->commit or die $dbh->errstr; +$dbh->disconnect or die $dbh->errstr; + +print "svc_acct_sm records sucessfully migrated\n"; + +sub usage { + die "Usage:\n fs-migrate-svc_acct_sm user\n"; +} + diff --git a/bin/fs-setup b/bin/fs-setup index 314a7c234..a3e067bec 100755 --- a/bin/fs-setup +++ b/bin/fs-setup @@ -1,6 +1,6 @@ #!/usr/bin/perl -Tw # -# $Id: fs-setup,v 1.40 2001-08-11 05:53:42 ivan Exp $ +# $Id: fs-setup,v 1.41 2001-08-12 19:41:25 jeff Exp $ # # ivan@sisd.com 97-nov-8,9 # @@ -32,7 +32,10 @@ # fix radius attributes ivan@sisd.com 98-sep-27 # # $Log: fs-setup,v $ -# Revision 1.40 2001-08-11 05:53:42 ivan +# Revision 1.41 2001-08-12 19:41:25 jeff +# merging vpopmail support branch +# +# Revision 1.40 2001/08/11 05:53:42 ivan # add comments field # # Revision 1.39 2001/07/30 07:42:39 ivan @@ -271,7 +274,7 @@ my($part_svc)=$dbdef->table('part_svc'); #because of svc_acct_pop #foreach (grep /^svc_/, $dbdef->tables) { #foreach (qw(svc_acct svc_acct_sm svc_charge svc_domain svc_wo)) { -foreach (qw(svc_acct svc_acct_sm svc_domain svc_www)) { +foreach (qw(svc_acct svc_acct_sm svc_domain svc_forward svc_www)) { my($table)=$dbdef->table($_); my($col); foreach $col ( $table->columns ) { @@ -707,10 +710,11 @@ sub tables_hash_hack { 'quota', 'varchar', 'NULL', $char_d, 'slipip', 'varchar', 'NULL', 15, #four TINYINTs, bah. 'seconds', 'int', 'NULL', '', #uhhhh + 'domsvc', 'int', '', '', ], 'primary_key' => 'svcnum', 'unique' => [ [] ], - 'index' => [ ['username'] ], + 'index' => [ ['username'], ['domsvc'] ], }, 'svc_acct_sm' => { @@ -739,6 +743,7 @@ sub tables_hash_hack { 'columns' => [ 'svcnum', 'int', '', '', 'domain', 'varchar', '', $char_d, + 'catchall', 'int', '', '', ], 'primary_key' => 'svcnum', 'unique' => [ ['domain'] ], @@ -759,6 +764,18 @@ sub tables_hash_hack { 'index' => [ ['svcnum'] ], }, + 'svc_forward' => { + 'columns' => [ + 'svcnum', 'int', '', '', + 'srcsvc', 'int', '', '', + 'dstsvc', 'int', '', '', + 'dst', 'varchar', 'NULL', $char_d, + ], + 'primary_key' => 'svcnum', + 'unique' => [ [] ], + 'index' => [ ['srcsvc'], ['dstsvc'] ], + }, + 'svc_www' => { 'columns' => [ 'svcnum', 'int', '', '', diff --git a/bin/svc_acct.export b/bin/svc_acct.export index 7e92c61e8..a7a21b3e5 100755 --- a/bin/svc_acct.export +++ b/bin/svc_acct.export @@ -1,99 +1,42 @@ #!/usr/bin/perl -w # -# $Id: svc_acct.export,v 1.21 2001-07-30 06:07:46 ivan Exp $ +# $Id: svc_acct.export,v 1.22 2001-08-12 19:41:25 jeff Exp $ # -# Create and export password files: passwd, passwd.adjunct, shadow, -# acp_passwd, acp_userinfo, acp_dialup, users +# Create and export password, radius and vpopmail password files: +# passwd, passwd.adjunct, shadow, acp_passwd, acp_userinfo, acp_dialup +# users/assign, domains/vdomain/vpasswd +# Also export sendmail and qmail config files. # -# ivan@voicenet.com late august/september 96 -# (the password encryption bits were from melody) # -# use a temporary copy of svc_acct to minimize lock time on the real file, -# and skip blank entries. -# -# ivan@voicenet.com 96-Oct-6 -# -# change users / acp_dialup file formats -# ivan@voicenet.com 97-jan-28-31 -# -# change priority (after copies) to 19, not 10 -# ivan@voicenet.com 97-feb-5 -# -# added exit if stuff is already locked 97-apr-15 -# -# rewrite ivan@sisd.com 98-mar-9 -# -# Changed 'password' to '_password' because Pg6.3 reserves this word -# Added code to create a FreeBSD style master.passwd file -# bmccane@maxbaud.net 98-Apr-3 -# -# don't export non-root 0 UID's, even if they get put in the database -# ivan@sisd.com 98-jul-14 -# -# Uses Idle_Timeout, Port_Limit, Framed_Netmask and Framed_Route if they -# exist; need some way to support arbitrary radius fields. also -# /var/spool/freeside/conf/ ivan@sisd.com 98-jul-26, aug-9 -# -# OOPS! added arbitrary radius fields (pry 98-aug-16) but forgot to say so. -# ivan@sisd.com 98-sep-18 -# # $Log: svc_acct.export,v $ -# Revision 1.21 2001-07-30 06:07:46 ivan -# allow !! for locked accounts instead of changing to *SUSPENDED* -# -# Revision 1.20 2001/06/20 08:33:42 ivan -# > Use of uninitialized value in concatenation (.) at svc_acct.export line -# > 276. -# -# Revision 1.19 2001/05/08 10:44:17 ivan -# fix for OO Net::SCP -# -# Revision 1.18 2001/04/22 01:56:15 ivan -# get rid of FS::SSH.pm (became Net::SSH and Net::SCP on CPAN) -# -# Revision 1.17 2001/02/21 23:48:19 ivan -# add icradius_secrets config file to export to a non-Freeside MySQL database for -# ICRADIUS -# -# Revision 1.16 2000/07/06 13:23:29 ivan -# tyop +# Revision 1.22 2001-08-12 19:41:25 jeff +# merging vpopmail support branch # -# Revision 1.15 2000/07/06 08:57:28 ivan -# support for radius check attributes (except importing). poorly documented. -# -# Revision 1.14 2000/06/29 15:01:25 ivan -# another silly typo in svc_acct.export -# -# Revision 1.13 2000/06/28 12:37:28 ivan -# add support for config option textradiusprepend -# -# Revision 1.12 2000/06/15 14:07:02 ivan -# added ICRADIUS radreply table support, courtesy of Kenny Elliott -# -# Revision 1.11 2000/03/06 16:00:39 ivan -# sync up with working versoin -# -# Revision 1.2 1998/12/10 07:23:15 ivan -# use FS::Conf, need user (for datasrc) # use strict; use vars qw($conf); +use Archive::Tar; use Fcntl qw(:flock); +use File::Path; use IO::Handle; -use DBI; use FS::Conf; use Net::SSH qw(ssh); use Net::SCP qw(scp); use FS::UID qw(adminsuidsetup datasrc dbh); -use FS::Record qw(qsearch fields); +use FS::Record qw(qsearch qsearchs fields); use FS::svc_acct; +use FS::svc_domain; +use FS::svc_forward; my $user = shift or die &usage; adminsuidsetup $user; $conf = new FS::Conf; +my $userpolicy = $conf->config('username_policy') + if $conf->exists('username_policy'); + my @shellmachines = $conf->config('shellmachines') if $conf->exists('shellmachines'); @@ -130,6 +73,29 @@ my $textradiusprepend = ? $conf->config('textradiusprepend') : ''; +my @vpopmailmachines = $conf->config('vpopmailmachines') + if $conf->exists('vpopmailmachines'); + +my ($machine, $vpopdir, $vpopuid, $vpopgid) = split (/\s+/, $vpopmailmachines[0]); + +my($shellmachine, @qmailmachines); +if ( $conf->exists('qmailmachines') ) { + $shellmachine = $conf->config('shellmachine'); + @qmailmachines = $conf->config('qmailmachines'); +} + +my(@sendmailmachines, $sendmailconfigpath, $sendmailrestart); +if ( $conf->exists('sendmailmachines') ) { + @sendmailmachines = $conf->config('sendmailmachines'); + $sendmailconfigpath = $conf->config('sendmailconfigpath') || '/etc'; + $sendmailrestart = $conf->config('sendmailrestart'); +} + +my $mydomain = $conf->config('domain') if $conf->exists('domain'); + + + + my(@saltset)= ( 'a'..'z' , 'A'..'Z' , '0'..'9' , '.' , '/' ); require 5.004; #srand(time|$$); @@ -142,42 +108,81 @@ unless ( flock(EXPORT,LOCK_EX|LOCK_NB) ) { seek(EXPORT,0,0); my($pid)=; chop($pid); - #no reason to start loct of blocking processes + #no reason to start lots of blocking processes die "Is another export process running under pid $pid?\n"; } seek(EXPORT,0,0); print EXPORT $$,"\n"; -my(@svc_acct)=qsearch('svc_acct',{}); +my(@svc_domain)=qsearch('svc_domain',{}); ( open(MASTER,">$spooldir/master.passwd") - and flock(MASTER,LOCK_EX|LOCK_NB) -) or die "Can't open $spooldir/master.passwd: $!"; + and flock(MASTER,LOCK_EX|LOCK_NB) +) or die "Can't open $spooldir/.master.passwd: $!"; ( open(PASSWD,">$spooldir/passwd") and flock(PASSWD,LOCK_EX|LOCK_NB) ) or die "Can't open $spooldir/passwd: $!"; ( open(SHADOW,">$spooldir/shadow") - and flock(SHADOW,LOCK_EX|LOCK_NB) + and flock(SHADOW,LOCK_EX|LOCK_NB) ) or die "Can't open $spooldir/shadow: $!"; -( open(ACP_PASSWD,">$spooldir/acp_passwd") - and flock (ACP_PASSWD,LOCK_EX|LOCK_NB) +( open(ACP_PASSWD,">$spooldir/acp_passwd") + and flock(ACP_PASSWD,LOCK_EX|LOCK_NB) ) or die "Can't open $spooldir/acp_passwd: $!"; -( open (ACP_DIALUP,">$spooldir/acp_dialup") - and flock(ACP_DIALUP,LOCK_EX|LOCK_NB) +( open(ACP_DIALUP,">$spooldir/acp_dialup") + and flock(ACP_DIALUP,LOCK_EX|LOCK_NB) ) or die "Can't open $spooldir/acp_dialup: $!"; -( open (USERS,">$spooldir/users") - and flock(USERS,LOCK_EX|LOCK_NB) +( open(USERS,">$spooldir/users") + and flock(USERS,LOCK_EX|LOCK_NB) ) or die "Can't open $spooldir/users: $!"; +( open(ASSIGN,">$spooldir/assign") + and flock(ASSIGN,LOCK_EX|LOCK_NB) +) or die "Can't open $spooldir/assign: $!"; +( open(RCPTHOSTS,">$spooldir/rcpthosts") + and flock(RCPTHOSTS,LOCK_EX|LOCK_NB) +) or die "Can't open $spooldir/rcpthosts: $!"; +( open(VPOPRCPTHOSTS,">$spooldir/vpoprcpthosts") + and flock(VPOPRCPTHOSTS,LOCK_EX|LOCK_NB) +) or die "Can't open $spooldir/rcpthosts: $!"; +( open(RECIPIENTMAP,">$spooldir/recipientmap") + and flock(RECIPIENTMAP,LOCK_EX|LOCK_NB) +) or die "Can't open $spooldir/recipientmap: $!"; +( open(VIRTUALDOMAINS,">$spooldir/virtualdomains") + and flock(VIRTUALDOMAINS,LOCK_EX|LOCK_NB) +) or die "Can't open $spooldir/virtualdomains: $!"; +( open(VPOPVIRTUALDOMAINS,">$spooldir/vpopvirtualdomains") + and flock(VPOPVIRTUALDOMAINS,LOCK_EX|LOCK_NB) +) or die "Can't open $spooldir/virtualdomains: $!"; +( open(VIRTUSERTABLE,">$spooldir/virtusertable") + and flock(VIRTUSERTABLE,LOCK_EX|LOCK_NB) +) or die "Can't open $spooldir/virtusertable: $!"; +( open(SENDMAIL_CW,">$spooldir/sendmail.cw") + and flock(SENDMAIL_CW,LOCK_EX|LOCK_NB) +) or die "Can't open $spooldir/sendmail.cw: $!"; + + + chmod 0644, "$spooldir/passwd", "$spooldir/acp_dialup", + "$spooldir/assign", + "$spooldir/sendmail.cw", + "$spooldir/virtusertable", + "$spooldir/rcpthosts", + "$spooldir/vpoprcpthosts", + "$spooldir/recipientmap", + "$spooldir/virtualdomains", + "$spooldir/vpopvirtualdomains", + ; chmod 0600, "$spooldir/master.passwd", - "$spooldir/acp_passwd", + "$spooldir/acp_passwd", "$spooldir/shadow", "$spooldir/users", ; +rmtree"$spooldir/domains", 0, 1; +mkdir "$spooldir/domains", 0700; + if ( $icradiusmachines ) { my $sth = $icradius_dbh->prepare("DELETE FROM radcheck"); $sth->execute or die "Can't reset radcheck table: ". $sth->errstr; @@ -187,168 +192,321 @@ if ( $icradiusmachines ) { setpriority(0,0,10); -my($svc_acct); -foreach $svc_acct (@svc_acct) { - - my($password)=$svc_acct->getfield('_password'); - my($cpassword,$rpassword); - if ( ( length($password) <= 8 ) - && ( $password ne '*' ) - && ( $password ne '!!' ) - && ( $password ne '' ) - ) { - $cpassword=crypt($password, - $saltset[int(rand(64))].$saltset[int(rand(64))] - ); - $rpassword=$password; - } else { - $cpassword=$password; - $rpassword='UNIX'; - } - - if ( $svc_acct->uid =~ /^(\d+)$/ ) { - - die "Non-root user ". $svc_acct->username. " has 0 UID!" - if $svc_acct->uid == 0 && $svc_acct->username ne 'root'; +my %usernames; ## this hack helps keep the passwd files sane +my @sendmail; + +my $svc_domain; +foreach $svc_domain (sort {$a->domain cmp $b->domain} @svc_domain) { + + my($domain)=$svc_domain->domain; + print RCPTHOSTS "$domain\n.$domain\n"; + print VPOPRCPTHOSTS "$domain\n"; + print SENDMAIL_CW "$domain\n"; + + ### + # FORMAT OF THE ASSIGN/USERS FILE HERE + print ASSIGN join(":", + "+" . $domain . "-", + $domain, + $vpopuid, + $vpopgid, + $vpopdir . "/domains/" . $domain, + "-", + "", + "", + ), "\n"; + + (mkdir "$spooldir/domains/" . $domain, 0700) + or die "Can't create $spooldir/domains/" . $domain .": $!"; + + ( open(QMAILDEFAULT,">$spooldir/domains/" . $domain . "/.qmail-default") + and flock(QMAILDEFAULT,LOCK_EX|LOCK_NB) + ) or die "Can't open $spooldir/domains/" . $domain . "/.qmail-default: $!"; + + ( open(VPASSWD,">$spooldir/domains/" . $domain . "/vpasswd") + and flock(VPASSWD,LOCK_EX|LOCK_NB) + ) or die "Can't open $spooldir/domains/" . $domain . "/vpasswd: $!"; + + my ($svc_acct); + + if ($svc_domain->catchall) { + $svc_acct = qsearchs('svc_acct', {'svcnum' => $svc_domain->catchall}); + die "Cannot find catchall account for domain $domain\n" unless $svc_acct; + + my $username = $svc_acct->username; + push @sendmail, "\@$domain\t$username\n"; + print VIRTUALDOMAINS "$domain:$username-$domain\n", + ".$domain:$username-$domain\n", + ; ### - # FORMAT OF FreeBSD MASTER PASSWD FILE HERE - print MASTER join(":", - $svc_acct->username, # User name - $cpassword, # Encrypted password - $svc_acct->uid, # User ID - $svc_acct->gid, # Group ID - "", # Login Class - "0", # Password Change Time - "0", # Password Expiration Time - $svc_acct->finger, # Users name - $svc_acct->dir, # Users home directory - $svc_acct->shell, # shell - ), "\n" ; + # FORMAT OF THE .QMAIL-DEFAULT FILE HERE + print QMAILDEFAULT "| $vpopdir/bin/vdelivermail \"\" $username\@$domain\n"; + }else{ ### - # FORMAT OF THE PASSWD FILE HERE - print PASSWD join(":", - $svc_acct->username, - 'x', # "##". $svc_acct->$username, - $svc_acct->uid, - $svc_acct->gid, - $svc_acct->finger, - $svc_acct->dir, - $svc_acct->shell, - ), "\n"; - - ### - # FORMAT OF THE SHADOW FILE HERE - print SHADOW join(":", - $svc_acct->username, - $cpassword, - '', - '', - '', - '', - '', - '', - '', - ), "\n"; - + # FORMAT OF THE .QMAIL-DEFAULT FILE HERE + print QMAILDEFAULT "| $vpopdir/bin/vdelivermail \"\" bounce-no-mailbox\n"; } - if ( $svc_acct->slipip ne '' ) { + print VPOPVIRTUALDOMAINS "$domain:$domain\n"; + + foreach $svc_acct (qsearch('svc_acct', {'domsvc' => $svc_domain->svcnum})) { + my($password)=$svc_acct->getfield('_password'); + my($cpassword,$rpassword); + if ( ( length($password) <= 8 ) + && ( $password ne '*' ) + && ( $password ne '!!' ) + && ( $password ne '' ) + ) { + $cpassword=crypt($password, + $saltset[int(rand(64))].$saltset[int(rand(64))] + ); + $rpassword=$password; + } else { + $cpassword=$password; + $rpassword='UNIX'; + } + + my $username; - ### - # FORMAT OF THE ACP_* FILES HERE - print ACP_PASSWD join(":", - $svc_acct->username, - $cpassword, - "0", - "0", - "", - "", - "", - ), "\n"; - - my($ip)=$svc_acct->slipip; - - unless ( $ip eq '0.0.0.0' || $svc_acct->slipip eq '0e0' ) { - print ACP_DIALUP $svc_acct->username, "\t*\t", $svc_acct->slipip, "\n"; + if ($mydomain && ($mydomain eq $svc_domain->domain)) { + $username=$svc_acct->username; + } elsif ($userpolicy =~ /^prepend domsvc$/) { + $username=$svc_acct->domsvc . $svc_acct->username; + } elsif ($userpolicy =~ /^append domsvc$/) { + $username=$svc_acct->username . $svc_acct->domsvc; + } elsif ($userpolicy =~ /^append domain$/) { + $username=$svc_acct->username . $svc_domain->domain; + } else { + die "Unknown policy in username_policy\n"; } - my %radreply = $svc_acct->radius_reply; - my %radcheck = $svc_acct->radius_check; + if ($svc_acct->dir ne '/dev/null' || $svc_acct->slipip ne '') { + if ($usernames{$username}++) { + die "Duplicate username detected: $username\n"; + } + } + + if ( $svc_acct->uid =~ /^(\d+)$/ ) { + + die "Non-root user ". $svc_acct->username. " has 0 UID!" + if $svc_acct->uid == 0 && $svc_acct->username ne 'root'; + + if ( $svc_acct->dir ne "/dev/null") { + + ### + # FORMAT OF FreeBSD MASTER PASSWD FILE HERE + print MASTER join(":", + $username, # User name + $cpassword, # Encrypted password + $svc_acct->uid, # User ID + $svc_acct->gid, # Group ID + "", # Login Class + "0", # Password Change Time + "0", # Password Expiration Time + $svc_acct->finger, # Users name + $svc_acct->dir, # Users home directory + $svc_acct->shell, # shell + ), "\n" ; + + + ### + # FORMAT OF THE PASSWD FILE HERE + print PASSWD join(":", + $username, + 'x', # "##". $username, + $svc_acct->uid, + $svc_acct->gid, + $svc_acct->finger, + $svc_acct->dir, + $svc_acct->shell, + ), "\n"; + + ### + # FORMAT OF THE SHADOW FILE HERE + print SHADOW join(":", + $username, + $cpassword, + '', + '', + '', + '', + '', + '', + '', + ), "\n"; + } - my $radcheck = join ", ", map { qq($_ = "$radcheck{$_}") } keys %radcheck; - $radcheck .= ", " if $radcheck; + ### + # FORMAT OF THE VPASSWD FILE HERE + print VPASSWD join(":", + $svc_acct->username, + $cpassword, + '1', + '0', + $svc_acct->username, + "$vpopdir/domains/" . $svc_domain->domain ."/" . $svc_acct->username, + 'NOQUOTA', + ), "\n"; - ### - # FORMAT OF THE USERS FILE HERE - print USERS - $svc_acct->username, - qq(\t${textradiusprepend}), - $radcheck, - qq(Password = "$rpassword"\n\t), - join ",\n\t", map { qq($_ = "$radreply{$_}") } keys %radreply; - - if ( $ip && $ip ne '0e0' ) { - #print USERS qq(,\n\tFramed-Address = "$ip"\n\n); - print USERS qq(,\n\tFramed-IP-Address = "$ip"\n\n); - } else { - print USERS qq(\n\n); } - ### - # ICRADIUS export - if ( $icradiusmachines ) { + if ( $svc_acct->slipip ne '' ) { - my $sth = $icradius_dbh->prepare( - "INSERT INTO radcheck ( id, UserName, Attribute, Value ) VALUES ( ". - join(", ", map { $icradius_dbh->quote( $_ ) } ( - '', - $svc_acct->username, - "Password", - $svc_acct->_password, - ) ). " )" - ); - $sth->execute or die "Can't insert into radcheck table: ". $sth->errstr; + ### + # FORMAT OF THE ACP_* FILES HERE + print ACP_PASSWD join(":", + $username, + $cpassword, + "0", + "0", + "", + "", + "", + ), "\n"; - foreach my $attribute ( keys %radcheck ) { + my($ip)=$svc_acct->slipip; + + unless ( $ip eq '0.0.0.0' || $svc_acct->slipip eq '0e0' ) { + print ACP_DIALUP $username, "\t*\t", $svc_acct->slipip, "\n"; + } + + my %radreply = $svc_acct->radius_reply; + my %radcheck = $svc_acct->radius_check; + + my $radcheck = join ", ", map { qq($_ = "$radcheck{$_}") } keys %radcheck; + $radcheck .= ", " if $radcheck; + + ### + # FORMAT OF THE USERS FILE HERE + print USERS + $username, + qq(\t${textradiusprepend}), + $radcheck, + qq(Password = "$rpassword"\n\t), + join ",\n\t", map { qq($_ = "$radreply{$_}") } keys %radreply; + + if ( $ip && $ip ne '0e0' ) { + #print USERS qq(,\n\tFramed-Address = "$ip"\n\n); + print USERS qq(,\n\tFramed-IP-Address = "$ip"\n\n); + } else { + print USERS qq(\n\n); + } + + ### + # ICRADIUS export + if ( $icradiusmachines ) { + my $sth = $icradius_dbh->prepare( "INSERT INTO radcheck ( id, UserName, Attribute, Value ) VALUES ( ". join(", ", map { $icradius_dbh->quote( $_ ) } ( '', - $svc_acct->username, - $attribute, - $radcheck{$attribute}, + $username, + "Password", + $svc_acct->_password, ) ). " )" ); $sth->execute or die "Can't insert into radcheck table: ". $sth->errstr; + + foreach my $attribute ( keys %radcheck ) { + my $sth = $icradius_dbh->prepare( + "INSERT INTO radcheck ( id, UserName, Attribute, Value ) VALUES ( ". + join(", ", map { $icradius_dbh->quote( $_ ) } ( + '', + $username, + $attribute, + $radcheck{$attribute}, + ) ). " )" + ); + $sth->execute or die "Can't insert into radcheck table: ". $sth->errstr; } + + foreach my $attribute ( keys %radreply ) { + my $sth = $icradius_dbh->prepare( + "INSERT INTO radreply (id, UserName, Attribute, Value) VALUES ( ". + join(", ", map { $icradius_dbh->quote( $_ ) } ( + '', + $username, + $attribute, + $radreply{$attribute}, + ) ). " )" + ); + $sth->execute or die "Can't insert into radreply table: ". $sth->errstr; } } - - foreach my $attribute ( keys %radreply ) { - my $sth = $icradius_dbh->prepare( - "INSERT INTO radreply (id, UserName, Attribute, Value) VALUES ( ". - join(", ", map { $icradius_dbh->quote( $_ ) } ( - '', - $svc_acct->username, - $attribute, - $radreply{$attribute}, - ) ). " )" - ); - $sth->execute or die "Can't insert into radreply table: ". $sth->errstr; + } + + ### + # vpopmail directory structure creation + + (mkdir "$spooldir/domains/" . $svc_domain->domain . "/" . $svc_acct->username, 0700) + or die "Can't create $spooldir/domains/" . $svc_domain->domain . "/" . $svc_acct->username . ": $!"; + (mkdir "$spooldir/domains/" . $svc_domain->domain . "/" . $svc_acct->username . "/Maildir", 0700) + or die "Can't create $spooldir/domains/" . $svc_domain->domain . "/" . $svc_acct->username . " /Maildir: $!"; + (mkdir "$spooldir/domains/" . $svc_domain->domain . "/" . $svc_acct->username . "/Maildir/cur", 0700) + or die "Can't create $spooldir/domains/" . $svc_domain->domain . "/" . $svc_acct->username . " /Maildir/cur: $!"; + (mkdir "$spooldir/domains/" . $svc_domain->domain . "/" . $svc_acct->username . "/Maildir/new", 0700) + or die "Can't create $spooldir/domains/" . $svc_domain->domain . "/" . $svc_acct->username . " /Maildir/new: $!"; + (mkdir "$spooldir/domains/" . $svc_domain->domain . "/" . $svc_acct->username . "/Maildir/tmp", 0700) + or die "Can't create $spooldir/domains/" . $svc_domain->domain . "/" . $svc_acct->username . " /Maildir/tmp: $!"; + + ( open(DOTQMAIL,">$spooldir/domains/" . $svc_domain->domain . "/" . $svc_acct->username . "/.qmail") + and flock(DOTQMAIL,LOCK_EX|LOCK_NB) + ) or die "Can't open $spooldir/domains/" . $svc_domain->domain . "/" . $svc_acct->username . "/.qmail: $!"; + + my($svc_forward); + foreach $svc_forward (qsearch('svc_forward', {'srcsvc' => $svc_acct->svcnum})) { + my($destination); + if ($svc_forward->dstsvc) { + my $dst_acct = qsearchs('svc_acct', {'svcnum' => $svc_forward->dstsvc}); + my $dst_domain = qsearchs('svc_domain', {'svcnum' => $dst_acct->domsvc}); + $destination = $dst_acct->username . '@' . $dst_domain->domain; + + if ($dst_domain->domain eq $mydomain) { + print VIRTUSERTABLE $svc_acct->username . "@" . $svc_domain->domain . + "\t" . $dst_acct->username . "\n"; + print RECIPIENTMAP $svc_acct->username . "@" . $svc_domain->domain . + ":$destination\n"; + } + } else { + $destination = $svc_forward->dst; } - + + ### + # FORMAT OF .QMAIL FILES HERE + print DOTQMAIL "$destination\n"; } + flock(DOTQMAIL,LOCK_UN); + close DOTQMAIL; + } + flock(VPASSWD,LOCK_UN); + flock(QMAILDEFAULT,LOCK_UN); + close VPASSWD; + close QMAILDEFAULT; + } +### +# FORMAT OF THE ASSIGN/USERS FILE FINAL LINE HERE +print ASSIGN ".\n"; + +print VIRTUSERTABLE @sendmail; + flock(MASTER,LOCK_UN); flock(PASSWD,LOCK_UN); flock(SHADOW,LOCK_UN); flock(ACP_DIALUP,LOCK_UN); flock(ACP_PASSWD,LOCK_UN); flock(USERS,LOCK_UN); +flock(ASSIGN,LOCK_UN); +flock(SENDMAIL_CW,LOCK_UN); +flock(VIRTUSERTABLE,LOCK_UN); +flock(RCPTHOSTS,LOCK_UN); +flock(VPOPRCPTHOSTS,LOCK_UN); +flock(RECIPIENTMAP,LOCK_UN); +flock(VPOPVIRTUALDOMAINS,LOCK_UN); close MASTER; close PASSWD; @@ -356,19 +514,26 @@ close SHADOW; close ACP_DIALUP; close ACP_PASSWD; close USERS; +close ASSIGN; +close SENDMAIL_CW; +close VIRTUSERTABLE; +close RCPTHOSTS; +close VPOPRCPTHOSTS; +close RECIPIENTMAP; +close VPOPVIRTUALDOMAINS; ### # export stuff # -my($shellmachine); -foreach $shellmachine (@shellmachines) { +my($ashellmachine); +foreach $ashellmachine (@shellmachines) { my $scp = new Net::SCP; - $scp->scp("$spooldir/passwd","root\@$shellmachine:/etc/passwd.new") + $scp->scp("$spooldir/passwd","root\@$ashellmachine:/etc/passwd.new") or die "scp error: ". $scp->{errstr}; - $scp->scp("$spooldir/shadow","root\@$shellmachine:/etc/shadow.new") + $scp->scp("$spooldir/shadow","root\@$ashellmachine:/etc/shadow.new") or die "scp error: ". $scp->{errstr}; - ssh("root\@$shellmachine", + ssh("root\@$ashellmachine", "( ". "mv /etc/passwd.new /etc/passwd; ". "mv /etc/shadow.new /etc/shadow; ". @@ -457,6 +622,65 @@ foreach my $icradiusmachine ( @icradiusmachines ) { close WRITER; } +my @args = ("/bin/tar", "c", "--force-local", "-C", "$spooldir", "-f", "$spooldir/vpoptarball", "domains"); + +system {$args[0]} @args; + +my($vpopmailmachine); +foreach $vpopmailmachine (@vpopmailmachines) { + my ($machine, $vpopdir, $vpopuid, $vpopgid) = split (/\s+/, $vpopmailmachine); + my $scp = new Net::SCP; + $scp->scp("$spooldir/vpoptarball","root\@$machine:vpoptarball") + or die "scp error: ". $scp->{errstr}; + ssh("root\@$machine", + "( ". + "tar xf vpoptarball; ". + "chown -R $vpopuid:$vpopgid domains; ". + "tar cf vpoptarball domains; ". + "cd $vpopdir; ". + "tar xf ~/vpoptarball; ". + " )" + ) + == 0 or die "ssh error: $!"; + + $scp->scp("$spooldir/assign","root\@$machine:/var/qmail/users/assign") + or die "scp error: ". $scp->{errstr}; + $scp->scp("$spooldir/vpopvirtualdomains","root\@$machine:/var/qmail/control/virtualdomains") + or die "scp error: ". $scp->{errstr}; + $scp->scp("$spooldir/vpoprcpthosts","root\@$machine:/var/qmail/control/rcpthosts") + or die "scp error: ". $scp->{errstr}; +} + +my($sendmailmachine); +foreach $sendmailmachine (@sendmailmachines) { + my $scp = new Net::SCP; + $scp->scp("$spooldir/sendmail.cw","root\@$sendmailmachine:$sendmailconfigpath/sendmail.cw.new") + or die "scp error: ". $scp->{errstr}; + $scp->scp("$spooldir/virtusertable","root\@$sendmailmachine:$sendmailconfigpath/virtusertable.new") + or die "scp error: ". $scp->{errstr}; + ssh("root\@$sendmailmachine", + "( ". + "mv $sendmailconfigpath/sendmail.cw.new $sendmailconfigpath/sendmail.cw; ". + "mv $sendmailconfigpath/virtusertable.new $sendmailconfigpath/virtusertable; ". + $sendmailrestart. + " )" + ) + == 0 or die "ssh error: $!"; +} + +my($qmailmachine); +foreach $qmailmachine (@qmailmachines) { + my $scp = new Net::SCP; + $scp->scp("$spooldir/recipientmap","root\@$qmailmachine:/var/qmail/control/recipientmap") + or die "scp error: ". $scp->{errstr}; + $scp->scp("$spooldir/virtualdomains","root\@$qmailmachine:/var/qmail/control/virtualdomains") + or die "scp error: ". $scp->{errstr}; + $scp->scp("$spooldir/rcpthosts","root\@$qmailmachine:/var/qmail/control/rcpthosts") + or die "scp error: ". $scp->{errstr}; + #ssh("root\@$qmailmachine","/etc/init.d/qmail restart") + # == 0 or die "ssh error: $!"; +} + unlink $spoollock; flock(EXPORT,LOCK_UN); close EXPORT; diff --git a/bin/svc_acct_sm.export b/bin/svc_acct_sm.export deleted file mode 100755 index d7a7840f1..000000000 --- a/bin/svc_acct_sm.export +++ /dev/null @@ -1,254 +0,0 @@ -#!/usr/bin/perl -Tw -# -# $Id: svc_acct_sm.export,v 1.10 2001-05-08 10:44:17 ivan Exp $ -# -# Create and export config files for sendmail, qmail -# -# (used to) Create and export VoiceNet_quasar.m4 -# -# ivan@voicenet.com late oct 96 -# -# change priority (after copies) to 19, not 10 -# ivan@voicenet.com 97-feb-5 -# -# put file in different place and run different script, as per matt and -# mohamed -# ivan@voicenet.com 97-mar-10 -# -# added exit if stuff is already locked ivan@voicenet.com 97-apr-15 -# -# removed mail2 -# ivan@voicenet.com 97-jul-10 -# -# rewrote lots of the bits, now exports qmail "virtualdomain", -# "recipientmap" and "rcpthosts" files as well -# -# ivan@voicenet.com 97-sep-4 -# -# adds ".extra" files -# -# ivan@voicenet.com 97-sep-29 -# -# added ".pp" files, ugh. -# -# ivan@voicenet.com 97-oct-1 -# -# rewrite ivan@sisd.com 98-mar-9 -# -# now can create .qmail-default files ivan@sisd.com 98-mar-10 -# -# put example $my_domain declaration in ivan@sisd.com 98-mar-23 -# -# /var/spool/freeside/conf and sendmail updates ivan@sisd.com 98-aug-14 -# -# $Log: svc_acct_sm.export,v $ -# Revision 1.10 2001-05-08 10:44:17 ivan -# fix for OO Net::SCP -# -# Revision 1.9 2001/04/22 01:56:15 ivan -# get rid of FS::SSH.pm (became Net::SSH and Net::SCP on CPAN) -# -# Revision 1.8 2000/07/06 03:37:24 ivan -# don't error out on invalid svc_acct_sm.domuid's that can't be matched in -# svc_acct.uid - just warn. -# -# Revision 1.7 2000/07/03 09:13:10 ivan -# get rid of double sendmailrestart invocation; no need for multiple sessions -# -# Revision 1.6 2000/07/03 09:09:14 ivan -# typo -# -# Revision 1.5 2000/07/03 09:03:14 ivan -# added sendmailrestart and sendmailconfigpath config files -# -# Revision 1.4 2000/06/29 14:02:29 ivan -# add sendmailrestart configuration file -# -# Revision 1.3 2000/06/12 08:37:56 ivan -# sendmail fix from Jeff Finucane -# -# Revision 1.2 1998/12/10 07:23:17 ivan -# use FS::Conf, need user (for datasrc) -# - -use strict; -use vars qw($conf); -use Fcntl qw(:flock); -use Net::SSH qw(ssh); -use Net::SCP qw(scp); -use FS::UID qw(adminsuidsetup datasrc); -use FS::Record qw(qsearch qsearchs); -use FS::svc_acct; -use FS::svc_acct_sm; -use FS::svc_domain; - -my $user = shift or die &usage; -adminsuidsetup $user; - -$conf = new FS::Conf; - -my($shellmachine, @qmailmachines); -if ( $conf->exists('qmailmachines') ) { - $shellmachine = $conf->config('shellmachine'); - @qmailmachines = $conf->config('qmailmachines'); -} - -my(@sendmailmachines, $sendmailconfigpath, $sendmailrestart); -if ( $conf->exists('sendmailmachines') ) { - @sendmailmachines = $conf->config('sendmailmachines'); - $sendmailconfigpath = $conf->config('sendmailconfigpath') || '/etc'; - $sendmailrestart = $conf->config('sendmailrestart'); -} - -my $mydomain = $conf->config('domain'); - -my $spooldir = "/usr/local/etc/freeside/export.". datasrc; -my $spoollock = "/usr/local/etc/freeside/svc_acct_sm.export.lock.". datasrc; - -umask 066; - -open(EXPORT,"+>>$spoollock") or die "Can't open $spoollock: $!"; -select(EXPORT); $|=1; select(STDOUT); -unless ( flock(EXPORT,LOCK_EX|LOCK_NB) ) { - seek(EXPORT,0,0); - my($pid)=; - chop($pid); - #no reason to start locks of blocking processes - die "Is another export process running under pid $pid?\n"; -} -seek(EXPORT,0,0); -print EXPORT $$,"\n"; - -( open(RCPTHOSTS,">$spooldir/rcpthosts") - and flock(RCPTHOSTS,LOCK_EX|LOCK_NB) -) or die "Can't open $spooldir/rcpthosts: $!"; -( open(RECIPIENTMAP,">$spooldir/recipientmap") - and flock(RECIPIENTMAP,LOCK_EX|LOCK_NB) -) or die "Can't open $spooldir/recipientmap: $!"; -( open(VIRTUALDOMAINS,">$spooldir/virtualdomains") - and flock(VIRTUALDOMAINS,LOCK_EX|LOCK_NB) -) or die "Can't open $spooldir/virtualdomains: $!"; -( open(VIRTUSERTABLE,">$spooldir/virtusertable") - and flock(VIRTUSERTABLE,LOCK_EX|LOCK_NB) -) or die "Can't open $spooldir/virtusertable: $!"; -( open(SENDMAIL_CW,">$spooldir/sendmail.cw") - and flock(SENDMAIL_CW,LOCK_EX|LOCK_NB) -) or die "Can't open $spooldir/sendmail.cw: $!"; - -setpriority(0,0,10); - -my($svc_domain,%domain); -foreach $svc_domain ( qsearch('svc_domain',{}) ) { - my($domain)=$svc_domain->domain; - $domain{$svc_domain->svcnum}=$domain; - print RCPTHOSTS "$domain\n.$domain\n"; - print SENDMAIL_CW "$domain\n"; -} - -my(@sendmail); - -my($svc_acct_sm); -foreach $svc_acct_sm ( qsearch('svc_acct_sm') ) { - my($domsvc,$domuid,$domuser)=( - $svc_acct_sm->domsvc, - $svc_acct_sm->domuid, - $svc_acct_sm->domuser, - ); - my($domain)=$domain{$domsvc}; - my($svc_acct)=qsearchs('svc_acct',{'uid'=>$domuid}); - unless ( $svc_acct ) { - warn "WARNING: couldn't find svc_acct.uid $domuid (svc_acct_sm.svcnum ". - $svc_acct_sm->svcnum. ") - corruped database?\n"; - next; - } - my($username,$dir,$uid,$gid)=( - $svc_acct->username, - $svc_acct->dir, - $svc_acct->uid, - $svc_acct->gid, - ); - next unless $username && $domain && $domuser; - - if ($domuser eq '*') { - push @sendmail, "\@$domain\t$username\n"; - print VIRTUALDOMAINS "$domain:$username-$domain\n", - ".$domain:$username-$domain\n", - ; - ### - # qmail - ssh("root\@$shellmachine", - "[ -e $dir/.qmail-default ] || { touch $dir/.qmail-default; chown $uid:$gid $dir/.qmail-default; }" - ) if ( $shellmachine && $dir && $uid ); - - } else { - print VIRTUSERTABLE "$domuser\@$domain\t$username\n"; - print RECIPIENTMAP "$domuser\@$domain:$username\@$mydomain\n"; - } - -} - -print VIRTUSERTABLE @sendmail; - -chmod 0644, "$spooldir/sendmail.cw", - "$spooldir/virtusertable", - "$spooldir/rcpthosts", - "$spooldir/recipientmap", - "$spooldir/virtualdomains", -; - -flock(SENDMAIL_CW,LOCK_UN); -flock(VIRTUSERTABLE,LOCK_UN); -flock(RCPTHOSTS,LOCK_UN); -flock(RECIPIENTMAP,LOCK_UN); -flock(VIRTUALDOMAINS,LOCK_UN); - -close SENDMAIL_CW; -close VIRTUSERTABLE; -close RCPTHOSTS; -close RECIPIENTMAP; -close VIRTUALDOMAINS; - -### -# export stuff -# - -my($sendmailmachine); -foreach $sendmailmachine (@sendmailmachines) { - my $scp = new Net::SCP; - $scp->scp("$spooldir/sendmail.cw","root\@$sendmailmachine:$sendmailconfigpath/sendmail.cw.new") - or die "scp error: ". $scp->{errstr}; - $scp->scp("$spooldir/virtusertable","root\@$sendmailmachine:$sendmailconfigpath/virtusertable.new") - or die "scp error: ". $scp->{errstr}; - ssh("root\@$sendmailmachine", - "( ". - "mv $sendmailconfigpath/sendmail.cw.new $sendmailconfigpath/sendmail.cw; ". - "mv $sendmailconfigpath/virtusertable.new $sendmailconfigpath/virtusertable; ". - $sendmailrestart. - " )" - ) - == 0 or die "ssh error: $!"; -} - -my($qmailmachine); -foreach $qmailmachine (@qmailmachines) { - my $scp = new Net::SCP; - $scp->scp("$spooldir/recipientmap","root\@$qmailmachine:/var/qmail/control/recipientmap") - or die "scp error: ". $scp->{errstr}; - $scp->scp("$spooldir/virtualdomains","root\@$qmailmachine:/var/qmail/control/virtualdomains") - or die "scp error: ". $scp->{errstr}; - $scp->scp("$spooldir/rcpthosts","root\@$qmailmachine:/var/qmail/control/rcpthosts") - or die "scp error: ". $scp->{errstr}; - #ssh("root\@$qmailmachine","/etc/init.d/qmail restart") - # == 0 or die "ssh error: $!"; -} - -unlink $spoollock; -flock(EXPORT,LOCK_UN); -close EXPORT; - -# - -sub usage { - die "Usage:\n\n svc_acct.export user\n"; -} - -- cgit v1.2.1 From bda1b3f43f3f7fe95c6ad221a2ae94bb47b8b9c7 Mon Sep 17 00:00:00 2001 From: ivan Date: Mon, 13 Aug 2001 00:19:02 +0000 Subject: depriciate svc_acct_sm, add unique index for username+domsvc on svc_acct, remove silly $Log$ --- bin/fs-setup | 174 +++++------------------------------------------------------ 1 file changed, 14 insertions(+), 160 deletions(-) (limited to 'bin') diff --git a/bin/fs-setup b/bin/fs-setup index a3e067bec..ec8b75089 100755 --- a/bin/fs-setup +++ b/bin/fs-setup @@ -1,152 +1,6 @@ #!/usr/bin/perl -Tw # -# $Id: fs-setup,v 1.41 2001-08-12 19:41:25 jeff Exp $ -# -# ivan@sisd.com 97-nov-8,9 -# -# agent_type and type_pkgs added. -# (index need to be declared, & primary keys shoudln't have mysql syntax) -# ivan@sisd.com 97-nov-13 -# -# pulled modified version back out of register.cgi ivan@sisd.com 98-feb-21 -# -# removed extraneous sample data ivan@sisd.com 98-mar-23 -# -# gained the big hash from dbdef.pm, dbdef.pm usage rewrite ivan@sisd.com -# 98-apr-19 - 98-may-11 plus -# -# finished up ivan@sisd.com 98-jun-1 -# -# part_svc fields are all forced NULL, not the opposite -# hmm: also are forced varchar($char_d) as fixed '0' for things like -# uid is Not Good. will this break anything else? -# ivan@sisd.com 98-jun-29 -# -# ss is 11 chars ivan@sisd.com 98-jul-20 -# -# setup of arbitrary radius fields ivan@sisd.com 98-aug-9 -# -# ouch, removed index on company name that wasn't supposed to be there -# ivan@sisd.com 98-sep-4 -# -# fix radius attributes ivan@sisd.com 98-sep-27 -# -# $Log: fs-setup,v $ -# Revision 1.41 2001-08-12 19:41:25 jeff -# merging vpopmail support branch -# -# Revision 1.40 2001/08/11 05:53:42 ivan -# add comments field -# -# Revision 1.39 2001/07/30 07:42:39 ivan -# need an DBIx::DBSchema with delcolumn -# -# Revision 1.38 2001/07/30 07:36:04 ivan -# templates!!! -# -# Revision 1.37 2001/06/03 14:16:11 ivan -# allow empty refund reasons -# -# Revision 1.36 2001/04/15 12:56:31 ivan -# s/dbdef/DBIx::DBSchema/ -# -# Revision 1.35 2001/04/15 09:36:43 ivan -# http://www.sisd.com/freeside/list-archive/msg01450.html -# -# Revision 1.34 2001/04/09 23:05:16 ivan -# Transactions Part I!!! -# -# Revision 1.33 2001/02/03 14:03:50 ivan -# time-based prepaid cards, session monitor. woop! -# -# Revision 1.32 2000/12/04 00:13:02 ivan -# fix nas.last type -# -# Revision 1.31 2000/12/01 18:34:53 ivan -# another tyop -# -# Revision 1.30 2000/12/01 18:33:32 ivan -# tyop -# -# Revision 1.29 2000/11/07 15:00:37 ivan -# session monitor -# -# Revision 1.28 2000/10/30 10:47:26 ivan -# nas.last can't be defined NULL if indexed -# -# Revision 1.26 2000/07/06 08:57:27 ivan -# support for radius check attributes (except importing). poorly documented. -# -# Revision 1.25 2000/06/29 12:00:49 ivan -# support for pre-encrypted md5 passwords. -# -# Revision 1.24 2000/03/02 07:44:07 ivan -# typo forgot closing ' -# -# Revision 1.23 2000/02/03 05:16:52 ivan -# beginning of DNS and Apache support -# -# Revision 1.22 2000/01/31 05:22:23 ivan -# prepaid "internet cards" -# -# Revision 1.21 2000/01/30 06:03:26 ivan -# postgres 6.5 finally supports decimal(10,2) -# -# Revision 1.20 2000/01/28 22:53:33 ivan -# track full phone number -# -# Revision 1.19 1999/07/29 08:50:35 ivan -# wrong type for cust_pay_batch.exp -# -# Revision 1.18 1999/04/15 22:46:30 ivan -# TT isn't a state! -# -# Revision 1.17 1999/04/14 07:58:39 ivan -# export getsecrets from FS::UID instead of calling it explicitly -# -# Revision 1.16 1999/02/28 19:44:16 ivan -# constructors s/create/new/ pointed out by "Bao C. Ha" -# -# Revision 1.15 1999/02/27 21:06:21 ivan -# cust_main.paydate should be varchar(10), not @date_type ; problem reported -# by Ben Leibig -# -# Revision 1.14 1999/02/07 09:59:14 ivan -# more mod_perl fixes, and bugfixes Peter Wemm sent via email -# -# Revision 1.13 1999/02/04 06:09:23 ivan -# add AU provences -# -# Revision 1.12 1999/02/03 10:42:27 ivan -# *** empty log message *** -# -# Revision 1.11 1999/01/17 03:11:52 ivan -# remove preliminary completehost changes -# -# Revision 1.10 1998/12/16 06:05:38 ivan -# add table cust_main_invoice -# -# Revision 1.9 1998/12/15 04:36:29 ivan -# s/croak/die/; #oops -# -# Revision 1.8 1998/12/15 04:33:27 ivan -# dies if it isn't running as the freeside user -# -# Revision 1.7 1998/11/18 09:01:31 ivan -# i18n! i18n! -# -# Revision 1.6 1998/11/15 13:18:02 ivan -# remove debugging -# -# Revision 1.5 1998/11/15 09:43:03 ivan -# update for new config file syntax, new adminsuidsetup -# -# Revision 1.4 1998/10/22 15:51:23 ivan -# also varchar with no length specified - postgresql fix broke mysql. -# -# Revision 1.3 1998/10/22 15:46:28 ivan -# now smallint is illegal, so remove that too. -# +# $Id: fs-setup,v 1.42 2001-08-13 00:19:02 ivan Exp $ #to delay loading dbdef until we're ready BEGIN { $FS::Record::setup_hack = 1; } @@ -274,7 +128,7 @@ my($part_svc)=$dbdef->table('part_svc'); #because of svc_acct_pop #foreach (grep /^svc_/, $dbdef->tables) { #foreach (qw(svc_acct svc_acct_sm svc_charge svc_domain svc_wo)) { -foreach (qw(svc_acct svc_acct_sm svc_domain svc_forward svc_www)) { +foreach (qw(svc_acct svc_domain svc_forward svc_www)) { my($table)=$dbdef->table($_); my($col); foreach $col ( $table->columns ) { @@ -713,21 +567,21 @@ sub tables_hash_hack { 'domsvc', 'int', '', '', ], 'primary_key' => 'svcnum', - 'unique' => [ [] ], + 'unique' => [ [ 'username', 'domsvc' ] ], 'index' => [ ['username'], ['domsvc'] ], }, - 'svc_acct_sm' => { - 'columns' => [ - 'svcnum', 'int', '', '', - 'domsvc', 'int', '', '', - 'domuid', 'int', '', '', - 'domuser', 'varchar', '', $char_d, - ], - 'primary_key' => 'svcnum', - 'unique' => [ [] ], - 'index' => [ ['domsvc'], ['domuid'] ], - }, +# 'svc_acct_sm' => { +# 'columns' => [ +# 'svcnum', 'int', '', '', +# 'domsvc', 'int', '', '', +# 'domuid', 'int', '', '', +# 'domuser', 'varchar', '', $char_d, +# ], +# 'primary_key' => 'svcnum', +# 'unique' => [ [] ], +# 'index' => [ ['domsvc'], ['domuid'] ], +# }, #'svc_charge' => { # 'columns' => [ -- cgit v1.2.1 From 55b29dc1d28b0c27e7f8271e7fe382a36d75d268 Mon Sep 17 00:00:00 2001 From: ivan Date: Fri, 17 Aug 2001 10:57:40 +0000 Subject: gah --- bin/dbdef-create | 9 +++++++-- bin/svc_acct.export | 11 +++-------- bin/svc_acct.import | 9 ++++++--- 3 files changed, 16 insertions(+), 13 deletions(-) (limited to 'bin') diff --git a/bin/dbdef-create b/bin/dbdef-create index 902f7f145..e71eb36b4 100755 --- a/bin/dbdef-create +++ b/bin/dbdef-create @@ -1,6 +1,6 @@ #!/usr/bin/perl -Tw # -# $Id: dbdef-create,v 1.3 2001-04-15 12:56:31 ivan Exp $ +# $Id: dbdef-create,v 1.4 2001-08-17 10:57:40 ivan Exp $ # # create dbdef file for existing mySQL database (needs SHOW|DESCRIBE command # not in Pg) based on fs-setup @@ -8,7 +8,10 @@ # ivan@sisd.com 98-jun-2 # # $Log: dbdef-create,v $ -# Revision 1.3 2001-04-15 12:56:31 ivan +# Revision 1.4 2001-08-17 10:57:40 ivan +# gah +# +# Revision 1.3 2001/04/15 12:56:31 ivan # s/dbdef/DBIx::DBSchema/ # # Revision 1.2 1998/11/19 11:17:44 ivan @@ -29,6 +32,8 @@ my($dbdef_file) = "/usr/local/etc/freeside/dbdef.". datasrc; my $dbdef = new_native DBIx::DBSchema $dbh; +#print $dbdef->pretty_print; + #important $dbdef->save($dbdef_file); diff --git a/bin/svc_acct.export b/bin/svc_acct.export index a7a21b3e5..a5ec45d48 100755 --- a/bin/svc_acct.export +++ b/bin/svc_acct.export @@ -1,18 +1,11 @@ #!/usr/bin/perl -w # -# $Id: svc_acct.export,v 1.22 2001-08-12 19:41:25 jeff Exp $ +# $Id: svc_acct.export,v 1.23 2001-08-17 10:57:40 ivan Exp $ # # Create and export password, radius and vpopmail password files: # passwd, passwd.adjunct, shadow, acp_passwd, acp_userinfo, acp_dialup # users/assign, domains/vdomain/vpasswd # Also export sendmail and qmail config files. -# -# -# $Log: svc_acct.export,v $ -# Revision 1.22 2001-08-12 19:41:25 jeff -# merging vpopmail support branch -# -# use strict; use vars qw($conf); @@ -73,6 +66,8 @@ my $textradiusprepend = ? $conf->config('textradiusprepend') : ''; +warn "using depriciated textradiusprepend file" if $textradiusprepend; + my @vpopmailmachines = $conf->config('vpopmailmachines') if $conf->exists('vpopmailmachines'); diff --git a/bin/svc_acct.import b/bin/svc_acct.import index eaf0c03c5..119f7705b 100755 --- a/bin/svc_acct.import +++ b/bin/svc_acct.import @@ -1,6 +1,6 @@ #!/usr/bin/perl -Tw # -# $Id: svc_acct.import,v 1.15 2001-07-30 06:07:47 ivan Exp $ +# $Id: svc_acct.import,v 1.16 2001-08-17 10:57:40 ivan Exp $ # # ivan@sisd.com 98-mar-9 # @@ -17,7 +17,10 @@ # don't import /var/spool/freeside/conf/shells! ivan@sisd.com 98-aug-13 # # $Log: svc_acct.import,v $ -# Revision 1.15 2001-07-30 06:07:47 ivan +# Revision 1.16 2001-08-17 10:57:40 ivan +# gah +# +# Revision 1.15 2001/07/30 06:07:47 ivan # allow !! for locked accounts instead of changing to *SUSPENDED* # # Revision 1.14 2001/05/07 15:24:15 ivan @@ -166,7 +169,7 @@ while () { next if /^\s*$/; next if /^\s*#/; if ( /^\S/ ) { - /^(\w+)\s+(Auth-Type\s+=\s+Local,\s+)Password\s+=\s+"([^"]+)"(,\s+Expiration\s+=\s+"([^"]*")\s*)?$/ + /^(\w+)\s+(Auth-Type\s+=\s+Local,\s+)?Password\s+=\s+"([^"]+)"(,\s+Expiration\s+=\s+"([^"]*")\s*)?$/ or die "1Unexpected line in users.import: $_"; my($password,$expiration); ($username,$password,$expiration)=(lc($1),$3,$5); -- cgit v1.2.1 From b400f5e930df471ad42906ae118f0f3b00cec512 Mon Sep 17 00:00:00 2001 From: ivan Date: Sun, 19 Aug 2001 10:25:44 +0000 Subject: add system shells to @FS::svc_acct:shells on the fly, fixes: ticket #88 --- bin/svc_acct.import | 63 +++-------------------------------------------------- 1 file changed, 3 insertions(+), 60 deletions(-) (limited to 'bin') diff --git a/bin/svc_acct.import b/bin/svc_acct.import index 119f7705b..eb94e1c37 100755 --- a/bin/svc_acct.import +++ b/bin/svc_acct.import @@ -1,64 +1,5 @@ #!/usr/bin/perl -Tw -# -# $Id: svc_acct.import,v 1.16 2001-08-17 10:57:40 ivan Exp $ -# -# ivan@sisd.com 98-mar-9 -# -# changed 'password' field to '_password' because PgSQL 6.3 reserves this word -# bmccane@maxbaud.net 98-Apr-3 -# -# generalized svcparts (still needs radius import) ivan@sisd.com 98-mar-23 -# -# radius import, now an interactive script. still needs erpcd import? -# ivan@sisd.com 98-jun-24 -# -# arbitrary radius attributes ivan@sisd.com 98-aug-9 -# -# don't import /var/spool/freeside/conf/shells! ivan@sisd.com 98-aug-13 -# -# $Log: svc_acct.import,v $ -# Revision 1.16 2001-08-17 10:57:40 ivan -# gah -# -# Revision 1.15 2001/07/30 06:07:47 ivan -# allow !! for locked accounts instead of changing to *SUSPENDED* -# -# Revision 1.14 2001/05/07 15:24:15 ivan -# s/!/*/ -# -# Revision 1.13 2001/05/05 08:51:16 ivan -# http://www.sisd.com/freeside/list-archive/msg01915.html -# -# Revision 1.12 2001/04/22 01:56:15 ivan -# get rid of FS::SSH.pm (became Net::SSH and Net::SCP on CPAN) -# -# Revision 1.11 2000/06/29 12:27:01 ivan -# s/password/_password/ for PostgreSQL wasn't done in the import. -# -# Revision 1.10 2000/06/28 12:32:30 ivan -# allow RADIUS lines with "Auth-Type = Local" too -# -# Revision 1.8 2000/02/03 05:16:52 ivan -# beginning of DNS and Apache support -# -# Revision 1.7 1999/07/08 02:32:26 ivan -# import fix, noticed by Ben Leibig and Joel Griffiths -# -# Revision 1.6 1999/07/08 01:49:00 ivan -# updates to avoid -w warnings from Joel Griffiths -# -# Revision 1.5 1999/03/25 08:42:19 ivan -# import stuff uses Term::Query and spits out (some kinds of) nonsensical input -# -# Revision 1.4 1999/03/24 00:43:38 ivan -# die if no relevant services -# -# Revision 1.3 1998/12/10 07:23:16 ivan -# use FS::Conf, need user (for datasrc) -# -# Revision 1.2 1998/10/13 12:07:51 ivan -# Assigns password from the shadow file for RADIUS password "UNIX" -# +# $Id: svc_acct.import,v 1.17 2001-08-19 10:25:44 ivan Exp $ use strict; use vars qw(%part_svc); @@ -73,6 +14,8 @@ use FS::part_svc; my $user = shift or die &usage; adminsuidsetup $user; +push @FS::svc_acct::shells, qw(/bin/sync /sbin/shuddown /bin/halt); #others? + my($spooldir)="/usr/local/etc/freeside/export.". datasrc; $FS::svc_acct::nossh_hack = 1; -- cgit v1.2.1 From 8c7396531e6bf6f7c6cc4e5d19e2d381442223c5 Mon Sep 17 00:00:00 2001 From: ivan Date: Sun, 19 Aug 2001 13:50:47 +0000 Subject: indices on cust_main ship_last and ship_country --- bin/fs-setup | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'bin') diff --git a/bin/fs-setup b/bin/fs-setup index ec8b75089..7056347e6 100755 --- a/bin/fs-setup +++ b/bin/fs-setup @@ -1,6 +1,6 @@ #!/usr/bin/perl -Tw # -# $Id: fs-setup,v 1.42 2001-08-13 00:19:02 ivan Exp $ +# $Id: fs-setup,v 1.43 2001-08-19 13:50:47 ivan Exp $ #to delay loading dbdef until we're ready BEGIN { $FS::Record::setup_hack = 1; } @@ -92,10 +92,11 @@ my($dbdef) = new DBIx::DBSchema ( map { ); } (keys %tables) ); -#remove ship_ from cust_main -unless ($ship) { - my $cust_main = $dbdef->table('cust_main'); +my $cust_main = $dbdef->table('cust_main'); +unless ($ship) { #remove ship_ from cust_main $cust_main->delcolumn($_) foreach ( grep /^ship_/, $cust_main->columns ); +} else { #add indices on ship_last and ship_company + push @{$cust_main->index->lol_ref}, ( ['ship_last'], ['ship_company'] ) } #add radius attributes to svc_acct @@ -363,7 +364,7 @@ sub tables_hash_hack { 'primary_key' => 'custnum', 'unique' => [ [] ], #'index' => [ ['last'], ['company'] ], - 'index' => [ ['last'], ], + 'index' => [ ['last'], [ 'company' ] ], }, 'cust_main_invoice' => { -- cgit v1.2.1 From 4ac49026e732c19ef88103ab85536cea40cbc41c Mon Sep 17 00:00:00 2001 From: ivan Date: Tue, 21 Aug 2001 02:43:18 +0000 Subject: i think svc_acct_sm.import should go away, but... --- bin/dbdef-create | 18 +----------------- bin/fs-migrate-svc_acct_sm | 14 +------------- bin/svc_acct_sm.import | 41 +---------------------------------------- 3 files changed, 3 insertions(+), 70 deletions(-) (limited to 'bin') diff --git a/bin/dbdef-create b/bin/dbdef-create index e71eb36b4..0b297b9e6 100755 --- a/bin/dbdef-create +++ b/bin/dbdef-create @@ -1,22 +1,6 @@ #!/usr/bin/perl -Tw # -# $Id: dbdef-create,v 1.4 2001-08-17 10:57:40 ivan Exp $ -# -# create dbdef file for existing mySQL database (needs SHOW|DESCRIBE command -# not in Pg) based on fs-setup -# -# ivan@sisd.com 98-jun-2 -# -# $Log: dbdef-create,v $ -# Revision 1.4 2001-08-17 10:57:40 ivan -# gah -# -# Revision 1.3 2001/04/15 12:56:31 ivan -# s/dbdef/DBIx::DBSchema/ -# -# Revision 1.2 1998/11/19 11:17:44 ivan -# adminsuidsetup requires argument -# +# $Id: dbdef-create,v 1.5 2001-08-21 02:43:18 ivan Exp $ use strict; use DBI; diff --git a/bin/fs-migrate-svc_acct_sm b/bin/fs-migrate-svc_acct_sm index d0d4a94b6..ae2dc764d 100755 --- a/bin/fs-migrate-svc_acct_sm +++ b/bin/fs-migrate-svc_acct_sm @@ -1,20 +1,8 @@ #!/usr/bin/perl -Tw # -# $Id: fs-migrate-svc_acct_sm,v 1.2 2001-08-12 19:41:25 jeff Exp $ +# $Id: fs-migrate-svc_acct_sm,v 1.3 2001-08-21 02:43:18 ivan Exp $ # # jeff@cmh.net 01-Jul-20 -# -# $Log: fs-migrate-svc_acct_sm,v $ -# Revision 1.2 2001-08-12 19:41:25 jeff -# merging vpopmail support branch -# -# Revision 1.1.2.1 2001/08/08 17:45:35 jeff -# initial vpopmail support -# -# -# -# Initial vpopmail changes -# #to delay loading dbdef until we're ready #BEGIN { $FS::Record::setup_hack = 1; } diff --git a/bin/svc_acct_sm.import b/bin/svc_acct_sm.import index 723fb029f..b668405f5 100755 --- a/bin/svc_acct_sm.import +++ b/bin/svc_acct_sm.import @@ -1,45 +1,6 @@ #!/usr/bin/perl -Tw # -# $Id: svc_acct_sm.import,v 1.9 2001-04-22 01:56:15 ivan Exp $ -# -# ivan@sisd.com 98-mar-9 -# -# generalized svcparts ivan@sisd.com 98-mar-23 - -# You really need to enable ssh into a shell machine as this needs to rename -# .qmail-extension files. -# -# now an interactive script ivan@sisd.com 98-jun-30 -# -# has an (untested) section for sendmail, s/warn/die/g and generates a program -# to run on your mail machine _later_ instead of ssh'ing for each user -# ivan@sisd.com 98-jul-13 -# -# $Log: svc_acct_sm.import,v $ -# Revision 1.9 2001-04-22 01:56:15 ivan -# get rid of FS::SSH.pm (became Net::SSH and Net::SCP on CPAN) -# -# Revision 1.8 2000/12/03 15:14:00 ivan -# bugfixes from Jeff Finucane , thanks! -# -# Revision 1.7 2000/06/29 10:51:52 ivan -# oops, silly mistake -# -# Revision 1.6 2000/06/29 10:48:25 ivan -# make svc_acct_sm skip blank lines in sendmail import -# -# Revision 1.5 2000/02/03 05:16:52 ivan -# beginning of DNS and Apache support -# -# Revision 1.4 1999/03/25 08:42:20 ivan -# import stuff uses Term::Query and spits out (some kinds of) nonsensical input -# -# Revision 1.3 1999/03/24 00:51:55 ivan -# die if no relevant services... cvspain -# -# Revision 1.2 1998/12/10 07:23:18 ivan -# use FS::Conf, need user (for datasrc) -# +# $Id: svc_acct_sm.import,v 1.10 2001-08-21 02:43:18 ivan Exp $ use strict; use vars qw(%d_part_svc %m_part_svc); -- cgit v1.2.1 From 3ae5a3652e8d8270ba7d5b6cd061bf28fe629e61 Mon Sep 17 00:00:00 2001 From: ivan Date: Wed, 29 Aug 2001 08:45:04 +0000 Subject: catchall *can* be NULL --- bin/fs-setup | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'bin') diff --git a/bin/fs-setup b/bin/fs-setup index 7056347e6..faa0e07f1 100755 --- a/bin/fs-setup +++ b/bin/fs-setup @@ -1,6 +1,6 @@ #!/usr/bin/perl -Tw # -# $Id: fs-setup,v 1.43 2001-08-19 13:50:47 ivan Exp $ +# $Id: fs-setup,v 1.44 2001-08-29 08:45:04 ivan Exp $ #to delay loading dbdef until we're ready BEGIN { $FS::Record::setup_hack = 1; } @@ -359,12 +359,13 @@ sub tables_hash_hack { 'tax', 'char', 'NULL', 1, 'otaker', 'varchar', '', 8, 'refnum', 'int', '', '', + 'referral_custnum', 'int', 'NULL', '', 'comments', 'varchar', 'NULL', '', ], 'primary_key' => 'custnum', 'unique' => [ [] ], #'index' => [ ['last'], ['company'] ], - 'index' => [ ['last'], [ 'company' ] ], + 'index' => [ ['last'], [ 'company' ], [ 'referral_custnum' ] ], }, 'cust_main_invoice' => { @@ -598,7 +599,7 @@ sub tables_hash_hack { 'columns' => [ 'svcnum', 'int', '', '', 'domain', 'varchar', '', $char_d, - 'catchall', 'int', '', '', + 'catchall', 'int', 'NULL', '', ], 'primary_key' => 'svcnum', 'unique' => [ ['domain'] ], -- cgit v1.2.1 From cdd5aa1d86cd5b266e02bed58570c97c2d7698ba Mon Sep 17 00:00:00 2001 From: ivan Date: Sat, 1 Sep 2001 20:11:07 +0000 Subject: cust_bill_pay and cust_credit_refund. payments can apply to multiple invoices and refunds can apply to multiple credits. --- bin/fs-setup | 34 +++++++++++++++++++++++++++++++--- 1 file changed, 31 insertions(+), 3 deletions(-) (limited to 'bin') diff --git a/bin/fs-setup b/bin/fs-setup index faa0e07f1..2cba840ef 100755 --- a/bin/fs-setup +++ b/bin/fs-setup @@ -1,6 +1,6 @@ #!/usr/bin/perl -Tw # -# $Id: fs-setup,v 1.44 2001-08-29 08:45:04 ivan Exp $ +# $Id: fs-setup,v 1.45 2001-09-01 20:11:07 ivan Exp $ #to delay loading dbdef until we're ready BEGIN { $FS::Record::setup_hack = 1; } @@ -398,7 +398,7 @@ sub tables_hash_hack { 'cust_pay' => { 'columns' => [ 'paynum', 'int', '', '', - 'invnum', 'int', '', '', + #now cust_bill_pay #'invnum', 'int', '', '', 'paid', @money_type, '_date', @date_type, 'payby', 'char', '', 4, # CARD/BILL/COMP, should be index into @@ -411,6 +411,19 @@ sub tables_hash_hack { 'index' => [ ['invnum'] ], }, + 'cust_bill_pay' => { + 'column' => [ + 'billpaynum', 'int', '', '', + 'invnum', 'int', '', '', + 'paynum', 'int', '', '', + 'amount', @money_type, + '_date', @date_type + ], + 'primary_key' => 'billpaynum' + 'unique' => [ [] ], + 'index' => [ [ 'paynum', 'invnum' ] ], + }, + 'cust_pay_batch' => { #what's this used for again? list of customers #in current CARD batch? (necessarily CARD?) 'columns' => [ @@ -456,7 +469,7 @@ sub tables_hash_hack { 'cust_refund' => { 'columns' => [ 'refundnum', 'int', '', '', - 'crednum', 'int', '', '', + #now cust_credit_refund #'crednum', 'int', '', '', '_date', @date_type, 'refund', @money_type, 'otaker', 'varchar', '', 8, @@ -464,12 +477,27 @@ sub tables_hash_hack { 'payby', 'char', '', 4, # CARD/BILL/COMP, should be index # into payment type table. 'payinfo', 'varchar', 'NULL', 16, #see cust_main above + 'paybatch', 'varchar', 'NULL', $char_d, ], 'primary_key' => 'refundnum', 'unique' => [ [] ], 'index' => [ ['crednum'] ], }, + 'cust_credit_refund' => { + 'column' => [ + 'creditrefundnum', 'int', '', '', + 'crednum', 'int', '', '', + 'refundnum', 'int', '', '', + 'amount', @money_type, + '_date', @date_type + ], + 'primary_key' => 'creditrefundnum' + 'unique' => [ [] ], + 'index' => [ [ 'crednum', 'refundnum' ] ], + }, + + 'cust_svc' => { 'columns' => [ 'svcnum', 'int', '', '', -- cgit v1.2.1 From 6412f71a3557249225abf5eb2096ebad1729c585 Mon Sep 17 00:00:00 2001 From: jeff Date: Sat, 1 Sep 2001 21:52:20 +0000 Subject: add cust_credit_bill relating multiple invoices to credits --- bin/fs-setup | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'bin') diff --git a/bin/fs-setup b/bin/fs-setup index 2cba840ef..8fbc67ef3 100755 --- a/bin/fs-setup +++ b/bin/fs-setup @@ -1,6 +1,6 @@ #!/usr/bin/perl -Tw # -# $Id: fs-setup,v 1.45 2001-09-01 20:11:07 ivan Exp $ +# $Id: fs-setup,v 1.46 2001-09-01 21:52:20 jeff Exp $ #to delay loading dbdef until we're ready BEGIN { $FS::Record::setup_hack = 1; } @@ -317,6 +317,18 @@ sub tables_hash_hack { 'index' => [ ['custnum'] ], }, + 'cust_credit_bill' => { + 'columns' => [ + 'crednum', 'int', '', '', + 'invnum', 'int', '', '', + '_date', @date_type, + 'amount', @money_type, + ], + 'primary_key' => 'crednum', + 'unique' => [ [] ], + 'index' => [ ['invnum'] ], + }, + 'cust_main' => { 'columns' => [ 'custnum', 'int', '', '', -- cgit v1.2.1 From 60c10ab363668ec3016306e6069eaade9e04d544 Mon Sep 17 00:00:00 2001 From: ivan Date: Sat, 1 Sep 2001 22:18:38 +0000 Subject: add primary key --- bin/fs-setup | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'bin') diff --git a/bin/fs-setup b/bin/fs-setup index 8fbc67ef3..71d53ef85 100755 --- a/bin/fs-setup +++ b/bin/fs-setup @@ -1,6 +1,6 @@ #!/usr/bin/perl -Tw # -# $Id: fs-setup,v 1.46 2001-09-01 21:52:20 jeff Exp $ +# $Id: fs-setup,v 1.47 2001-09-01 22:18:38 ivan Exp $ #to delay loading dbdef until we're ready BEGIN { $FS::Record::setup_hack = 1; } @@ -319,14 +319,15 @@ sub tables_hash_hack { 'cust_credit_bill' => { 'columns' => [ + 'creditbillnum', 'int', '', '', 'crednum', 'int', '', '', 'invnum', 'int', '', '', '_date', @date_type, 'amount', @money_type, ], - 'primary_key' => 'crednum', + 'primary_key' => 'creditbillnum', 'unique' => [ [] ], - 'index' => [ ['invnum'] ], + 'index' => [ ['crednum'], ['invnum'] ], }, 'cust_main' => { @@ -420,7 +421,7 @@ sub tables_hash_hack { ], 'primary_key' => 'paynum', 'unique' => [ [] ], - 'index' => [ ['invnum'] ], + 'index' => [ [] ], }, 'cust_bill_pay' => { -- cgit v1.2.1 From 8c1f9804d9a02c0c054eededeb500c72a640249a Mon Sep 17 00:00:00 2001 From: ivan Date: Sun, 2 Sep 2001 02:46:55 +0000 Subject: cust_refund and cust_pay get custnums --- bin/fs-setup | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'bin') diff --git a/bin/fs-setup b/bin/fs-setup index 71d53ef85..5e735294f 100755 --- a/bin/fs-setup +++ b/bin/fs-setup @@ -1,6 +1,6 @@ #!/usr/bin/perl -Tw # -# $Id: fs-setup,v 1.47 2001-09-01 22:18:38 ivan Exp $ +# $Id: fs-setup,v 1.48 2001-09-02 02:46:55 ivan Exp $ #to delay loading dbdef until we're ready BEGIN { $FS::Record::setup_hack = 1; } @@ -412,6 +412,7 @@ sub tables_hash_hack { 'columns' => [ 'paynum', 'int', '', '', #now cust_bill_pay #'invnum', 'int', '', '', + 'custnum', 'int', '', '', 'paid', @money_type, '_date', @date_type, 'payby', 'char', '', 4, # CARD/BILL/COMP, should be index into @@ -483,6 +484,7 @@ sub tables_hash_hack { 'columns' => [ 'refundnum', 'int', '', '', #now cust_credit_refund #'crednum', 'int', '', '', + 'custnum', 'int', '', '', '_date', @date_type, 'refund', @money_type, 'otaker', 'varchar', '', 8, -- cgit v1.2.1 From 4f8a0bb6d0c789c7e156a446dc61dbe27938a372 Mon Sep 17 00:00:00 2001 From: ivan Date: Sun, 2 Sep 2001 05:38:13 +0000 Subject: migration. ugh. --- bin/fs-migrate-payref | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100755 bin/fs-migrate-payref (limited to 'bin') diff --git a/bin/fs-migrate-payref b/bin/fs-migrate-payref new file mode 100755 index 000000000..f1513112b --- /dev/null +++ b/bin/fs-migrate-payref @@ -0,0 +1,30 @@ +#!/usr/bin/perl + +use strict; +use FS::UID qw(adminsuidsetup); +use FS::Record qw(qsearch); +use FS::cust_pay; +use FS::cust_refund; + +my $user = shift or die &usage; +my $dbh = adminsuidsetup $user; + +#local $FS::UID::AutoCommit = 0; #quelle hack, in this case +# $FS::UID::AutoCommit = 0; #quelle hack, in this case + +# apply payments to invoices + +foreach my $cust_pay ( qsearch('cust_pay', {} ) ) { + my $error = $cust_pay->upgrade_replace; + warn $error if $error; +} + +# apply refunds to credits + +foreach my $cust_refund ( qsearch('cust_refund') ) { + my $error = $cust_refund->upgrade_replace; + warn $error if $error; +} + +# ? apply credits to invoices + -- cgit v1.2.1 From a5876f5e6c47fd651af9cc648c4b150a0f81279d Mon Sep 17 00:00:00 2001 From: ivan Date: Sun, 2 Sep 2001 07:57:32 +0000 Subject: gawl --- bin/generate-tests | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100755 bin/generate-tests (limited to 'bin') diff --git a/bin/generate-tests b/bin/generate-tests new file mode 100755 index 000000000..73fd29ecb --- /dev/null +++ b/bin/generate-tests @@ -0,0 +1,21 @@ +#!/usr/bin/perl +@files = glob('FS/*.pm'); +foreach (@files) { +# warn $_; + chomp; + s/^FS\///; + $f=$_; + $f=~s/pm$/t/; + $m=$_; + $m=~s/\.pm$//; + open(TEST,">t/$f"); + print "t/$f\n"; + print TEST + 'BEGIN { $| = 1; print "1..1\n" }'. "\n". + 'END {print "not ok 1\n" unless $loaded;}'. "\n". + "use FS::$m;\n". + '$loaded=1;'. "\n". + 'print "ok 1\n";'. "\n" + ; + close TEST; +} -- cgit v1.2.1 From a296741e258d3433ed44652903f2f47467c41d2c Mon Sep 17 00:00:00 2001 From: ivan Date: Mon, 3 Sep 2001 22:16:29 +0000 Subject: this too --- bin/fs-setup | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'bin') diff --git a/bin/fs-setup b/bin/fs-setup index 5e735294f..6efdd65bb 100755 --- a/bin/fs-setup +++ b/bin/fs-setup @@ -1,6 +1,6 @@ #!/usr/bin/perl -Tw # -# $Id: fs-setup,v 1.48 2001-09-02 02:46:55 ivan Exp $ +# $Id: fs-setup,v 1.49 2001-09-03 22:16:29 ivan Exp $ #to delay loading dbdef until we're ready BEGIN { $FS::Record::setup_hack = 1; } @@ -496,7 +496,7 @@ sub tables_hash_hack { ], 'primary_key' => 'refundnum', 'unique' => [ [] ], - 'index' => [ ['crednum'] ], + 'index' => [ [] ], }, 'cust_credit_refund' => { -- cgit v1.2.1 From 2bad1d2cc99f713d10f447d018742eb03453d422 Mon Sep 17 00:00:00 2001 From: ivan Date: Tue, 4 Sep 2001 11:03:22 +0000 Subject: silly syntax error and doc updates --- bin/fs-setup | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'bin') diff --git a/bin/fs-setup b/bin/fs-setup index 6efdd65bb..0c2b67dda 100755 --- a/bin/fs-setup +++ b/bin/fs-setup @@ -1,6 +1,6 @@ #!/usr/bin/perl -Tw # -# $Id: fs-setup,v 1.49 2001-09-03 22:16:29 ivan Exp $ +# $Id: fs-setup,v 1.50 2001-09-04 11:03:22 ivan Exp $ #to delay loading dbdef until we're ready BEGIN { $FS::Record::setup_hack = 1; } @@ -433,7 +433,7 @@ sub tables_hash_hack { 'amount', @money_type, '_date', @date_type ], - 'primary_key' => 'billpaynum' + 'primary_key' => 'billpaynum', 'unique' => [ [] ], 'index' => [ [ 'paynum', 'invnum' ] ], }, @@ -507,7 +507,7 @@ sub tables_hash_hack { 'amount', @money_type, '_date', @date_type ], - 'primary_key' => 'creditrefundnum' + 'primary_key' => 'creditrefundnum', 'unique' => [ [] ], 'index' => [ [ 'crednum', 'refundnum' ] ], }, -- cgit v1.2.1 From 7258cc4a7bf97ab2a0bca9dd2242e328e1a017ee Mon Sep 17 00:00:00 2001 From: ivan Date: Tue, 4 Sep 2001 11:14:13 +0000 Subject: tyops --- bin/fs-setup | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'bin') diff --git a/bin/fs-setup b/bin/fs-setup index 0c2b67dda..3d56d9f1f 100755 --- a/bin/fs-setup +++ b/bin/fs-setup @@ -1,6 +1,6 @@ #!/usr/bin/perl -Tw # -# $Id: fs-setup,v 1.50 2001-09-04 11:03:22 ivan Exp $ +# $Id: fs-setup,v 1.51 2001-09-04 11:14:13 ivan Exp $ #to delay loading dbdef until we're ready BEGIN { $FS::Record::setup_hack = 1; } @@ -79,6 +79,8 @@ my(%tables)=&tables_hash_hack; #turn it into objects my($dbdef) = new DBIx::DBSchema ( map { my(@columns); + warn $_; + warn $tables{$_}{'columns'}; while (@{$tables{$_}{'columns'}}) { my($name,$type,$null,$length)=splice @{$tables{$_}{'columns'}}, 0, 4; push @columns, new DBIx::DBSchema::Column ( $name,$type,$null,$length ); @@ -426,7 +428,7 @@ sub tables_hash_hack { }, 'cust_bill_pay' => { - 'column' => [ + 'columns' => [ 'billpaynum', 'int', '', '', 'invnum', 'int', '', '', 'paynum', 'int', '', '', @@ -500,7 +502,7 @@ sub tables_hash_hack { }, 'cust_credit_refund' => { - 'column' => [ + 'columns' => [ 'creditrefundnum', 'int', '', '', 'crednum', 'int', '', '', 'refundnum', 'int', '', '', -- cgit v1.2.1 From 895e5dd0c472e41875435cc625f1ca0a36bd2524 Mon Sep 17 00:00:00 2001 From: ivan Date: Tue, 4 Sep 2001 11:15:15 +0000 Subject: much better --- bin/fs-setup | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'bin') diff --git a/bin/fs-setup b/bin/fs-setup index 3d56d9f1f..1c720e698 100755 --- a/bin/fs-setup +++ b/bin/fs-setup @@ -1,6 +1,6 @@ #!/usr/bin/perl -Tw # -# $Id: fs-setup,v 1.51 2001-09-04 11:14:13 ivan Exp $ +# $Id: fs-setup,v 1.52 2001-09-04 11:15:15 ivan Exp $ #to delay loading dbdef until we're ready BEGIN { $FS::Record::setup_hack = 1; } @@ -79,7 +79,6 @@ my(%tables)=&tables_hash_hack; #turn it into objects my($dbdef) = new DBIx::DBSchema ( map { my(@columns); - warn $_; warn $tables{$_}{'columns'}; while (@{$tables{$_}{'columns'}}) { my($name,$type,$null,$length)=splice @{$tables{$_}{'columns'}}, 0, 4; -- cgit v1.2.1 From feafaf45ee709ef15b6cf7892abf89e4878c627b Mon Sep 17 00:00:00 2001 From: ivan Date: Tue, 4 Sep 2001 11:15:58 +0000 Subject: rar --- bin/fs-setup | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'bin') diff --git a/bin/fs-setup b/bin/fs-setup index 1c720e698..5dc666a1e 100755 --- a/bin/fs-setup +++ b/bin/fs-setup @@ -1,6 +1,6 @@ #!/usr/bin/perl -Tw # -# $Id: fs-setup,v 1.52 2001-09-04 11:15:15 ivan Exp $ +# $Id: fs-setup,v 1.53 2001-09-04 11:15:58 ivan Exp $ #to delay loading dbdef until we're ready BEGIN { $FS::Record::setup_hack = 1; } @@ -79,7 +79,6 @@ my(%tables)=&tables_hash_hack; #turn it into objects my($dbdef) = new DBIx::DBSchema ( map { my(@columns); - warn $tables{$_}{'columns'}; while (@{$tables{$_}{'columns'}}) { my($name,$type,$null,$length)=splice @{$tables{$_}{'columns'}}, 0, 4; push @columns, new DBIx::DBSchema::Column ( $name,$type,$null,$length ); -- cgit v1.2.1 From 57d69d5c1f98f778a0df82795ce21ee7bd21042a Mon Sep 17 00:00:00 2001 From: ivan Date: Thu, 6 Sep 2001 20:42:00 +0000 Subject: finally fix part_svc!!! --- bin/fs-migrate-part_svc | 40 +++++++++++++++++++++++++++++ bin/fs-migrate-payref | 7 +++--- bin/fs-radius-add-check | 4 +-- bin/fs-radius-add-reply | 4 +-- bin/fs-setup | 67 +++++++++++++++++++++++++++++-------------------- 5 files changed, 88 insertions(+), 34 deletions(-) create mode 100755 bin/fs-migrate-part_svc (limited to 'bin') diff --git a/bin/fs-migrate-part_svc b/bin/fs-migrate-part_svc new file mode 100755 index 000000000..96332f72a --- /dev/null +++ b/bin/fs-migrate-part_svc @@ -0,0 +1,40 @@ +#!/usr/bin/perl + +use strict; +use FS::UID qw(adminsuidsetup); +use FS::Record qw(qsearchs); +use FS::part_svc + +my $user = shift or die &usage; +my $dbh = adminsuidsetup $user; + +my $oldAutoCommit = $FS::UID::AutoCommit; +local $FS::UID::AutoCommit = 0 + +foreach my $part_svc ( qsearch('part_svc', {} ) ) { + foreach my $field ( + grep { defined($part_svc->getfield($part_svc->svcdb.'__'.$field.'_flag') ) } + fields($self->svcdb) + ) { + my $flag = $self->getfield($part_svc->svcdb.'__'.$field.'_flag'); + if ( uc($flag) =~ /^([DF])$/ ) { + $part_svc_column->setfield('columnflag', $1); + $part_svc_column->setfield('columnvalue', + $self->getfield($part_svc->svcdb.'__'.$field) + ); + $error = $part_svc_column->insert; + } else { + $error = $part_svc_column->delete; + } + if ( $error ) { + $dbh->rollback if $oldAutoCommit; + die $error; + } + + } +} + +sub usage { + die "Usage:\n fs-migrate-part_svc user\n"; +} + diff --git a/bin/fs-migrate-payref b/bin/fs-migrate-payref index f1513112b..158419706 100755 --- a/bin/fs-migrate-payref +++ b/bin/fs-migrate-payref @@ -9,9 +9,6 @@ use FS::cust_refund; my $user = shift or die &usage; my $dbh = adminsuidsetup $user; -#local $FS::UID::AutoCommit = 0; #quelle hack, in this case -# $FS::UID::AutoCommit = 0; #quelle hack, in this case - # apply payments to invoices foreach my $cust_pay ( qsearch('cust_pay', {} ) ) { @@ -28,3 +25,7 @@ foreach my $cust_refund ( qsearch('cust_refund') ) { # ? apply credits to invoices +sub usage { + die "Usage:\n fs-migrate-payref user\n"; +} + diff --git a/bin/fs-radius-add-check b/bin/fs-radius-add-check index 92523eb95..fadba0165 100755 --- a/bin/fs-radius-add-check +++ b/bin/fs-radius-add-check @@ -35,8 +35,8 @@ my($char_d) = 80; #default maxlength for text fields foreach my $attribute ( @attributes ) { foreach my $statement ( "ALTER TABLE svc_acct ADD rc_$attribute varchar($char_d) NULL", - "ALTER TABLE part_svc ADD svc_acct__rc_$attribute varchar($char_d) NULL;", - "ALTER TABLE part_svc ADD svc_acct__rc_${attribute}_flag char(1) NULL;", +# "ALTER TABLE part_svc ADD svc_acct__rc_$attribute varchar($char_d) NULL;", +# "ALTER TABLE part_svc ADD svc_acct__rc_${attribute}_flag char(1) NULL;", ) { $dbh->do( $statement ) or warn "Error executing $statement: ". $dbh->errstr; } } diff --git a/bin/fs-radius-add-reply b/bin/fs-radius-add-reply index 7938feac6..997a8eac7 100755 --- a/bin/fs-radius-add-reply +++ b/bin/fs-radius-add-reply @@ -35,8 +35,8 @@ my($char_d) = 80; #default maxlength for text fields foreach my $attribute ( @attributes ) { foreach my $statement ( "ALTER TABLE svc_acct ADD radius_$attribute varchar($char_d) NULL", - "ALTER TABLE part_svc ADD svc_acct__radius_$attribute varchar($char_d) NULL;", - "ALTER TABLE part_svc ADD svc_acct__radius_${attribute}_flag char(1) NULL;", +# "ALTER TABLE part_svc ADD svc_acct__radius_$attribute varchar($char_d) NULL;", +# "ALTER TABLE part_svc ADD svc_acct__radius_${attribute}_flag char(1) NULL;", ) { $dbh->do( $statement ) or warn "Error executing $statement: ". $dbh->errstr; } } diff --git a/bin/fs-setup b/bin/fs-setup index 5dc666a1e..53d96f692 100755 --- a/bin/fs-setup +++ b/bin/fs-setup @@ -1,6 +1,6 @@ #!/usr/bin/perl -Tw # -# $Id: fs-setup,v 1.53 2001-09-04 11:15:58 ivan Exp $ +# $Id: fs-setup,v 1.54 2001-09-06 20:41:59 ivan Exp $ #to delay loading dbdef until we're ready BEGIN { $FS::Record::setup_hack = 1; } @@ -122,32 +122,32 @@ foreach $attribute (@check_attributes) { )); } -#make part_svc table (but now as object) - -my($part_svc)=$dbdef->table('part_svc'); - -#because of svc_acct_pop -#foreach (grep /^svc_/, $dbdef->tables) { -#foreach (qw(svc_acct svc_acct_sm svc_charge svc_domain svc_wo)) { -foreach (qw(svc_acct svc_domain svc_forward svc_www)) { - my($table)=$dbdef->table($_); - my($col); - foreach $col ( $table->columns ) { - next if $col =~ /^svcnum$/; - $part_svc->addcolumn( new DBIx::DBSchema::Column ( - $table->name. '__' . $table->column($col)->name, - 'varchar', #$table->column($col)->type, - 'NULL', - $char_d, #$table->column($col)->length, - )); - $part_svc->addcolumn ( new DBIx::DBSchema::Column ( - $table->name. '__'. $table->column($col)->name . "_flag", - 'char', - 'NULL', - 1, - )); - } -} +##make part_svc table (but now as object) +# +#my($part_svc)=$dbdef->table('part_svc'); +# +##because of svc_acct_pop +##foreach (grep /^svc_/, $dbdef->tables) { +##foreach (qw(svc_acct svc_acct_sm svc_charge svc_domain svc_wo)) { +#foreach (qw(svc_acct svc_domain svc_forward svc_www)) { +# my($table)=$dbdef->table($_); +# my($col); +# foreach $col ( $table->columns ) { +# next if $col =~ /^svcnum$/; +# $part_svc->addcolumn( new DBIx::DBSchema::Column ( +# $table->name. '__' . $table->column($col)->name, +# 'varchar', #$table->column($col)->type, +# 'NULL', +# $char_d, #$table->column($col)->length, +# )); +# $part_svc->addcolumn ( new DBIx::DBSchema::Column ( +# $table->name. '__'. $table->column($col)->name . "_flag", +# 'char', +# 'NULL', +# 1, +# )); +# } +#} #important $dbdef->save($dbdef_file); @@ -580,6 +580,19 @@ sub tables_hash_hack { 'index' => [ [] ], }, + 'part_svc_column' => { + 'columns' => [ + 'columnnum', 'int', '', '', + 'svcpart', 'int', '', '', + 'columnname', 'varchar', '', 64, + 'columnvalue', 'varchar', 'NULL', $char_d, + 'columnflag', 'char', 'NULL', 1, + ], + 'primary_key' => 'columnnum', + 'unique' => [ [ 'svcpart', 'columnname' ] ], + 'index' => [ [ 'svcpart' ] ], + } + #(this should be renamed to part_pop) 'svc_acct_pop' => { 'columns' => [ -- cgit v1.2.1 From 3beb58199322355f8caa166000bb94e9419b4232 Mon Sep 17 00:00:00 2001 From: ivan Date: Fri, 7 Sep 2001 20:17:50 +0000 Subject: fix RADIUS attribute capitalization --- bin/fs-radius-add-check | 8 +++++++- bin/fs-radius-add-reply | 8 +++++++- bin/fs-setup | 12 +++++++++--- bin/generate-raddb | 35 +++++++++++++++++++++++++++++++++++ 4 files changed, 58 insertions(+), 5 deletions(-) create mode 100755 bin/generate-raddb (limited to 'bin') diff --git a/bin/fs-radius-add-check b/bin/fs-radius-add-check index fadba0165..eedd9b699 100755 --- a/bin/fs-radius-add-check +++ b/bin/fs-radius-add-check @@ -5,8 +5,13 @@ use strict; use DBI; use FS::UID qw(adminsuidsetup checkeuid getsecrets); +use FS::raddb; + die "Not running uid freeside!" unless checkeuid(); +my %attrib2db = + map { $FS::raddb::attrib{lc($_)} => $_ } keys %FS::raddb::attrib; + my $user = shift or die &usage; getsecrets($user); @@ -18,7 +23,8 @@ print "\n\n", <); diff --git a/bin/fs-radius-add-reply b/bin/fs-radius-add-reply index 997a8eac7..d2f2e11f0 100755 --- a/bin/fs-radius-add-reply +++ b/bin/fs-radius-add-reply @@ -5,8 +5,13 @@ use strict; use DBI; use FS::UID qw(adminsuidsetup checkeuid getsecrets); +use FS::raddb; + die "Not running uid freeside!" unless checkeuid(); +my %attrib2db = + map { $FS::raddb::attrib{lc($_)} => $_ } keys %FS::raddb::attrib; + my $user = shift or die &usage; getsecrets($user); @@ -18,7 +23,8 @@ print "\n\n", <); diff --git a/bin/fs-setup b/bin/fs-setup index 53d96f692..dc597ccb4 100755 --- a/bin/fs-setup +++ b/bin/fs-setup @@ -1,6 +1,6 @@ #!/usr/bin/perl -Tw # -# $Id: fs-setup,v 1.54 2001-09-06 20:41:59 ivan Exp $ +# $Id: fs-setup,v 1.55 2001-09-07 20:17:50 ivan Exp $ #to delay loading dbdef until we're ready BEGIN { $FS::Record::setup_hack = 1; } @@ -15,9 +15,13 @@ use DBIx::DBSchema::ColGroup::Index; use FS::UID qw(adminsuidsetup datasrc checkeuid getsecrets); use FS::Record; use FS::cust_main_county; +use FS::raddb; die "Not running uid freeside!" unless checkeuid(); +my %attrib2db = + map { $FS::raddb::attrib{lc($_)} => $_ } keys %FS::raddb::attrib; + my $user = shift or die &usage; getsecrets($user); @@ -35,13 +39,15 @@ reply attribute Framed-IP-Address for each user. You can specify additional check and reply attributes. First enter any additional RADIUS check attributes you need to track for each user, separated by whitespace. END -my @check_attributes = map { s/\-/_/g; $_; } split(" ",&getvalue); +my @check_attributes = map { $attrib2db{lc($_)} or die "unknown attribute $_"; } + split(" ",&getvalue); print "\n\n", <raddb.pm +# i.e.: generate-raddb ~/src/freeradius-0.2/raddb/dictionary* >FS/raddb.pm + +print <) { + next if /^(#|\s*$|\$INCLUDE\s+)/; + next if /^(VALUE|VENDOR|BEGIN\-VENDOR|END\-VENDOR)\s+/; + /^(ATTRIBUTE|ATTRIB_NMC)\s+([\w\-]+)\s+/ or die $_; + $attrib = $2; + $dbname = lc($2); + $dbname =~ s/\-/_/g; + $hash{$dbname} = $attrib; + #print "$2\n"; +} + +foreach ( keys %hash ) { +# print "$_\n" if length($_)>24; +# print substr($_,0,24),"\n" if length($_)>24; +# $max = length($_) if length($_)>$max; +#everything >24 is still unique, at least with freeradius comprehensive dataset + print " '". substr($_,0,24). "' => '$hash{$_}'\n"; +} + +print < Date: Fri, 7 Sep 2001 20:26:33 +0000 Subject: tyops --- bin/generate-raddb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'bin') diff --git a/bin/generate-raddb b/bin/generate-raddb index e9580d645..1d0053a2b 100755 --- a/bin/generate-raddb +++ b/bin/generate-raddb @@ -26,10 +26,12 @@ foreach ( keys %hash ) { # print substr($_,0,24),"\n" if length($_)>24; # $max = length($_) if length($_)>$max; #everything >24 is still unique, at least with freeradius comprehensive dataset - print " '". substr($_,0,24). "' => '$hash{$_}'\n"; + print " '". substr($_,0,24). "' => '$hash{$_}',\n"; } print < Date: Sat, 8 Sep 2001 00:28:49 +0000 Subject: First post. Sorry. Missing comma. --- bin/fs-setup | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'bin') diff --git a/bin/fs-setup b/bin/fs-setup index dc597ccb4..03b5a04a9 100755 --- a/bin/fs-setup +++ b/bin/fs-setup @@ -1,6 +1,6 @@ #!/usr/bin/perl -Tw # -# $Id: fs-setup,v 1.55 2001-09-07 20:17:50 ivan Exp $ +# $Id: fs-setup,v 1.56 2001-09-08 00:28:49 khoff Exp $ #to delay loading dbdef until we're ready BEGIN { $FS::Record::setup_hack = 1; } @@ -597,7 +597,7 @@ sub tables_hash_hack { 'primary_key' => 'columnnum', 'unique' => [ [ 'svcpart', 'columnname' ] ], 'index' => [ [ 'svcpart' ] ], - } + }, #(this should be renamed to part_pop) 'svc_acct_pop' => { -- cgit v1.2.1 From 85e59606c0b5eed9780534ffaf554aa32bcf9baf Mon Sep 17 00:00:00 2001 From: ivan Date: Tue, 11 Sep 2001 00:07:30 +0000 Subject: fixing fs-migrate-part_svc updateing fs-setup for job queues freeside-init for starting freeside-queued --- bin/freeside-init | 60 +++++++++++++++++++++++++++++++++++++++++++++++++ bin/fs-migrate-part_svc | 37 +++++++++++++++--------------- bin/fs-setup | 24 +++++++++++++++++++- 3 files changed, 102 insertions(+), 19 deletions(-) create mode 100755 bin/freeside-init (limited to 'bin') diff --git a/bin/freeside-init b/bin/freeside-init new file mode 100755 index 000000000..fe12931fc --- /dev/null +++ b/bin/freeside-init @@ -0,0 +1,60 @@ +#! /bin/sh +# +# start the freeside job queue daemon + +#PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin +DAEMON=/usr/local/bin/freeside-queued +NAME=freeside-queued +DESC="freeside job queue daemon" +USER="ivan" + +test -f $DAEMON || exit 0 + +set -e + +case "$1" in + start) + echo -n "Starting $DESC: " +# start-stop-daemon --start --quiet --pidfile /var/run/$NAME.pid -b -m\ +# --exec $DAEMON + $DAEMON $USER & + echo "$NAME." + ;; + stop) + echo -n "Stopping $DESC: " + start-stop-daemon --stop --quiet --pidfile /var/run/$NAME.pid \ + --exec $DAEMON + echo "$NAME." + rm /var/run/$NAME.pid + ;; + #reload) + # + # If the daemon can reload its config files on the fly + # for example by sending it SIGHUP, do it here. + # + # If the daemon responds to changes in its config file + # directly anyway, make this a do-nothing entry. + # + # echo "Reloading $DESC configuration files." + # start-stop-daemon --stop --signal 1 --quiet --pidfile \ + # /var/run/$NAME.pid --exec $DAEMON + #;; + restart|force-reload) + # + # If the "reload" option is implemented, move the "force-reload" + # option to the "reload" entry above. If not, "force-reload" is + # just the same as "restart". + # + $0 stop + sleep 1 + $0 start + ;; + *) + N=/etc/init.d/$NAME + # echo "Usage: $N {start|stop|restart|reload|force-reload}" >&2 + echo "Usage: $N {start|stop|restart|force-reload}" >&2 + exit 1 + ;; +esac + +exit 0 diff --git a/bin/fs-migrate-part_svc b/bin/fs-migrate-part_svc index 96332f72a..b0f3ac57e 100755 --- a/bin/fs-migrate-part_svc +++ b/bin/fs-migrate-part_svc @@ -2,38 +2,39 @@ use strict; use FS::UID qw(adminsuidsetup); -use FS::Record qw(qsearchs); -use FS::part_svc +use FS::Record qw(qsearch fields); +use FS::part_svc; my $user = shift or die &usage; my $dbh = adminsuidsetup $user; my $oldAutoCommit = $FS::UID::AutoCommit; -local $FS::UID::AutoCommit = 0 +local $FS::UID::AutoCommit = 0; foreach my $part_svc ( qsearch('part_svc', {} ) ) { foreach my $field ( - grep { defined($part_svc->getfield($part_svc->svcdb.'__'.$field.'_flag') ) } - fields($self->svcdb) + grep { defined($part_svc->getfield($part_svc->svcdb.'__'.$_.'_flag') ) } + fields($part_svc->svcdb) ) { - my $flag = $self->getfield($part_svc->svcdb.'__'.$field.'_flag'); + my $flag = $part_svc->getfield($part_svc->svcdb.'__'.$field.'_flag'); if ( uc($flag) =~ /^([DF])$/ ) { - $part_svc_column->setfield('columnflag', $1); - $part_svc_column->setfield('columnvalue', - $self->getfield($part_svc->svcdb.'__'.$field) - ); - $error = $part_svc_column->insert; - } else { - $error = $part_svc_column->delete; + my $part_svc_column = new FS::part_svc_column { + 'svcpart' => $part_svc->svcpart, + 'columnname' => $field, + 'columnflag' => $1, + 'columnvalue' => $part_svc->getfield($part_svc->svcdb.'__'.$field), + }; + my $error = $part_svc_column->insert; + if ( $error ) { + $dbh->rollback if $oldAutoCommit; + die $error; + } } - if ( $error ) { - $dbh->rollback if $oldAutoCommit; - die $error; - } - } } +$dbh->commit or die $dbh->errstr; + sub usage { die "Usage:\n fs-migrate-part_svc user\n"; } diff --git a/bin/fs-setup b/bin/fs-setup index 03b5a04a9..9534eb23f 100755 --- a/bin/fs-setup +++ b/bin/fs-setup @@ -1,6 +1,6 @@ #!/usr/bin/perl -Tw # -# $Id: fs-setup,v 1.56 2001-09-08 00:28:49 khoff Exp $ +# $Id: fs-setup,v 1.57 2001-09-11 00:07:30 ivan Exp $ #to delay loading dbdef until we're ready BEGIN { $FS::Record::setup_hack = 1; } @@ -768,6 +768,28 @@ sub tables_hash_hack { 'index' => [ [ 'portnum' ] ], }, + 'queue' => { + 'columns' => [ + 'jobnum', 'int', '', '', + 'job', 'varchar', '', '', + '_date', 'int', '', '', + 'status', 'varchar', '', $char_d, + ], + 'primary_key' => 'jobnum', + 'unique' => [], + 'index' => [], + }, + + 'queue_arg' => { + 'columns' => [ + 'argnum', 'int', '', '', + 'jobnum', 'int', '', '', + 'arg', 'varchar', 'NULL', '', + ], + 'primary_key' => 'argnum', + 'unique' => [], + 'index' => [ [ 'jobnum' ] ], + }, ); %tables; -- cgit v1.2.1 From cf7ca698138c8708c68cb969cc843311e385a7a8 Mon Sep 17 00:00:00 2001 From: ivan Date: Tue, 11 Sep 2001 22:20:28 +0000 Subject: fix radius attribute adding --- bin/fs-radius-add-check | 17 +++++++++-------- bin/fs-radius-add-reply | 16 +++++++++------- bin/fs-setup | 4 ++-- bin/svc_acct.export | 4 ++-- 4 files changed, 22 insertions(+), 19 deletions(-) (limited to 'bin') diff --git a/bin/fs-radius-add-check b/bin/fs-radius-add-check index eedd9b699..ca0492f4c 100755 --- a/bin/fs-radius-add-check +++ b/bin/fs-radius-add-check @@ -10,7 +10,7 @@ use FS::raddb; die "Not running uid freeside!" unless checkeuid(); my %attrib2db = - map { $FS::raddb::attrib{lc($_)} => $_ } keys %FS::raddb::attrib; + map { lc($FS::raddb::attrib{$_}) => $_ } keys %FS::raddb::attrib; my $user = shift or die &usage; getsecrets($user); @@ -39,14 +39,16 @@ my($char_d) = 80; #default maxlength for text fields ### foreach my $attribute ( @attributes ) { - foreach my $statement ( - "ALTER TABLE svc_acct ADD rc_$attribute varchar($char_d) NULL", -# "ALTER TABLE part_svc ADD svc_acct__rc_$attribute varchar($char_d) NULL;", -# "ALTER TABLE part_svc ADD svc_acct__rc_${attribute}_flag char(1) NULL;", - ) { - $dbh->do( $statement ) or warn "Error executing $statement: ". $dbh->errstr; } + my $statement = + "ALTER TABLE svc_acct ADD COLUMN rc_$attribute varchar($char_d) NULL"; + my $sth = $dbh->prepare( $statement ) + or warn "Error preparing $statement: ". $dbh->errstr; + my $rc = $sth->execute + or warn "Error executing $statement: ". $sth->errstr; } +$dbh->commit or die $dbh->errstr; + $dbh->disconnect or die $dbh->errstr; print "\n\n", "Now you must run dbdef-create.\n\n"; @@ -55,4 +57,3 @@ sub usage { die "Usage:\n fs-radius-add user\n"; } - diff --git a/bin/fs-radius-add-reply b/bin/fs-radius-add-reply index d2f2e11f0..2f38fbcf7 100755 --- a/bin/fs-radius-add-reply +++ b/bin/fs-radius-add-reply @@ -10,7 +10,7 @@ use FS::raddb; die "Not running uid freeside!" unless checkeuid(); my %attrib2db = - map { $FS::raddb::attrib{lc($_)} => $_ } keys %FS::raddb::attrib; + map { lc($FS::raddb::attrib{$_}) => $_ } keys %FS::raddb::attrib; my $user = shift or die &usage; getsecrets($user); @@ -39,14 +39,16 @@ my($char_d) = 80; #default maxlength for text fields ### foreach my $attribute ( @attributes ) { - foreach my $statement ( - "ALTER TABLE svc_acct ADD radius_$attribute varchar($char_d) NULL", -# "ALTER TABLE part_svc ADD svc_acct__radius_$attribute varchar($char_d) NULL;", -# "ALTER TABLE part_svc ADD svc_acct__radius_${attribute}_flag char(1) NULL;", - ) { - $dbh->do( $statement ) or warn "Error executing $statement: ". $dbh->errstr; } + my $statement = + "ALTER TABLE svc_acct ADD COLUMN radius_$attribute varchar($char_d) NULL"; + my $sth = $dbh->prepare( $statement ) + or warn "Error preparing $statement: ". $dbh->errstr; + $sth->execute + or warn "Error executing $statement: ". $sth->errstr; } +$dbh->commit or die $dbh->errstr; + $dbh->disconnect or die $dbh->errstr; print "\n\n", "Now you must run dbdef-create.\n\n"; diff --git a/bin/fs-setup b/bin/fs-setup index 9534eb23f..e7dda8ed7 100755 --- a/bin/fs-setup +++ b/bin/fs-setup @@ -1,6 +1,6 @@ #!/usr/bin/perl -Tw # -# $Id: fs-setup,v 1.57 2001-09-11 00:07:30 ivan Exp $ +# $Id: fs-setup,v 1.58 2001-09-11 22:20:28 ivan Exp $ #to delay loading dbdef until we're ready BEGIN { $FS::Record::setup_hack = 1; } @@ -20,7 +20,7 @@ use FS::raddb; die "Not running uid freeside!" unless checkeuid(); my %attrib2db = - map { $FS::raddb::attrib{lc($_)} => $_ } keys %FS::raddb::attrib; + map { lc($FS::raddb::attrib{$_}) => $_ } keys %FS::raddb::attrib; my $user = shift or die &usage; getsecrets($user); diff --git a/bin/svc_acct.export b/bin/svc_acct.export index a5ec45d48..3b8853bb0 100755 --- a/bin/svc_acct.export +++ b/bin/svc_acct.export @@ -1,6 +1,6 @@ #!/usr/bin/perl -w # -# $Id: svc_acct.export,v 1.23 2001-08-17 10:57:40 ivan Exp $ +# $Id: svc_acct.export,v 1.24 2001-09-11 22:20:28 ivan Exp $ # # Create and export password, radius and vpopmail password files: # passwd, passwd.adjunct, shadow, acp_passwd, acp_userinfo, acp_dialup @@ -56,7 +56,7 @@ my $icradius_mysqlsource = my $icradius_dbh; if ( $icradiusmachines && $conf->exists('icradius_secrets') ) { $icradius_dbh = DBI->connect($conf->config('icradius_secrets')) - or die $DBI::errstr;; + or die $DBI::errstr; } else { $icradius_dbh = dbh; } -- cgit v1.2.1 From 8ca6f203e5dae208d7af581d68671fe47c5e1a1a Mon Sep 17 00:00:00 2001 From: ivan Date: Wed, 26 Sep 2001 09:17:06 +0000 Subject: add part_pop_local table --- bin/fs-setup | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) (limited to 'bin') diff --git a/bin/fs-setup b/bin/fs-setup index e7dda8ed7..52a2505e5 100755 --- a/bin/fs-setup +++ b/bin/fs-setup @@ -1,6 +1,6 @@ #!/usr/bin/perl -Tw # -# $Id: fs-setup,v 1.58 2001-09-11 22:20:28 ivan Exp $ +# $Id: fs-setup,v 1.59 2001-09-26 09:17:06 ivan Exp $ #to delay loading dbdef until we're ready BEGIN { $FS::Record::setup_hack = 1; } @@ -611,7 +611,21 @@ sub tables_hash_hack { ], 'primary_key' => 'popnum', 'unique' => [ [] ], - 'index' => [ [] ], + 'index' => [ [ 'state' ] ], + }, + + 'part_pop_local' => { + 'columns' => [ + 'localnum', 'int', '', '', + 'popnum', 'int', '', '', + 'city', 'varchar', 'NULL', $char_d, + 'state', 'char', 'NULL', 2, + 'npa', 'char', '', 3, + 'nxx', 'char', '', 3, + ], + 'primary_key' => 'popnum', + 'unique' => [ [] ], + 'index' => [ [ 'npa', 'nxx' ] ], }, 'svc_acct' => { -- cgit v1.2.1 From 44e51a5c50be350fa698bcdcf86ad5c01a7631a2 Mon Sep 17 00:00:00 2001 From: jeff Date: Tue, 2 Oct 2001 16:00:31 +0000 Subject: add pkey to batch payments and fix a doc typo --- bin/fs-setup | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'bin') diff --git a/bin/fs-setup b/bin/fs-setup index 52a2505e5..476b84d87 100755 --- a/bin/fs-setup +++ b/bin/fs-setup @@ -1,6 +1,6 @@ #!/usr/bin/perl -Tw # -# $Id: fs-setup,v 1.59 2001-09-26 09:17:06 ivan Exp $ +# $Id: fs-setup,v 1.60 2001-10-02 16:00:30 jeff Exp $ #to delay loading dbdef until we're ready BEGIN { $FS::Record::setup_hack = 1; } @@ -447,6 +447,7 @@ sub tables_hash_hack { 'cust_pay_batch' => { #what's this used for again? list of customers #in current CARD batch? (necessarily CARD?) 'columns' => [ + 'paybatchnum', 'int', '', '', 'invnum', 'int', '', '', 'custnum', 'int', '', '', 'last', 'varchar', '', $char_d, @@ -464,7 +465,7 @@ sub tables_hash_hack { 'payname', 'varchar', 'NULL', $char_d, 'amount', @money_type, ], - 'primary_key' => '', + 'primary_key' => 'paybatchnum', 'unique' => [ [] ], 'index' => [ ['invnum'], ['custnum'] ], }, -- cgit v1.2.1 From 4bbf90e800406ff75a5fed09ba5cd71293cda542 Mon Sep 17 00:00:00 2001 From: ivan Date: Tue, 9 Oct 2001 23:10:17 +0000 Subject: add `unsuspendauto' config file: enable the automatic unsuspension of suspended packages when a customer's balance due changes from positive to zero or negative as the result of a payment or credit add cust_pkg.manual_flag to disable this behaviour per customer package (no UI to set this yet) --- bin/fs-setup | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'bin') diff --git a/bin/fs-setup b/bin/fs-setup index 476b84d87..edfc5ff1c 100755 --- a/bin/fs-setup +++ b/bin/fs-setup @@ -1,6 +1,6 @@ #!/usr/bin/perl -Tw # -# $Id: fs-setup,v 1.60 2001-10-02 16:00:30 jeff Exp $ +# $Id: fs-setup,v 1.61 2001-10-09 23:10:17 ivan Exp $ #to delay loading dbdef until we're ready BEGIN { $FS::Record::setup_hack = 1; } @@ -481,6 +481,7 @@ sub tables_hash_hack { 'susp', @date_type, 'cancel', @date_type, 'expire', @date_type, + 'manual_flag', 'char', 'NULL', 1, ], 'primary_key' => 'pkgnum', 'unique' => [ [] ], -- cgit v1.2.1 From a6d3e4dc73803cffad96fd4b6270b2fb5f4b0568 Mon Sep 17 00:00:00 2001 From: ivan Date: Mon, 15 Oct 2001 10:42:29 +0000 Subject: price plans web gui 1st pass, oh my --- bin/fs-setup | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'bin') diff --git a/bin/fs-setup b/bin/fs-setup index edfc5ff1c..96ec2b74b 100755 --- a/bin/fs-setup +++ b/bin/fs-setup @@ -1,6 +1,6 @@ #!/usr/bin/perl -Tw # -# $Id: fs-setup,v 1.61 2001-10-09 23:10:17 ivan Exp $ +# $Id: fs-setup,v 1.62 2001-10-15 10:42:28 ivan Exp $ #to delay loading dbdef until we're ready BEGIN { $FS::Record::setup_hack = 1; } @@ -73,7 +73,7 @@ my($char_d) = 80; #default maxlength for text fields #my(@date_type) = ( 'timestamp', '', '' ); my(@date_type) = ( 'int', 'NULL', '' ); -my(@perl_type) = ( 'varchar', 'NULL', 255 ); +my(@perl_type) = ( 'varchar', 'NULL', '' ); my @money_type = ( 'decimal', '', '10,2' ); ### @@ -540,6 +540,8 @@ sub tables_hash_hack { 'setup', @perl_type, 'freq', 'int', '', '', #billing frequency (months) 'recur', @perl_type, + 'plan', 'varchar', 'NULL', '', + 'plandata', 'varchar', 'NULL', '', ], 'primary_key' => 'pkgpart', 'unique' => [ [] ], -- cgit v1.2.1 From fcb5658290eb457f0b2493b405c152a9cc1ad5a4 Mon Sep 17 00:00:00 2001 From: jeff Date: Tue, 16 Oct 2001 20:33:02 +0000 Subject: added slipip insertion for icradius and vpopmail restart config --- bin/svc_acct.export | 40 +++++++++++++++++++++++++++++++++------- 1 file changed, 33 insertions(+), 7 deletions(-) (limited to 'bin') diff --git a/bin/svc_acct.export b/bin/svc_acct.export index 3b8853bb0..bc27f7f02 100755 --- a/bin/svc_acct.export +++ b/bin/svc_acct.export @@ -1,6 +1,6 @@ #!/usr/bin/perl -w # -# $Id: svc_acct.export,v 1.24 2001-09-11 22:20:28 ivan Exp $ +# $Id: svc_acct.export,v 1.25 2001-10-16 20:33:02 jeff Exp $ # # Create and export password, radius and vpopmail password files: # passwd, passwd.adjunct, shadow, acp_passwd, acp_userinfo, acp_dialup @@ -48,7 +48,7 @@ my @radiusmachines = $conf->config('radiusmachines') my $icradiusmachines = $conf->exists('icradiusmachines'); my @icradiusmachines = $conf->config('icradiusmachines') if $icradiusmachines; my $icradius_mysqldest = - $conf->config('icradius_mysqldest') || "/usr/local/var/" + $conf->config('icradius_mysqldest') || "/usr/local/var" if $icradiusmachines; my $icradius_mysqlsource = $conf->config('icradius_mysqlsource') || "/usr/local/var/freeside" @@ -70,8 +70,11 @@ warn "using depriciated textradiusprepend file" if $textradiusprepend; my @vpopmailmachines = $conf->config('vpopmailmachines') if $conf->exists('vpopmailmachines'); +my $vpopmailrestart = ''; +$vpopmailrestart = $conf->config('vpopmailrestart') + if $conf->exists('vpopmailrestart'); -my ($machine, $vpopdir, $vpopuid, $vpopgid) = split (/\s+/, $vpopmailmachines[0]); +my ($machine, $vpopdir, $vpopuid, $vpopgid) = split (/\s+/, $vpopmailmachines[0]) if $vpopmailmachines[0]; my($shellmachine, @qmailmachines); if ( $conf->exists('qmailmachines') ) { @@ -209,7 +212,7 @@ foreach $svc_domain (sort {$a->domain cmp $b->domain} @svc_domain) { "-", "", "", - ), "\n"; + ), "\n" if $vpopmailmachines[0]; (mkdir "$spooldir/domains/" . $domain, 0700) or die "Can't create $spooldir/domains/" . $domain .": $!"; @@ -224,7 +227,7 @@ foreach $svc_domain (sort {$a->domain cmp $b->domain} @svc_domain) { my ($svc_acct); - if ($svc_domain->catchall) { + if ($svc_domain->getfield('catchall')) { $svc_acct = qsearchs('svc_acct', {'svcnum' => $svc_domain->catchall}); die "Cannot find catchall account for domain $domain\n" unless $svc_acct; @@ -236,12 +239,14 @@ foreach $svc_domain (sort {$a->domain cmp $b->domain} @svc_domain) { ### # FORMAT OF THE .QMAIL-DEFAULT FILE HERE - print QMAILDEFAULT "| $vpopdir/bin/vdelivermail \"\" $username\@$domain\n"; + print QMAILDEFAULT "| $vpopdir/bin/vdelivermail \"\" " . $svc_acct->email . "\n" + if $vpopmailmachines[0]; }else{ ### # FORMAT OF THE .QMAIL-DEFAULT FILE HERE - print QMAILDEFAULT "| $vpopdir/bin/vdelivermail \"\" bounce-no-mailbox\n"; + print QMAILDEFAULT "| $vpopdir/bin/vdelivermail \"\" bounce-no-mailbox\n" + if $vpopmailmachines[0]; } print VPOPVIRTUALDOMAINS "$domain:$domain\n"; @@ -427,6 +432,18 @@ foreach $svc_domain (sort {$a->domain cmp $b->domain} @svc_domain) { ) ). " )" ); $sth->execute or die "Can't insert into radreply table: ". $sth->errstr; } + + if ( $ip && $ip ne '0e0' ) { + my $sth = $icradius_dbh->prepare( + "INSERT INTO radreply (id, UserName, Attribute, Value) VALUES ( ". + join(", ", map { $icradius_dbh->quote( $_ ) } ( + '', + $username, + 'Framed-IP-Address', + $ip, + ) ). " )" + ); + $sth->execute or die "Can't insert into radreply table: ". $sth->errstr; } } } @@ -644,6 +661,15 @@ foreach $vpopmailmachine (@vpopmailmachines) { or die "scp error: ". $scp->{errstr}; $scp->scp("$spooldir/vpoprcpthosts","root\@$machine:/var/qmail/control/rcpthosts") or die "scp error: ". $scp->{errstr}; + + ssh("root\@$machine", + "( ". + $vpopmailrestart . + " )" + ) + == 0 or die "ssh error: $!"; + + } my($sendmailmachine); -- cgit v1.2.1 From 60c837e0aaf454dfa0b0c0283dc36928782d1b6c Mon Sep 17 00:00:00 2001 From: ivan Date: Sat, 20 Oct 2001 12:18:00 +0000 Subject: setup and recurring fee tax exempt flags, UI to edit rework part_pkg editing UI some more --- bin/fs-setup | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'bin') diff --git a/bin/fs-setup b/bin/fs-setup index 96ec2b74b..5927f88f7 100755 --- a/bin/fs-setup +++ b/bin/fs-setup @@ -1,6 +1,6 @@ #!/usr/bin/perl -Tw # -# $Id: fs-setup,v 1.62 2001-10-15 10:42:28 ivan Exp $ +# $Id: fs-setup,v 1.63 2001-10-20 12:17:59 ivan Exp $ #to delay loading dbdef until we're ready BEGIN { $FS::Record::setup_hack = 1; } @@ -540,6 +540,8 @@ sub tables_hash_hack { 'setup', @perl_type, 'freq', 'int', '', '', #billing frequency (months) 'recur', @perl_type, + 'setuptax', 'char', 'NULL', 1, + 'recurtax', 'char', 'NULL', 1, 'plan', 'varchar', 'NULL', '', 'plandata', 'varchar', 'NULL', '', ], -- cgit v1.2.1 From 8e59cbe916e8d4127a83576f98ba2c23aa04ceaa Mon Sep 17 00:00:00 2001 From: ivan Date: Tue, 23 Oct 2001 18:15:06 +0000 Subject: mysql fixes --- bin/fs-setup | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'bin') diff --git a/bin/fs-setup b/bin/fs-setup index 5927f88f7..3d76bf823 100755 --- a/bin/fs-setup +++ b/bin/fs-setup @@ -1,6 +1,6 @@ #!/usr/bin/perl -Tw # -# $Id: fs-setup,v 1.63 2001-10-20 12:17:59 ivan Exp $ +# $Id: fs-setup,v 1.64 2001-10-23 18:15:06 ivan Exp $ #to delay loading dbdef until we're ready BEGIN { $FS::Record::setup_hack = 1; } @@ -73,7 +73,7 @@ my($char_d) = 80; #default maxlength for text fields #my(@date_type) = ( 'timestamp', '', '' ); my(@date_type) = ( 'int', 'NULL', '' ); -my(@perl_type) = ( 'varchar', 'NULL', '' ); +my(@perl_type) = ( 'text', 'NULL', '' ); my @money_type = ( 'decimal', '', '10,2' ); ### @@ -316,7 +316,7 @@ sub tables_hash_hack { '_date', @date_type, 'amount', @money_type, 'otaker', 'varchar', '', 8, - 'reason', 'varchar', 'NULL', 255, + 'reason', 'text', 'NULL', '', ], 'primary_key' => 'crednum', 'unique' => [ [] ], @@ -379,7 +379,7 @@ sub tables_hash_hack { 'otaker', 'varchar', '', 8, 'refnum', 'int', '', '', 'referral_custnum', 'int', 'NULL', '', - 'comments', 'varchar', 'NULL', '', + 'comments', 'text', 'NULL', '', ], 'primary_key' => 'custnum', 'unique' => [ [] ], @@ -542,8 +542,8 @@ sub tables_hash_hack { 'recur', @perl_type, 'setuptax', 'char', 'NULL', 1, 'recurtax', 'char', 'NULL', 1, - 'plan', 'varchar', 'NULL', '', - 'plandata', 'varchar', 'NULL', '', + 'plan', 'varchar', 'NULL', $char_d, + 'plandata', 'text', 'NULL', '', ], 'primary_key' => 'pkgpart', 'unique' => [ [] ], @@ -791,7 +791,7 @@ sub tables_hash_hack { 'queue' => { 'columns' => [ 'jobnum', 'int', '', '', - 'job', 'varchar', '', '', + 'job', 'text', '', '', '_date', 'int', '', '', 'status', 'varchar', '', $char_d, ], @@ -804,7 +804,7 @@ sub tables_hash_hack { 'columns' => [ 'argnum', 'int', '', '', 'jobnum', 'int', '', '', - 'arg', 'varchar', 'NULL', '', + 'arg', 'text', 'NULL', '', ], 'primary_key' => 'argnum', 'unique' => [], -- cgit v1.2.1 From e6b57805f6b3e76448ab9b6d280f2c53bc1410f3 Mon Sep 17 00:00:00 2001 From: ivan Date: Wed, 24 Oct 2001 15:29:31 +0000 Subject: preliminary web config editor new config files: username-ampersand, passwordmax fs-setup updates get rid of old and crufty and unused registries/ config foo documentation updates --- bin/fs-setup | 18 +++++++++++------- bin/svc_acct.export | 5 +++-- 2 files changed, 14 insertions(+), 9 deletions(-) (limited to 'bin') diff --git a/bin/fs-setup b/bin/fs-setup index 3d76bf823..f3889f0dc 100755 --- a/bin/fs-setup +++ b/bin/fs-setup @@ -1,13 +1,13 @@ #!/usr/bin/perl -Tw # -# $Id: fs-setup,v 1.64 2001-10-23 18:15:06 ivan Exp $ +# $Id: fs-setup,v 1.65 2001-10-24 15:29:30 ivan Exp $ #to delay loading dbdef until we're ready BEGIN { $FS::Record::setup_hack = 1; } use strict; use DBI; -use DBIx::DBSchema 0.18; +use DBIx::DBSchema 0.19; use DBIx::DBSchema::Table; use DBIx::DBSchema::Column; use DBIx::DBSchema::ColGroup::Unique; @@ -30,14 +30,18 @@ my($dbdef_file) = "/usr/local/etc/freeside/dbdef.". datasrc; ### -print "\nEnter the maximum username length: "; -my($username_len)=&getvalue; +#print "\nEnter the maximum username length: "; +#my($username_len)=&getvalue; +my $username_len = 32; #usernamemax config file print "\n\n", <domain cmp $b->domain} @svc_domain) { foreach $svc_acct (qsearch('svc_acct', {'domsvc' => $svc_domain->svcnum})) { my($password)=$svc_acct->getfield('_password'); my($cpassword,$rpassword); - if ( ( length($password) <= 8 ) + #if ( ( length($password) <= 8 ) + if ( ( length($password) <= 12 ) && ( $password ne '*' ) && ( $password ne '!!' ) && ( $password ne '' ) -- cgit v1.2.1 From 20c1183d2673b62bd0e29eb65f0a9a2c974b8027 Mon Sep 17 00:00:00 2001 From: ivan Date: Tue, 30 Oct 2001 19:05:27 +0000 Subject: depriciate cust_pay_batch.trancode web interface to view pending batch --- bin/fs-setup | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'bin') diff --git a/bin/fs-setup b/bin/fs-setup index f3889f0dc..4df3773af 100755 --- a/bin/fs-setup +++ b/bin/fs-setup @@ -1,6 +1,6 @@ #!/usr/bin/perl -Tw # -# $Id: fs-setup,v 1.65 2001-10-24 15:29:30 ivan Exp $ +# $Id: fs-setup,v 1.66 2001-10-30 19:05:27 ivan Exp $ #to delay loading dbdef until we're ready BEGIN { $FS::Record::setup_hack = 1; } @@ -462,7 +462,7 @@ sub tables_hash_hack { 'state', 'varchar', '', $char_d, 'zip', 'varchar', '', 10, 'country', 'char', '', 2, - 'trancode', 'int', '', '', +# 'trancode', 'int', '', '', 'cardnum', 'varchar', '', 16, #'exp', @date_type, 'exp', 'varchar', '', 11, -- cgit v1.2.1 From 2893c82b194c167229b07bebe27a5979bff43018 Mon Sep 17 00:00:00 2001 From: ivan Date: Mon, 5 Nov 2001 12:07:10 +0000 Subject: this is unfinished and untested anyway, but this corrects a silly typo --- bin/svc_domain.import | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'bin') diff --git a/bin/svc_domain.import b/bin/svc_domain.import index 3d3be9da5..10fe5b584 100644 --- a/bin/svc_domain.import +++ b/bin/svc_domain.import @@ -1,6 +1,6 @@ #!/usr/bin/perl -w # -# $Id: svc_domain.import,v 1.2 2001-04-22 01:56:15 ivan Exp $ +# $Id: svc_domain.import,v 1.3 2001-11-05 12:07:10 ivan Exp $ use strict; use vars qw( %d_part_svc ); @@ -56,7 +56,7 @@ while () { last if /^\s*directory\s+\"([\/\w+]+)\";/; } $directory = $1 or die "can't locate directory in named.conf!"; -whlie () { +while () { next unless /^\s*zone\s+\"([\w\.\-]+)\"\s+\{/; my $zone = $1; while () { -- cgit v1.2.1 From 9718b44594231631a1e045f17b6521881790b297 Mon Sep 17 00:00:00 2001 From: ivan Date: Tue, 6 Nov 2001 17:48:17 +0000 Subject: payinfo changed from length 16 to $char_d for future expansion --- bin/fs-setup | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'bin') diff --git a/bin/fs-setup b/bin/fs-setup index 4df3773af..da6c167e9 100755 --- a/bin/fs-setup +++ b/bin/fs-setup @@ -1,6 +1,6 @@ #!/usr/bin/perl -Tw # -# $Id: fs-setup,v 1.66 2001-10-30 19:05:27 ivan Exp $ +# $Id: fs-setup,v 1.67 2001-11-06 17:48:17 ivan Exp $ #to delay loading dbdef until we're ready BEGIN { $FS::Record::setup_hack = 1; } @@ -375,7 +375,7 @@ sub tables_hash_hack { 'ship_night', 'varchar', 'NULL', 20, 'ship_fax', 'varchar', 'NULL', 12, 'payby', 'char', '', 4, - 'payinfo', 'varchar', 'NULL', 16, + 'payinfo', 'varchar', 'NULL', $char_d, #'paydate', @date_type, 'paydate', 'varchar', 'NULL', 10, 'payname', 'varchar', 'NULL', $char_d, -- cgit v1.2.1 From 03dcc6e0f48fae0b892dbd36229884e684b94049 Mon Sep 17 00:00:00 2001 From: ivan Date: Tue, 11 Dec 2001 10:38:56 +0000 Subject: radiusprepend config file for export add Archive::Tar to docs --- bin/svc_acct.export | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'bin') diff --git a/bin/svc_acct.export b/bin/svc_acct.export index 727186085..8c408a2e8 100755 --- a/bin/svc_acct.export +++ b/bin/svc_acct.export @@ -1,6 +1,6 @@ #!/usr/bin/perl -w # -# $Id: svc_acct.export,v 1.26 2001-10-24 15:29:30 ivan Exp $ +# $Id: svc_acct.export,v 1.27 2001-12-11 10:38:56 ivan Exp $ # # Create and export password, radius and vpopmail password files: # passwd, passwd.adjunct, shadow, acp_passwd, acp_userinfo, acp_dialup @@ -68,6 +68,12 @@ my $textradiusprepend = warn "using depriciated textradiusprepend file" if $textradiusprepend; + +my $radiusprepend = + $conf->exists('radiusprepend') + ? $conf->config('radiusprepend') + : ''; + my @vpopmailmachines = $conf->config('vpopmailmachines') if $conf->exists('vpopmailmachines'); my $vpopmailrestart = ''; @@ -190,6 +196,8 @@ if ( $icradiusmachines ) { setpriority(0,0,10); +print USERS "$radiusprepend\n"; + my %usernames; ## this hack helps keep the passwd files sane my @sendmail; -- cgit v1.2.1 From aa858d1764680bb3a195a574e7daec0feb206dbf Mon Sep 17 00:00:00 2001 From: ivan Date: Wed, 12 Dec 2001 07:59:33 +0000 Subject: use pwd_mkdb to install /etc/master.passwd.new instead of moving it into place --- bin/svc_acct.export | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'bin') diff --git a/bin/svc_acct.export b/bin/svc_acct.export index 8c408a2e8..3ac7a4f8f 100755 --- a/bin/svc_acct.export +++ b/bin/svc_acct.export @@ -1,6 +1,6 @@ #!/usr/bin/perl -w # -# $Id: svc_acct.export,v 1.27 2001-12-11 10:38:56 ivan Exp $ +# $Id: svc_acct.export,v 1.28 2001-12-12 07:59:33 ivan Exp $ # # Create and export password, radius and vpopmail password files: # passwd, passwd.adjunct, shadow, acp_passwd, acp_userinfo, acp_dialup @@ -573,7 +573,8 @@ foreach $bsdshellmachine (@bsdshellmachines) { ssh("root\@$bsdshellmachine", "( ". "mv /etc/passwd.new /etc/passwd; ". - "mv /etc/master.passwd.new /etc/master.passwd; ". + #"mv /etc/master.passwd.new /etc/master.passwd; ". + "pwd_mkdb /etc/master.passwd.new; ". " )" ) == 0 or die "ssh error: $!"; -- cgit v1.2.1 From cf16b23820da69e3c8d0156ae27e21c635bf1ec5 Mon Sep 17 00:00:00 2001 From: ivan Date: Thu, 27 Dec 2001 09:26:14 +0000 Subject: service and package disable! --- bin/fs-setup | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'bin') diff --git a/bin/fs-setup b/bin/fs-setup index da6c167e9..e7aa3b0d9 100755 --- a/bin/fs-setup +++ b/bin/fs-setup @@ -1,6 +1,6 @@ #!/usr/bin/perl -Tw # -# $Id: fs-setup,v 1.67 2001-11-06 17:48:17 ivan Exp $ +# $Id: fs-setup,v 1.68 2001-12-27 09:26:13 ivan Exp $ #to delay loading dbdef until we're ready BEGIN { $FS::Record::setup_hack = 1; } @@ -548,6 +548,7 @@ sub tables_hash_hack { 'recurtax', 'char', 'NULL', 1, 'plan', 'varchar', 'NULL', $char_d, 'plandata', 'text', 'NULL', '', + 'disabled', 'char', 'NULL', 1, ], 'primary_key' => 'pkgpart', 'unique' => [ [] ], @@ -590,6 +591,7 @@ sub tables_hash_hack { 'svcpart', 'int', '', '', 'svc', 'varchar', '', $char_d, 'svcdb', 'varchar', '', $char_d, + 'disabled', 'char', 'NULL', 1, ], 'primary_key' => 'svcpart', 'unique' => [ [] ], -- cgit v1.2.1 From 69a0a7504f84aa9bb1f204d1f3522e1520e0885e Mon Sep 17 00:00:00 2001 From: ivan Date: Thu, 3 Jan 2002 17:40:26 +0000 Subject: more schema changes: part_bill_event and cust_bill_event tables remove old 1.4.0pre READMEs --- bin/fs-setup | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) (limited to 'bin') diff --git a/bin/fs-setup b/bin/fs-setup index e7aa3b0d9..c7335a8fb 100755 --- a/bin/fs-setup +++ b/bin/fs-setup @@ -1,6 +1,6 @@ #!/usr/bin/perl -Tw # -# $Id: fs-setup,v 1.68 2001-12-27 09:26:13 ivan Exp $ +# $Id: fs-setup,v 1.69 2002-01-03 17:40:26 ivan Exp $ #to delay loading dbdef until we're ready BEGIN { $FS::Record::setup_hack = 1; } @@ -299,6 +299,32 @@ sub tables_hash_hack { 'index' => [ ['custnum'] ], }, + 'cust_bill_event' => { + 'columns' => [ + 'eventnum', 'int', '', '', + 'invnum', 'int', '', '', + 'eventpart', 'int', '', '', + '_date', @date_type, + ], + 'primary_key' => 'eventnum', + 'unique' => [ [ 'eventpart', 'invnum' ] ], + 'index' => [ ['invnum'] ], + }, + + 'part_bill_event' => { + 'columns' => [ + 'eventpart', 'int', '', '', + 'payby', 'int', '', '', + 'event', 'varchar', '', $char_d, + 'eventcode', @perl_type, + 'seconds', 'int', 'NULL', '', + 'disabled', 'char', 'NULL', 1, + ], + 'primary_key' => 'eventpart', + 'unique' => [ [] ], + 'index' => [ ['payby'] ], + }, + 'cust_bill_pkg' => { 'columns' => [ 'pkgnum', 'int', '', '', -- cgit v1.2.1 From b03df92e48df653460cb8b6034a06dd1de6f4095 Mon Sep 17 00:00:00 2001 From: ivan Date: Mon, 28 Jan 2002 05:15:29 +0000 Subject: part_export schema changes --- bin/fs-setup | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) (limited to 'bin') diff --git a/bin/fs-setup b/bin/fs-setup index c7335a8fb..5b82eaf86 100755 --- a/bin/fs-setup +++ b/bin/fs-setup @@ -1,6 +1,6 @@ #!/usr/bin/perl -Tw # -# $Id: fs-setup,v 1.69 2002-01-03 17:40:26 ivan Exp $ +# $Id: fs-setup,v 1.70 2002-01-28 05:15:28 ivan Exp $ #to delay loading dbdef until we're ready BEGIN { $FS::Record::setup_hack = 1; } @@ -842,6 +842,32 @@ sub tables_hash_hack { 'unique' => [], 'index' => [ [ 'jobnum' ] ], }, + + 'part_export' => { + 'columns' => [ + 'exportnum', 'int', '', '', + 'svcpart', 'int', '', '', + 'machine', 'varchar', '', $char_d, + 'exporttype', 'varchar', '', $char_d, + 'nodomain', 'char', 'NULL', 1, + ], + 'primary_key' => 'exportnum', + 'unique' => [], + 'index' => [ [ 'machine' ], [ 'exporttype' ] ], + }, + + 'part_export_option' => { + 'columns' => [ + 'optionnum', 'int', '', '', + 'exportnum', 'int', '', '', + 'option', 'varchar', '', $char_d, + 'optionvalue', 'text', 'NULL', '', + ], + 'primary_key' => 'optionnum', + 'unique' => [], + 'index' => [ [ 'exportnum' ], [ 'option' ] ], + }, + ); %tables; -- cgit v1.2.1 From 1aa750eba2b9b73b4f09f28b9acd748ee3669bd4 Mon Sep 17 00:00:00 2001 From: ivan Date: Mon, 28 Jan 2002 06:57:23 +0000 Subject: book closing schema changes --- bin/fs-setup | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'bin') diff --git a/bin/fs-setup b/bin/fs-setup index 5b82eaf86..e3dd8b0ea 100755 --- a/bin/fs-setup +++ b/bin/fs-setup @@ -1,6 +1,6 @@ #!/usr/bin/perl -Tw # -# $Id: fs-setup,v 1.70 2002-01-28 05:15:28 ivan Exp $ +# $Id: fs-setup,v 1.71 2002-01-28 06:57:23 ivan Exp $ #to delay loading dbdef until we're ready BEGIN { $FS::Record::setup_hack = 1; } @@ -293,6 +293,7 @@ sub tables_hash_hack { '_date', @date_type, 'charged', @money_type, 'printed', 'int', '', '', + 'closed', 'char', 'NULL', 1, ], 'primary_key' => 'invnum', 'unique' => [ [] ], @@ -347,6 +348,7 @@ sub tables_hash_hack { 'amount', @money_type, 'otaker', 'varchar', '', 8, 'reason', 'text', 'NULL', '', + 'closed', 'char', 'NULL', 1, ], 'primary_key' => 'crednum', 'unique' => [ [] ], @@ -455,6 +457,7 @@ sub tables_hash_hack { # payment type table. 'payinfo', 'varchar', 'NULL', 16, #see cust_main above 'paybatch', 'varchar', 'NULL', $char_d, #for auditing purposes. + 'closed', 'char', 'NULL', 1, ], 'primary_key' => 'paynum', 'unique' => [ [] ], @@ -531,6 +534,7 @@ sub tables_hash_hack { # into payment type table. 'payinfo', 'varchar', 'NULL', 16, #see cust_main above 'paybatch', 'varchar', 'NULL', $char_d, + 'closed', 'char', 'NULL', 1, ], 'primary_key' => 'refundnum', 'unique' => [ [] ], -- cgit v1.2.1 From f02dd9b0e5042ef000d9338089eed50988d48914 Mon Sep 17 00:00:00 2001 From: ivan Date: Tue, 29 Jan 2002 11:11:06 +0000 Subject: oops bad column type for part_bill_event.payby --- bin/fs-setup | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'bin') diff --git a/bin/fs-setup b/bin/fs-setup index e3dd8b0ea..f3ff031d4 100755 --- a/bin/fs-setup +++ b/bin/fs-setup @@ -1,6 +1,6 @@ #!/usr/bin/perl -Tw # -# $Id: fs-setup,v 1.71 2002-01-28 06:57:23 ivan Exp $ +# $Id: fs-setup,v 1.72 2002-01-29 11:11:06 ivan Exp $ #to delay loading dbdef until we're ready BEGIN { $FS::Record::setup_hack = 1; } @@ -315,7 +315,7 @@ sub tables_hash_hack { 'part_bill_event' => { 'columns' => [ 'eventpart', 'int', '', '', - 'payby', 'int', '', '', + 'payby', 'char', '', 4, 'event', 'varchar', '', $char_d, 'eventcode', @perl_type, 'seconds', 'int', 'NULL', '', -- cgit v1.2.1 From 6991d4986df7fb3a6c7c49b5ae1b3713e87a16c4 Mon Sep 17 00:00:00 2001 From: ivan Date: Tue, 29 Jan 2002 16:33:16 +0000 Subject: - web interface for hourly account charges! (FS::cust_pkg, FS::cust_svc and FS::svc_acct seconds_since methods) - Makefile target to regenerate HTML manpages on install - FS.pm doc update - $FS::Record::Debug now dumps all SQL - new FS::cust_main methods: ->cancel, ->invoicing_list_addpost - start of a billing event web interface - cust_pay::upgrade_replace doesn't error out if history includes overapplied payments --- bin/pod2x | 32 ++++++++++++++++++++++++++++---- 1 file changed, 28 insertions(+), 4 deletions(-) (limited to 'bin') diff --git a/bin/pod2x b/bin/pod2x index 8c020062c..cbe142389 100755 --- a/bin/pod2x +++ b/bin/pod2x @@ -15,17 +15,41 @@ die "Can't find $site_perl" unless -d $site_perl; #die "Can't find $catman" unless -d $catman; die "Can't find $html" unless -d $html; +#make some useless links +foreach my $file ( + glob("$site_perl/bin/freeside-*"), +) { + next if $file =~ /\.pod$/; + #symlink $file, "$file.pod"; # or die "link $file to $file.pod: $!"; + system("cp $file $file.pod"); +} + foreach my $file ( glob("$site_perl/*.pm"), glob("$site_perl/*/*.pm"), - glob("$site_perl/*/*/*.pm") + glob("$site_perl/*/*/*.pm"), + glob("$site_perl/bin/*.pod"), + glob("./fs_sesmon/FS-SessionClient/*.pm"), + glob("./fs_signup/FS-SignupClient/*.pm"), + glob("./fs_selfadmin/FS-MailAdminServer/*.pm"), ) { #$file =~ /\/([\w\-]+)\.pm$/ or die "oops file $file"; - $file =~ /$site_perl\/(.*)\.pm$/ or die "oops file $file"; - my $name = $1; + my $name; + if ( $file =~ /fs_\w+\/FS\-\w+\/(.*)\.pm$/ ) { + $name = "FS/$1"; + } elsif ( $file =~ /$site_perl\/(.*)\.(pm|pod)$/ ) { + $name = $1; + } else { + die "oops file $file"; + } print "$name\n"; my $htmlroot = join('/', map '..',1..(scalar($file =~ tr/\///)-2)) || '.'; # system "pod2text $file >$catman/$name.txt"; - system "pod2html --podroot=$site_perl --podpath=./FS:./FS/UI:. --norecurse --htmlroot=$htmlroot $file >$html/$name.html"; + system "pod2html --podroot=$site_perl --podpath=./FS:./FS/UI:.:./bin --norecurse --htmlroot=$htmlroot $file >$html/$name.html"; + #system "pod2html --podroot=$site_perl --htmlroot=$htmlroot $file >$html/$name.html"; # system "pod2html $file >$html/$name.html"; } + +#remove the useless links +unlink glob("$site_perl/bin/*.pod"); + -- cgit v1.2.1 From c5c0ba135749164ec8ba75d18f76c29625e1bc7e Mon Sep 17 00:00:00 2001 From: ivan Date: Tue, 29 Jan 2002 17:42:46 +0000 Subject: weight, plan and plandata fields in part_bill_event --- bin/fs-setup | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'bin') diff --git a/bin/fs-setup b/bin/fs-setup index f3ff031d4..7e043d238 100755 --- a/bin/fs-setup +++ b/bin/fs-setup @@ -1,6 +1,6 @@ #!/usr/bin/perl -Tw # -# $Id: fs-setup,v 1.72 2002-01-29 11:11:06 ivan Exp $ +# $Id: fs-setup,v 1.73 2002-01-29 17:42:46 ivan Exp $ #to delay loading dbdef until we're ready BEGIN { $FS::Record::setup_hack = 1; } @@ -319,6 +319,9 @@ sub tables_hash_hack { 'event', 'varchar', '', $char_d, 'eventcode', @perl_type, 'seconds', 'int', 'NULL', '', + 'weight', 'int', '', '', + 'plan', 'varchar', 'NULL', $char_d, + 'plandata', 'text', 'NULL', '', 'disabled', 'char', 'NULL', 1, ], 'primary_key' => 'eventpart', -- cgit v1.2.1 From 79f83ad93cc6f77a155528661a4681946fdd17a6 Mon Sep 17 00:00:00 2001 From: ivan Date: Mon, 4 Feb 2002 17:04:33 +0000 Subject: have fs-setup create the necessary "default" billing events documentation on necessary "default" billing events --- bin/fs-setup | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) (limited to 'bin') diff --git a/bin/fs-setup b/bin/fs-setup index 7e043d238..912fc98fc 100755 --- a/bin/fs-setup +++ b/bin/fs-setup @@ -1,6 +1,6 @@ #!/usr/bin/perl -Tw # -# $Id: fs-setup,v 1.73 2002-01-29 17:42:46 ivan Exp $ +# $Id: fs-setup,v 1.74 2002-02-04 17:04:33 ivan Exp $ #to delay loading dbdef until we're ready BEGIN { $FS::Record::setup_hack = 1; } @@ -16,6 +16,7 @@ use FS::UID qw(adminsuidsetup datasrc checkeuid getsecrets); use FS::Record; use FS::cust_main_county; use FS::raddb; +use FS::part_bill_invoice; die "Not running uid freeside!" unless checkeuid(); @@ -234,6 +235,28 @@ YE YU ZR ZM ZW die $error if $error; } +#billing events +foreach my $aref ( + [ 'COMP', 'Comp invoice', '$cust_bill->comp();', 30, 'comp' ], + [ 'CARD', 'Batch card', '$cust_bill->batch_card();', 40, 'batch-card' ], + [ 'BILL', 'Send invoice', '$cust_bill->send();', 50, 'send' ], +) { + + my $part_bill_event = new FS::part_bill_event({ + 'payby' => $aref->[0], + 'event' => $aref->[1], + 'eventcode' => $aref->[2], + 'seconds' => 0, + 'weight' => $aref->[3], + 'plan' => $aref->[4], + }); + my($error); + $error=$part_bill_event->insert; + die $error if $error; + +} + + $dbh->disconnect or die $dbh->errstr; print "Freeside database initialized sucessfully\n"; -- cgit v1.2.1 From ce32d23f68c3137da0e0c43e14bea90c5eec9635 Mon Sep 17 00:00:00 2001 From: ivan Date: Wed, 6 Feb 2002 15:07:49 +0000 Subject: tyop --- bin/fs-setup | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'bin') diff --git a/bin/fs-setup b/bin/fs-setup index 912fc98fc..07c9709a1 100755 --- a/bin/fs-setup +++ b/bin/fs-setup @@ -1,6 +1,6 @@ #!/usr/bin/perl -Tw # -# $Id: fs-setup,v 1.74 2002-02-04 17:04:33 ivan Exp $ +# $Id: fs-setup,v 1.75 2002-02-06 15:07:49 ivan Exp $ #to delay loading dbdef until we're ready BEGIN { $FS::Record::setup_hack = 1; } @@ -16,7 +16,7 @@ use FS::UID qw(adminsuidsetup datasrc checkeuid getsecrets); use FS::Record; use FS::cust_main_county; use FS::raddb; -use FS::part_bill_invoice; +use FS::part_bill_event; die "Not running uid freeside!" unless checkeuid(); -- cgit v1.2.1 From 88d4198ff452581be05e3018b3e23db564545525 Mon Sep 17 00:00:00 2001 From: ivan Date: Wed, 6 Feb 2002 15:55:47 +0000 Subject: doc updates and pod2x fix to skip blib/ files --- bin/pod2x | 1 + 1 file changed, 1 insertion(+) (limited to 'bin') diff --git a/bin/pod2x b/bin/pod2x index cbe142389..385c5db0a 100755 --- a/bin/pod2x +++ b/bin/pod2x @@ -33,6 +33,7 @@ foreach my $file ( glob("./fs_signup/FS-SignupClient/*.pm"), glob("./fs_selfadmin/FS-MailAdminServer/*.pm"), ) { + next if $file =~ /^blib\//; #$file =~ /\/([\w\-]+)\.pm$/ or die "oops file $file"; my $name; if ( $file =~ /fs_\w+\/FS\-\w+\/(.*)\.pm$/ ) { -- cgit v1.2.1 From ddb53fcc9fc80561354b97e4e7803004990138d0 Mon Sep 17 00:00:00 2001 From: ivan Date: Sun, 10 Feb 2002 18:56:49 +0000 Subject: use unique tokens to prevent double-submission of payments in the web UI (closes: Bug#320) --- bin/fs-setup | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'bin') diff --git a/bin/fs-setup b/bin/fs-setup index 07c9709a1..5f8059425 100755 --- a/bin/fs-setup +++ b/bin/fs-setup @@ -1,6 +1,6 @@ #!/usr/bin/perl -Tw # -# $Id: fs-setup,v 1.75 2002-02-06 15:07:49 ivan Exp $ +# $Id: fs-setup,v 1.76 2002-02-10 18:56:49 ivan Exp $ #to delay loading dbdef until we're ready BEGIN { $FS::Record::setup_hack = 1; } @@ -500,7 +500,7 @@ sub tables_hash_hack { ], 'primary_key' => 'billpaynum', 'unique' => [ [] ], - 'index' => [ [ 'paynum', 'invnum' ] ], + 'index' => [ [ 'paynum' ], [ 'custnum' ], [ 'paybatch' ] ], }, 'cust_pay_batch' => { #what's this used for again? list of customers -- cgit v1.2.1 From ae23f6fe1ca915c995cfbf29bb39e7ed5e1cce2c Mon Sep 17 00:00:00 2001 From: ivan Date: Tue, 12 Feb 2002 02:11:07 +0000 Subject: add username_policy "@append domain" add "select" config type, mmm --- bin/svc_acct.export | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'bin') diff --git a/bin/svc_acct.export b/bin/svc_acct.export index 3ac7a4f8f..e28de4aa7 100755 --- a/bin/svc_acct.export +++ b/bin/svc_acct.export @@ -1,6 +1,6 @@ #!/usr/bin/perl -w # -# $Id: svc_acct.export,v 1.28 2001-12-12 07:59:33 ivan Exp $ +# $Id: svc_acct.export,v 1.29 2002-02-12 02:11:07 ivan Exp $ # # Create and export password, radius and vpopmail password files: # passwd, passwd.adjunct, shadow, acp_passwd, acp_userinfo, acp_dialup @@ -287,6 +287,10 @@ foreach $svc_domain (sort {$a->domain cmp $b->domain} @svc_domain) { $username=$svc_acct->username . $svc_acct->domsvc; } elsif ($userpolicy =~ /^append domain$/) { $username=$svc_acct->username . $svc_domain->domain; + } elsif ($userpolicy =~ /^append domain$/) { + $username=$svc_acct->username . $svc_domain->domain; + } elsif ($userpolicy =~ /^append @domain$/) { + $username=$svc_acct->username . '@'. $svc_domain->domain; } else { die "Unknown policy in username_policy\n"; } -- cgit v1.2.1 From 04ccbc0a0d5a09a8522427bcb278fa1b96826d74 Mon Sep 17 00:00:00 2001 From: ivan Date: Tue, 12 Feb 2002 05:58:42 +0000 Subject: fixes: bug#331 --- bin/fs-setup | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'bin') diff --git a/bin/fs-setup b/bin/fs-setup index 5f8059425..7c716d35e 100755 --- a/bin/fs-setup +++ b/bin/fs-setup @@ -1,6 +1,6 @@ #!/usr/bin/perl -Tw # -# $Id: fs-setup,v 1.76 2002-02-10 18:56:49 ivan Exp $ +# $Id: fs-setup,v 1.77 2002-02-12 05:58:42 ivan Exp $ #to delay loading dbdef until we're ready BEGIN { $FS::Record::setup_hack = 1; } @@ -487,7 +487,7 @@ sub tables_hash_hack { ], 'primary_key' => 'paynum', 'unique' => [ [] ], - 'index' => [ [] ], + 'index' => [ [ 'custnum' ], [ 'paybatch' ] ], }, 'cust_bill_pay' => { @@ -500,7 +500,7 @@ sub tables_hash_hack { ], 'primary_key' => 'billpaynum', 'unique' => [ [] ], - 'index' => [ [ 'paynum' ], [ 'custnum' ], [ 'paybatch' ] ], + 'index' => [ [ 'paynum' ], [ 'invnum' ] ], }, 'cust_pay_batch' => { #what's this used for again? list of customers -- cgit v1.2.1 From f3a66fc4b25eb9fcc74a9fea56c48a61a1eea012 Mon Sep 17 00:00:00 2001 From: ivan Date: Tue, 12 Feb 2002 18:37:43 +0000 Subject: fixes: In string, @domain now must be written as \@domain at ./svc_acct.export line 292, near "^append @domain" Global symbol "@domain" requires explicit package name at ./svc_acct.export line 292. Execution of ./svc_acct.export aborted due to compilation errors. --- bin/svc_acct.export | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'bin') diff --git a/bin/svc_acct.export b/bin/svc_acct.export index e28de4aa7..3ea444df9 100755 --- a/bin/svc_acct.export +++ b/bin/svc_acct.export @@ -1,6 +1,6 @@ #!/usr/bin/perl -w # -# $Id: svc_acct.export,v 1.29 2002-02-12 02:11:07 ivan Exp $ +# $Id: svc_acct.export,v 1.30 2002-02-12 18:37:43 ivan Exp $ # # Create and export password, radius and vpopmail password files: # passwd, passwd.adjunct, shadow, acp_passwd, acp_userinfo, acp_dialup @@ -289,7 +289,7 @@ foreach $svc_domain (sort {$a->domain cmp $b->domain} @svc_domain) { $username=$svc_acct->username . $svc_domain->domain; } elsif ($userpolicy =~ /^append domain$/) { $username=$svc_acct->username . $svc_domain->domain; - } elsif ($userpolicy =~ /^append @domain$/) { + } elsif ($userpolicy =~ /^append \@domain$/) { $username=$svc_acct->username . '@'. $svc_domain->domain; } else { die "Unknown policy in username_policy\n"; -- cgit v1.2.1 From c348097ed3e8864cfd7cc58c94c1457067a0bd2c Mon Sep 17 00:00:00 2001 From: ivan Date: Thu, 14 Feb 2002 18:06:57 +0000 Subject: docs? haha --- bin/fs-radius-add-check | 2 +- bin/fs-radius-add-reply | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'bin') diff --git a/bin/fs-radius-add-check b/bin/fs-radius-add-check index ca0492f4c..35f4d3262 100755 --- a/bin/fs-radius-add-check +++ b/bin/fs-radius-add-check @@ -54,6 +54,6 @@ $dbh->disconnect or die $dbh->errstr; print "\n\n", "Now you must run dbdef-create.\n\n"; sub usage { - die "Usage:\n fs-radius-add user\n"; + die "Usage:\n fs-radius-add-check user\n"; } diff --git a/bin/fs-radius-add-reply b/bin/fs-radius-add-reply index 2f38fbcf7..6b9a39e49 100755 --- a/bin/fs-radius-add-reply +++ b/bin/fs-radius-add-reply @@ -54,7 +54,7 @@ $dbh->disconnect or die $dbh->errstr; print "\n\n", "Now you must run dbdef-create.\n\n"; sub usage { - die "Usage:\n fs-radius-add user\n"; + die "Usage:\n fs-radius-add-reply user\n"; } -- cgit v1.2.1 From e72b1302bd8af9968a0520e1ab5f77d98571a4e6 Mon Sep 17 00:00:00 2001 From: jeff Date: Thu, 14 Feb 2002 22:37:38 +0000 Subject: fix bug in multiline radiusprepend --- bin/svc_acct.export | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'bin') diff --git a/bin/svc_acct.export b/bin/svc_acct.export index 3ea444df9..aeb49d2b1 100755 --- a/bin/svc_acct.export +++ b/bin/svc_acct.export @@ -1,6 +1,6 @@ #!/usr/bin/perl -w # -# $Id: svc_acct.export,v 1.30 2002-02-12 18:37:43 ivan Exp $ +# $Id: svc_acct.export,v 1.31 2002-02-14 22:37:38 jeff Exp $ # # Create and export password, radius and vpopmail password files: # passwd, passwd.adjunct, shadow, acp_passwd, acp_userinfo, acp_dialup @@ -71,7 +71,7 @@ warn "using depriciated textradiusprepend file" if $textradiusprepend; my $radiusprepend = $conf->exists('radiusprepend') - ? $conf->config('radiusprepend') + ? join("\n", $conf->config('radiusprepend')) : ''; my @vpopmailmachines = $conf->config('vpopmailmachines') -- cgit v1.2.1 From 7a03e0f0cd9e1eae507be2ab17151059bcb1d3cb Mon Sep 17 00:00:00 2001 From: jeff Date: Fri, 15 Feb 2002 20:21:56 +0000 Subject: remove arbitary uid requirement for vpasswd generation --- bin/svc_acct.export | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) (limited to 'bin') diff --git a/bin/svc_acct.export b/bin/svc_acct.export index aeb49d2b1..cee63bcd5 100755 --- a/bin/svc_acct.export +++ b/bin/svc_acct.export @@ -1,6 +1,6 @@ #!/usr/bin/perl -w # -# $Id: svc_acct.export,v 1.31 2002-02-14 22:37:38 jeff Exp $ +# $Id: svc_acct.export,v 1.32 2002-02-15 20:21:56 jeff Exp $ # # Create and export password, radius and vpopmail password files: # passwd, passwd.adjunct, shadow, acp_passwd, acp_userinfo, acp_dialup @@ -350,20 +350,20 @@ foreach $svc_domain (sort {$a->domain cmp $b->domain} @svc_domain) { '', ), "\n"; } + } - ### - # FORMAT OF THE VPASSWD FILE HERE - print VPASSWD join(":", - $svc_acct->username, - $cpassword, - '1', - '0', - $svc_acct->username, - "$vpopdir/domains/" . $svc_domain->domain ."/" . $svc_acct->username, - 'NOQUOTA', - ), "\n"; + ### + # FORMAT OF THE VPASSWD FILE HERE + print VPASSWD join(":", + $svc_acct->username, + $cpassword, + '1', + '0', + $svc_acct->username, + "$vpopdir/domains/" . $svc_domain->domain ."/" . $svc_acct->username, + 'NOQUOTA', + ), "\n"; - } if ( $svc_acct->slipip ne '' ) { -- cgit v1.2.1 From b35b650a6078d645d6f97620f3c79ae941915dd9 Mon Sep 17 00:00:00 2001 From: jeff Date: Mon, 18 Feb 2002 00:13:58 +0000 Subject: trading in tar for rsync for improved vpopmail support --- bin/svc_acct.export | 39 ++++++++++++++++++++++++--------------- 1 file changed, 24 insertions(+), 15 deletions(-) (limited to 'bin') diff --git a/bin/svc_acct.export b/bin/svc_acct.export index cee63bcd5..11178c962 100755 --- a/bin/svc_acct.export +++ b/bin/svc_acct.export @@ -1,6 +1,6 @@ #!/usr/bin/perl -w # -# $Id: svc_acct.export,v 1.32 2002-02-15 20:21:56 jeff Exp $ +# $Id: svc_acct.export,v 1.33 2002-02-18 00:13:57 jeff Exp $ # # Create and export password, radius and vpopmail password files: # passwd, passwd.adjunct, shadow, acp_passwd, acp_userinfo, acp_dialup @@ -22,6 +22,9 @@ use FS::svc_acct; use FS::svc_domain; use FS::svc_forward; +my $ssh='ssh'; +my $rsync='rsync'; + my $user = shift or die &usage; adminsuidsetup $user; @@ -648,26 +651,32 @@ foreach my $icradiusmachine ( @icradiusmachines ) { close WRITER; } -my @args = ("/bin/tar", "c", "--force-local", "-C", "$spooldir", "-f", "$spooldir/vpoptarball", "domains"); +#my @args = ("/bin/tar", "c", "--force-local", "-C", "$spooldir", "-f", "$spooldir/vpoptarball", "domains"); -system {$args[0]} @args; +#system {$args[0]} @args; my($vpopmailmachine); foreach $vpopmailmachine (@vpopmailmachines) { my ($machine, $vpopdir, $vpopuid, $vpopgid) = split (/\s+/, $vpopmailmachine); my $scp = new Net::SCP; - $scp->scp("$spooldir/vpoptarball","root\@$machine:vpoptarball") - or die "scp error: ". $scp->{errstr}; - ssh("root\@$machine", - "( ". - "tar xf vpoptarball; ". - "chown -R $vpopuid:$vpopgid domains; ". - "tar cf vpoptarball domains; ". - "cd $vpopdir; ". - "tar xf ~/vpoptarball; ". - " )" - ) - == 0 or die "ssh error: $!"; +# $scp->scp("$spooldir/vpoptarball","root\@$machine:vpoptarball") +# or die "scp error: ". $scp->{errstr}; +# ssh("root\@$machine", +# "( ". +# "rm -rf domains; ". +# "tar xf vpoptarball; ". +# "chown -R $vpopuid:$vpopgid domains; ". +# "tar cf vpoptarball domains; ". +# "cd $vpopdir; ". +# "tar xf ~/vpoptarball; ". +# " )" +# ) +# == 0 or die "ssh error: $!"; + + chdir $spooldir; + my @args = ("$rsync", "-rlpt", "-e", "$ssh", "domains/", "vpopmail\@$machine:$vpopdir/domains/"); + + system {$args[0]} @args; $scp->scp("$spooldir/assign","root\@$machine:/var/qmail/users/assign") or die "scp error: ". $scp->{errstr}; -- cgit v1.2.1 From 8f42b751aebda2e7dce2c363bed6f1e15b411b1d Mon Sep 17 00:00:00 2001 From: ivan Date: Wed, 20 Feb 2002 01:03:10 +0000 Subject: use Net::SSH::ssh_cmd for all job queueing rather than local duplicated ssh subs queue daemon updates: retry & remove links work, bubble up error message to webinterface, link to svcnum & have job listings on view/svc_* pages, closes: Bug#280 s/option/optionname/ schema change, dumb mysql, closes: Bug#334 --- bin/fs-setup | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'bin') diff --git a/bin/fs-setup b/bin/fs-setup index 7c716d35e..48d28c6f0 100755 --- a/bin/fs-setup +++ b/bin/fs-setup @@ -1,6 +1,6 @@ #!/usr/bin/perl -Tw # -# $Id: fs-setup,v 1.77 2002-02-12 05:58:42 ivan Exp $ +# $Id: fs-setup,v 1.78 2002-02-20 01:03:09 ivan Exp $ #to delay loading dbdef until we're ready BEGIN { $FS::Record::setup_hack = 1; } @@ -856,10 +856,12 @@ sub tables_hash_hack { 'job', 'text', '', '', '_date', 'int', '', '', 'status', 'varchar', '', $char_d, + 'statustext', 'text', '', '', + 'svcnum', 'int', '', '', ], 'primary_key' => 'jobnum', 'unique' => [], - 'index' => [], + 'index' => [ [ 'svcnum' ], [ 'status' ] ], }, 'queue_arg' => { @@ -890,12 +892,12 @@ sub tables_hash_hack { 'columns' => [ 'optionnum', 'int', '', '', 'exportnum', 'int', '', '', - 'option', 'varchar', '', $char_d, + 'optionname', 'varchar', '', $char_d, 'optionvalue', 'text', 'NULL', '', ], 'primary_key' => 'optionnum', 'unique' => [], - 'index' => [ [ 'exportnum' ], [ 'option' ] ], + 'index' => [ [ 'exportnum' ], [ 'optionname' ] ], }, ); -- cgit v1.2.1 From 0ef5eb21cd3c5ed66216bc986c59a33383da746c Mon Sep 17 00:00:00 2001 From: ivan Date: Thu, 21 Feb 2002 21:43:57 +0000 Subject: looks like statustext field is missing NULL flag in fs-setup --- bin/fs-setup | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'bin') diff --git a/bin/fs-setup b/bin/fs-setup index 48d28c6f0..708bb9cd6 100755 --- a/bin/fs-setup +++ b/bin/fs-setup @@ -1,6 +1,6 @@ #!/usr/bin/perl -Tw # -# $Id: fs-setup,v 1.78 2002-02-20 01:03:09 ivan Exp $ +# $Id: fs-setup,v 1.79 2002-02-21 21:43:57 ivan Exp $ #to delay loading dbdef until we're ready BEGIN { $FS::Record::setup_hack = 1; } @@ -856,7 +856,7 @@ sub tables_hash_hack { 'job', 'text', '', '', '_date', 'int', '', '', 'status', 'varchar', '', $char_d, - 'statustext', 'text', '', '', + 'statustext', 'text', NULL, '', 'svcnum', 'int', '', '', ], 'primary_key' => 'jobnum', -- cgit v1.2.1 From 33859df31410294de8c6d775f7e4f892534d4145 Mon Sep 17 00:00:00 2001 From: ivan Date: Thu, 21 Feb 2002 23:17:06 +0000 Subject: queue.svcnum is nullable too, oops --- bin/fs-setup | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'bin') diff --git a/bin/fs-setup b/bin/fs-setup index 708bb9cd6..5ec4204da 100755 --- a/bin/fs-setup +++ b/bin/fs-setup @@ -1,6 +1,6 @@ #!/usr/bin/perl -Tw # -# $Id: fs-setup,v 1.79 2002-02-21 21:43:57 ivan Exp $ +# $Id: fs-setup,v 1.80 2002-02-21 23:17:06 ivan Exp $ #to delay loading dbdef until we're ready BEGIN { $FS::Record::setup_hack = 1; } @@ -857,7 +857,7 @@ sub tables_hash_hack { '_date', 'int', '', '', 'status', 'varchar', '', $char_d, 'statustext', 'text', NULL, '', - 'svcnum', 'int', '', '', + 'svcnum', 'int', NULL, '', ], 'primary_key' => 'jobnum', 'unique' => [], -- cgit v1.2.1 From 7738e200fa23a98b3b493d6e47d44615cd64828b Mon Sep 17 00:00:00 2001 From: ivan Date: Fri, 22 Feb 2002 07:50:19 +0000 Subject: doh --- bin/fs-setup | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'bin') diff --git a/bin/fs-setup b/bin/fs-setup index 5ec4204da..3ad0bbdf6 100755 --- a/bin/fs-setup +++ b/bin/fs-setup @@ -1,6 +1,6 @@ #!/usr/bin/perl -Tw # -# $Id: fs-setup,v 1.80 2002-02-21 23:17:06 ivan Exp $ +# $Id: fs-setup,v 1.81 2002-02-22 07:50:19 ivan Exp $ #to delay loading dbdef until we're ready BEGIN { $FS::Record::setup_hack = 1; } @@ -856,8 +856,8 @@ sub tables_hash_hack { 'job', 'text', '', '', '_date', 'int', '', '', 'status', 'varchar', '', $char_d, - 'statustext', 'text', NULL, '', - 'svcnum', 'int', NULL, '', + 'statustext', 'text', 'NULL', '', + 'svcnum', 'int', 'NULL', '', ], 'primary_key' => 'jobnum', 'unique' => [], -- cgit v1.2.1 From cefb9727ed4cdfacf3b967485d58b25fbea98c6b Mon Sep 17 00:00:00 2001 From: jeff Date: Sat, 23 Feb 2002 02:14:26 +0000 Subject: report fixes and cruft removal --- bin/svc_acct.export | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'bin') diff --git a/bin/svc_acct.export b/bin/svc_acct.export index 11178c962..82a8935b6 100755 --- a/bin/svc_acct.export +++ b/bin/svc_acct.export @@ -1,6 +1,6 @@ #!/usr/bin/perl -w # -# $Id: svc_acct.export,v 1.33 2002-02-18 00:13:57 jeff Exp $ +# $Id: svc_acct.export,v 1.34 2002-02-23 02:14:26 jeff Exp $ # # Create and export password, radius and vpopmail password files: # passwd, passwd.adjunct, shadow, acp_passwd, acp_userinfo, acp_dialup @@ -9,7 +9,6 @@ use strict; use vars qw($conf); -use Archive::Tar; use Fcntl qw(:flock); use File::Path; use IO::Handle; -- cgit v1.2.1 From 6a37289c12238d48ea864b8177216ca276b33a40 Mon Sep 17 00:00:00 2001 From: ivan Date: Wed, 27 Feb 2002 22:39:14 +0000 Subject: add status and statustext fields to cust_bill_event --- bin/fs-setup | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'bin') diff --git a/bin/fs-setup b/bin/fs-setup index 3ad0bbdf6..62c2cd490 100755 --- a/bin/fs-setup +++ b/bin/fs-setup @@ -1,6 +1,6 @@ #!/usr/bin/perl -Tw # -# $Id: fs-setup,v 1.81 2002-02-22 07:50:19 ivan Exp $ +# $Id: fs-setup,v 1.82 2002-02-27 22:39:14 ivan Exp $ #to delay loading dbdef until we're ready BEGIN { $FS::Record::setup_hack = 1; } @@ -329,10 +329,12 @@ sub tables_hash_hack { 'invnum', 'int', '', '', 'eventpart', 'int', '', '', '_date', @date_type, + 'status', 'varchar', '', $char_d, + 'statustext', 'text', 'NULL', '', ], 'primary_key' => 'eventnum', 'unique' => [ [ 'eventpart', 'invnum' ] ], - 'index' => [ ['invnum'] ], + 'index' => [ ['invnum'], ['status'] ], }, 'part_bill_event' => { -- cgit v1.2.1 From 239484572a9191100993bb1e85ffe8834689feb0 Mon Sep 17 00:00:00 2001 From: ivan Date: Mon, 4 Mar 2002 12:48:49 +0000 Subject: *** empty log message *** --- bin/create-history-tables | 78 +++++++++++++++++++++++++++++++++++++++++++++++ bin/fs-radius-add-check | 9 ++++++ bin/fs-radius-add-reply | 11 ++++++- bin/fs-setup | 59 ++++++++++++++++++++++++++++++++--- 4 files changed, 151 insertions(+), 6 deletions(-) create mode 100755 bin/create-history-tables (limited to 'bin') diff --git a/bin/create-history-tables b/bin/create-history-tables new file mode 100755 index 000000000..fb4c866c6 --- /dev/null +++ b/bin/create-history-tables @@ -0,0 +1,78 @@ +#!/usr/bin/perl -Tw + +use strict; +use DBI; +use DBIx::DBSchema 0.20; +use DBIx::DBSchema::Table; +use DBIx::DBSchema::Column; +use DBIx::DBSchema::ColGroup::Unique; +use DBIx::DBSchema::ColGroup::Index; +use FS::UID qw(adminsuidsetup); +use FS::Record qw(dbdef); + +my $user = shift or die &usage; +my $dbh = adminsuidsetup $user; + +my $schema = dbdef(); + +#false laziness w/fs-setup +foreach my $table ( grep { ! /^h_/ } $schema->tables ) { + my $tableobj = $schema->table($table); + my $h_tableobj = DBIx::DBSchema::Table->new( { + name => "h_$table", + primary_key => 'historynum', + unique => DBIx::DBSchema::ColGroup::Unique->new( [] ), + 'index' => DBIx::DBSchema::ColGroup::Index->new( [ + @{$tableobj->unique->lol_ref}, + @{$tableobj->index->lol_ref} + ] ), + columns => [ + DBIx::DBSchema::Column->new( { + 'name' => 'historynum', + 'type' => 'serial', + 'null' => 'NOT NULL', + 'length' => '', + 'default' => '', + 'local' => '', + } ), + DBIx::DBSchema::Column->new( { + 'name' => 'history_date', + 'type' => 'int', + 'null' => 'NULL', + 'length' => '', + 'default' => '', + 'local' => '', + } ), + DBIx::DBSchema::Column->new( { + 'name' => 'history_user', + 'type' => 'varchar', + 'null' => 'NOT NULL', + 'length' => '80', + 'default' => '', + 'local' => '', + } ), + DBIx::DBSchema::Column->new( { + 'name' => 'history_action', + 'type' => 'varchar', + 'null' => 'NOT NULL', + 'length' => '80', + 'default' => '', + 'local' => '', + } ), + map { $tableobj->column($_) } $tableobj->columns + ], + } ); + foreach my $statement ( $h_tableobj->sql_create_table($dbh) ) { + $dbh->do( $statement ) + or die "CREATE error: ". $dbh->errstr. "\ndoing statement: $statement"; + } + +} + +$dbh->commit or die $dbh->errstr; +$dbh->disconnect or die $dbh->errstr; + +sub usage { + die "Usage:\n create-history-tables user\n"; +} + diff --git a/bin/fs-radius-add-check b/bin/fs-radius-add-check index 35f4d3262..4e4769e58 100755 --- a/bin/fs-radius-add-check +++ b/bin/fs-radius-add-check @@ -39,12 +39,21 @@ my($char_d) = 80; #default maxlength for text fields ### foreach my $attribute ( @attributes ) { + my $statement = "ALTER TABLE svc_acct ADD COLUMN rc_$attribute varchar($char_d) NULL"; my $sth = $dbh->prepare( $statement ) or warn "Error preparing $statement: ". $dbh->errstr; my $rc = $sth->execute or warn "Error executing $statement: ". $sth->errstr; + + $statement = + "ALTER TABLE h_svc_acct ADD COLUMN rc_$attribute varchar($char_d) NULL"; + $sth = $dbh->prepare( $statement ) + or warn "Error preparing $statement: ". $dbh->errstr; + $rc = $sth->execute + or warn "Error executing $statement: ". $sth->errstr; + } $dbh->commit or die $dbh->errstr; diff --git a/bin/fs-radius-add-reply b/bin/fs-radius-add-reply index 6b9a39e49..3de01374f 100755 --- a/bin/fs-radius-add-reply +++ b/bin/fs-radius-add-reply @@ -39,12 +39,21 @@ my($char_d) = 80; #default maxlength for text fields ### foreach my $attribute ( @attributes ) { + my $statement = "ALTER TABLE svc_acct ADD COLUMN radius_$attribute varchar($char_d) NULL"; my $sth = $dbh->prepare( $statement ) or warn "Error preparing $statement: ". $dbh->errstr; - $sth->execute + my $rc = $sth->execute or warn "Error executing $statement: ". $sth->errstr; + + $statement = + "ALTER TABLE h_svc_acct ADD COLUMN radius_$attribute varchar($char_d) NULL"; + $sth = $dbh->prepare( $statement ) + or warn "Error preparing $statement: ". $dbh->errstr; + $rc = $sth->execute + or warn "Error executing $statement: ". $sth->errstr; + } $dbh->commit or die $dbh->errstr; diff --git a/bin/fs-setup b/bin/fs-setup index 62c2cd490..7ee04a5d8 100755 --- a/bin/fs-setup +++ b/bin/fs-setup @@ -1,13 +1,13 @@ #!/usr/bin/perl -Tw # -# $Id: fs-setup,v 1.82 2002-02-27 22:39:14 ivan Exp $ +# $Id: fs-setup,v 1.83 2002-03-04 12:48:49 ivan Exp $ #to delay loading dbdef until we're ready BEGIN { $FS::Record::setup_hack = 1; } use strict; use DBI; -use DBIx::DBSchema 0.19; +use DBIx::DBSchema 0.20; use DBIx::DBSchema::Table; use DBIx::DBSchema::Column; use DBIx::DBSchema::ColGroup::Unique; @@ -160,6 +160,56 @@ foreach $attribute (@check_attributes) { # } #} +#create history tables (false laziness w/create-history-tables) +foreach my $table ( grep { ! /^h_/ } $dbdef->tables ) { + my $tableobj = $dbdef->table($table); + my $h_tableobj = DBIx::DBSchema::Table->new( { + name => "h_$table", + primary_key => 'historynum', + unique => DBIx::DBSchema::ColGroup::Unique->new( [] ), + 'index' => DBIx::DBSchema::ColGroup::Index->new( [ + @{$tableobj->unique->lol_ref}, + @{$tableobj->index->lol_ref} + ] ), + columns => [ + DBIx::DBSchema::Column->new( { + 'name' => 'historynum', + 'type' => 'serial', + 'null' => 'NOT NULL', + 'length' => '', + 'default' => '', + 'local' => '', + } ), + DBIx::DBSchema::Column->new( { + 'name' => 'history_date', + 'type' => 'int', + 'null' => 'NULL', + 'length' => '', + 'default' => '', + 'local' => '', + } ), + DBIx::DBSchema::Column->new( { + 'name' => 'history_user', + 'type' => 'varchar', + 'null' => 'NOT NULL', + 'length' => '80', + 'default' => '', + 'local' => '', + } ), + DBIx::DBSchema::Column->new( { + 'name' => 'history_action', + 'type' => 'varchar', + 'null' => 'NOT NULL', + 'length' => '80', + 'default' => '', + 'local' => '', + } ), + map { $tableobj->column($_) } $tableobj->columns + ], + } ); + $dbdef->addtable($h_tableobj); +} + #important $dbdef->save($dbdef_file); &FS::Record::reload_dbdef($dbdef_file); @@ -173,10 +223,9 @@ my($dbh)=adminsuidsetup $user; #create tables $|=1; -my @sql = $dbdef->sql($dbh); foreach my $statement ( $dbdef->sql($dbh) ) { $dbh->do( $statement ) - or die "CREATE error: ",$dbh->errstr, "\ndoing statement: $statement"; + or die "CREATE error: ". $dbh->errstr. "\ndoing statement: $statement"; } #not really sample data (and shouldn't default to US) @@ -256,7 +305,7 @@ foreach my $aref ( } - +$dbh->commit or die $dbh->errstr; $dbh->disconnect or die $dbh->errstr; print "Freeside database initialized sucessfully\n"; -- cgit v1.2.1 From c6bc9049d8836fb3c362eb738f99ce238981fbcf Mon Sep 17 00:00:00 2001 From: ivan Date: Mon, 18 Mar 2002 16:07:04 +0000 Subject: removing backup-freeside script from here --- bin/backup-freeside | 6 ------ 1 file changed, 6 deletions(-) delete mode 100644 bin/backup-freeside (limited to 'bin') diff --git a/bin/backup-freeside b/bin/backup-freeside deleted file mode 100644 index a39b04692..000000000 --- a/bin/backup-freeside +++ /dev/null @@ -1,6 +0,0 @@ -#!/bin/sh -/etc/init.d/apache stop -/etc/init.d/mysql stop -tar czvf var-lib-mysql-`date +%y%m%d%H%M%S`.tar.gz /var/lib/mysql -/etc/init.d/mysql start -/etc/init.d/apache start -- cgit v1.2.1 From f1038a648b3d53db925b23519e7cd2a30c6837ed Mon Sep 17 00:00:00 2001 From: ivan Date: Wed, 20 Mar 2002 21:31:49 +0000 Subject: new export! infostreet and sqlradius provisioning switched over (Bug #299 - doesn't close it, but all the groundwork is done) also removes non-transactional ICRADIUS export from svc_acct.export (closes: Bug#347) --- bin/icradius_reset | 7 ++++ bin/svc_acct.export | 99 ++--------------------------------------------------- 2 files changed, 9 insertions(+), 97 deletions(-) create mode 100644 bin/icradius_reset (limited to 'bin') diff --git a/bin/icradius_reset b/bin/icradius_reset new file mode 100644 index 000000000..58663ee6b --- /dev/null +++ b/bin/icradius_reset @@ -0,0 +1,7 @@ + + my $sth = $icradius_dbh->prepare("DELETE FROM radcheck"); + $sth->execute or die "Can't reset radcheck table: ". $sth->errstr; + my $sth2 = $icradius_dbh->prepare("DELETE FROM radreply"); + $sth2->execute or die "Can't reset radreply table: ". $sth2->errstr; + + diff --git a/bin/svc_acct.export b/bin/svc_acct.export index 82a8935b6..261f499da 100755 --- a/bin/svc_acct.export +++ b/bin/svc_acct.export @@ -1,6 +1,6 @@ #!/usr/bin/perl -w # -# $Id: svc_acct.export,v 1.34 2002-02-23 02:14:26 jeff Exp $ +# $Id: svc_acct.export,v 1.35 2002-03-20 21:31:49 ivan Exp $ # # Create and export password, radius and vpopmail password files: # passwd, passwd.adjunct, shadow, acp_passwd, acp_userinfo, acp_dialup @@ -47,22 +47,6 @@ my @erpcdmachines = $conf->config('erpcdmachines') my @radiusmachines = $conf->config('radiusmachines') if $conf->exists('radiusmachines'); -my $icradiusmachines = $conf->exists('icradiusmachines'); -my @icradiusmachines = $conf->config('icradiusmachines') if $icradiusmachines; -my $icradius_mysqldest = - $conf->config('icradius_mysqldest') || "/usr/local/var" - if $icradiusmachines; -my $icradius_mysqlsource = - $conf->config('icradius_mysqlsource') || "/usr/local/var/freeside" - if $icradiusmachines; -my $icradius_dbh; -if ( $icradiusmachines && $conf->exists('icradius_secrets') ) { - $icradius_dbh = DBI->connect($conf->config('icradius_secrets')) - or die $DBI::errstr; -} else { - $icradius_dbh = dbh; -} - my $textradiusprepend = $conf->exists('textradiusprepend') ? $conf->config('textradiusprepend') @@ -189,13 +173,6 @@ chmod 0600, "$spooldir/master.passwd", rmtree"$spooldir/domains", 0, 1; mkdir "$spooldir/domains", 0700; -if ( $icradiusmachines ) { - my $sth = $icradius_dbh->prepare("DELETE FROM radcheck"); - $sth->execute or die "Can't reset radcheck table: ". $sth->errstr; - my $sth2 = $icradius_dbh->prepare("DELETE FROM radreply"); - $sth2->execute or die "Can't reset radreply table: ". $sth2->errstr; -} - setpriority(0,0,10); print USERS "$radiusprepend\n"; @@ -399,7 +376,7 @@ foreach $svc_domain (sort {$a->domain cmp $b->domain} @svc_domain) { $username, qq(\t${textradiusprepend}), $radcheck, - qq(Password = "$rpassword"\n\t), +# qq(Password = "$rpassword"\n\t), join ",\n\t", map { qq($_ = "$radreply{$_}") } keys %radreply; if ( $ip && $ip ne '0e0' ) { @@ -409,57 +386,6 @@ foreach $svc_domain (sort {$a->domain cmp $b->domain} @svc_domain) { print USERS qq(\n\n); } - ### - # ICRADIUS export - if ( $icradiusmachines ) { - - my $sth = $icradius_dbh->prepare( - "INSERT INTO radcheck ( id, UserName, Attribute, Value ) VALUES ( ". - join(", ", map { $icradius_dbh->quote( $_ ) } ( - '', - $username, - "Password", - $svc_acct->_password, - ) ). " )" - ); - $sth->execute or die "Can't insert into radcheck table: ". $sth->errstr; - - foreach my $attribute ( keys %radcheck ) { - my $sth = $icradius_dbh->prepare( - "INSERT INTO radcheck ( id, UserName, Attribute, Value ) VALUES ( ". - join(", ", map { $icradius_dbh->quote( $_ ) } ( - '', - $username, - $attribute, - $radcheck{$attribute}, - ) ). " )" - ); - $sth->execute or die "Can't insert into radcheck table: ". $sth->errstr; } - - foreach my $attribute ( keys %radreply ) { - my $sth = $icradius_dbh->prepare( - "INSERT INTO radreply (id, UserName, Attribute, Value) VALUES ( ". - join(", ", map { $icradius_dbh->quote( $_ ) } ( - '', - $username, - $attribute, - $radreply{$attribute}, - ) ). " )" - ); - $sth->execute or die "Can't insert into radreply table: ". $sth->errstr; } - - if ( $ip && $ip ne '0e0' ) { - my $sth = $icradius_dbh->prepare( - "INSERT INTO radreply (id, UserName, Attribute, Value) VALUES ( ". - join(", ", map { $icradius_dbh->quote( $_ ) } ( - '', - $username, - 'Framed-IP-Address', - $ip, - ) ). " )" - ); - $sth->execute or die "Can't insert into radreply table: ". $sth->errstr; } - } } ### @@ -629,27 +555,6 @@ foreach $radiusmachine (@radiusmachines) { == 0 or die "ssh error: $!"; } -foreach my $icradiusmachine ( @icradiusmachines ) { - my( $machine, $db, $user, $pass ) = split(/\s+/, $icradiusmachine); - chdir $icradius_mysqlsource or die "Can't cd $icradius_mysqlsource: $!"; - open(WRITER,"|ssh root\@$machine mysql -v --user=$user -p $db"); - my $oldfh = select WRITER; $|=1; select $oldfh; - print WRITER "$pass\n"; - sleep 2; - print WRITER "LOCK TABLES radcheck WRITE, radreply WRITE;\n"; - foreach my $file ( glob("radcheck.*") ) { - my $scp = new Net::SCP; - $scp->scp($file,"root\@$machine:$icradius_mysqldest/$db/$file") - or die "scp error: ". $scp->{errstr}; - } - foreach my $file ( glob("radreply.*") ) { - my $scp = new Net::SCP; - $scp->scp($file,"root\@$machine:$icradius_mysqldest/$db/$file") - or die "scp error: ". $scp->{errstr}; - } - close WRITER; -} - #my @args = ("/bin/tar", "c", "--force-local", "-C", "$spooldir", "-f", "$spooldir/vpoptarball", "domains"); #system {$args[0]} @args; -- cgit v1.2.1 From 20bb426a02c0ea54d8feaea7c5da51735ab70293 Mon Sep 17 00:00:00 2001 From: ivan Date: Fri, 22 Mar 2002 18:56:33 +0000 Subject: RADIUS groups on the way! --- bin/create-history-tables | 11 ++++++++--- bin/fs-setup | 13 ++++++++++++- 2 files changed, 20 insertions(+), 4 deletions(-) (limited to 'bin') diff --git a/bin/create-history-tables b/bin/create-history-tables index fb4c866c6..9ed641efd 100755 --- a/bin/create-history-tables +++ b/bin/create-history-tables @@ -16,8 +16,13 @@ my $dbh = adminsuidsetup $user; my $schema = dbdef(); #false laziness w/fs-setup -foreach my $table ( grep { ! /^h_/ } $schema->tables ) { - my $tableobj = $schema->table($table); +my @tables = scalar(@ARGV) + ? @ARGV + : grep { ! /^h_/ } $schema->tables; +foreach my $table ( @tables ) { + warn "creating history table for $table\n"; + my $tableobj = $schema->table($table) + or die "unknown talble $table (did you run dbdef-create?)\n"; my $h_tableobj = DBIx::DBSchema::Table->new( { name => "h_$table", primary_key => 'historynum', @@ -73,6 +78,6 @@ $dbh->commit or die $dbh->errstr; $dbh->disconnect or die $dbh->errstr; sub usage { - die "Usage:\n create-history-tables user\n"; + die "Usage:\n create-history-tables user [ table table ... ] \n"; } diff --git a/bin/fs-setup b/bin/fs-setup index 7ee04a5d8..01e08f77d 100755 --- a/bin/fs-setup +++ b/bin/fs-setup @@ -1,6 +1,6 @@ #!/usr/bin/perl -Tw # -# $Id: fs-setup,v 1.83 2002-03-04 12:48:49 ivan Exp $ +# $Id: fs-setup,v 1.84 2002-03-22 18:56:32 ivan Exp $ #to delay loading dbdef until we're ready BEGIN { $FS::Record::setup_hack = 1; } @@ -951,6 +951,17 @@ sub tables_hash_hack { 'index' => [ [ 'exportnum' ], [ 'optionname' ] ], }, + 'radius_usergroup' => { + 'columns' => [ + 'usergroupnum', 'int', '', '', + 'svcnum', 'int', '', '', + 'groupname', 'varchar', '', $char_d, + ], + 'primary_key' => 'usergroupnum', + 'unique' => [], + 'index' => [ [ 'svcnum' ], [ 'groupname' ] ], + }, + ); %tables; -- cgit v1.2.1 From 8932bfd9e536bc1e0c075500847e05f51f639a7a Mon Sep 17 00:00:00 2001 From: ivan Date: Sun, 24 Mar 2002 23:16:56 +0000 Subject: s/icradius/sqlradius/ --- bin/icradius_reset | 7 ------- bin/sqlradius_reset | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 46 insertions(+), 7 deletions(-) delete mode 100644 bin/icradius_reset create mode 100644 bin/sqlradius_reset (limited to 'bin') diff --git a/bin/icradius_reset b/bin/icradius_reset deleted file mode 100644 index 58663ee6b..000000000 --- a/bin/icradius_reset +++ /dev/null @@ -1,7 +0,0 @@ - - my $sth = $icradius_dbh->prepare("DELETE FROM radcheck"); - $sth->execute or die "Can't reset radcheck table: ". $sth->errstr; - my $sth2 = $icradius_dbh->prepare("DELETE FROM radreply"); - $sth2->execute or die "Can't reset radreply table: ". $sth2->errstr; - - diff --git a/bin/sqlradius_reset b/bin/sqlradius_reset new file mode 100644 index 000000000..fe31d67f9 --- /dev/null +++ b/bin/sqlradius_reset @@ -0,0 +1,46 @@ +#!/usr/bin/perl -Tw + +use strict; +use FS::UID qw(adminsuidsetup); +use FS::part_export; + +my $user = shift or die &usage; +adminsuidsetup $user; + +#my $machine = shift or die &usage; + +my @exports = qsearch('part_export', { 'exporttype' => 'sqlradius' } ); + +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; + } +} + +foreach my $export ( @exports ) { + my @svc_acct = + map { qsearchs{'svc_acct', { 'svcnum' => $_->svcnum } ) } + qsearch('cust_svc', { 'svcpart' => $export->part_svc->svcpart } ); + foreach my $svc_acct ( @svc_acct ) { + + #flase laziness with FS::svc_acct::insert (like it matters) + my $error = $part_export->export_insert($self); + if ( $error ) { + $dbh->rollback if $oldAutoCommit; + return "exporting to ". $part_export->exporttype. + " (transaction rolled back): $error"; + } + + } +} + +sub usage { + #die "Usage:\n\n icradius_reset user machine\n"; + die "Usage:\n\n icradius_reset user\n"; +} + + -- cgit v1.2.1 From c6da895a2fb2c233716381b7e45ebbeb1c2f6aaa Mon Sep 17 00:00:00 2001 From: ivan Date: Tue, 26 Mar 2002 00:32:46 +0000 Subject: further export bugfixing add 10 kid limit to freeside-queued sqlradius_reset now works (closes: Bug#372) --- bin/sqlradius_reset | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) (limited to 'bin') diff --git a/bin/sqlradius_reset b/bin/sqlradius_reset index fe31d67f9..501685449 100644 --- a/bin/sqlradius_reset +++ b/bin/sqlradius_reset @@ -2,7 +2,10 @@ use strict; 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; @@ -23,17 +26,13 @@ foreach my $export ( @exports ) { foreach my $export ( @exports ) { my @svc_acct = - map { qsearchs{'svc_acct', { 'svcnum' => $_->svcnum } ) } + map { qsearchs('svc_acct', { 'svcnum' => $_->svcnum } ) } qsearch('cust_svc', { 'svcpart' => $export->part_svc->svcpart } ); foreach my $svc_acct ( @svc_acct ) { - #flase laziness with FS::svc_acct::insert (like it matters) - my $error = $part_export->export_insert($self); - if ( $error ) { - $dbh->rollback if $oldAutoCommit; - return "exporting to ". $part_export->exporttype. - " (transaction rolled back): $error"; - } + #false laziness with FS::svc_acct::insert (like it matters) + my $error = $export->export_insert($svc_acct); + die $error if $error; } } -- cgit v1.2.1 From 6fd7d458e1fcd100546168ec3992182d628d89ce Mon Sep 17 00:00:00 2001 From: ivan Date: Tue, 26 Mar 2002 13:04:31 +0000 Subject: error message typo --- bin/create-history-tables | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'bin') diff --git a/bin/create-history-tables b/bin/create-history-tables index 9ed641efd..d37d682d8 100755 --- a/bin/create-history-tables +++ b/bin/create-history-tables @@ -22,7 +22,7 @@ my @tables = scalar(@ARGV) foreach my $table ( @tables ) { warn "creating history table for $table\n"; my $tableobj = $schema->table($table) - or die "unknown talble $table (did you run dbdef-create?)\n"; + or die "unknown table $table (did you run dbdef-create?)\n"; my $h_tableobj = DBIx::DBSchema::Table->new( { name => "h_$table", primary_key => 'historynum', -- cgit v1.2.1 From 87af741da0dd5f6a76bbb566b4d6c54cd5b15315 Mon Sep 17 00:00:00 2001 From: ivan Date: Fri, 5 Apr 2002 23:51:18 +0000 Subject: - add message catalog table & beginning of web interface - add security_phrase and conf option to svc_acct.pm - random other stuff --- bin/freeside-session-kill | 3 +++ bin/fs-setup | 15 ++++++++++++++- bin/populate-msgcat | 45 +++++++++++++++++++++++++++++++++++++++++++++ bin/sqlradius_reset | 4 ++-- 4 files changed, 64 insertions(+), 3 deletions(-) create mode 100755 bin/populate-msgcat (limited to 'bin') diff --git a/bin/freeside-session-kill b/bin/freeside-session-kill index 9f11abd5b..d5fd703f6 100755 --- a/bin/freeside-session-kill +++ b/bin/freeside-session-kill @@ -98,3 +98,6 @@ foreach my $join ( @session ) { $dbh->commit or die $dbh->errstr; +sub usage { + die "Usage:\n\n freeside-session-kill user\n"; +} diff --git a/bin/fs-setup b/bin/fs-setup index 01e08f77d..55edeb6dd 100755 --- a/bin/fs-setup +++ b/bin/fs-setup @@ -1,6 +1,6 @@ #!/usr/bin/perl -Tw # -# $Id: fs-setup,v 1.84 2002-03-22 18:56:32 ivan Exp $ +# $Id: fs-setup,v 1.85 2002-04-05 23:51:17 ivan Exp $ #to delay loading dbdef until we're ready BEGIN { $FS::Record::setup_hack = 1; } @@ -752,6 +752,7 @@ sub tables_hash_hack { 'svcnum', 'int', '', '', 'username', 'varchar', '', $username_len, #unique (& remove dup code) '_password', 'varchar', '', 50, #13 for encryped pw's plus ' *SUSPENDED* (mp5 passwords can be 34) + 'sec_phrase', 'varchar', 'NULL', $char_d, 'popnum', 'int', 'NULL', '', 'uid', 'int', 'NULL', '', 'gid', 'int', 'NULL', '', @@ -962,6 +963,18 @@ sub tables_hash_hack { 'index' => [ [ 'svcnum' ], [ 'groupname' ] ], }, + 'msgcat' => { + 'columns' => [ + 'msgnum', 'int', '', '', + 'msgcode', 'varchar', '', $char_d, + 'locale', 'varchar', '', 16, + 'msg', 'text', '', '', + ], + 'primary_key' => 'msgnum', + 'unique' => [ [ 'msgcode', 'locale' ] ], + 'index' => [], + }, + ); %tables; diff --git a/bin/populate-msgcat b/bin/populate-msgcat new file mode 100755 index 000000000..fa88732ce --- /dev/null +++ b/bin/populate-msgcat @@ -0,0 +1,45 @@ +#!/usr/bin/perl + +use FS::UID qw(adminsuidsetup); +use FS::msgcat; + +my $user = shift or die &usage; +adminsuidsetup $user; + +foreach my $del_msgcat ( qsearchs('msgcat', {}) ) { + my $error = $del_msgcat->delete; + die $error if $error; +} + +my %messages = messages(); + +foreach $msgcode ( keys %messages ) { + foreach my $locale ( keys %{$messages{$msgcode}} ) { + my $msgcat = new FS::msgcat( { + 'msgcode' => $msgcode, + 'locale' => $locale, + }); + my $error = $msgcat->insert; + die $error if $error; + } +} + +sub messages { + + # 'msgcode' => { + # 'en_US' => 'Message', + # }, + + ( + + 'msgcode' => { + 'en_US' => 'Message', + }, + + ); +} + +sub usage { + die "Usage:\n\n populate-msgcat user\n"; +} + diff --git a/bin/sqlradius_reset b/bin/sqlradius_reset index 501685449..da98fe6be 100644 --- a/bin/sqlradius_reset +++ b/bin/sqlradius_reset @@ -38,8 +38,8 @@ foreach my $export ( @exports ) { } sub usage { - #die "Usage:\n\n icradius_reset user machine\n"; - die "Usage:\n\n icradius_reset user\n"; + #die "Usage:\n\n sqlradius_reset user machine\n"; + die "Usage:\n\n sqlradius_reset user\n"; } -- cgit v1.2.1 From 44e3eff0aa6e7bdb7f4ecd9ee1ddf141e1b68af3 Mon Sep 17 00:00:00 2001 From: ivan Date: Sun, 7 Apr 2002 05:56:09 +0000 Subject: working message catalogs (not used for enough yet) - almost (but not quite) closes Bug#385 - still have to catalog the backend things triggered by signup server. --- bin/populate-msgcat | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) (limited to 'bin') diff --git a/bin/populate-msgcat b/bin/populate-msgcat index fa88732ce..51f04c10f 100755 --- a/bin/populate-msgcat +++ b/bin/populate-msgcat @@ -1,23 +1,26 @@ -#!/usr/bin/perl +#!/usr/bin/perl -Tw +use strict; use FS::UID qw(adminsuidsetup); +use FS::Record qw(qsearch); use FS::msgcat; my $user = shift or die &usage; adminsuidsetup $user; -foreach my $del_msgcat ( qsearchs('msgcat', {}) ) { +foreach my $del_msgcat ( qsearch('msgcat', {}) ) { my $error = $del_msgcat->delete; die $error if $error; } my %messages = messages(); -foreach $msgcode ( keys %messages ) { +foreach my $msgcode ( keys %messages ) { foreach my $locale ( keys %{$messages{$msgcode}} ) { my $msgcat = new FS::msgcat( { 'msgcode' => $msgcode, 'locale' => $locale, + 'msg' => $messages{$msgcode}{$locale}, }); my $error = $msgcat->insert; die $error if $error; @@ -32,8 +35,20 @@ sub messages { ( - 'msgcode' => { - 'en_US' => 'Message', + 'passwords_dont_match' => { + 'en_US' => "Passwords don't match", + }, + + 'invalid_card' => { + 'en_US' => 'Invalid credit card number', + }, + + 'unknown_card_type' => { + 'en_US' => 'Unknown card type', + }, + + 'not_a' => { + 'en_US' => 'Not a ', }, ); -- cgit v1.2.1 From fd597aef277c522889a849d78dc7dcae67d00d95 Mon Sep 17 00:00:00 2001 From: ivan Date: Wed, 10 Apr 2002 08:39:47 +0000 Subject: fix mistake in part_pop_local schema (not used by anyone really so no big deal) --- bin/fs-setup | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'bin') diff --git a/bin/fs-setup b/bin/fs-setup index 55edeb6dd..2da0431bb 100755 --- a/bin/fs-setup +++ b/bin/fs-setup @@ -1,6 +1,6 @@ #!/usr/bin/perl -Tw # -# $Id: fs-setup,v 1.85 2002-04-05 23:51:17 ivan Exp $ +# $Id: fs-setup,v 1.86 2002-04-10 08:39:47 ivan Exp $ #to delay loading dbdef until we're ready BEGIN { $FS::Record::setup_hack = 1; } @@ -742,9 +742,9 @@ sub tables_hash_hack { 'npa', 'char', '', 3, 'nxx', 'char', '', 3, ], - 'primary_key' => 'popnum', + 'primary_key' => 'localnum', 'unique' => [ [] ], - 'index' => [ [ 'npa', 'nxx' ] ], + 'index' => [ [ 'npa', 'nxx' ], [ 'popnum' ] ], }, 'svc_acct' => { -- cgit v1.2.1 From 0b65ce59c7d2ee712389c27954382274ddf718a5 Mon Sep 17 00:00:00 2001 From: ivan Date: Wed, 10 Apr 2002 13:42:49 +0000 Subject: bulk checkin from working on the road: - use msgcat for more error messages - should be all things that would come3 back from the signup server normally now - signup server: don't display access number