diff options
author | cvs2git <cvs2git> | 1998-11-07 10:24:26 +0000 |
---|---|---|
committer | cvs2git <cvs2git> | 1998-11-07 10:24:26 +0000 |
commit | 48e7e549a27a76c357d50dd637e7ad5a29b9d43f (patch) | |
tree | e61ddacc0b1d6248ccfc61346f7f36fbb6723e56 /bin | |
parent | 47806ec845818ba69604e0452e7c7b25d62f0772 (diff) | |
parent | 4c9347994ca4e1aefdb622d9f51ac8687e6a177b (diff) |
This commit was manufactured by cvs2svn to create tag 'freeside_stable'.freeside_stable
Diffstat (limited to 'bin')
-rwxr-xr-x | bin/bill | 9 | ||||
-rwxr-xr-x | bin/dbdef-create | 85 | ||||
-rwxr-xr-x | bin/fs-setup | 542 | ||||
-rwxr-xr-x | bin/pod2x | 23 | ||||
-rwxr-xr-x | bin/svc_acct.export | 351 | ||||
-rwxr-xr-x | bin/svc_acct.import | 227 | ||||
-rwxr-xr-x | bin/svc_acct_sm.export | 221 | ||||
-rwxr-xr-x | bin/svc_acct_sm.import | 252 |
8 files changed, 7 insertions, 1703 deletions
@@ -76,6 +76,11 @@ # 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 @@ -85,7 +90,7 @@ use Date::Parse; use Getopt::Std; use FS::UID qw(adminsuidsetup swapuid); use FS::Record qw(qsearch qsearchs); -use FS::Bill; +use FS::cust_main; my($batchfile)="/var/spool/freeside/batch"; my($batchlock)="/var/spool/freeside/batch.lock"; @@ -118,7 +123,7 @@ foreach $cust_main ( print "Billing customer #" . $cust_main->getfield('custnum') . "\n"; - bless($cust_main,"FS::Bill"); + bless($cust_main,"FS::cust_main"); my($error); diff --git a/bin/dbdef-create b/bin/dbdef-create deleted file mode 100755 index eb62c77e3..000000000 --- a/bin/dbdef-create +++ /dev/null @@ -1,85 +0,0 @@ -#!/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); - diff --git a/bin/fs-setup b/bin/fs-setup deleted file mode 100755 index 45332d85c..000000000 --- a/bin/fs-setup +++ /dev/null @@ -1,542 +0,0 @@ -#!/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", <<END, ":"; -Freeside tracks the RADIUS attributes User-Name, Password and Framed-IP-Address -for each user. Enter any additional RADIUS attributes you need to track for -each user, separated by whitespace. -END -my @attributes = map { s/\-/_/g; $_; } split(" ",&getvalue); - -sub getvalue { - my($x)=scalar(<STDIN>); - 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; - -} - diff --git a/bin/pod2x b/bin/pod2x deleted file mode 100755 index 1edb1c41e..000000000 --- a/bin/pod2x +++ /dev/null @@ -1,23 +0,0 @@ -#!/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"; -} diff --git a/bin/svc_acct.export b/bin/svc_acct.export deleted file mode 100755 index 3f65a08ba..000000000 --- a/bin/svc_acct.export +++ /dev/null @@ -1,351 +0,0 @@ -#!/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 $_ !~ /^(#|$)/, <SHELLMACHINES>; - 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 $_ !~ /^(#|$)/, <BSDSHELLMACHINES>; - 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 $_ !~ /^(#|$)/, <NISMACHINES>; - 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 $_ !~ /^(#|$)/, <ERPCDMACHINES>; - 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 $_ !~ /^(#|$)/, <RADIUSMACHINES>; - 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)=<EXPORT>; - 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; - diff --git a/bin/svc_acct.import b/bin/svc_acct.import deleted file mode 100755 index c4b8c5ec5..000000000 --- a/bin/svc_acct.import +++ /dev/null @@ -1,227 +0,0 @@ -#!/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", <<END; -Most accounts probably have entries in passwd and users (with Port-Limit -nonexistant or 1). -END -my($ppp_svcpart)=&getpart; - -print "\n\n", &menu_svc, "\n", <<END; -Some accounts have entries in passwd and users, but with Port-Limit 2 (or -more). -END -my($isdn_svcpart)=&getpart; - -print "\n\n", &menu_svc, "\n", <<END; -Some accounts might have entries in users only (Port-Limit 1) -END -my($oppp_svcpart)=&getpart; - -print "\n\n", &menu_svc, "\n", <<END; -Some accounts might have entries in users only (Port-Limit >= 2) -END -my($oisdn_svcpart)=&getpart; - -print "\n\n", &menu_svc, "\n", <<END; -POP mail accounts have entries in passwd only, and have a particular shell. -END -print "Enter that shell: "; -my($pop_shell)=&getvalue; -my($popmail_svcpart)=&getpart; - -print "\n\n", &menu_svc, "\n", <<END; -Everything else in passwd is a shell account. -END -my($shell_svcpart)=&getpart; - -print "\n\n", <<END; -Enter the location and name of your _user_ passwd file, for example -"mail.isp.com:/etc/passwd" or "nis.isp.com:/etc/global/passwd" -END -print ":"; -my($loc_passwd)=&getvalue; -iscp("root\@$loc_passwd", "$spooldir/passwd.import"); - -print "\n\n", <<END; -Enter the location and name of your _user_ shadow file, for example -"mail.isp.com:/etc/shadow" or "bsd.isp.com:/etc/master.passwd" -END -print ":"; -my($loc_shadow)=&getvalue; -iscp("root\@$loc_shadow", "$spooldir/shadow.import"); - -print "\n\n", <<END; -Enter the location and name of your radius "users" file, for example -"radius.isp.com:/etc/raddb/users" -END -print ":"; -my($loc_users)=&getvalue; -iscp("root\@$loc_users", "$spooldir/users.import"); - -sub menu_svc { - ( join "\n", map "$_: ".$part_svc{$_}->svc, sort keys %part_svc ). "\n"; -} -sub getpart { - print "Enter part number, or 0 for none: "; - &getvalue; -} -sub getvalue { - my($x)=scalar(<STDIN>); - 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 (<USERS>) { - 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 (<USERS>) { - 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 (<SHADOW>) { - chop; - my($username,$password)=split(/:/); - $password{$username}=$password; -} - -while (<PASSWD>) { - 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}; -} - diff --git a/bin/svc_acct_sm.export b/bin/svc_acct_sm.export deleted file mode 100755 index c2ec1e53f..000000000 --- a/bin/svc_acct_sm.export +++ /dev/null @@ -1,221 +0,0 @@ -#!/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: $!"; - <SHELLMACHINE> =~ /^([\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 $_ !~ /^(#|$)/, <QMAILMACHINES>; - 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 $_ !~ /^(#|$)/, <SENDMAILMACHINES>; - 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 $_ !~ /^(#|$)/, <DOMAIN>; -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)=<EXPORT>; - 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; - diff --git a/bin/svc_acct_sm.import b/bin/svc_acct_sm.import deleted file mode 100755 index 10d7e4c20..000000000 --- a/bin/svc_acct_sm.import +++ /dev/null @@ -1,252 +0,0 @@ -#!/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", <<END; -Select your MTA from the following list. -END -print join "\n", map "$_: $mta{$_}", sort keys %mta; -print "\n\n:"; -my($mta)=&getvalue; - -if ( $mta{$mta} eq "qmail" ) { - - print "\n\n", <<END; -Enter the location and name of your qmail control directory, for example -"mail.isp.com:/var/qmail/control" -END - print ":"; - my($control)=&getvalue; - iscp("root\@$control/rcpthosts","$spooldir/rcpthosts.import"); -# iscp("root\@$control/recipientmap","$spooldir/recipientmap.import"); - iscp("root\@$control/virtualdomains","$spooldir/virtualdomains.import"); - -# print "\n\n", <<END; -#Enter the name of the machine with your user .qmail files, for example -#"mail.isp.com" -#END -# print ":"; -# my($shellmachine)=&getvalue; - -} elsif ( $mta{$mta} eq "sendmail" ) { - - print "\n\n", <<END; -Enter the location and name of your sendmail virtual user table, for example -"mail.isp.com:/etc/virtusertable" -END - print ":"; - my($virtusertable)=&getvalue; - iscp("root\@$virtusertable","$spooldir/virtusertable.import"); - - print "\n\n", <<END; -Enter the location and name of your sendmail.cw file, for example -"mail.isp.com:/etc/sendmail.cw" -END - print ":"; - my($sendmail_cw)=&getvalue; - iscp("root\@$sendmail_cw","$spooldir/sendmail.cw.import"); - -} else { - die "Unknown MTA!\n"; -} - -sub getvalue { - my($x)=scalar(<STDIN>); - 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 (<RCPTHOSTS>) { - 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 (<VIRTUALDOMAINS>) { - 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 <<END; -foreach \$file (<$dir/.qmail$dash_ext-*>) { - \$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 (<VIRTUSERTABLE>) { - 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", <<END if $mta{$mta} eq "qmail"; -Don\'t forget to run $spooldir/virtualdomains.FIX before using -$spooldir/virtualdomains ! -END - |