option for shellcommands to ignore errors, #15357
[freeside.git] / FS / FS / part_export / shellcommands_withdomain.pm
1 package FS::part_export::shellcommands_withdomain;
2
3 use vars qw(@ISA %info);
4 use Tie::IxHash;
5 use FS::part_export::shellcommands;
6
7 @ISA = qw(FS::part_export::shellcommands);
8
9 tie my %options, 'Tie::IxHash',
10   'user' => { label=>'Remote username', default=>'root' },
11   'useradd' => { label=>'Insert command',
12                  #default=>''
13                },
14   'useradd_stdin' => { label=>'Insert command STDIN',
15                        type =>'textarea',
16                        #default=>"$_password\n$_password\n",
17                      },
18   'useradd_no_queue' => { label => 'Run immediately',
19                  type  => 'checkbox',
20            },
21   'userdel' => { label=>'Delete command',
22                  #default=>'',
23                },
24   'userdel_stdin' => { label=>'Delete command STDIN',
25                        type =>'textarea',
26                        #default=>'',
27                      },
28   'userdel_no_queue' => { label => 'Run immediately',
29                  type  => 'checkbox',
30            },
31   'usermod' => { label=>'Modify command',
32                  default=>'',
33                },
34   'usermod_stdin' => { label=>'Modify command STDIN',
35                        type =>'textarea',
36                        #default=>"$_password\n$_password\n",
37                      },
38   'usermod_no_queue' => { label => 'Run immediately',
39                  type  => 'checkbox',
40            },
41   'usermod_pwonly' => { label=>'Disallow username, domain, uid, dir and RADIUS group changes',
42                         type =>'checkbox',
43                       },
44   'usermod_nousername' => { label=>'Disallow just username changes',
45                             type =>'checkbox',
46                           },
47   'suspend' => { label=>'Suspension command',
48                  default=>'',
49                },
50   'suspend_stdin' => { label=>'Suspension command STDIN',
51                        default=>'',
52                      },
53   'suspend_no_queue' => { label => 'Run immediately',
54                  type  => 'checkbox',
55            },
56   'unsuspend' => { label=>'Unsuspension command',
57                    default=>'',
58                  },
59   'unsuspend_stdin' => { label=>'Unsuspension command STDIN',
60                          default=>'',
61                        },
62   'unsuspend_no_queue' => { label => 'Run immediately',
63                  type  => 'checkbox',
64            },
65   'crypt' => { label   => 'Default password encryption',
66                type=>'select', options=>[qw(crypt md5)],
67                default => 'crypt',
68              },
69   'ignore_all_output' => {
70     label => 'Ignore all output and errors from the command',
71     type  => 'checkbox',
72   },
73 ;
74
75 %info = (
76   'svc'     => 'svc_acct',
77   'desc'    => 'Real-time export via remote SSH (vpopmail, ISPMan)',
78   'options' => \%options,
79   'notes'   => <<'END'
80 Run remote commands via SSH.  username@domain (rather than just usernames) are
81 considered unique (also see shellcommands).  You probably want this if the
82 commands you are running will accept a domain as a parameter, and will allow
83 the same username with different domains.  You will need to
84 <a href="http://www.freeside.biz/mediawiki/index.php/Freeside:1.9:Documentation:Administration:SSH_Keys">setup SSH for unattended operation</a>.
85
86 <BR><BR>Use these buttons for some useful presets:
87 <UL>
88   <LI><INPUT TYPE="button" VALUE="vpopmail" onClick='
89     this.form.useradd.value = "/home/vpopmail/bin/vadduser $username\\\@$domain $quoted_password";
90     this.form.useradd_stdin.value = "";
91     this.form.userdel.value = "/home/vpopmail/bin/vdeluser $username\\\@$domain";
92     this.form.userdel_stdin.value="";
93     this.form.usermod.value = "/home/vpopmail/bin/vpasswd $new_username\\\@$new_domain $new_quoted_password";
94     this.form.usermod_stdin.value = "";
95     this.form.usermod_pwonly.checked = true;
96   '>
97   <LI><INPUT TYPE="button" VALUE="ISPMan CLI" onClick='
98     this.form.useradd.value = "/usr/local/ispman/bin/ispman.addUser -d $domain -f $first -l $last -q $quota -p $quoted_password $username";
99     this.form.useradd_stdin.value = "";
100     this.form.userdel.value = "/usr/local/ispman/bin/ispman.delUser -d $domain $username";
101     this.form.userdel_stdin.value="";
102     this.form.usermod.value = "/usr/local/ispman/bin/ispman.passwd.user $new_username\\\@$new_domain $new_quoted_password";
103     this.form.usermod_stdin.value = "";
104     this.form.usermod_pwonly.checked = true;
105   '>
106   <LI><INPUT TYPE="button" VALUE="MagicMail" onClick='
107     this.form.useradd.value = "/usr/bin/mm_create_email_service -e $svcnum -d $domain -u $username -p $quoted_password -f $first -l $last -m $svcnum -g EMAIL";
108     this.form.useradd_stdin.value = "";
109     this.form.useradd_no_queue.checked = 1;
110     this.form.userdel.value = "/usr/bin/mm_delete_user -e ${username}\\\@${domain}";
111     this.form.userdel_stdin.value = "";
112     this.form.suspend.value = "/usr/bin/mm_suspend_user -e ${username}\\\@${domain}";
113     this.form.suspend_stdin.value = "";
114     this.form.unsuspend.value = "/usr/bin/mm_activate_user -e ${username}\\\@${domain}";
115     this.form.unsuspend_stdin.value = "";
116   '>
117 </UL>
118
119 The following variables are available for interpolation (prefixed with
120 <code>new_</code> or <code>old_</code> for replace operations):
121 <UL>
122   <LI><code>$username</code>
123   <LI><code>$domain</code>
124   <LI><code>$_password</code>
125   <LI><code>$quoted_password</code> - unencrypted password, already quoted for the shell (do not add additional quotes)
126   <LI><code>$crypt_password</code> - encrypted password, already quoted for the shell (do not add additional quotes)
127   <LI><code>$uid</code>
128   <LI><code>$gid</code>
129   <LI><code>$finger</code> - GECOS, already quoted for the shell (do not add additional quotes)
130   <LI><code>$first</code> - First name of GECOS, already quoted for the shell (do not add additional quotes)
131   <LI><code>$last</code> - Last name of GECOS, already quoted for the shell (do not add additional quotes)
132   <LI><code>$dir</code> - home directory
133   <LI><code>$shell</code>
134   <LI><code>$quota</code>
135   <LI><code>@radius_groups</code>
136   <LI>All other fields in <a href="../docs/schema.html#svc_acct">svc_acct</a> are also available.
137 </UL>
138 END
139 );
140
141 1;
142