1 package FS::part_export::shellcommands;
3 use vars qw(@ISA @saltset);
6 @ISA = qw(FS::part_export);
8 @saltset = ( 'a'..'z' , 'A'..'Z' , '0'..'9' , '.' , '/' );
10 sub rebless { shift; }
14 $self->_export_command('useradd', @_);
19 $self->_export_command('userdel', @_);
23 my ( $self, $action, $svc_acct) = (shift, shift, shift);
24 my $command = $self->option($action);
25 my $stdin = $self->option($action."_stdin");
27 ${$_} = $svc_acct->getfield($_) foreach $svc_acct->fields;
28 $crypt_password = crypt( $svc_acct->_password,
29 $saltset[int(rand(64))].$saltset[int(rand(64))] );
30 $self->shellcommands_queue( $svc_acct->svcnum,
31 user => $self->option('user')||'root',
32 host => $self->machine,
33 command => eval(qq("$command")),
34 stdin_string => eval(qq("$stdin")),
39 my($self, $new, $old ) = (shift, shift, shift);
40 my $command = $self->option('usermod');
41 my $stdin = $self->option('usermod_stdin');
43 ${"old_$_"} = $old->getfield($_) foreach $old->fields;
44 ${"new_$_"} = $new->getfield($_) foreach $new->fields;
45 $new_crypt_password = crypt( $svc_acct->_password,
46 $saltset[int(rand(64))].$saltset[int(rand(64))]);
47 $self->shellcommands_queue( $new->svcnum,
48 user => $self->option('user')||'root',
49 host => $self->machine,
50 command => eval(qq("$command")),
51 stdin_string => eval(qq("$stdin")),
55 #a good idea to queue anything that could fail or take any time
56 sub shellcommands_queue {
57 my( $self, $svcnum ) = (shift, shift);
58 my $queue = new FS::queue {
60 'job' => "FS::part_export::shellcommands::ssh_cmd",
65 sub ssh_cmd { #subroutine, not method
67 &Net::SSH::ssh_cmd( { @_ } );
70 #sub shellcommands_insert { #subroutine, not method
72 #sub shellcommands_replace { #subroutine, not method
74 #sub shellcommands_delete { #subroutine, not method