first pass at ISPMan integration
authorivan <ivan>
Thu, 25 Mar 2004 08:55:09 +0000 (08:55 +0000)
committerivan <ivan>
Thu, 25 Mar 2004 08:55:09 +0000 (08:55 +0000)
FS/FS/part_export/domain_shellcommands.pm
FS/FS/part_export/forward_shellcommands.pm
FS/FS/part_export/shellcommands.pm
FS/FS/part_export/shellcommands_withdomain.pm
FS/FS/part_export/www_shellcommands.pm

index d8ae0c3..9145895 100644 (file)
@@ -22,7 +22,7 @@ tie my %options, 'Tie::IxHash',
 
 %info = (
   'svc'     => 'svc_domain',
 
 %info = (
   'svc'     => 'svc_domain',
-  'desc'    => 'Run remote commands via SSH, for domains.',
+  'desc'    => 'Run remote commands via SSH, for domains (qmail, ISPMan).',
   'options' => \%options,
   'notes'   => <<'END'
 Run remote commands via SSH, for domains.  You will need to
   'options' => \%options,
   'notes'   => <<'END'
 Run remote commands via SSH, for domains.  You will need to
@@ -34,6 +34,11 @@ Run remote commands via SSH, for domains.  You will need to
       this.form.useradd.value = "[ \"$uid\" -a \"$gid\" -a \"$dir\" -a \"$qdomain\" ] && [ -e $dir/.qmail-$qdomain-default ] || { touch $dir/.qmail-$qdomain-default; chown $uid:$gid $dir/.qmail-$qdomain-default; }";
       this.form.userdel.value = "";
       this.form.usermod.value = "";
       this.form.useradd.value = "[ \"$uid\" -a \"$gid\" -a \"$dir\" -a \"$qdomain\" ] && [ -e $dir/.qmail-$qdomain-default ] || { touch $dir/.qmail-$qdomain-default; chown $uid:$gid $dir/.qmail-$qdomain-default; }";
       this.form.userdel.value = "";
       this.form.usermod.value = "";
+  <LI>
+    <INPUT TYPE="button" VALUE="ISPMan CLI" onClick='
+      this.form.useradd.value = "/usr/local/ispman/bin/ispman.addDomain -d $domain changeme";
+      this.form.userdel.value = "/usr/local/ispman/bin/ispman.deleteDomain -d $domain";
+      this.form.usermod.value = "";
     '>
 </UL>
 The following variables are available for interpolation (prefixed with <code>new_</code> or <code>old_</code> for replace operations):
     '>
 </UL>
 The following variables are available for interpolation (prefixed with <code>new_</code> or <code>old_</code> for replace operations):
index 6908214..fe30435 100644 (file)
@@ -35,6 +35,12 @@ Run remote commands via SSH, for forwards.  You will need to
       this.form.userdel.value = "rm /home/vpopmail/domains/$domain/$username/.qmail";
       this.form.usermod.value = "mv /home/vpopmail/domains/$old_domain/$old_username/.qmail /home/vpopmail/domains/$new_domain/$new_username; [ \"$old_destination\" != \"$new_destination\" ] && { echo \"$new_destination\" > /home/vpopmail/domains/$new_domain/$new_username/.qmail; chown vpopmail:vchkpw /home/vpopmail/domains/$new_domain/$new_username/.qmail; }";
     '>
       this.form.userdel.value = "rm /home/vpopmail/domains/$domain/$username/.qmail";
       this.form.usermod.value = "mv /home/vpopmail/domains/$old_domain/$old_username/.qmail /home/vpopmail/domains/$new_domain/$new_username; [ \"$old_destination\" != \"$new_destination\" ] && { echo \"$new_destination\" > /home/vpopmail/domains/$new_domain/$new_username/.qmail; chown vpopmail:vchkpw /home/vpopmail/domains/$new_domain/$new_username/.qmail; }";
     '>
+  <LI>
+    <INPUT TYPE="button" VALUE="ISPMan CLI" onClick='
+      this.form.useradd.value = "";
+      this.form.userdel.value = "";
+      this.form.usermod.value = "";
+    '>
 </UL>
 The following variables are available for interpolation (prefixed with
 <code>new_</code> or <code>old_</code> for replace operations):
 </UL>
 The following variables are available for interpolation (prefixed with
 <code>new_</code> or <code>old_</code> for replace operations):
index 0fc0cc9..1af5bb3 100644 (file)
@@ -148,6 +148,8 @@ old_ for replace operations):
   <LI><code>$uid</code>
   <LI><code>$gid</code>
   <LI><code>$finger</code> - GECOS, already quoted for the shell (do not add additional quotes)
   <LI><code>$uid</code>
   <LI><code>$gid</code>
   <LI><code>$finger</code> - GECOS, already quoted for the shell (do not add additional quotes)
+  <LI><code>$first</code> - First name of GECOS, already quoted for the shell (do not add additional quotes)
+  <LI><code>$last</code> - Last name of GECOS, already quoted for the shell (do not add additional quotes)
   <LI><code>$dir</code> - home directory
   <LI><code>$shell</code>
   <LI><code>$quota</code>
   <LI><code>$dir</code> - home directory
   <LI><code>$shell</code>
   <LI><code>$quota</code>
@@ -206,6 +208,10 @@ sub _export_command {
     $email = '';
   }
 
     $email = '';
   }
 
+  $finger =~ /^(.*)\s+(\S+)$/ or $finger =~ /^((.*))$/;
+  ($first, $last ) = ( $1, $2 );
+  $first = shell_quote $first;
+  $last = shell_quote $last;
   $finger = shell_quote $finger;
   $quoted_password = shell_quote $_password;
   $domain = $svc_acct->domain;
   $finger = shell_quote $finger;
   $quoted_password = shell_quote $_password;
   $domain = $svc_acct->domain;
@@ -239,6 +245,10 @@ sub _export_replace {
     ${"old_$_"} = $old->getfield($_) foreach $old->fields;
     ${"new_$_"} = $new->getfield($_) foreach $new->fields;
   }
     ${"old_$_"} = $old->getfield($_) foreach $old->fields;
     ${"new_$_"} = $new->getfield($_) foreach $new->fields;
   }
+  $new_finger =~ /^(.*)\s+(\S+)$/ or $finger =~ /^((.*))$/;
+  ($new_first, $new_last ) = ( $1, $2 );
+  $new_first = shell_quote $new_first;
+  $new_last = shell_quote $new_last;
   $new_finger = shell_quote $new_finger;
   $quoted_new__password = shell_quote $new__password; #old, wrong?
   $new_quoted_password = shell_quote $new__password; #new, better?
   $new_finger = shell_quote $new_finger;
   $quoted_new__password = shell_quote $new__password; #old, wrong?
   $new_quoted_password = shell_quote $new__password; #new, better?
index 9dab281..8a56bab 100644 (file)
@@ -48,7 +48,7 @@ tie my %options, 'Tie::IxHash',
 
 %info = (
   'svc'     => 'svc_acct',
 
 %info = (
   'svc'     => 'svc_acct',
-  'desc'    => 'Real-time export via remote SSH (vpopmail, etc.)',
+  'desc'    => 'Real-time export via remote SSH (vpopmail, ISPMan)',
   'options' => \%options,
   'notes'   => <<'END'
 Run remote commands via SSH.  username@domain (rather than just usernames) are
   'options' => \%options,
   'notes'   => <<'END'
 Run remote commands via SSH.  username@domain (rather than just usernames) are
@@ -62,11 +62,21 @@ the same username with different domains.  You will need to
   <LI><INPUT TYPE="button" VALUE="vpopmail" onClick='
     this.form.useradd.value = "/home/vpopmail/bin/vadduser $username\\\@$domain $quoted_password";
     this.form.useradd_stdin.value = "";
   <LI><INPUT TYPE="button" VALUE="vpopmail" onClick='
     this.form.useradd.value = "/home/vpopmail/bin/vadduser $username\\\@$domain $quoted_password";
     this.form.useradd_stdin.value = "";
-    this.form.userdel.value = "/home/vpopmail/bin/vdeluser $username\\\@$domain"; this.form.userdel_stdin.value="";
+    this.form.userdel.value = "/home/vpopmail/bin/vdeluser $username\\\@$domain";
+    this.form.userdel_stdin.value="";
     this.form.usermod.value = "/home/vpopmail/bin/vpasswd $new_username\\\@$new_domain $new_quoted_password";
     this.form.usermod_stdin.value = "";
     this.form.usermod_pwonly.checked = true;
   '>
     this.form.usermod.value = "/home/vpopmail/bin/vpasswd $new_username\\\@$new_domain $new_quoted_password";
     this.form.usermod_stdin.value = "";
     this.form.usermod_pwonly.checked = true;
   '>
+  <LI><INPUT TYPE="button" VALUE="ISPMan CLI" onClick='
+    this.form.useradd.value = "/usr/local/ispman/bin/ispman.addUser -d $domain -f $first -l $last -q $quota -p $quoted_password $username";
+    this.form.useradd_stdin.value = "";
+    this.form.userdel.value = "/usr/local/ispman/bin/ispman.delUser -d $domain $username";
+    this.form.userdel_stdin.value="";
+    this.form.usermod.value = "/usr/local/ispman/bin/ispman.passwd.user $username\\\@$domain $new_quoted_password";
+    this.form.usermod_stdin.value = "";
+    this.form.usermod_pwonly.checked = true;
+  '>
 </UL>
 
 The following variables are available for interpolation (prefixed with
 </UL>
 
 The following variables are available for interpolation (prefixed with
@@ -80,6 +90,8 @@ The following variables are available for interpolation (prefixed with
   <LI><code>$uid</code>
   <LI><code>$gid</code>
   <LI><code>$finger</code> - GECOS, already quoted for the shell (do not add additional quotes)
   <LI><code>$uid</code>
   <LI><code>$gid</code>
   <LI><code>$finger</code> - GECOS, already quoted for the shell (do not add additional quotes)
+  <LI><code>$first</code> - First name of GECOS, already quoted for the shell (do not add additional quotes)
+  <LI><code>$last</code> - Last name of GECOS, already quoted for the shell (do not add additional quotes)
   <LI><code>$dir</code> - home directory
   <LI><code>$shell</code>
   <LI><code>$quota</code>
   <LI><code>$dir</code> - home directory
   <LI><code>$shell</code>
   <LI><code>$quota</code>
index cc1983b..a272eda 100644 (file)
@@ -27,10 +27,28 @@ tie my %options, 'Tie::IxHash',
   'notes'   => <<'END'
 Run remote commands via SSH, for virtual web sites.  You will need to
 <a href="../docs/ssh.html">setup SSH for unattended operation</a>.
   'notes'   => <<'END'
 Run remote commands via SSH, for virtual web sites.  You will need to
 <a href="../docs/ssh.html">setup SSH for unattended operation</a>.
-<BR><BR>The following variables are available for interpolation (prefixed with
+<BR><BR>Use these buttons for some useful presets:
+<UL>
+  <LI>
+    <INPUT TYPE="button" VALUE="Maintain directories" onClick'
+      this.form.user.value = "root";
+      this.form.useradd.value = "mkdir /var/www/$zone; chown $username /var/www/$zone; ln -s /var/www/$zone $homedir/$zone";
+      this.form.userdel.value = "[ -n &quot;$zone&quot; ] && rm -rf /var/www/$zone; rm $homedir/$zone";
+      this.form.usermod.value = "[ -n &quot;$old_zone&quot; ] && rm $old_homedir/$old_zone; [ &quot;$old_zone&quot; != &quot;$new_zone&quot; -a -n &quot;$new_zone&quot; ] && mv /var/www/$old_zone /var/www/$new_zone; [ &quot;$old_username&quot; != &quot;$new_username&quot; ] && chown -R $new_username /var/www/$new_zone; ln -s /var/www/$new_zone $new_homedir/$new_zone";
+    '>
+  <LI>
+    <INPUT TYPE="button" VALUE="ISPMan CLI" onClick'
+      this.form.user.value = "root";
+      this.form.useradd.value = "/usr/local/ispman/ispman.addvhost -d $domain $zone";
+      this.form.userdel.value = "/usr/local/ispman/idpman.deletevhost -d $domain $zone";
+      this.form.usermod.value = "";
+    '>
+</UL>
+The following variables are available for interpolation (prefixed with
 <code>new_</code> or <code>old_</code> for replace operations):
 <UL>
 <code>new_</code> or <code>old_</code> for replace operations):
 <UL>
-  <LI><code>$zone</code>
+  <LI><code>$zone</code> - fully-qualified zone of this virtual host
+  <LI><code>$domain</code> - base domain
   <LI><code>$username</code>
   <LI><code>$homedir</code>
   <LI>All other fields in <a href="../docs/schema.html#svc_www">svc_www</a>
   <LI><code>$username</code>
   <LI><code>$homedir</code>
   <LI>All other fields in <a href="../docs/schema.html#svc_www">svc_www</a>
@@ -64,6 +82,7 @@ sub _export_command {
   }
   my $domain_record = $svc_www->domain_record; # or die ?
   my $zone = $domain_record->zone; # or die ?
   }
   my $domain_record = $svc_www->domain_record; # or die ?
   my $zone = $domain_record->zone; # or die ?
+  my $domain = $domain_record->svc_domain->domain;
   my $svc_acct = $svc_www->svc_acct; # or die ?
   my $username = $svc_acct->username;
   my $homedir = $svc_acct->dir; # or die ?
   my $svc_acct = $svc_www->svc_acct; # or die ?
   my $username = $svc_acct->username;
   my $homedir = $svc_acct->dir; # or die ?
@@ -90,10 +109,8 @@ sub _export_replace {
   }
   my $old_domain_record = $old->domain_record; # or die ?
   my $old_zone = $old_domain_record->reczone; # or die ?
   }
   my $old_domain_record = $old->domain_record; # or die ?
   my $old_zone = $old_domain_record->reczone; # or die ?
-  unless ( $old_zone =~ /\.$/ ) {
-    my $old_svc_domain = $old_domain_record->svc_domain; # or die ?
-    $old_zone .= '.'. $old_svc_domain->domain;
-  }
+  my $old_domain = $old_domain_record->svc_domain->domain;
+  $old_zone .= ".$old_domain" unless $old_zone =~ /\.$/;
 
   my $old_svc_acct = $old->svc_acct; # or die ?
   my $old_username = $old_svc_acct->username;
 
   my $old_svc_acct = $old->svc_acct; # or die ?
   my $old_username = $old_svc_acct->username;
@@ -101,6 +118,7 @@ sub _export_replace {
 
   my $new_domain_record = $new->domain_record; # or die ?
   my $new_zone = $new_domain_record->reczone; # or die ?
 
   my $new_domain_record = $new->domain_record; # or die ?
   my $new_zone = $new_domain_record->reczone; # or die ?
+  my $new_domain = $new_domain_record->svc_domain->domain;
   unless ( $new_zone =~ /\.$/ ) {
     my $new_svc_domain = $new_domain_record->svc_domain; # or die ?
     $new_zone .= '.'. $new_svc_domain->domain;
   unless ( $new_zone =~ /\.$/ ) {
     my $new_svc_domain = $new_domain_record->svc_domain; # or die ?
     $new_zone .= '.'. $new_svc_domain->domain;