add postfix export
[freeside.git] / FS / FS / part_export.pm
1 package FS::part_export;
2
3 use strict;
4 use vars qw( @ISA @EXPORT_OK %exports );
5 use Exporter;
6 use Tie::IxHash;
7 use FS::Record qw( qsearch qsearchs dbh );
8 use FS::part_svc;
9 use FS::part_export_option;
10 use FS::export_svc;
11
12 @ISA = qw(FS::Record);
13 @EXPORT_OK = qw(export_info);
14
15 =head1 NAME
16
17 FS::part_export - Object methods for part_export records
18
19 =head1 SYNOPSIS
20
21   use FS::part_export;
22
23   $record = new FS::part_export \%hash;
24   $record = new FS::part_export { 'column' => 'value' };
25
26   #($new_record, $options) = $template_recored->clone( $svcpart );
27
28   $error = $record->insert( { 'option' => 'value' } );
29   $error = $record->insert( \%options );
30
31   $error = $new_record->replace($old_record);
32
33   $error = $record->delete;
34
35   $error = $record->check;
36
37 =head1 DESCRIPTION
38
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:
42
43 =over 4
44
45 =item exportnum - primary key
46
47 =item machine - Machine name 
48
49 =item exporttype - Export type
50
51 =item nodomain - blank or "Y" : usernames are exported to this service with no domain
52
53 =back
54
55 =head1 METHODS
56
57 =over 4
58
59 =item new HASHREF
60
61 Creates a new export.  To add the export to the database, see L<"insert">.
62
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.
65
66 =cut
67
68 # the new method can be inherited from FS::Record, if a table method is defined
69
70 sub table { 'part_export'; }
71
72 =cut
73
74 #=item clone SVCPART
75 #
76 #An alternate constructor.  Creates a new export by duplicating an existing
77 #export.  The given svcpart is assigned to the new export.
78 #
79 #Returns a list consisting of the new export object and a hashref of options.
80 #
81 #=cut
82 #
83 #sub clone {
84 #  my $self = shift;
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 } )
92 #    }
93 #  );
94 #}
95
96 =item insert HASHREF
97
98 Adds this record to the database.  If there is an error, returns the error,
99 otherwise returns false.
100
101 If a hash reference of options is supplied, part_export_option records are
102 created (see L<FS::part_export_option>).
103
104 =cut
105
106 #false laziness w/queue.pm
107 sub insert {
108   my $self = shift;
109   my $options = shift;
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';
116
117   my $oldAutoCommit = $FS::UID::AutoCommit;
118   local $FS::UID::AutoCommit = 0;
119   my $dbh = dbh;
120
121   my $error = $self->SUPER::insert;
122   if ( $error ) {
123     $dbh->rollback if $oldAutoCommit;
124     return $error;
125   }
126
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},
132     } );
133     $error = $part_export_option->insert;
134     if ( $error ) {
135       $dbh->rollback if $oldAutoCommit;
136       return $error;
137     }
138   }
139
140   $dbh->commit or die $dbh->errstr if $oldAutoCommit;
141
142   '';
143
144 }
145
146 =item delete
147
148 Delete this record from the database.
149
150 =cut
151
152 #foreign keys would make this much less tedious... grr dumb mysql
153 sub delete {
154   my $self = shift;
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';
161
162   my $oldAutoCommit = $FS::UID::AutoCommit;
163   local $FS::UID::AutoCommit = 0;
164   my $dbh = dbh;
165
166   my $error = $self->SUPER::delete;
167   if ( $error ) {
168     $dbh->rollback if $oldAutoCommit;
169     return $error;
170   }
171
172   foreach my $part_export_option ( $self->part_export_option ) {
173     my $error = $part_export_option->delete;
174     if ( $error ) {
175       $dbh->rollback if $oldAutoCommit;
176       return $error;
177     }
178   }
179
180   foreach my $export_svc ( $self->export_svc ) {
181     my $error = $export_svc->delete;
182     if ( $error ) {
183       $dbh->rollback if $oldAutoCommit;
184       return $error;
185     }
186   }
187
188   $dbh->commit or die $dbh->errstr if $oldAutoCommit;
189
190   '';
191
192 }
193
194 =item replace OLD_RECORD HASHREF
195
196 Replaces the OLD_RECORD with this one in the database.  If there is an error,
197 returns the error, otherwise returns false.
198
199 If a hash reference of options is supplied, part_export_option records are
200 created or modified (see L<FS::part_export_option>).
201
202 =cut
203
204 sub replace {
205   my $self = shift;
206   my $old = shift;
207   my $options = shift;
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';
214
215   my $oldAutoCommit = $FS::UID::AutoCommit;
216   local $FS::UID::AutoCommit = 0;
217   my $dbh = dbh;
218
219   my $error = $self->SUPER::replace($old);
220   if ( $error ) {
221     $dbh->rollback if $oldAutoCommit;
222     return $error;
223   }
224
225   foreach my $optionname ( keys %{$options} ) {
226     my $old = qsearchs( 'part_export_option', {
227         'exportnum'   => $self->exportnum,
228         'optionname'  => $optionname,
229     } );
230     my $new = new FS::part_export_option ( {
231         'exportnum'   => $self->exportnum,
232         'optionname'  => $optionname,
233         'optionvalue' => $options->{$optionname},
234     } );
235     $new->optionnum($old->optionnum) if $old;
236     my $error = $old ? $new->replace($old) : $new->insert;
237     if ( $error ) {
238       $dbh->rollback if $oldAutoCommit;
239       return $error;
240     }
241   }
242
243   #remove extraneous old options
244   foreach my $opt (
245     grep { !exists $options->{$_->optionname} } $old->part_export_option
246   ) {
247     my $error = $opt->delete;
248     if ( $error ) {
249       $dbh->rollback if $oldAutoCommit;
250       return $error;
251     }
252   }
253
254   $dbh->commit or die $dbh->errstr if $oldAutoCommit;
255
256   '';
257
258 };
259
260 =item check
261
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
264 and replace methods.
265
266 =cut
267
268 sub check {
269   my $self = shift;
270   my $error = 
271     $self->ut_numbern('exportnum')
272     || $self->ut_domain('machine')
273     || $self->ut_alpha('exporttype')
274   ;
275   return $error if $error;
276
277   $self->nodomain =~ /^(Y?)$/ or return "Illegal nodomain: ". $self->nodomain;
278   $self->nodomain($1);
279
280   $self->deprecated(1); #BLAH
281
282   #check exporttype?
283
284   $self->SUPER::check;
285 }
286
287 #=item part_svc
288 #
289 #Returns the service definition (see L<FS::part_svc>) for this export.
290 #
291 #=cut
292 #
293 #sub part_svc {
294 #  my $self = shift;
295 #  qsearchs('part_svc', { svcpart => $self->svcpart } );
296 #}
297
298 sub part_svc {
299   use Carp;
300   croak "FS::part_export::part_svc deprecated";
301   #confess "FS::part_export::part_svc deprecated";
302 }
303
304 =item svc_x
305
306 Returns a list of associated FS::svc_* records.
307
308 =cut
309
310 sub svc_x {
311   my $self = shift;
312   map { $_->svc_x } $self->cust_svc;
313 }
314
315 =item cust_svc
316
317 Returns a list of associated FS::cust_svc records.
318
319 =cut
320
321 sub cust_svc {
322   my $self = shift;
323   map { qsearch('cust_svc', { 'svcpart' => $_->svcpart } ) }
324     grep { qsearch('cust_svc', { 'svcpart' => $_->svcpart } ) }
325       $self->export_svc;
326 }
327
328 =item export_svc
329
330 Returns a list of associated FS::export_svc records.
331
332 =cut
333
334 sub export_svc {
335   my $self = shift;
336   qsearch('export_svc', { 'exportnum' => $self->exportnum } );
337 }
338
339 =item part_export_option
340
341 Returns all options as FS::part_export_option objects (see
342 L<FS::part_export_option>).
343
344 =cut
345
346 sub part_export_option {
347   my $self = shift;
348   qsearch('part_export_option', { 'exportnum' => $self->exportnum } );
349 }
350
351 =item options 
352
353 Returns a list of option names and values suitable for assigning to a hash.
354
355 =cut
356
357 sub options {
358   my $self = shift;
359   map { $_->optionname => $_->optionvalue } $self->part_export_option;
360 }
361
362 =item option OPTIONNAME
363
364 Returns the option value for the given name, or the empty string.
365
366 =cut
367
368 sub option {
369   my $self = shift;
370   my $part_export_option =
371     qsearchs('part_export_option', {
372       exportnum  => $self->exportnum,
373       optionname => shift,
374   } );
375   $part_export_option ? $part_export_option->optionvalue : '';
376 }
377
378 =item rebless
379
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>.
384
385 =cut
386
387 sub rebless {
388   my $self = shift;
389   my $exporttype = $self->exporttype;
390   my $class = ref($self). "::$exporttype";
391   eval "use $class;";
392   die $@ if $@;
393   bless($self, $class);
394 }
395
396 =item export_insert SVC_OBJECT
397
398 =cut
399
400 sub export_insert {
401   my $self = shift;
402   $self->rebless;
403   $self->_export_insert(@_);
404 }
405
406 #sub AUTOLOAD {
407 #  my $self = shift;
408 #  $self->rebless;
409 #  my $method = $AUTOLOAD;
410 #  #$method =~ s/::(\w+)$/::_$1/; #infinite loop prevention
411 #  $method =~ s/::(\w+)$/_$1/; #infinite loop prevention
412 #  $self->$method(@_);
413 #}
414
415 =item export_replace NEW OLD
416
417 =cut
418
419 sub export_replace {
420   my $self = shift;
421   $self->rebless;
422   $self->_export_replace(@_);
423 }
424
425 =item export_delete
426
427 =cut
428
429 sub export_delete {
430   my $self = shift;
431   $self->rebless;
432   $self->_export_delete(@_);
433 }
434
435 =item export_suspend
436
437 =cut
438
439 sub export_suspend {
440   my $self = shift;
441   $self->rebless;
442   $self->_export_suspend(@_);
443 }
444
445 =item export_unsuspend
446
447 =cut
448
449 sub export_unsuspend {
450   my $self = shift;
451   $self->rebless;
452   $self->_export_unsuspend(@_);
453 }
454
455 #fallbacks providing useful error messages intead of infinite loops
456 sub _export_insert {
457   my $self = shift;
458   return "_export_insert: unknown export type ". $self->exporttype;
459 }
460
461 sub _export_replace {
462   my $self = shift;
463   return "_export_replace: unknown export type ". $self->exporttype;
464 }
465
466 sub _export_delete {
467   my $self = shift;
468   return "_export_delete: unknown export type ". $self->exporttype;
469 }
470
471 #fallbacks providing null operations
472
473 sub _export_suspend {
474   my $self = shift;
475   #warn "warning: _export_suspened unimplemented for". ref($self);
476   '';
477 }
478
479 sub _export_unsuspend {
480   my $self = shift;
481   #warn "warning: _export_unsuspend unimplemented for ". ref($self);
482   '';
483 }
484
485 =back
486
487 =head1 SUBROUTINES
488
489 =over 4
490
491 =item export_info [ SVCDB ]
492
493 Returns a hash reference of the exports for the given I<svcdb>, or if no
494 I<svcdb> is specified, for all exports.  The keys of the hash are
495 I<exporttype>s and the values are again hash references containing information
496 on the export:
497
498   'desc'     => 'Description',
499   'options'  => {
500                   'option'  => { label=>'Option Label' },
501                   'option2' => { label=>'Another label' },
502                 },
503   'nodomain' => 'Y', #or ''
504   'notes'    => 'Additional notes',
505
506 =cut
507
508 sub export_info {
509   #warn $_[0];
510   return $exports{$_[0]} if @_;
511   #{ map { %{$exports{$_}} } keys %exports };
512   my $r = { map { %{$exports{$_}} } keys %exports };
513 }
514
515 #=item exporttype2svcdb EXPORTTYPE
516 #
517 #Returns the applicable I<svcdb> for an I<exporttype>.
518 #
519 #=cut
520 #
521 #sub exporttype2svcdb {
522 #  my $exporttype = $_[0];
523 #  foreach my $svcdb ( keys %exports ) {
524 #    return $svcdb if grep { $exporttype eq $_ } keys %{$exports{$svcdb}};
525 #  }
526 #  '';
527 #}
528
529 tie my %sysvshell_options, 'Tie::IxHash',
530   'crypt' => { label=>'Password encryption',
531                type=>'select', options=>[qw(crypt md5)],
532                default=>'crypt',
533              },
534 ;
535
536 tie my %bsdshell_options, 'Tie::IxHash', 
537   'crypt' => { label=>'Password encryption',
538                type=>'select', options=>[qw(crypt md5)],
539                default=>'crypt',
540              },
541 ;
542
543 tie my %shellcommands_options, 'Tie::IxHash',
544   #'machine' => { label=>'Remote machine' },
545   'user' => { label=>'Remote username', default=>'root' },
546   'useradd' => { label=>'Insert command',
547                  default=>'useradd -c $finger -d $dir -m -s $shell -u $uid -p $crypt_password $username'
548                 #default=>'cp -pr /etc/skel $dir; chown -R $uid.$gid $dir'
549                },
550   'useradd_stdin' => { label=>'Insert command STDIN',
551                        type =>'textarea',
552                        default=>'',
553                      },
554   'userdel' => { label=>'Delete command',
555                  default=>'userdel -r $username',
556                  #default=>'rm -rf $dir',
557                },
558   'userdel_stdin' => { label=>'Delete command STDIN',
559                        type =>'textarea',
560                        default=>'',
561                      },
562   'usermod' => { label=>'Modify command',
563                  default=>'usermod -c $new_finger -d $new_dir -m -l $new_username -s $new_shell -u $new_uid -p $new_crypt_password $old_username',
564                 #default=>'[ -d $old_dir ] && mv $old_dir $new_dir || ( '.
565                  #  'chmod u+t $old_dir; mkdir $new_dir; cd $old_dir; '.
566                  #  'find . -depth -print | cpio -pdm $new_dir; '.
567                  #  'chmod u-t $new_dir; chown -R $uid.$gid $new_dir; '.
568                  #  'rm -rf $old_dir'.
569                  #')'
570                },
571   'usermod_stdin' => { label=>'Modify command STDIN',
572                        type =>'textarea',
573                        default=>'',
574                      },
575   'usermod_pwonly' => { label=>'Disallow username changes',
576                         type =>'checkbox',
577                       },
578   'suspend' => { label=>'Suspension command',
579                  default=>'usermod -L $username',
580                },
581   'suspend_stdin' => { label=>'Suspension command STDIN',
582                        default=>'',
583                      },
584   'unsuspend' => { label=>'Unsuspension command',
585                    default=>'usermod -U $username',
586                  },
587   'unsuspend_stdin' => { label=>'Unsuspension command STDIN',
588                          default=>'',
589                        },
590 ;
591
592 tie my %shellcommands_withdomain_options, 'Tie::IxHash',
593   'user' => { label=>'Remote username', default=>'root' },
594   'useradd' => { label=>'Insert command',
595                  #default=>''
596                },
597   'useradd_stdin' => { label=>'Insert command STDIN',
598                        type =>'textarea',
599                        #default=>"$_password\n$_password\n",
600                      },
601   'userdel' => { label=>'Delete command',
602                  #default=>'',
603                },
604   'userdel_stdin' => { label=>'Delete command STDIN',
605                        type =>'textarea',
606                        #default=>'',
607                      },
608   'usermod' => { label=>'Modify command',
609                  default=>'',
610                },
611   'usermod_stdin' => { label=>'Modify command STDIN',
612                        type =>'textarea',
613                        #default=>"$_password\n$_password\n",
614                      },
615   'usermod_pwonly' => { label=>'Disallow username changes',
616                         type =>'checkbox',
617                       },
618   'suspend' => { label=>'Suspension command',
619                  default=>'',
620                },
621   'suspend_stdin' => { label=>'Suspension command STDIN',
622                        default=>'',
623                      },
624   'unsuspend' => { label=>'Unsuspension command',
625                    default=>'',
626                  },
627   'unsuspend_stdin' => { label=>'Unsuspension command STDIN',
628                          default=>'',
629                        },
630 ;
631
632 tie my %www_shellcommands_options, 'Tie::IxHash',
633   'user' => { label=>'Remote username', default=>'root' },
634   'useradd' => { label=>'Insert command',
635                  default=>'mkdir /var/www/$zone; chown $username /var/www/$zone; ln -s /var/www/$zone $homedir/$zone',
636                },
637   'userdel'  => { label=>'Delete command',
638                   default=>'[ -n &quot;$zone&quot; ] && rm -rf /var/www/$zone; rm $homedir/$zone',
639                 },
640   'usermod'  => { label=>'Modify command',
641                   default=>'[ -n &quot;$old_zone&quot; ] && rm $old_homedir/$old_zone; [ &quot;$old_zone&quot; != &quot;$new_zone&quot; -a -n &quot;$new_zone&quot; ] && mv /var/www/$old_zone /var/www/$new_zone; [ &quot;$old_username&quot; != &quot;$new_username&quot; ] && chown -R $new_username /var/www/$new_zone; ln -s /var/www/$new_zone $new_homedir/$new_zone',
642                 },
643 ;
644
645 tie my %apache_options, 'Tie::IxHash',
646   'user'       => { label=>'Remote username', default=>'root' },
647   'httpd_conf' => { label=>'httpd.conf snippet location',
648                     default=>'/etc/apache/httpd-freeside.conf', },
649   'template'   => {
650     label   => 'Template',
651     type    => 'textarea',
652     default => <<'END',
653 <VirtualHost $domain> #generic
654 #<VirtualHost ip.addr> #preferred, http://httpd.apache.org/docs/dns-caveats.html
655 DocumentRoot /var/www/$zone
656 ServerName $zone
657 ServerAlias *.$zone
658 #BandWidthModule On
659 #LargeFileLimit 4096 12288
660 </VirtualHost>
661
662 END
663   },
664 ;
665
666 tie my %router_options, 'Tie::IxHash',
667   'protocol' => {
668           label=>'Protocol',
669           type =>'select',
670           options => [qw(telnet ssh)],
671           default => 'telnet'},
672   'insert' => {label=>'Insert command', default=>'' },
673   'delete' => {label=>'Delete command', default=>'' },
674   'replace' => {label=>'Replace command', default=>'' },
675   'Timeout' => {label=>'Time to wait for prompt', default=>'20' },
676   'Prompt' => {label=>'Prompt string', default=>'#' }
677 ;
678
679 tie my %domain_shellcommands_options, 'Tie::IxHash',
680   'user' => { label=>'Remote username', default=>'root' },
681   'useradd' => { label=>'Insert command',
682                  default=>'',
683                },
684   'userdel'  => { label=>'Delete command',
685                   default=>'',
686                 },
687   'usermod'  => { label=>'Modify command',
688                   default=>'',
689                 },
690 ;
691
692 tie my %textradius_options, 'Tie::IxHash',
693   'user' => { label=>'Remote username', default=>'root' },
694   'users' => { label=>'users file location', default=>'/etc/raddb/users' },
695 ;
696
697 tie my %sqlradius_options, 'Tie::IxHash',
698   'datasrc'  => { label=>'DBI data source ' },
699   'username' => { label=>'Database username' },
700   'password' => { label=>'Database password' },
701   'ignore_accounting' => {
702      type => 'checkbox',
703      label=>'Ignore accounting records from this database'
704   },
705 ;
706
707 tie my %sqlradius_withdomain_options, 'Tie::IxHash',
708   'datasrc'  => { label=>'DBI data source ' },
709   'username' => { label=>'Database username' },
710   'password' => { label=>'Database password' },
711   'ignore_accounting' => {
712      type => 'checkbox',
713      label=>'Ignore accounting records from this database'
714   },
715 ;
716
717 tie my %cyrus_options, 'Tie::IxHash',
718   'server' => { label=>'IMAP server' },
719   'username' => { label=>'Admin username' },
720   'password' => { label=>'Admin password' },
721 ;
722
723 tie my %cp_options, 'Tie::IxHash',
724   'port'      => { label=>'Port number' },
725   'username'  => { label=>'Username' },
726   'password'  => { label=>'Password' },
727   'domain'    => { label=>'Domain' },
728   'workgroup' => { label=>'Default Workgroup' },
729 ;
730
731 tie my %infostreet_options, 'Tie::IxHash',
732   'url'      => { label=>'XML-RPC Access URL', },
733   'login'    => { label=>'InfoStreet login', },
734   'password' => { label=>'InfoStreet password', },
735   'groupID'  => { label=>'InfoStreet groupID', },
736 ;
737
738 tie my %vpopmail_options, 'Tie::IxHash',
739   #'machine' => { label=>'vpopmail machine', },
740   'dir'     => { label=>'directory', }, # ?more info? default?
741   'uid'     => { label=>'vpopmail uid' },
742   'gid'     => { label=>'vpopmail gid' },
743   'restart' => { label=> 'vpopmail restart command',
744                  default=> 'cd /home/vpopmail/domains; for domain in *; do /home/vpopmail/bin/vmkpasswd $domain; done; /var/qmail/bin/qmail-newu; killall -HUP qmail-send',
745                },
746 ;
747
748 tie my %communigate_pro_options, 'Tie::IxHash',
749   'port'     => { label=>'Port number', default=>'106', },
750   'login'    => { label=>'The administrator account name.  The name can contain a domain part.', },
751   'password' => { label=>'The administrator account password.', },
752   'accountType' => { label=>'Type for newly-created accounts',
753                      type=>'select',
754                      options=>[qw( MultiMailbox TextMailbox MailDirMailbox )],
755                      default=>'MultiMailbox',
756                    },
757   'externalFlag' => { label=> 'Create accounts with an external (visible for legacy mailers) INBOX.',
758                       type=>'checkbox',
759                     },
760   'AccessModes' => { label=>'Access modes',
761                      default=>'Mail POP IMAP PWD WebMail WebSite',
762                    },
763 ;
764
765 tie my %communigate_pro_singledomain_options, 'Tie::IxHash',
766   'port'     => { label=>'Port number', default=>'106', },
767   'login'    => { label=>'The administrator account name.  The name can contain a domain part.', },
768   'password' => { label=>'The administrator account password.', },
769   'domain'   => { label=>'Domain', },
770   'accountType' => { label=>'Type for newly-created accounts',
771                      type=>'select',
772                      options=>[qw( MultiMailbox TextMailbox MailDirMailbox )],
773                      default=>'MultiMailbox',
774                    },
775   'externalFlag' => { label=> 'Create accounts with an external (visible for legacy mailers) INBOX.',
776                       type=>'checkbox',
777                     },
778   'AccessModes' => { label=>'Access modes',
779                      default=>'Mail POP IMAP PWD WebMail WebSite',
780                    },
781 ;
782
783 tie my %bind_options, 'Tie::IxHash',
784   #'machine'     => { label=>'named machine' },
785   'named_conf'   => { label  => 'named.conf location',
786                       default=> '/etc/bind/named.conf' },
787   'zonepath'     => { label => 'path to zone files',
788                       default=> '/etc/bind/', },
789   'bind_release' => { label => 'ISC BIND Release',
790                       type  => 'select',
791                       options => [qw(BIND8 BIND9)],
792                       default => 'BIND8' },
793   'bind9_minttl' => { label => 'The minttl required by bind9 and RFC1035.',
794                       default => '1D' },
795 ;
796
797 tie my %bind_slave_options, 'Tie::IxHash',
798   #'machine'     => { label=> 'Slave machine' },
799   'master'       => { label=> 'Master IP address(s) (semicolon-separated)' },
800   'named_conf'   => { label   => 'named.conf location',
801                       default => '/etc/bind/named.conf' },
802   'bind_release' => { label => 'ISC BIND Release',
803                       type  => 'select',
804                       options => [qw(BIND8 BIND9)],
805                       default => 'BIND8' },
806   'bind9_minttl' => { label => 'The minttl required by bind9 and RFC1035.',
807                       default => '1D' },
808 ;
809
810 tie my %http_options, 'Tie::IxHash',
811   'method' => { label   =>'Method',
812                 type    =>'select',
813                 #options =>[qw(POST GET)],
814                 options =>[qw(POST)],
815                 default =>'POST' },
816   'url'    => { label   => 'URL', default => 'http://', },
817   'insert_data' => {
818     label   => 'Insert data',
819     type    => 'textarea',
820     default => join("\n",
821       'DomainName $svc_x->domain',
822       'Email ( grep { $_ ne "POST" } $svc_x->cust_svc->cust_pkg->cust_main->invoicing_list)[0]',
823       'test 1',
824       'reseller $svc_x->cust_svc->cust_pkg->part_pkg->pkg =~ /reseller/i',
825     ),
826   },
827   'delete_data' => {
828     label   => 'Delete data',
829     type    => 'textarea',
830     default => join("\n",
831     ),
832   },
833   'replace_data' => {
834     label   => 'Replace data',
835     type    => 'textarea',
836     default => join("\n",
837     ),
838   },
839 ;
840
841 tie my %sqlmail_options, 'Tie::IxHash',
842   'datasrc'            => { label => 'DBI data source' },
843   'username'           => { label => 'Database username' },
844   'password'           => { label => 'Database password' },
845   'server_type'        => {
846     label   => 'Server type',
847     type    => 'select',
848     options => [qw(dovecot_plain dovecot_crypt dovecot_digest_md5 courier_plain
849                    courier_crypt)],
850     default => ['dovecot_plain'], },
851   'svc_acct_table'     => { label => 'User Table', default => 'user_acct' },
852   'svc_forward_table'  => { label => 'Forward Table', default => 'forward' },
853   'svc_domain_table'   => { label => 'Domain Table', default => 'domain' },
854   'svc_acct_fields'    => { label => 'svc_acct Export Fields',
855                             default => 'username _password domsvc svcnum' },
856   'svc_forward_fields' => { label => 'svc_forward Export Fields',
857                             default => 'domain svcnum catchall' },
858   'svc_domain_fields'  => { label => 'svc_domain Export Fields',
859                             default => 'srcsvc dstsvc dst' },
860   '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.)},
861                             type => 'checkbox' },
862
863 ;
864
865 tie my %ldap_options, 'Tie::IxHash',
866   'dn'         => { label=>'Root DN' },
867   'password'   => { label=>'Root DN password' },
868   'userdn'     => { label=>'User DN' },
869   'attributes' => { label=>'Attributes',
870                     type=>'textarea',
871                     default=>join("\n",
872                       'uid $username',
873                       'mail $username\@$domain',
874                       'uidno $uid',
875                       'gidno $gid',
876                       'cn $first',
877                       'sn $last',
878                       'mailquota $quota',
879                       'vmail',
880                       'location',
881                       'mailtag',
882                       'mailhost',
883                       'mailmessagestore $dir',
884                       'userpassword $crypt_password',
885                       'hint',
886                       'answer $sec_phrase',
887                       'objectclass top,person,inetOrgPerson',
888                     ),
889                   },
890   'radius'     => { label=>'Export RADIUS attributes', type=>'checkbox', },
891 ;
892
893 tie my %forward_shellcommands_options, 'Tie::IxHash',
894   'user' => { label=>'Remote username', default=>'root' },
895   'useradd' => { label=>'Insert command',
896                  default=>'',
897                },
898   'userdel'  => { label=>'Delete command',
899                   default=>'',
900                 },
901   'usermod'  => { label=>'Modify command',
902                   default=>'',
903                 },
904 ;
905
906 tie my %postfix_options, 'Tie::IxHash',
907   'user' => { label=>'Remote username', default=>'root' },
908   'aliases' => { label=>'aliases file location', default=>'/etc/aliases' },
909   'virtual' => { label=>'virtual file location', default=>'/etc/postfix/virtual' },
910   'mydomain' => { label=>'local domain', default=>'' },
911 ;
912
913 #export names cannot have dashes...
914 %exports = (
915   'svc_acct' => {
916     'sysvshell' => {
917       'desc' =>
918         'Batch export of /etc/passwd and /etc/shadow files (Linux/SysV).',
919       'options' => \%sysvshell_options,
920       'nodomain' => 'Y',
921       '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.',
922     },
923     'bsdshell' => {
924       'desc' =>
925         'Batch export of /etc/passwd and /etc/master.passwd files (BSD).',
926       'options' => \%bsdshell_options,
927       'nodomain' => 'Y',
928       '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.',
929     },
930 #    'nis' => {
931 #      'desc' =>
932 #        'Batch export of /etc/global/passwd and /etc/global/shadow for NIS ',
933 #      'options' => {},
934 #    },
935     'textradius' => {
936       'desc' => 'Real-time export to a text /etc/raddb/users file (Livingston, Cistron)',
937       'options' => \%textradius_options,
938       '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>.',
939     },
940
941     'shellcommands' => {
942       'desc' => 'Real-time export via remote SSH (i.e. useradd, userdel, etc.)',
943       'options' => \%shellcommands_options,
944       'nodomain' => 'Y',
945       '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>',
946     },
947
948     'shellcommands_withdomain' => {
949       'desc' => 'Real-time export via remote SSH (vpopmail, etc.).',
950       'options' => \%shellcommands_withdomain_options,
951       '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>',
952     },
953
954     'ldap' => {
955       'desc' => 'Real-time export to LDAP',
956       'options' => \%ldap_options,
957       '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.',
958     },
959
960     'sqlradius' => {
961       'desc' => 'Real-time export to SQL-backed RADIUS (FreeRADIUS, ICRADIUS, Radiator)',
962       'options' => \%sqlradius_options,
963       'nodomain' => 'Y',
964       '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&nbsp;TABLE&nbsp;radcheck&nbsp;ADD&nbsp;COLUMN&nbsp;op&nbsp;VARCHAR(2)&nbsp;NOT&nbsp;NULL&nbsp;DEFAULT&nbsp;\'==\'<br>ALTER&nbsp;TABLE&nbsp;radreply&nbsp;ADD&nbsp;COLUMN&nbsp;op&nbsp;VARCHAR(2)&nbsp;NOT&nbsp;NULL&nbsp;DEFAULT&nbsp;\'==\'<br>ALTER&nbsp;TABLE&nbsp;radgroupcheck&nbsp;ADD&nbsp;COLUMN&nbsp;op&nbsp;VARCHAR(2)&nbsp;NOT&nbsp;NULL&nbsp;DEFAULT&nbsp;\'==\'<br>ALTER&nbsp;TABLE&nbsp;radgroupreply&nbsp;ADD&nbsp;COLUMN&nbsp;op&nbsp;VARCHAR(2)&nbsp;NOT&nbsp;NULL&nbsp;DEFAULT&nbsp;\'==\'</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>',
965     },
966
967     'sqlradius_withdomain' => {
968       'desc' => 'Real-time export to SQL-backed RADIUS (FreeRADIUS, ICRADIUS, Radiator) with realms',
969       'options' => \%sqlradius_withdomain_options,
970       'nodomain' => '',
971       '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&nbsp;TABLE&nbsp;radcheck&nbsp;ADD&nbsp;COLUMN&nbsp;op&nbsp;VARCHAR(2)&nbsp;NOT&nbsp;NULL&nbsp;DEFAULT&nbsp;\'==\'<br>ALTER&nbsp;TABLE&nbsp;radreply&nbsp;ADD&nbsp;COLUMN&nbsp;op&nbsp;VARCHAR(2)&nbsp;NOT&nbsp;NULL&nbsp;DEFAULT&nbsp;\'==\'<br>ALTER&nbsp;TABLE&nbsp;radgroupcheck&nbsp;ADD&nbsp;COLUMN&nbsp;op&nbsp;VARCHAR(2)&nbsp;NOT&nbsp;NULL&nbsp;DEFAULT&nbsp;\'==\'<br>ALTER&nbsp;TABLE&nbsp;radgroupreply&nbsp;ADD&nbsp;COLUMN&nbsp;op&nbsp;VARCHAR(2)&nbsp;NOT&nbsp;NULL&nbsp;DEFAULT&nbsp;\'==\'</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>',
972     },
973
974     'sqlmail' => {
975       'desc' => 'Real-time export to SQL-backed mail server',
976       'options' => \%sqlmail_options,
977       'nodomain' => '',
978       'notes' => 'Database schema can be made to work with Courier IMAP and Exim.  Others could work but are untested. (...extended description from pc-intouch?...)',
979     },
980
981     'cyrus' => {
982       'desc' => 'Real-time export to Cyrus IMAP server',
983       'options' => \%cyrus_options,
984       'nodomain' => 'Y',
985       '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. '
986     },
987
988     'cp' => {
989       'desc' => 'Real-time export to Critical Path Account Provisioning Protocol',
990       'options' => \%cp_options,
991       '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.',
992     },
993     
994     'infostreet' => {
995       'desc' => 'Real-time export to InfoStreet streetSmartAPI',
996       'options' => \%infostreet_options,
997       'nodomain' => 'Y',
998       '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.',
999     },
1000
1001     'vpopmail' => {
1002       'desc' => 'Real-time export to vpopmail text files',
1003       'options' => \%vpopmail_options,
1004       '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>.',
1005     },
1006
1007     'communigate_pro' => {
1008       'desc' => 'Real-time export to a CommuniGate Pro mail server',
1009       'options' => \%communigate_pro_options,
1010       '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.',
1011     },
1012
1013     'communigate_pro_singledomain' => {
1014       'desc' => 'Real-time export to a CommuniGate Pro mail server, one domain only',
1015       'options' => \%communigate_pro_singledomain_options,
1016       'nodomain' => 'Y',
1017       '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.',
1018     },
1019
1020   },
1021
1022   'svc_domain' => {
1023
1024     'bind' => {
1025       'desc' =>'Batch export to BIND named',
1026       'options' => \%bind_options,
1027       '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.',
1028     },
1029
1030     'bind_slave' => {
1031       'desc' =>'Batch export to slave BIND named',
1032       'options' => \%bind_slave_options,
1033       '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.',
1034     },
1035
1036     'http' => {
1037       'desc' => 'Send an HTTP or HTTPS GET or POST request',
1038       'options' => \%http_options,
1039       '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.',
1040     },
1041
1042     'sqlmail' => {
1043       'desc' => 'Real-time export to SQL-backed mail server',
1044       'options' => \%sqlmail_options,
1045       #'nodomain' => 'Y',
1046       'notes' => 'Database schema can be made to work with Courier IMAP and Exim.  Others could work but are untested. (...extended description from pc-intouch?...)',
1047     },
1048
1049     'domain_shellcommands' => {
1050       'desc' => 'Run remote commands via SSH, for domains.',
1051       'options' => \%domain_shellcommands_options,
1052       '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>',
1053     },
1054
1055
1056   },
1057
1058   'svc_forward' => {
1059     'sqlmail' => {
1060       'desc' => 'Real-time export to SQL-backed mail server',
1061       'options' => \%sqlmail_options,
1062       #'nodomain' => 'Y',
1063       'notes' => 'Database schema can be made to work with Courier IMAP and Exim.  Others could work but are untested. (...extended description from fire2wire?...)',
1064     },
1065
1066     'forward_shellcommands' => {
1067       'desc' => 'Run remote commands via SSH, for forwards',
1068       'options' => \%forward_shellcommands_options,
1069       '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>',
1070     },
1071
1072     'postfix' => {
1073       'desc' => 'Real-time export to Postfix text files',
1074       'options' => \%postfix_options,
1075       #'nodomain' => 'Y',
1076       '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.',
1077     },
1078
1079   },
1080
1081   'svc_www' => {
1082     'www_shellcommands' => {
1083       'desc' => 'Run remote commands via SSH, for virtual web sites.',
1084       'options' => \%www_shellcommands_options,
1085       '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>',
1086     },
1087
1088     'apache' => {
1089       'desc' => 'Export an Apache httpd.conf file snippet.',
1090       'options' => \%apache_options,
1091       '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.',
1092     },
1093   },
1094
1095   'svc_broadband' => {
1096     'router' => {
1097       'desc' => 'Send a command to a router.',
1098       'options' => \%router_options,
1099       'notes' => '',
1100     },
1101   },
1102
1103   'svc_external' => {
1104   },
1105
1106 );
1107
1108 =back
1109
1110 =head1 NEW EXPORT CLASSES
1111
1112 Should be added to the %export hash here, and a module should be added in
1113 FS/FS/part_export/ (an example may be found in eg/export_template.pm)
1114
1115 =head1 BUGS
1116
1117 All the stuff in the %exports hash should be generated from the specific
1118 export modules.
1119
1120 Hmm... cust_export class (not necessarily a database table...) ... ?
1121
1122 deprecated column...
1123
1124 =head1 SEE ALSO
1125
1126 L<FS::part_export_option>, L<FS::export_svc>, L<FS::svc_acct>,
1127 L<FS::svc_domain>,
1128 L<FS::svc_forward>, L<FS::Record>, schema.html from the base documentation.
1129
1130 =cut
1131
1132 1;
1133