apache 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->machine =~ /^([\w\-\.]*)$/
278     or return "Illegal machine: ". $self->machine;
279   $self->machine($1);
280
281   $self->nodomain =~ /^(Y?)$/ or return "Illegal nodomain: ". $self->nodomain;
282   $self->nodomain($1);
283
284   $self->deprecated(1); #BLAH
285
286   #check exporttype?
287
288   ''; #no error
289 }
290
291 #=item part_svc
292 #
293 #Returns the service definition (see L<FS::part_svc>) for this export.
294 #
295 #=cut
296 #
297 #sub part_svc {
298 #  my $self = shift;
299 #  qsearchs('part_svc', { svcpart => $self->svcpart } );
300 #}
301
302 sub part_svc {
303   use Carp;
304   croak "FS::part_export::part_svc deprecated";
305   #confess "FS::part_export::part_svc deprecated";
306 }
307
308 =item export_svc
309
310 Returns a list of associated FS::export_svc records.
311
312 =cut
313
314 sub export_svc {
315   my $self = shift;
316   qsearch('export_svc', { 'exportnum' => $self->exportnum } );
317 }
318
319 =item part_export_option
320
321 Returns all options as FS::part_export_option objects (see
322 L<FS::part_export_option>).
323
324 =cut
325
326 sub part_export_option {
327   my $self = shift;
328   qsearch('part_export_option', { 'exportnum' => $self->exportnum } );
329 }
330
331 =item options 
332
333 Returns a list of option names and values suitable for assigning to a hash.
334
335 =cut
336
337 sub options {
338   my $self = shift;
339   map { $_->optionname => $_->optionvalue } $self->part_export_option;
340 }
341
342 =item option OPTIONNAME
343
344 Returns the option value for the given name, or the empty string.
345
346 =cut
347
348 sub option {
349   my $self = shift;
350   my $part_export_option =
351     qsearchs('part_export_option', {
352       exportnum  => $self->exportnum,
353       optionname => shift,
354   } );
355   $part_export_option ? $part_export_option->optionvalue : '';
356 }
357
358 =item rebless
359
360 Reblesses the object into the FS::part_export::EXPORTTYPE class, where
361 EXPORTTYPE is the object's I<exporttype> field.  There should be better docs
362 on how to create new exports (and they should live in their own files and be
363 autoloaded-on-demand), but until then, see L</NEW EXPORT CLASSES>.
364
365 =cut
366
367 sub rebless {
368   my $self = shift;
369   my $exporttype = $self->exporttype;
370   my $class = ref($self). "::$exporttype";
371   eval "use $class;";
372   die $@ if $@;
373   bless($self, $class);
374 }
375
376 =item export_insert SVC_OBJECT
377
378 =cut
379
380 sub export_insert {
381   my $self = shift;
382   $self->rebless;
383   $self->_export_insert(@_);
384 }
385
386 #sub AUTOLOAD {
387 #  my $self = shift;
388 #  $self->rebless;
389 #  my $method = $AUTOLOAD;
390 #  #$method =~ s/::(\w+)$/::_$1/; #infinite loop prevention
391 #  $method =~ s/::(\w+)$/_$1/; #infinite loop prevention
392 #  $self->$method(@_);
393 #}
394
395 =item export_replace NEW OLD
396
397 =cut
398
399 sub export_replace {
400   my $self = shift;
401   $self->rebless;
402   $self->_export_replace(@_);
403 }
404
405 =item export_delete
406
407 =cut
408
409 sub export_delete {
410   my $self = shift;
411   $self->rebless;
412   $self->_export_delete(@_);
413 }
414
415 =item export_suspend
416
417 =cut
418
419 sub export_suspend {
420   my $self = shift;
421   $self->rebless;
422   $self->_export_suspend(@_);
423 }
424
425 =item export_unsuspend
426
427 =cut
428
429 sub export_unsuspend {
430   my $self = shift;
431   $self->rebless;
432   $self->_export_unsuspend(@_);
433 }
434
435 #fallbacks providing useful error messages intead of infinite loops
436 sub _export_insert {
437   my $self = shift;
438   return "_export_insert: unknown export type ". $self->exporttype;
439 }
440
441 sub _export_replace {
442   my $self = shift;
443   return "_export_replace: unknown export type ". $self->exporttype;
444 }
445
446 sub _export_delete {
447   my $self = shift;
448   return "_export_delete: unknown export type ". $self->exporttype;
449 }
450
451 #fallbacks providing null operations
452
453 sub _export_suspend {
454   my $self = shift;
455   #warn "warning: _export_suspened unimplemented for". ref($self);
456   '';
457 }
458
459 sub _export_unsuspend {
460   my $self = shift;
461   #warn "warning: _export_unsuspend unimplemented for ". ref($self);
462   '';
463 }
464
465 =back
466
467 =head1 SUBROUTINES
468
469 =over 4
470
471 =item export_info [ SVCDB ]
472
473 Returns a hash reference of the exports for the given I<svcdb>, or if no
474 I<svcdb> is specified, for all exports.  The keys of the hash are
475 I<exporttype>s and the values are again hash references containing information
476 on the export:
477
478   'desc'     => 'Description',
479   'options'  => {
480                   'option'  => { label=>'Option Label' },
481                   'option2' => { label=>'Another label' },
482                 },
483   'nodomain' => 'Y', #or ''
484   'notes'    => 'Additional notes',
485
486 =cut
487
488 sub export_info {
489   #warn $_[0];
490   return $exports{$_[0]} if @_;
491   #{ map { %{$exports{$_}} } keys %exports };
492   my $r = { map { %{$exports{$_}} } keys %exports };
493 }
494
495 #=item exporttype2svcdb EXPORTTYPE
496 #
497 #Returns the applicable I<svcdb> for an I<exporttype>.
498 #
499 #=cut
500 #
501 #sub exporttype2svcdb {
502 #  my $exporttype = $_[0];
503 #  foreach my $svcdb ( keys %exports ) {
504 #    return $svcdb if grep { $exporttype eq $_ } keys %{$exports{$svcdb}};
505 #  }
506 #  '';
507 #}
508
509 tie my %sysvshell_options, 'Tie::IxHash',
510   'crypt' => { label=>'Password encryption',
511                type=>'select', options=>[qw(crypt md5)],
512                default=>'crypt',
513              },
514 ;
515
516 tie my %bsdshell_options, 'Tie::IxHash', 
517   'crypt' => { label=>'Password encryption',
518                type=>'select', options=>[qw(crypt md5)],
519                default=>'crypt',
520              },
521 ;
522
523 tie my %shellcommands_options, 'Tie::IxHash',
524   #'machine' => { label=>'Remote machine' },
525   'user' => { label=>'Remote username', default=>'root' },
526   'useradd' => { label=>'Insert command',
527                  default=>'useradd -d $dir -m -s $shell -u $uid -p $crypt_password $username'
528                 #default=>'cp -pr /etc/skel $dir; chown -R $uid.$gid $dir'
529                },
530   'useradd_stdin' => { label=>'Insert command STDIN',
531                        type =>'textarea',
532                        default=>'',
533                      },
534   'userdel' => { label=>'Delete command',
535                  default=>'userdel -r $username',
536                  #default=>'rm -rf $dir',
537                },
538   'userdel_stdin' => { label=>'Delete command STDIN',
539                        type =>'textarea',
540                        default=>'',
541                      },
542   'usermod' => { label=>'Modify command',
543                  default=>'usermod -d $new_dir -m -l $new_username -s $new_shell -u $new_uid -p $new_crypt_password $old_username',
544                 #default=>'[ -d $old_dir ] && mv $old_dir $new_dir || ( '.
545                  #  'chmod u+t $old_dir; mkdir $new_dir; cd $old_dir; '.
546                  #  'find . -depth -print | cpio -pdm $new_dir; '.
547                  #  'chmod u-t $new_dir; chown -R $uid.$gid $new_dir; '.
548                  #  'rm -rf $old_dir'.
549                  #')'
550                },
551   'usermod_stdin' => { label=>'Modify command STDIN',
552                        type =>'textarea',
553                        default=>'',
554                      },
555   'suspend' => { label=>'Suspension command',
556                  default=>'',
557                },
558   'suspend_stdin' => { label=>'Suspension command STDIN',
559                        default=>'',
560                      },
561   'unsuspend' => { label=>'Unsuspension command',
562                    default=>'',
563                  },
564   'unsuspend_stdin' => { label=>'Unsuspension command STDIN',
565                          default=>'',
566                        },
567 ;
568
569 tie my %shellcommands_withdomain_options, 'Tie::IxHash',
570   'user' => { label=>'Remote username', default=>'root' },
571   'useradd' => { label=>'Insert command',
572                  #default=>''
573                },
574   'useradd_stdin' => { label=>'Insert command STDIN',
575                        type =>'textarea',
576                        #default=>"$_password\n$_password\n",
577                      },
578   'userdel' => { label=>'Delete command',
579                  #default=>'',
580                },
581   'userdel_stdin' => { label=>'Delete command STDIN',
582                        type =>'textarea',
583                        #default=>'',
584                      },
585   'usermod' => { label=>'Modify command',
586                  default=>'',
587                },
588   'usermod_stdin' => { label=>'Modify command STDIN',
589                        type =>'textarea',
590                        #default=>"$_password\n$_password\n",
591                      },
592   'suspend' => { label=>'Suspension command',
593                  default=>'',
594                },
595   'suspend_stdin' => { label=>'Suspension command STDIN',
596                        default=>'',
597                      },
598   'unsuspend' => { label=>'Unsuspension command',
599                    default=>'',
600                  },
601   'unsuspend_stdin' => { label=>'Unsuspension command STDIN',
602                          default=>'',
603                        },
604 ;
605
606 tie my %www_shellcommands_options, 'Tie::IxHash',
607   'user' => { label=>'Remote username', default=>'root' },
608   'useradd' => { label=>'Insert command',
609                  default=>'mkdir /var/www/$zone; chown $username /var/www/$zone; ln -s /var/www/$zone $homedir/$zone',
610                },
611   'userdel'  => { label=>'Delete command',
612                   default=>'[ -n &quot;$zone&quot; ] && rm -rf /var/www/$zone; rm $homedir/$zone',
613                 },
614   'usermod'  => { label=>'Modify command',
615                   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',
616                 },
617 ;
618
619 tie my %apache_options, 'Tie::IxHash',
620   'user'       => { label=>'Remote username', default=>'root' },
621   'httpd_conf' => { label=>'httpd.conf snippet location',
622                     default=>'/etc/apache/httpd-freeside.conf', },
623   'template'   => {
624     label   => 'Template',
625     type    => 'textarea',
626     default => <<'END',
627 <VirtualHost $domain> #generic
628 #<VirtualHost ip.addr> #preferred, http://httpd.apache.org/docs/dns-caveats.html
629 DocumentRoot /var/www/$zone
630 ServerName $zone
631 ServerAlias *.$zone
632 #BandWidthModule On
633 #LargeFileLimit 4096 12288
634 </VirtualHost>
635
636 END
637   },
638 ;
639
640 tie my %domain_shellcommands_options, 'Tie::IxHash',
641   'user' => { lable=>'Remote username', default=>'root' },
642   'useradd' => { label=>'Insert command',
643                  default=>'',
644                },
645   'userdel'  => { label=>'Delete command',
646                   default=>'',
647                 },
648   'usermod'  => { label=>'Modify command',
649                   default=>'',
650                 },
651 ;
652
653 tie my %textradius_options, 'Tie::IxHash',
654   'user' => { label=>'Remote username', default=>'root' },
655   'users' => { label=>'users file location', default=>'/etc/raddb/users' },
656 ;
657
658 tie my %sqlradius_options, 'Tie::IxHash',
659   'datasrc'  => { label=>'DBI data source ' },
660   'username' => { label=>'Database username' },
661   'password' => { label=>'Database password' },
662 ;
663
664 tie my %cyrus_options, 'Tie::IxHash',
665   'server' => { label=>'IMAP server' },
666   'username' => { label=>'Admin username' },
667   'password' => { label=>'Admin password' },
668 ;
669
670 tie my %cp_options, 'Tie::IxHash',
671   'host'      => { label=>'Hostname' },
672   'port'      => { label=>'Port number' },
673   'username'  => { label=>'Username' },
674   'password'  => { label=>'Password' },
675   'domain'    => { label=>'Domain' },
676   'workgroup' => { label=>'Default Workgroup' },
677 ;
678
679 tie my %infostreet_options, 'Tie::IxHash',
680   'url'      => { label=>'XML-RPC Access URL', },
681   'login'    => { label=>'InfoStreet login', },
682   'password' => { label=>'InfoStreet password', },
683   'groupID'  => { label=>'InfoStreet groupID', },
684 ;
685
686 tie my %vpopmail_options, 'Tie::IxHash',
687   #'machine' => { label=>'vpopmail machine', },
688   'dir'     => { label=>'directory', }, # ?more info? default?
689   'uid'     => { label=>'vpopmail uid' },
690   'gid'     => { label=>'vpopmail gid' },
691   'restart' => { label=> 'vpopmail restart command',
692                  default=> 'cd /home/vpopmail/domains; for domain in *; do /home/vpopmail/bin/vmkpasswd $domain; done; /var/qmail/bin/qmail-newu; killall -HUP qmail-send',
693                },
694 ;
695
696 tie my %bind_options, 'Tie::IxHash',
697   #'machine'    => { label=>'named machine' },
698   'named_conf' => { label  => 'named.conf location',
699                     default=> '/etc/bind/named.conf' },
700   'zonepath'   => { label => 'path to zone files',
701                     default=> '/etc/bind/', },
702 ;
703
704 tie my %bind_slave_options, 'Tie::IxHash',
705   #'machine'    => { label=> 'Slave machine' },
706   'master'      => { label=> 'Master IP address(s) (semicolon-separated)' },
707   'named_conf'  => { label   => 'named.conf location',
708                      default => '/etc/bind/named.conf' },
709 ;
710
711 tie my %http_options, 'Tie::IxHash',
712   'method' => { label   =>'Method',
713                 type    =>'select',
714                 #options =>[qw(POST GET)],
715                 options =>[qw(POST)],
716                 default =>'POST' },
717   'url'    => { label   => 'URL', default => 'http://', },
718   'insert_data' => {
719     label   => 'Insert data',
720     type    => 'textarea',
721     default => join("\n",
722       'DomainName $svc_x->domain',
723       'Email ( grep { $_ ne "POST" } $svc_x->cust_svc->cust_pkg->cust_main->invoicing_list)[0]',
724       'test 1',
725       'reseller $svc_x->cust_svc->cust_pkg->part_pkg->pkg =~ /reseller/i',
726     ),
727   },
728   'delete_data' => {
729     label   => 'Delete data',
730     type    => 'textarea',
731     default => join("\n",
732     ),
733   },
734   'replace_data' => {
735     label   => 'Replace data',
736     type    => 'textarea',
737     default => join("\n",
738     ),
739   },
740 ;
741
742 tie my %sqlmail_options, 'Tie::IxHash',
743   'datasrc'  => { label=>'DBI data source' },
744   'username' => { label=>'Database username' },
745   'password' => { label=>'Database password' },
746 ;
747
748 tie my %ldap_options, 'Tie::IxHash',
749   'dn'         => { label=>'Root DN' },
750   'password'   => { label=>'Root DN password' },
751   'userdn'     => { label=>'User DN' },
752   'attributes' => { label=>'Attributes',
753                     type=>'textarea',
754                     default=>join("\n",
755                       'uid $username',
756                       'mail $username\@$domain',
757                       'uidno $uid',
758                       'gidno $gid',
759                       'cn $first',
760                       'sn $last',
761                       'mailquota $quota',
762                       'vmail',
763                       'location',
764                       'mailtag',
765                       'mailhost',
766                       'mailmessagestore $dir',
767                       'userpassword $crypt_password',
768                       'hint',
769                       'answer $sec_phrase',
770                       'objectclass top,person,inetOrgPerson',
771                     ),
772                   },
773   'radius'     => { label=>'Export RADIUS attributes', type=>'checkbox', },
774 ;
775
776
777 #export names cannot have dashes...
778 %exports = (
779   'svc_acct' => {
780     'sysvshell' => {
781       'desc' =>
782         'Batch export of /etc/passwd and /etc/shadow files (Linux/SysV).',
783       'options' => \%sysvshell_options,
784       'nodomain' => 'Y',
785       '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.',
786     },
787     'bsdshell' => {
788       'desc' =>
789         'Batch export of /etc/passwd and /etc/master.passwd files (BSD).',
790       'options' => \%bsdshell_options,
791       'nodomain' => 'Y',
792       '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.',
793     },
794 #    'nis' => {
795 #      'desc' =>
796 #        'Batch export of /etc/global/passwd and /etc/global/shadow for NIS ',
797 #      'options' => {},
798 #    },
799     'textradius' => {
800       'desc' => 'Real-time export to a text /etc/raddb/users file (Livingston, Cistron)',
801       'options' => \%textradius_options,
802       '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>.',
803     },
804
805     'shellcommands' => {
806       'desc' => 'Real-time export via remote SSH (i.e. useradd, userdel, etc.)',
807       'options' => \%shellcommands_options,
808       'nodomain' => 'Y',
809       '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/NetBSD" 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 = "";\'><LI><INPUT TYPE="button" VALUE="FreeBSD" onClick=\'this.form.useradd.value = "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 = "pw userdel $username -r"; this.form.userdel_stdin.value=""; this.form.usermod.value = "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";\'><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 $uid.$gid $new_dir; rm -rf $old_dir )"; this.form.usermod_stdin.value = ""; this.form.userdel.value = "rm -rf $dir"; this.form.userdel_stdin.value="";\'></UL>',
810     },
811
812     'shellcommands_withdomain' => {
813       'desc' => 'Real-time export via remote SSH.',
814       'options' => \%shellcommands_withdomain_options,
815       '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>.',
816     },
817
818     'ldap' => {
819       'desc' => 'Real-time export to LDAP',
820       'options' => \%ldap_options,
821       '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.',
822     },
823
824     'sqlradius' => {
825       'desc' => 'Real-time export to SQL-backed RADIUS (ICRADIUS, FreeRADIUS)',
826       'options' => \%sqlradius_options,
827       'nodomain' => 'Y',
828       'notes' => 'Real-time export of radcheck, radreply and usergroup tables to any SQL database for <a href="http://www.freeradius.org/">FreeRADIUS</a> or <a href="http://radius.innercite.com/">ICRADIUS</a>.  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-1.23/DBI.pm">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.  If using <a href="http://www.freeradius.org/">FreeRADIUS</a> 0.5 or above, make sure your <b>op</b> fields are set to allow NULL values.',
829     },
830
831     'sqlmail' => {
832       'desc' => 'Real-time export to SQL-backed mail server',
833       'options' => \%sqlmail_options,
834       'nodomain' => 'Y',
835       'notes' => 'Database schema can be made to work with Courier IMAP and Exim.  Others could work but are untested. (...extended description from pc-intouch?...)',
836     },
837
838     'cyrus' => {
839       'desc' => 'Real-time export to Cyrus IMAP server',
840       'options' => \%cyrus_options,
841       'nodomain' => 'Y',
842       '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. '
843     },
844
845     'cp' => {
846       'desc' => 'Real-time export to Critical Path Account Provisioning Protocol',
847       'options' => \%cp_options,
848       '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.',
849     },
850     
851     'infostreet' => {
852       'desc' => 'Real-time export to InfoStreet streetSmartAPI',
853       'options' => \%infostreet_options,
854       'nodomain' => 'Y',
855       '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.',
856     },
857
858     'vpopmail' => {
859       'desc' => 'Real-time export to vpopmail text files',
860       'options' => \%vpopmail_options,
861       '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>.',
862     },
863
864   },
865
866   'svc_domain' => {
867
868     'bind' => {
869       'desc' =>'Batch export to BIND named',
870       'options' => \%bind_options,
871       '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.',
872     },
873
874     'bind_slave' => {
875       'desc' =>'Batch export to slave BIND named',
876       'options' => \%bind_slave_options,
877       '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.',
878     },
879
880     'http' => {
881       'desc' => 'Send an HTTP or HTTPS GET or POST request',
882       'options' => \%http_options,
883       '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.',
884     },
885
886     'sqlmail' => {
887       'desc' => 'Real-time export to SQL-backed mail server',
888       'options' => \%sqlmail_options,
889       #'nodomain' => 'Y',
890       'notes' => 'Database schema can be made to work with Courier IMAP and Exim.  Others could work but are untested. (...extended description from pc-intouch?...)',
891     },
892
893     'domain_shellcommands' => {
894       'desc' => 'Run remote commands via SSH, for domains.',
895       'options' => \%domain_shellcommands_options,
896       'notes'    => 'Run remote commands via SSH, for domains.  You will need to <a href="../docs/ssh.html">setup SSH for unattended operation</a>.',
897     },
898
899
900   },
901
902   'svc_forward' => {
903     'sqlmail' => {
904       'desc' => 'Real-time export to SQL-backed mail server',
905       'options' => \%sqlmail_options,
906       #'nodomain' => 'Y',
907       'notes' => 'Database schema can be made to work with Courier IMAP and Exim.  Others could work but are untested. (...extended description from pc-intouch?...)',
908     },
909   },
910
911   'svc_www' => {
912     'www_shellcommands' => {
913       'desc' => 'Run remote commands via SSH, for virtual web sites.',
914       'options' => \%www_shellcommands_options,
915       '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>.',
916     },
917
918     'apache' => {
919       'desc' => 'Export an Apache httpd.conf file snippet.',
920       'options' => \%apache_options,
921       '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.',
922     },
923   },
924
925   'svc_broadband' => {
926   },
927
928 );
929
930 =back
931
932 =head1 NEW EXPORT CLASSES
933
934 Should be added to the %export hash here, and a module should be added in
935 FS/FS/part_export/ (an example may be found in eg/export_template.pm)
936
937 =head1 BUGS
938
939 All the stuff in the %exports hash should be generated from the specific
940 export modules.
941
942 Hmm... cust_export class (not necessarily a database table...) ... ?
943
944 deprecated column...
945
946 =head1 SEE ALSO
947
948 L<FS::part_export_option>, L<FS::export_svc>, L<FS::svc_acct>,
949 L<FS::svc_domain>,
950 L<FS::svc_forward>, L<FS::Record>, schema.html from the base documentation.
951
952 =cut
953
954 1;
955