X-Git-Url: http://git.freeside.biz/gitweb/?p=freeside.git;a=blobdiff_plain;f=FS%2FFS%2Fpart_export%2Fshellcommands.pm;h=7c280e5f8c2da55e1d08eacbb6a7c770e8a72bbc;hp=a3edd74a1668243cba3ca6eae37f6f8e865f65b3;hb=197f613bac6c3f9a4bd7d1ea5fbf4769aea4ce1a;hpb=a9f6fd089af5d158bdf5f5e7dd6bc238c82fd88d diff --git a/FS/FS/part_export/shellcommands.pm b/FS/FS/part_export/shellcommands.pm index a3edd74a1..7c280e5f8 100644 --- a/FS/FS/part_export/shellcommands.pm +++ b/FS/FS/part_export/shellcommands.pm @@ -2,29 +2,42 @@ package FS::part_export::shellcommands; use vars qw(@ISA %info); use Tie::IxHash; +use Date::Format; use String::ShellQuote; +use Net::OpenSSH; use FS::part_export; +use FS::Record qw( qsearch qsearchs ); @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 -g $gid -p $crypt_password $username' + 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_no_queue' => { label=>'Run immediately', + type => 'checkbox', + }, 'useradd_stdin' => { label=>'Insert command STDIN', type =>'textarea', default=>'', }, + 'userdel' => { label=>'Delete command', default=>'userdel -r $username', #default=>'rm -rf $dir', }, + 'userdel_no_queue' => { label=>'Run immediately', + type =>'checkbox', + }, '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 || ( '. @@ -34,48 +47,96 @@ tie my %options, 'Tie::IxHash', # 'rm -rf $old_dir'. #')' }, + 'usermod_no_queue' => { label=>'Run immediately', + type =>'checkbox', + }, 'usermod_stdin' => { label=>'Modify command STDIN', type =>'textarea', default=>'', }, - 'usermod_pwonly' => { label=>'Disallow username changes', + '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_no_queue' => { label=>'Run immediately', + type =>'checkbox', + }, 'suspend_stdin' => { label=>'Suspension command STDIN', default=>'', }, + 'unsuspend' => { label=>'Unsuspension command', default=>'usermod -U $username', }, + 'unsuspend_no_queue' => { label=>'Run immediately', + type =>'checkbox', + }, 'unsuspend_stdin' => { label=>'Unsuspension command STDIN', default=>'', }, + + 'pkg_change' => { label=>'Package changed command', + default=>'', + }, + + # run commands on package change for multiple services and roll back the + # package change transaciton if one fails? yuck. no. + # if this was really needed, would need to restrict to a single service with + # this kind of export configured. + #'pkg_change_no_queue' => { label=>'Run immediately', + # type =>'checkbox', + # }, + 'pkg_change_stdin' => { label=>'Package changed command STDIN', + default=>'', + }, + 'crypt' => { label => 'Default password encryption', - type=>'select', options=>[qw(crypt md5)], - default => 'crypt', + type=>'select', options=>[qw(crypt md5 sha512)], + default => 'md5', }, + 'groups_susp_reason' => { label => + 'Radius group mapping to reason (via template user)', + type => 'textarea', + }, + 'fail_on_output' => { + label => 'Treat any output from the command as an error', + type => 'checkbox', + }, + 'ignore_all_errors' => { + label => 'Ignore all errors from the command', + type => 'checkbox', + }, + 'ignored_errors' => { label => 'Regexes of specific errors to ignore, separated by newlines', + type => 'textarea' + }, +# 'no_queue' => { label => 'Run command immediately', +# type => 'checkbox', +# }, ; %info = ( - 'svc' => 'svc_acct', - 'desc' => - 'Real-time export via remote SSH (i.e. useradd, userdel, etc.)', - 'options' => \%options, - 'nodomain' => 'Y', - 'notes' => <<'END' + 'svc' => 'svc_acct', + 'desc' => 'Real-time export via remote SSH (i.e. useradd, userdel, etc.)', + 'options' => \%options, + 'nodomain' => 'Y', + 'svc_machine' => 1, + '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. +setup SSH for unattended operation.

Use these buttons for some useful presets: