X-Git-Url: http://git.freeside.biz/gitweb/?p=freeside.git;a=blobdiff_plain;f=FS%2FFS%2Fpart_export%2Fshellcommands.pm;h=cee54b48880a7b57f64cb5bf476c2c74c97aa9cf;hp=9fad36dad0653e13c053094699a31b5b91d04669;hb=dabdf357484badff95afcae50b08ec1c3bb58343;hpb=7de51deb0e3e3fe1b0a9e06be6498256d5511bd0 diff --git a/FS/FS/part_export/shellcommands.pm b/FS/FS/part_export/shellcommands.pm index 9fad36dad..cee54b488 100644 --- a/FS/FS/part_export/shellcommands.pm +++ b/FS/FS/part_export/shellcommands.pm @@ -1,11 +1,161 @@ package FS::part_export::shellcommands; -use vars qw(@ISA @saltset); +use vars qw(@ISA %info @saltset); +use Tie::IxHash; use String::ShellQuote; use FS::part_export; @ISA = qw(FS::part_export); +tie my %options, 'Tie::IxHash', + 'user' => { label=>'Remote username', default=>'root' }, + 'useradd' => { label=>'Insert command', + default=>'useradd -c $finger -d $dir -m -s $shell -u $uid -p $crypt_password $username' + #default=>'cp -pr /etc/skel $dir; chown -R $uid.$gid $dir' + }, + 'useradd_stdin' => { label=>'Insert command STDIN', + type =>'textarea', + default=>'', + }, + 'userdel' => { label=>'Delete command', + default=>'userdel -r $username', + #default=>'rm -rf $dir', + }, + 'userdel_stdin' => { label=>'Delete command STDIN', + type =>'textarea', + default=>'', + }, + 'usermod' => { label=>'Modify command', + default=>'usermod -c $new_finger -d $new_dir -m -l $new_username -s $new_shell -u $new_uid -p $new_crypt_password $old_username', + #default=>'[ -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'. + #')' + }, + 'usermod_stdin' => { label=>'Modify command STDIN', + type =>'textarea', + default=>'', + }, + 'usermod_pwonly' => { label=>'Disallow username changes', + type =>'checkbox', + }, + 'suspend' => { label=>'Suspension command', + default=>'usermod -L $username', + }, + 'suspend_stdin' => { label=>'Suspension command STDIN', + default=>'', + }, + 'unsuspend' => { label=>'Unsuspension command', + default=>'usermod -U $username', + }, + 'unsuspend_stdin' => { label=>'Unsuspension command STDIN', + default=>'', + }, +; + +%info = ( + 'svc' => 'svc_acct', + 'desc' => + 'Real-time export via remote SSH (i.e. useradd, userdel, etc.)', + 'options' => \%options, + 'nodomain' => 'Y', + 'notes' => <<'END' +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 +setup SSH for unattended operation. + +

Use these buttons for some useful presets: + + +The following variables are available for interpolation (prefixed with new_ or +old_ for replace operations): + +END +); + @saltset = ( 'a'..'z' , 'A'..'Z' , '0'..'9' , '.' , '/' ); sub rebless { shift; } @@ -152,3 +302,5 @@ sub ssh_cmd { #subroutine, not method #sub shellcommands_delete { #subroutine, not method #} +1; +