package FS::part_export::shellcommands;
use vars qw(@ISA %info);
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 -g $new_gid -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, domain, uid, gid, and dir changes', #and RADIUS group changes',
type =>'checkbox',
},
'usermod_nousername' => { label=>'Disallow just 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=>'',
},
'crypt' => { label => 'Default password encryption',
type=>'select', options=>[qw(crypt md5)],
default => 'crypt',
},
;
%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:
$username
$_password
$quoted_password
- unencrypted password, already quoted for the shell (do not add additional quotes)
$crypt_password
- encrypted password, already quoted for the shell (do not add additional quotes)
$uid
$gid
$finger
- GECOS, already quoted for the shell (do not add additional quotes)
$first
- First name of GECOS, already quoted for the shell (do not add additional quotes)
$last
- Last name of GECOS, already quoted for the shell (do not add additional quotes)
$dir
- home directory
$shell
$quota
@radius_groups