Add preset for magicmail
[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   'userdel' => { label=>'Delete command',
19                  #default=>'',
20                },
21   'userdel_stdin' => { label=>'Delete command STDIN',
22                        type =>'textarea',
23                        #default=>'',
24                      },
25   'usermod' => { label=>'Modify command',
26                  default=>'',
27                },
28   'usermod_stdin' => { label=>'Modify command STDIN',
29                        type =>'textarea',
30                        #default=>"$_password\n$_password\n",
31                      },
32   'usermod_pwonly' => { label=>'Disallow username, domain, uid, dir and RADIUS group changes',
33                         type =>'checkbox',
34                       },
35   'usermod_nousername' => { label=>'Disallow just username changes',
36                             type =>'checkbox',
37                           },
38   'suspend' => { label=>'Suspension command',
39                  default=>'',
40                },
41   'suspend_stdin' => { label=>'Suspension command STDIN',
42                        default=>'',
43                      },
44   'unsuspend' => { label=>'Unsuspension command',
45                    default=>'',
46                  },
47   'unsuspend_stdin' => { label=>'Unsuspension command STDIN',
48                          default=>'',
49                        },
50   'crypt' => { label   => 'Default password encryption',
51                type=>'select', options=>[qw(crypt md5)],
52                default => 'crypt',
53              },
54   'no_queue' => { label => 'Run command immediately',
55                  type  => 'checkbox',
56            },
57 ;
58
59 %info = (
60   'svc'     => 'svc_acct',
61   'desc'    => 'Real-time export via remote SSH (vpopmail, ISPMan)',
62   'options' => \%options,
63   'notes'   => <<'END'
64 Run remote commands via SSH.  username@domain (rather than just usernames) are
65 considered unique (also see shellcommands).  You probably want this if the
66 commands you are running will accept a domain as a parameter, and will allow
67 the same username with different domains.  You will need to
68 <a href="../docs/ssh.html">setup SSH for unattended operation</a>.
69
70 <BR><BR>Use these buttons for some useful presets:
71 <UL>
72   <LI><INPUT TYPE="button" VALUE="vpopmail" onClick='
73     this.form.useradd.value = "/home/vpopmail/bin/vadduser $username\\\@$domain $quoted_password";
74     this.form.useradd_stdin.value = "";
75     this.form.userdel.value = "/home/vpopmail/bin/vdeluser $username\\\@$domain";
76     this.form.userdel_stdin.value="";
77     this.form.usermod.value = "/home/vpopmail/bin/vpasswd $new_username\\\@$new_domain $new_quoted_password";
78     this.form.usermod_stdin.value = "";
79     this.form.usermod_pwonly.checked = true;
80   '>
81   <LI><INPUT TYPE="button" VALUE="ISPMan CLI" onClick='
82     this.form.useradd.value = "/usr/local/ispman/bin/ispman.addUser -d $domain -f $first -l $last -q $quota -p $quoted_password $username";
83     this.form.useradd_stdin.value = "";
84     this.form.userdel.value = "/usr/local/ispman/bin/ispman.delUser -d $domain $username";
85     this.form.userdel_stdin.value="";
86     this.form.usermod.value = "/usr/local/ispman/bin/ispman.passwd.user $new_username\\\@$new_domain $new_quoted_password";
87     this.form.usermod_stdin.value = "";
88     this.form.usermod_pwonly.checked = true;
89   '>
90   <LI><INPUT TYPE="button" VALUE="MagicMail" onClick='
91     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";
92     this.form.useradd_stdin.value = "";
93     this.form.userdel.value = "/usr/bin/mm_delete_user -e ${username}\\\@${domain}";
94     this.form.userdel_stdin.value = "";
95     this.form.suspend.value = "/usr/bin/mm_suspend_user -e ${username}\\\@${domain}";
96     this.form.suspend_stdin.value = "";
97     this.form.unsuspend.value = "/usr/bin/mm_activate_user -e ${username}\\\@${domain}";
98     this.form.unsuspend_stdin.value = "";
99     this.form.no_queue.checked = 1;
100   '>
101 </UL>
102
103 The following variables are available for interpolation (prefixed with
104 <code>new_</code> or <code>old_</code> for replace operations):
105 <UL>
106   <LI><code>$username</code>
107   <LI><code>$domain</code>
108   <LI><code>$_password</code>
109   <LI><code>$quoted_password</code> - unencrypted password, already quoted for the shell (do not add additional quotes)
110   <LI><code>$crypt_password</code> - encrypted password, already quoted for the shell (do not add additional quotes)
111   <LI><code>$uid</code>
112   <LI><code>$gid</code>
113   <LI><code>$finger</code> - GECOS, already quoted for the shell (do not add additional quotes)
114   <LI><code>$first</code> - First name of GECOS, already quoted for the shell (do not add additional quotes)
115   <LI><code>$last</code> - Last name of GECOS, already quoted for the shell (do not add additional quotes)
116   <LI><code>$dir</code> - home directory
117   <LI><code>$shell</code>
118   <LI><code>$quota</code>
119   <LI><code>@radius_groups</code>
120   <LI>All other fields in <a href="../docs/schema.html#svc_acct">svc_acct</a> are also available.
121 </UL>
122 END
123 );
124
125 1;
126