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