1 package FS::part_export;
4 use vars qw( @ISA @EXPORT_OK %exports );
7 use FS::Record qw( qsearch qsearchs dbh );
9 use FS::part_export_option;
12 @ISA = qw(FS::Record);
13 @EXPORT_OK = qw(export_info);
17 FS::part_export - Object methods for part_export records
23 $record = new FS::part_export \%hash;
24 $record = new FS::part_export { 'column' => 'value' };
26 #($new_record, $options) = $template_recored->clone( $svcpart );
28 $error = $record->insert( { 'option' => 'value' } );
29 $error = $record->insert( \%options );
31 $error = $new_record->replace($old_record);
33 $error = $record->delete;
35 $error = $record->check;
39 An FS::part_export object represents an export of Freeside data to an external
40 provisioning system. FS::part_export inherits from FS::Record. The following
41 fields are currently supported:
45 =item exportnum - primary key
47 =item machine - Machine name
49 =item exporttype - Export type
51 =item nodomain - blank or "Y" : usernames are exported to this service with no domain
61 Creates a new export. To add the export to the database, see L<"insert">.
63 Note that this stores the hash reference, not a distinct copy of the hash it
64 points to. You can ask the object for a copy with the I<hash> method.
68 # the new method can be inherited from FS::Record, if a table method is defined
70 sub table { 'part_export'; }
76 #An alternate constructor. Creates a new export by duplicating an existing
77 #export. The given svcpart is assigned to the new export.
79 #Returns a list consisting of the new export object and a hashref of options.
85 # my $class = ref($self);
86 # my %hash = $self->hash;
87 # $hash{'exportnum'} = '';
88 # $hash{'svcpart'} = shift;
89 # ( $class->new( \%hash ),
90 # { map { $_->optionname => $_->optionvalue }
91 # qsearch('part_export_option', { 'exportnum' => $self->exportnum } )
98 Adds this record to the database. If there is an error, returns the error,
99 otherwise returns false.
101 If a hash reference of options is supplied, part_export_option records are
102 created (see L<FS::part_export_option>).
106 #false laziness w/queue.pm
110 local $SIG{HUP} = 'IGNORE';
111 local $SIG{INT} = 'IGNORE';
112 local $SIG{QUIT} = 'IGNORE';
113 local $SIG{TERM} = 'IGNORE';
114 local $SIG{TSTP} = 'IGNORE';
115 local $SIG{PIPE} = 'IGNORE';
117 my $oldAutoCommit = $FS::UID::AutoCommit;
118 local $FS::UID::AutoCommit = 0;
121 my $error = $self->SUPER::insert;
123 $dbh->rollback if $oldAutoCommit;
127 foreach my $optionname ( keys %{$options} ) {
128 my $part_export_option = new FS::part_export_option ( {
129 'exportnum' => $self->exportnum,
130 'optionname' => $optionname,
131 'optionvalue' => $options->{$optionname},
133 $error = $part_export_option->insert;
135 $dbh->rollback if $oldAutoCommit;
140 $dbh->commit or die $dbh->errstr if $oldAutoCommit;
148 Delete this record from the database.
152 #foreign keys would make this much less tedious... grr dumb mysql
155 local $SIG{HUP} = 'IGNORE';
156 local $SIG{INT} = 'IGNORE';
157 local $SIG{QUIT} = 'IGNORE';
158 local $SIG{TERM} = 'IGNORE';
159 local $SIG{TSTP} = 'IGNORE';
160 local $SIG{PIPE} = 'IGNORE';
162 my $oldAutoCommit = $FS::UID::AutoCommit;
163 local $FS::UID::AutoCommit = 0;
166 my $error = $self->SUPER::delete;
168 $dbh->rollback if $oldAutoCommit;
172 foreach my $part_export_option ( $self->part_export_option ) {
173 my $error = $part_export_option->delete;
175 $dbh->rollback if $oldAutoCommit;
180 foreach my $export_svc ( $self->export_svc ) {
181 my $error = $export_svc->delete;
183 $dbh->rollback if $oldAutoCommit;
188 $dbh->commit or die $dbh->errstr if $oldAutoCommit;
194 =item replace OLD_RECORD HASHREF
196 Replaces the OLD_RECORD with this one in the database. If there is an error,
197 returns the error, otherwise returns false.
199 If a hash reference of options is supplied, part_export_option records are
200 created or modified (see L<FS::part_export_option>).
208 local $SIG{HUP} = 'IGNORE';
209 local $SIG{INT} = 'IGNORE';
210 local $SIG{QUIT} = 'IGNORE';
211 local $SIG{TERM} = 'IGNORE';
212 local $SIG{TSTP} = 'IGNORE';
213 local $SIG{PIPE} = 'IGNORE';
215 my $oldAutoCommit = $FS::UID::AutoCommit;
216 local $FS::UID::AutoCommit = 0;
219 my $error = $self->SUPER::replace($old);
221 $dbh->rollback if $oldAutoCommit;
225 foreach my $optionname ( keys %{$options} ) {
226 my $old = qsearchs( 'part_export_option', {
227 'exportnum' => $self->exportnum,
228 'optionname' => $optionname,
230 my $new = new FS::part_export_option ( {
231 'exportnum' => $self->exportnum,
232 'optionname' => $optionname,
233 'optionvalue' => $options->{$optionname},
235 $new->optionnum($old->optionnum) if $old;
236 my $error = $old ? $new->replace($old) : $new->insert;
238 $dbh->rollback if $oldAutoCommit;
243 #remove extraneous old options
245 grep { !exists $options->{$_->optionname} } $old->part_export_option
247 my $error = $opt->delete;
249 $dbh->rollback if $oldAutoCommit;
254 $dbh->commit or die $dbh->errstr if $oldAutoCommit;
262 Checks all fields to make sure this is a valid export. If there is
263 an error, returns the error, otherwise returns false. Called by the insert
271 $self->ut_numbern('exportnum')
272 || $self->ut_domain('machine')
273 || $self->ut_alpha('exporttype')
275 return $error if $error;
277 $self->nodomain =~ /^(Y?)$/ or return "Illegal nodomain: ". $self->nodomain;
280 $self->deprecated(1); #BLAH
289 #Returns the service definition (see L<FS::part_svc>) for this export.
295 # qsearchs('part_svc', { svcpart => $self->svcpart } );
300 croak "FS::part_export::part_svc deprecated";
301 #confess "FS::part_export::part_svc deprecated";
306 Returns a list of associated FS::svc_* records.
312 map { $_->svc_x } $self->cust_svc;
317 Returns a list of associated FS::cust_svc records.
323 map { qsearch('cust_svc', { 'svcpart' => $_->svcpart } ) }
324 grep { qsearch('cust_svc', { 'svcpart' => $_->svcpart } ) }
330 Returns a list of associated FS::export_svc records.
336 qsearch('export_svc', { 'exportnum' => $self->exportnum } );
339 =item part_export_option
341 Returns all options as FS::part_export_option objects (see
342 L<FS::part_export_option>).
346 sub part_export_option {
348 qsearch('part_export_option', { 'exportnum' => $self->exportnum } );
353 Returns a list of option names and values suitable for assigning to a hash.
359 map { $_->optionname => $_->optionvalue } $self->part_export_option;
362 =item option OPTIONNAME
364 Returns the option value for the given name, or the empty string.
370 my $part_export_option =
371 qsearchs('part_export_option', {
372 exportnum => $self->exportnum,
375 $part_export_option ? $part_export_option->optionvalue : '';
380 Reblesses the object into the FS::part_export::EXPORTTYPE class, where
381 EXPORTTYPE is the object's I<exporttype> field. There should be better docs
382 on how to create new exports (and they should live in their own files and be
383 autoloaded-on-demand), but until then, see L</NEW EXPORT CLASSES>.
389 my $exporttype = $self->exporttype;
390 my $class = ref($self). "::$exporttype";
393 bless($self, $class);
396 =item export_insert SVC_OBJECT
403 $self->_export_insert(@_);
409 # my $method = $AUTOLOAD;
410 # #$method =~ s/::(\w+)$/::_$1/; #infinite loop prevention
411 # $method =~ s/::(\w+)$/_$1/; #infinite loop prevention
412 # $self->$method(@_);
415 =item export_replace NEW OLD
422 $self->_export_replace(@_);
432 $self->_export_delete(@_);
442 $self->_export_suspend(@_);
445 =item export_unsuspend
449 sub export_unsuspend {
452 $self->_export_unsuspend(@_);
455 #fallbacks providing useful error messages intead of infinite loops
458 return "_export_insert: unknown export type ". $self->exporttype;
461 sub _export_replace {
463 return "_export_replace: unknown export type ". $self->exporttype;
468 return "_export_delete: unknown export type ". $self->exporttype;
471 #call svcdb-specific fallbacks
473 sub _export_suspend {
475 #warn "warning: _export_suspened unimplemented for". ref($self);
477 my $new = $svc_x->clone_suspended;
478 $self->_export_replace( $new, $svc_x );
481 sub _export_unsuspend {
483 #warn "warning: _export_unsuspend unimplemented for ". ref($self);
485 my $old = $svc_x->clone_kludge_unsuspend;
486 $self->_export_replace( $svc_x, $old );
495 =item export_info [ SVCDB ]
497 Returns a hash reference of the exports for the given I<svcdb>, or if no
498 I<svcdb> is specified, for all exports. The keys of the hash are
499 I<exporttype>s and the values are again hash references containing information
502 'desc' => 'Description',
504 'option' => { label=>'Option Label' },
505 'option2' => { label=>'Another label' },
507 'nodomain' => 'Y', #or ''
508 'notes' => 'Additional notes',
514 return $exports{$_[0]} if @_;
515 #{ map { %{$exports{$_}} } keys %exports };
516 my $r = { map { %{$exports{$_}} } keys %exports };
519 #=item exporttype2svcdb EXPORTTYPE
521 #Returns the applicable I<svcdb> for an I<exporttype>.
525 #sub exporttype2svcdb {
526 # my $exporttype = $_[0];
527 # foreach my $svcdb ( keys %exports ) {
528 # return $svcdb if grep { $exporttype eq $_ } keys %{$exports{$svcdb}};
533 tie my %sysvshell_options, 'Tie::IxHash',
534 'crypt' => { label=>'Password encryption',
535 type=>'select', options=>[qw(crypt md5)],
540 tie my %bsdshell_options, 'Tie::IxHash',
541 'crypt' => { label=>'Password encryption',
542 type=>'select', options=>[qw(crypt md5)],
547 tie my %shellcommands_options, 'Tie::IxHash',
548 #'machine' => { label=>'Remote machine' },
549 'user' => { label=>'Remote username', default=>'root' },
550 'useradd' => { label=>'Insert command',
551 default=>'useradd -c $finger -d $dir -m -s $shell -u $uid -p $crypt_password $username'
552 #default=>'cp -pr /etc/skel $dir; chown -R $uid.$gid $dir'
554 'useradd_stdin' => { label=>'Insert command STDIN',
558 'userdel' => { label=>'Delete command',
559 default=>'userdel -r $username',
560 #default=>'rm -rf $dir',
562 'userdel_stdin' => { label=>'Delete command STDIN',
566 'usermod' => { label=>'Modify command',
567 default=>'usermod -c $new_finger -d $new_dir -m -l $new_username -s $new_shell -u $new_uid -p $new_crypt_password $old_username',
568 #default=>'[ -d $old_dir ] && mv $old_dir $new_dir || ( '.
569 # 'chmod u+t $old_dir; mkdir $new_dir; cd $old_dir; '.
570 # 'find . -depth -print | cpio -pdm $new_dir; '.
571 # 'chmod u-t $new_dir; chown -R $uid.$gid $new_dir; '.
575 'usermod_stdin' => { label=>'Modify command STDIN',
579 'usermod_pwonly' => { label=>'Disallow username changes',
582 'suspend' => { label=>'Suspension command',
583 default=>'usermod -L $username',
585 'suspend_stdin' => { label=>'Suspension command STDIN',
588 'unsuspend' => { label=>'Unsuspension command',
589 default=>'usermod -U $username',
591 'unsuspend_stdin' => { label=>'Unsuspension command STDIN',
596 tie my %shellcommands_withdomain_options, 'Tie::IxHash',
597 'user' => { label=>'Remote username', default=>'root' },
598 'useradd' => { label=>'Insert command',
601 'useradd_stdin' => { label=>'Insert command STDIN',
603 #default=>"$_password\n$_password\n",
605 'userdel' => { label=>'Delete command',
608 'userdel_stdin' => { label=>'Delete command STDIN',
612 'usermod' => { label=>'Modify command',
615 'usermod_stdin' => { label=>'Modify command STDIN',
617 #default=>"$_password\n$_password\n",
619 'usermod_pwonly' => { label=>'Disallow username changes',
622 'suspend' => { label=>'Suspension command',
625 'suspend_stdin' => { label=>'Suspension command STDIN',
628 'unsuspend' => { label=>'Unsuspension command',
631 'unsuspend_stdin' => { label=>'Unsuspension command STDIN',
636 tie my %www_shellcommands_options, 'Tie::IxHash',
637 'user' => { label=>'Remote username', default=>'root' },
638 'useradd' => { label=>'Insert command',
639 default=>'mkdir /var/www/$zone; chown $username /var/www/$zone; ln -s /var/www/$zone $homedir/$zone',
641 'userdel' => { label=>'Delete command',
642 default=>'[ -n "$zone" ] && rm -rf /var/www/$zone; rm $homedir/$zone',
644 'usermod' => { label=>'Modify command',
645 default=>'[ -n "$old_zone" ] && rm $old_homedir/$old_zone; [ "$old_zone" != "$new_zone" -a -n "$new_zone" ] && mv /var/www/$old_zone /var/www/$new_zone; [ "$old_username" != "$new_username" ] && chown -R $new_username /var/www/$new_zone; ln -s /var/www/$new_zone $new_homedir/$new_zone',
649 tie my %apache_options, 'Tie::IxHash',
650 'user' => { label=>'Remote username', default=>'root' },
651 'httpd_conf' => { label=>'httpd.conf snippet location',
652 default=>'/etc/apache/httpd-freeside.conf', },
657 <VirtualHost $domain> #generic
658 #<VirtualHost ip.addr> #preferred, http://httpd.apache.org/docs/dns-caveats.html
659 DocumentRoot /var/www/$zone
663 #LargeFileLimit 4096 12288
670 tie my %router_options, 'Tie::IxHash',
674 options => [qw(telnet ssh)],
675 default => 'telnet'},
676 'insert' => {label=>'Insert command', default=>'' },
677 'delete' => {label=>'Delete command', default=>'' },
678 'replace' => {label=>'Replace command', default=>'' },
679 'Timeout' => {label=>'Time to wait for prompt', default=>'20' },
680 'Prompt' => {label=>'Prompt string', default=>'#' }
683 tie my %domain_shellcommands_options, 'Tie::IxHash',
684 'user' => { label=>'Remote username', default=>'root' },
685 'useradd' => { label=>'Insert command',
688 'userdel' => { label=>'Delete command',
691 'usermod' => { label=>'Modify command',
696 tie my %textradius_options, 'Tie::IxHash',
697 'user' => { label=>'Remote username', default=>'root' },
698 'users' => { label=>'users file location', default=>'/etc/raddb/users' },
701 tie my %sqlradius_options, 'Tie::IxHash',
702 'datasrc' => { label=>'DBI data source ' },
703 'username' => { label=>'Database username' },
704 'password' => { label=>'Database password' },
705 'ignore_accounting' => {
707 label=>'Ignore accounting records from this database'
711 tie my %sqlradius_withdomain_options, 'Tie::IxHash',
712 'datasrc' => { label=>'DBI data source ' },
713 'username' => { label=>'Database username' },
714 'password' => { label=>'Database password' },
715 'ignore_accounting' => {
717 label=>'Ignore accounting records from this database'
721 tie my %cyrus_options, 'Tie::IxHash',
722 'server' => { label=>'IMAP server' },
723 'username' => { label=>'Admin username' },
724 'password' => { label=>'Admin password' },
727 tie my %cp_options, 'Tie::IxHash',
728 'port' => { label=>'Port number' },
729 'username' => { label=>'Username' },
730 'password' => { label=>'Password' },
731 'domain' => { label=>'Domain' },
732 'workgroup' => { label=>'Default Workgroup' },
735 tie my %infostreet_options, 'Tie::IxHash',
736 'url' => { label=>'XML-RPC Access URL', },
737 'login' => { label=>'InfoStreet login', },
738 'password' => { label=>'InfoStreet password', },
739 'groupID' => { label=>'InfoStreet groupID', },
742 tie my %vpopmail_options, 'Tie::IxHash',
743 #'machine' => { label=>'vpopmail machine', },
744 'dir' => { label=>'directory', }, # ?more info? default?
745 'uid' => { label=>'vpopmail uid' },
746 'gid' => { label=>'vpopmail gid' },
747 'restart' => { label=> 'vpopmail restart command',
748 default=> 'cd /home/vpopmail/domains; for domain in *; do /home/vpopmail/bin/vmkpasswd $domain; done; /var/qmail/bin/qmail-newu; killall -HUP qmail-send',
752 tie my %communigate_pro_options, 'Tie::IxHash',
753 'port' => { label=>'Port number', default=>'106', },
754 'login' => { label=>'The administrator account name. The name can contain a domain part.', },
755 'password' => { label=>'The administrator account password.', },
756 'accountType' => { label=>'Type for newly-created accounts',
758 options=>[qw( MultiMailbox TextMailbox MailDirMailbox )],
759 default=>'MultiMailbox',
761 'externalFlag' => { label=> 'Create accounts with an external (visible for legacy mailers) INBOX.',
764 'AccessModes' => { label=>'Access modes',
765 default=>'Mail POP IMAP PWD WebMail WebSite',
769 tie my %communigate_pro_singledomain_options, 'Tie::IxHash',
770 'port' => { label=>'Port number', default=>'106', },
771 'login' => { label=>'The administrator account name. The name can contain a domain part.', },
772 'password' => { label=>'The administrator account password.', },
773 'domain' => { label=>'Domain', },
774 'accountType' => { label=>'Type for newly-created accounts',
776 options=>[qw( MultiMailbox TextMailbox MailDirMailbox )],
777 default=>'MultiMailbox',
779 'externalFlag' => { label=> 'Create accounts with an external (visible for legacy mailers) INBOX.',
782 'AccessModes' => { label=>'Access modes',
783 default=>'Mail POP IMAP PWD WebMail WebSite',
787 tie my %bind_options, 'Tie::IxHash',
788 #'machine' => { label=>'named machine' },
789 'named_conf' => { label => 'named.conf location',
790 default=> '/etc/bind/named.conf' },
791 'zonepath' => { label => 'path to zone files',
792 default=> '/etc/bind/', },
793 'bind_release' => { label => 'ISC BIND Release',
795 options => [qw(BIND8 BIND9)],
796 default => 'BIND8' },
797 'bind9_minttl' => { label => 'The minttl required by bind9 and RFC1035.',
801 tie my %bind_slave_options, 'Tie::IxHash',
802 #'machine' => { label=> 'Slave machine' },
803 'master' => { label=> 'Master IP address(s) (semicolon-separated)' },
804 'named_conf' => { label => 'named.conf location',
805 default => '/etc/bind/named.conf' },
806 'bind_release' => { label => 'ISC BIND Release',
808 options => [qw(BIND8 BIND9)],
809 default => 'BIND8' },
810 'bind9_minttl' => { label => 'The minttl required by bind9 and RFC1035.',
814 tie my %http_options, 'Tie::IxHash',
815 'method' => { label =>'Method',
817 #options =>[qw(POST GET)],
818 options =>[qw(POST)],
820 'url' => { label => 'URL', default => 'http://', },
822 label => 'Insert data',
824 default => join("\n",
825 'DomainName $svc_x->domain',
826 'Email ( grep { $_ ne "POST" } $svc_x->cust_svc->cust_pkg->cust_main->invoicing_list)[0]',
828 'reseller $svc_x->cust_svc->cust_pkg->part_pkg->pkg =~ /reseller/i',
832 label => 'Delete data',
834 default => join("\n",
838 label => 'Replace data',
840 default => join("\n",
845 tie my %sqlmail_options, 'Tie::IxHash',
846 'datasrc' => { label => 'DBI data source' },
847 'username' => { label => 'Database username' },
848 'password' => { label => 'Database password' },
850 label => 'Server type',
852 options => [qw(dovecot_plain dovecot_crypt dovecot_digest_md5 courier_plain
854 default => ['dovecot_plain'], },
855 'svc_acct_table' => { label => 'User Table', default => 'user_acct' },
856 'svc_forward_table' => { label => 'Forward Table', default => 'forward' },
857 'svc_domain_table' => { label => 'Domain Table', default => 'domain' },
858 'svc_acct_fields' => { label => 'svc_acct Export Fields',
859 default => 'username _password domsvc svcnum' },
860 'svc_forward_fields' => { label => 'svc_forward Export Fields',
861 default => 'domain svcnum catchall' },
862 'svc_domain_fields' => { label => 'svc_domain Export Fields',
863 default => 'srcsvc dstsvc dst' },
864 'resolve_dstsvc' => { label => q{Resolve svc_forward.dstsvc to an email address and store it in dst. (Doesn't require that you also export dstsvc.)},
865 type => 'checkbox' },
869 tie my %ldap_options, 'Tie::IxHash',
870 'dn' => { label=>'Root DN' },
871 'password' => { label=>'Root DN password' },
872 'userdn' => { label=>'User DN' },
873 'attributes' => { label=>'Attributes',
877 'mail $username\@$domain',
887 'mailmessagestore $dir',
888 'userpassword $crypt_password',
890 'answer $sec_phrase',
891 'objectclass top,person,inetOrgPerson',
894 'radius' => { label=>'Export RADIUS attributes', type=>'checkbox', },
897 tie my %forward_shellcommands_options, 'Tie::IxHash',
898 'user' => { label=>'Remote username', default=>'root' },
899 'useradd' => { label=>'Insert command',
902 'userdel' => { label=>'Delete command',
905 'usermod' => { label=>'Modify command',
910 tie my %postfix_options, 'Tie::IxHash',
911 'user' => { label=>'Remote username', default=>'root' },
912 'aliases' => { label=>'aliases file location', default=>'/etc/aliases' },
913 'virtual' => { label=>'virtual file location', default=>'/etc/postfix/virtual' },
914 'mydomain' => { label=>'local domain', default=>'' },
917 #export names cannot have dashes...
922 'Batch export of /etc/passwd and /etc/shadow files (Linux/SysV).',
923 'options' => \%sysvshell_options,
925 'notes' => 'MD5 crypt requires installation of <a href="http://search.cpan.org/search?dist=Crypt-PasswdMD5">Crypt::PasswdMD5</a> from CPAN. Run bin/sysvshell.export to export the files.',
929 'Batch export of /etc/passwd and /etc/master.passwd files (BSD).',
930 'options' => \%bsdshell_options,
932 'notes' => 'MD5 crypt requires installation of <a href="http://search.cpan.org/search?dist=Crypt-PasswdMD5">Crypt::PasswdMD5</a> from CPAN. Run bin/bsdshell.export to export the files.',
936 # 'Batch export of /etc/global/passwd and /etc/global/shadow for NIS ',
940 'desc' => 'Real-time export to a text /etc/raddb/users file (Livingston, Cistron)',
941 'options' => \%textradius_options,
942 'notes' => 'This will edit a text RADIUS users file in place on a remote server. Requires installation of <a href="http://search.cpan.org/search?dist=RADIUS-UserFile">RADIUS::UserFile</a> from CPAN. If using RADIUS::UserFile 1.01, make sure to apply <a href="http://rt.cpan.org/NoAuth/Bug.html?id=1210">this patch</a>. Also make sure <a href="http://rsync.samba.org/">rsync</a> is installed on the remote machine, and <a href="../docs/ssh.html">SSH is setup for unattended operation</a>.',
946 'desc' => 'Real-time export via remote SSH (i.e. useradd, userdel, etc.)',
947 'options' => \%shellcommands_options,
949 'notes' => 'Run remote commands via SSH. Usernames are considered unique (also see shellcommands_withdomain). You probably want this if the commands you are running will not accept a domain as a parameter. You will need to <a href="../docs/ssh.html">setup SSH for unattended operation</a>.<BR><BR>Use these buttons for some useful presets:<UL><LI><INPUT TYPE="button" VALUE="Linux" onClick=\'this.form.useradd.value = "useradd -c $finger -d $dir -m -s $shell -u $uid -p $crypt_password $username"; this.form.useradd_stdin.value = ""; this.form.userdel.value = "userdel -r $username"; this.form.userdel_stdin.value=""; this.form.usermod.value = "usermod -c $new_finger -d $new_dir -m -l $new_username -s $new_shell -u $new_uid -p $new_crypt_password $old_username"; this.form.usermod_stdin.value = ""; this.form.suspend.value = "usermod -L $username"; this.form.suspend_stdin.value=""; this.form.unsuspend.value = "usermod -U $username"; this.form.unsuspend_stdin.value="";\'><LI><INPUT TYPE="button" VALUE="FreeBSD" onClick=\'this.form.useradd.value = "lockf /etc/passwd.lock pw useradd $username -d $dir -m -s $shell -u $uid -g $gid -c $finger -h 0"; this.form.useradd_stdin.value = "$_password\n"; this.form.userdel.value = "lockf /etc/passwd.lock pw userdel $username -r"; this.form.userdel_stdin.value=""; this.form.usermod.value = "lockf /etc/passwd.lock pw usermod $old_username -d $new_dir -m -l $new_username -s $new_shell -u $new_uid -c $new_finger -h 0"; this.form.usermod_stdin.value = "$new__password\n"; this.form.suspend.value = "lockf /etc/passwd.lock pw lock $username"; this.form.suspend_stdin.value=""; this.form.unsuspend.value = "lockf /etc/passwd.lock pw unlock $username"; this.form.unsuspend_stdin.value="";\'> Note: On FreeBSD, due to deficient locking in pw(1), you must disable the chpass(1), chsh(1), chfn(1), passwd(1), and vipw(1) commands, or replace them with wrappers that prepend "lockf /etc/passwd.lock". Alternatively, apply the patch in <A HREF="http://www.freebsd.org/cgi/query-pr.cgi?pr=23501">FreeBSD PR#23501</A> and remove the "lockf /etc/passwd.lock" from these default commands.<LI><INPUT TYPE="button" VALUE="NetBSD/OpenBSD" onClick=\'this.form.useradd.value = "useradd -c $finger -d $dir -m -s $shell -u $uid -p $crypt_password $username"; this.form.useradd_stdin.value = ""; this.form.userdel.value = "userdel -r $username"; this.form.userdel_stdin.value=""; this.form.usermod.value = "usermod -c $new_finger -d $new_dir -m -l $new_username -s $new_shell -u $new_uid -p $new_crypt_password $old_username"; this.form.usermod_stdin.value = ""; this.form.suspend.value = ""; this.form.suspend_stdin.value=""; this.form.unsuspend.value = ""; this.form.unsuspend_stdin.value="";\'><LI><INPUT TYPE="button" VALUE="Just maintain directories (use with sysvshell or bsdshell)" onClick=\'this.form.useradd.value = "cp -pr /etc/skel $dir; chown -R $uid.$gid $dir"; this.form.useradd_stdin.value = ""; this.form.usermod.value = "[ -d $old_dir ] && mv $old_dir $new_dir || ( chmod u+t $old_dir; mkdir $new_dir; cd $old_dir; find . -depth -print | cpio -pdm $new_dir; chmod u-t $new_dir; chown -R $new_uid.$new_gid $new_dir; rm -rf $old_dir )"; this.form.usermod_stdin.value = ""; this.form.userdel.value = "rm -rf $dir"; this.form.userdel_stdin.value=""; this.form.suspend.value = ""; this.form.suspend_stdin.value=""; this.form.unsuspend.value = ""; this.form.unsuspend_stdin.value="";\'></UL>The following variables are available for interpolation (prefixed with new_ or old_ for replace operations): <UL><LI><code>$username</code><LI><code>$_password</code><LI><code>$quoted_password</code> - unencrypted password quoted for the shell<LI><code>$crypt_password</code> - encrypted password<LI><code>$uid</code><LI><code>$gid</code><LI><code>$finger</code> - GECOS, already quoted for the shell (do not add additional quotes)<LI><code>$dir</code> - home directory<LI><code>$shell</code><LI><code>$quota</code><LI>All other fields in <a href="../docs/schema.html#svc_acct">svc_acct</a> are also available.</UL>',
952 'shellcommands_withdomain' => {
953 'desc' => 'Real-time export via remote SSH (vpopmail, etc.).',
954 'options' => \%shellcommands_withdomain_options,
955 'notes' => 'Run remote commands via SSH. username@domain (rather than just usernames) are considered unique (also see shellcommands). You probably want this if the commands you are running will accept a domain as a parameter, and will allow the same username with different domains. You will need to <a href="../docs/ssh.html">setup SSH for unattended operation</a>.<BR><BR>Use these buttons for some useful presets:<UL><LI><INPUT TYPE="button" VALUE="vpopmail" onClick=\'this.form.useradd.value = "/home/vpopmail/bin/vadduser $username\\\@$domain $quoted_password"; this.form.useradd_stdin.value = ""; this.form.userdel.value = "/home/vpopmail/bin/vdeluser $username\\\@$domain"; this.form.userdel_stdin.value=""; this.form.usermod.value = "/home/vpopmail/bin/vpasswd $new_username\\\@$new_domain $new_quoted_password"; this.form.usermod_stdin.value = ""; this.form.usermod_pwonly.checked = true;\'></UL>The following variables are available for interpolation (prefixed with <code>new_</code> or <code>old_</code> for replace operations): <UL><LI><code>$username</code><LI><code>$domain</code><LI><code>$_password</code><LI><code>$quoted_password</code> - unencrypted password quoted for the shell<LI><code>$crypt_password</code> - encrypted password<LI><code>$uid</code><LI><code>$gid</code><LI><code>$finger</code> - GECOS, already quoted for the shell (do not add additional quotes)<LI><code>$dir</code> - home directory<LI><code>$shell</code><LI><code>$quota</code><LI>All other fields in <a href="../docs/schema.html#svc_acct">svc_acct</a> are also available.</UL>',
959 'desc' => 'Real-time export to LDAP',
960 'options' => \%ldap_options,
961 'notes' => 'Real-time export to arbitrary LDAP attributes. Requires installation of <a href="http://search.cpan.org/search?dist=Net-LDAP">Net::LDAP</a> from CPAN.',
965 'desc' => 'Real-time export to SQL-backed RADIUS (FreeRADIUS, ICRADIUS, Radiator)',
966 'options' => \%sqlradius_options,
968 'notes' => 'Real-time export of radcheck, radreply and usergroup tables to any SQL database for <a href="http://www.freeradius.org/">FreeRADIUS</a>, <a href="http://radius.innercite.com/">ICRADIUS</a> or <a href="http://www.open.com.au/radiator/">Radiator</a>. This export does not export RADIUS realms (see also sqlradius_withdomain). An existing RADIUS database will be updated in realtime, but you can use <a href="../docs/man/bin/freeside-sqlradius-reset">freeside-sqlradius-reset</a> to delete the entire RADIUS database and repopulate the tables from the Freeside database. See the <a href="http://search.cpan.org/doc/TIMB/DBI/DBI.pm#connect">DBI documentation</a> and the <a href="http://search.cpan.org/search?mode=module&query=DBD%3A%3A">documentation for your DBD</a> for the exact syntax of a DBI data source.<ul><li>Using FreeRADIUS 0.9.0 with the PostgreSQL backend, the db_postgresql.sql schema and postgresql.conf queries contain incompatible changes. This is fixed in 0.9.1. Only new installs with 0.9.0 and PostgreSQL are affected - upgrades and other database backends and versions are unaffected.<li>Using ICRADIUS, add a dummy "op" column to your database: <blockquote><code>ALTER TABLE radcheck ADD COLUMN op VARCHAR(2) NOT NULL DEFAULT \'==\'<br>ALTER TABLE radreply ADD COLUMN op VARCHAR(2) NOT NULL DEFAULT \'==\'<br>ALTER TABLE radgroupcheck ADD COLUMN op VARCHAR(2) NOT NULL DEFAULT \'==\'<br>ALTER TABLE radgroupreply ADD COLUMN op VARCHAR(2) NOT NULL DEFAULT \'==\'</code></blockquote><li>Using Radiator, see the <a href="http://www.open.com.au/radiator/faq.html#38">Radiator FAQ</a> for configuration information.</ul>',
971 'sqlradius_withdomain' => {
972 'desc' => 'Real-time export to SQL-backed RADIUS (FreeRADIUS, ICRADIUS, Radiator) with realms',
973 'options' => \%sqlradius_withdomain_options,
975 'notes' => 'Real-time export of radcheck, radreply and usergroup tables to any SQL database for <a href="http://www.freeradius.org/">FreeRADIUS</a>, <a href="http://radius.innercite.com/">ICRADIUS</a> or <a href="http://www.open.com.au/radiator/">Radiator</a>. This export exports domains to RADIUS realms (see also sqlradius). An existing RADIUS database will be updated in realtime, but you can use <a href="../docs/man/bin/freeside-sqlradius-reset">freeside-sqlradius-reset</a> to delete the entire RADIUS database and repopulate the tables from the Freeside database. See the <a href="http://search.cpan.org/doc/TIMB/DBI/DBI.pm#connect">DBI documentation</a> and the <a href="http://search.cpan.org/search?mode=module&query=DBD%3A%3A">documentation for your DBD</a> for the exact syntax of a DBI data source.<ul><li>Using FreeRADIUS 0.9.0 with the PostgreSQL backend, the db_postgresql.sql schema and postgresql.conf queries contain incompatible changes. This is fixed in 0.9.1. Only new installs with 0.9.0 and PostgreSQL are affected - upgrades and other database backends and versions are unaffected.<li>Using ICRADIUS, add a dummy "op" column to your database: <blockquote><code>ALTER TABLE radcheck ADD COLUMN op VARCHAR(2) NOT NULL DEFAULT \'==\'<br>ALTER TABLE radreply ADD COLUMN op VARCHAR(2) NOT NULL DEFAULT \'==\'<br>ALTER TABLE radgroupcheck ADD COLUMN op VARCHAR(2) NOT NULL DEFAULT \'==\'<br>ALTER TABLE radgroupreply ADD COLUMN op VARCHAR(2) NOT NULL DEFAULT \'==\'</code></blockquote><li>Using Radiator, see the <a href="http://www.open.com.au/radiator/faq.html#38">Radiator FAQ</a> for configuration information.</ul>',
979 'desc' => 'Real-time export to SQL-backed mail server',
980 'options' => \%sqlmail_options,
982 'notes' => 'Database schema can be made to work with Courier IMAP and Exim. Others could work but are untested. (...extended description from pc-intouch?...)',
986 'desc' => 'Real-time export to Cyrus IMAP server',
987 'options' => \%cyrus_options,
989 'notes' => 'Integration with <a href="http://asg.web.cmu.edu/cyrus/imapd/">Cyrus IMAP Server</a>. Cyrus::IMAP::Admin should be installed locally and the connection to the server secured. <B>svc_acct.quota</B>, if available, is used to set the Cyrus quota. '
993 'desc' => 'Real-time export to Critical Path Account Provisioning Protocol',
994 'options' => \%cp_options,
995 'notes' => 'Real-time export to <a href="http://www.cp.net/">Critial Path Account Provisioning Protocol</a>. Requires installation of <a href="http://search.cpan.org/search?dist=Net-APP">Net::APP</a> from CPAN.',
999 'desc' => 'Real-time export to InfoStreet streetSmartAPI',
1000 'options' => \%infostreet_options,
1002 'notes' => 'Real-time export to <a href="http://www.infostreet.com/">InfoStreet</a> streetSmartAPI. Requires installation of <a href="http://search.cpan.org/search?dist=Frontier-Client">Frontier::Client</a> from CPAN.',
1006 'desc' => 'Real-time export to vpopmail text files',
1007 'options' => \%vpopmail_options,
1008 'notes' => 'Real time export to <a href="http://inter7.com/vpopmail/">vpopmail</a> text files. <a href="http://search.cpan.org/search?dist=File-Rsync">File::Rsync</a> must be installed, and you will need to <a href="../docs/ssh.html">setup SSH for unattended operation</a> to <b>vpopmail</b>@<i>export.host</i>.',
1011 'communigate_pro' => {
1012 'desc' => 'Real-time export to a CommuniGate Pro mail server',
1013 'options' => \%communigate_pro_options,
1014 'notes' => 'Real time export to a <a href="http://www.stalker.com/CommuniGatePro/">CommuniGate Pro</a> mail server. The <a href="http://www.stalker.com/CGPerl/">CommuniGate Pro Perl Interface</a> must be installed as CGP::CLI.',
1017 'communigate_pro_singledomain' => {
1018 'desc' => 'Real-time export to a CommuniGate Pro mail server, one domain only',
1019 'options' => \%communigate_pro_singledomain_options,
1021 'notes' => 'Real time export to a <a href="http://www.stalker.com/CommuniGatePro/">CommuniGate Pro</a> mail server. This is an unusual export to CommuniGate Pro that forces all accounts into a single domain. As CommuniGate Pro supports multiple domains, unless you have a specific reason for using this export, you probably want to use the communigate_pro export instead. The <a href="http://www.stalker.com/CGPerl/">CommuniGate Pro Perl Interface</a> must be installed as CGP::CLI.',
1029 'desc' =>'Batch export to BIND named',
1030 'options' => \%bind_options,
1031 'notes' => 'Batch export of BIND zone and configuration files to primary nameserver. <a href="http://search.cpan.org/search?dist=File-Rsync">File::Rsync</a> must be installed. Run bin/bind.export to export the files.',
1035 'desc' =>'Batch export to slave BIND named',
1036 'options' => \%bind_slave_options,
1037 'notes' => 'Batch export of BIND configuration file to a secondary nameserver. Zones are slaved from the listed masters. <a href="http://search.cpan.org/search?dist=File-Rsync">File::Rsync</a> must be installed. Run bin/bind.export to export the files.',
1041 'desc' => 'Send an HTTP or HTTPS GET or POST request',
1042 'options' => \%http_options,
1043 'notes' => 'Send an HTTP or HTTPS GET or POST to the specified URL. <a href="http://search.cpan.org/search?dist=libwww-perl">libwww-perl</a> must be installed. For HTTPS support, <a href="http://search.cpan.org/search?dist=Crypt-SSLeay">Crypt::SSLeay</a> or <a href="http://search.cpan.org/search?dist=IO-Socket-SSL">IO::Socket::SSL</a> is required.',
1047 'desc' => 'Real-time export to SQL-backed mail server',
1048 'options' => \%sqlmail_options,
1050 'notes' => 'Database schema can be made to work with Courier IMAP and Exim. Others could work but are untested. (...extended description from pc-intouch?...)',
1053 'domain_shellcommands' => {
1054 'desc' => 'Run remote commands via SSH, for domains.',
1055 'options' => \%domain_shellcommands_options,
1056 'notes' => 'Run remote commands via SSH, for domains. You will need to <a href="../docs/ssh.html">setup SSH for unattended operation</a>.<BR><BR>Use these buttons for some useful presets:<UL><LI><INPUT TYPE="button" VALUE="qmail catchall .qmail-domain-default maintenance" onClick=\'this.form.useradd.value = "[ \"$uid\" -a \"$gid\" -a \"$dir\" -a \"$qdomain\" ] && [ -e $dir/.qmail-$qdomain-default ] || { touch $dir/.qmail-$qdomain-default; chown $uid:$gid $dir/.qmail-$qdomain-default; }"; this.form.userdel.value = ""; this.form.usermod.value = "";\'></UL>The following variables are available for interpolation (prefixed with <code>new_</code> or <code>old_</code> for replace operations): <UL><LI><code>$domain</code><LI><code>$qdomain</code> - domain with periods replaced by colons<LI><code>$uid</code> - of catchall account<LI><code>$gid</code> - of catchall account<LI><code>$dir</code> - home directory of catchall account<LI>All other fields in <a href="../docs/schema.html#svc_domain">svc_domain</a> are also available.</UL>',
1064 'desc' => 'Real-time export to SQL-backed mail server',
1065 'options' => \%sqlmail_options,
1067 'notes' => 'Database schema can be made to work with Courier IMAP and Exim. Others could work but are untested. (...extended description from fire2wire?...)',
1070 'forward_shellcommands' => {
1071 'desc' => 'Run remote commands via SSH, for forwards',
1072 'options' => \%forward_shellcommands_options,
1073 'notes' => 'Run remote commands via SSH, for forwards. You will need to <a href="../docs/ssh.html">setup SSH for unattended operation</a>.<BR><BR>Use these buttons for some useful presets:<UL><LI><INPUT TYPE="button" VALUE="text vpopmail maintenance" onClick=\'this.form.useradd.value = "[ -d /home/vpopmail/domains/$domain/$username ] && { echo \"$destination\" > /home/vpopmail/domains/$domain/$username/.qmail; chown vpopmail:vchkpw /home/vpopmail/domains/$domain/$username/.qmail; }"; this.form.userdel.value = "rm /home/vpopmail/domains/$domain/$username/.qmail"; this.form.usermod.value = "mv /home/vpopmail/domains/$old_domain/$old_username/.qmail /home/vpopmail/domains/$new_domain/$new_username; [ \"$old_destination\" != \"$new_destination\" ] && { echo \"$new_destination\" > /home/vpopmail/domains/$new_domain/$new_username/.qmail; chown vpopmail:vchkpw /home/vpopmail/domains/$new_domain/$new_username/.qmail; }";\'></UL>The following variables are available for interpolation (prefixed with <code>new_</code> or <code>old_</code> for replace operations): <UL><LI><code>$username</code><LI><code>$domain</code><LI><code>$destination</code> - forward destination<LI>All other fields in <a href="../docs/schema.html#svc_forward">svc_forward</a> are also available.</UL>',
1077 'desc' => 'Real-time export to Postfix text files',
1078 'options' => \%postfix_options,
1080 'notes' => 'Batch export of Postfix aliases and virtual files. <a href="http://search.cpan.org/search?dist=File-Rsync">File::Rsync</a> must be installed. Run bin/postfix.export to export the files.',
1086 'www_shellcommands' => {
1087 'desc' => 'Run remote commands via SSH, for virtual web sites.',
1088 'options' => \%www_shellcommands_options,
1089 'notes' => 'Run remote commands via SSH, for virtual web sites. You will need to <a href="../docs/ssh.html">setup SSH for unattended operation</a>.<BR><BR>The following variables are available for interpolation (prefixed with <code>new_</code> or <code>old_</code> for replace operations): <UL><LI><code>$zone</code><LI><code>$username</code><LI><code>$homedir</code><LI>All other fields in <a href="../docs/schema.html#svc_www">svc_www</a> are also available.</UL>',
1093 'desc' => 'Export an Apache httpd.conf file snippet.',
1094 'options' => \%apache_options,
1095 'notes' => 'Batch export of an httpd.conf snippet from a template. Typically used with something like <code>Include /etc/apache/httpd-freeside.conf</code> in httpd.conf. <a href="http://search.cpan.org/search?dist=File-Rsync">File::Rsync</a> must be installed. Run bin/apache.export to export the files.',
1099 'svc_broadband' => {
1101 'desc' => 'Send a command to a router.',
1102 'options' => \%router_options,
1114 =head1 NEW EXPORT CLASSES
1116 Should be added to the %export hash here, and a module should be added in
1117 FS/FS/part_export/ (an example may be found in eg/export_template.pm)
1121 All the stuff in the %exports hash should be generated from the specific
1124 Hmm... cust_export class (not necessarily a database table...) ... ?
1126 deprecated column...
1130 L<FS::part_export_option>, L<FS::export_svc>, L<FS::svc_acct>,
1132 L<FS::svc_forward>, L<FS::Record>, schema.html from the base documentation.