[freeside-devel] Possible Changes to svc_www.cgi and svc_www.pm

ivan ivan at 420.am
Sun Jun 23 12:48:54 PDT 2002


On Sun, Jun 23, 2002 at 10:34:50AM -0400, Stephen Bechard wrote:
> Please let me know what do you think?

I think it's rather counterproductive to continue writing 1.3-style
exports when almost everything else has been moved over to the new export
framework.  See the `NEW EXPORT CLASSES' section of the FS::part_export
manpage as well as any of the existing exports for information on how to
write new-style exports that use the job queue.

-- 
_ivan

On Sun, Jun 23, 2002 at 10:34:50AM -0400, Stephen Bechard wrote:
> > > However, this updates the recnum and usersvc in the svc_www table, but
> > > doesn't
> > > put anything back in the queue to make the necessary changes on the
> Remote
> > > Server.
> > > Is this not implemented yet?
> >
> > svc_www hasn't been moved over to the job queue yet; it's still trying to
> > run ssh processes directly.
> > http://pouncequick.420.am/rt/Ticket/Display.html?id=330
> 
> Seeing I don't know much about the job queue yet...
> I have altered the svc_www.pm so that it will run the necessary ssh
> processes
> for delete and edit (replace($old)) to the remote $apachemachine and take
> care
> of the $apacheroot stuff.
> 
> I have also updated the man page part of it to reflect the changes. :)
> I have tested it and all seems in order. Please let me know what do you
> think?
> 
> --- /tarballs/freeside-1.4.0pre14/FS/FS/svc_www.pm    Mon Feb 11 14:38:58
> 2002
> +++ /usr/local/lib/perl5/site_perl/5.005/FS/svc_www.pm  Sun Jun 23 10:29:48
> 2002
> @@ -184,7 +184,21 @@
> 
>  =item delete
> 
> -Delete this record from the database.
> +Delete this record from the database. If there is an error, returns the
> error,
> +otherwise returns false.
> +
> +If the configuration values (see L<FS::Conf>) I<apachemachine>, and
> +I<apacheroot> exist, the command:
> +
> +  rm -Rf $apacheroot/$zone;
> +  rm $homedir/$zone
> +
> +I<$zone> is the DNS A record pointed to by I<recnum>
> +I<$username> is the username pointed to by I<usersvc>
> +I<$homedir> is that user's home directory
> +
> +is executed on I<apachemachine> via ssh.  This behaviour can be surpressed
> by
> +setting $FS::svc_www::nossh_hack true.
> 
>  =cut
> 
> @@ -192,9 +206,51 @@
>    my $self = shift;
>    my $error;
> 
> +  local $SIG{HUP} = 'IGNORE';
> +  local $SIG{INT} = 'IGNORE';
> +  local $SIG{QUIT} = 'IGNORE';
> +  local $SIG{TERM} = 'IGNORE';
> +  local $SIG{TSTP} = 'IGNORE';
> +  local $SIG{PIPE} = 'IGNORE';
> +
>    $error = $self->SUPER::delete;
>    return $error if $error;
> 
> +  my $oldAutoCommit = $FS::UID::AutoCommit;
> +  local $FS::UID::AutoCommit = 0;
> +  my $dbh = dbh;
> +
> +  my $domain_record = qsearchs('domain_record', { 'recnum' =>
> $self->recnum } );    # or die ?
> +  my $zone = $domain_record->reczone;
> +    # or die ?
> +  unless ( $zone =~ /\.$/ ) {
> +    my $dom_svcnum = $domain_record->svcnum;
> +    my $svc_domain = qsearchs('svc_domain', { 'svcnum' => $dom_svcnum } );
> +      # or die ?
> +    $zone .= '.'. $svc_domain->domain;
> +  }
> +
> +  my $svc_acct = qsearchs('svc_acct', { 'svcnum' => $self->usersvc } );
> +    # or die ?
> +  my $username = $svc_acct->username;
> +    # or die ?
> +  my $homedir = $svc_acct->dir;
> +    # or die ?
> +
> +  if ( $apachemachine
> +       && $apacheroot
> +       && $zone
> +       && $username
> +       && $homedir
> +       && ! $nossh_hack
> +  ) {
> +    ssh("root\@$apachemachine",
> +        "rm -Rf $apacheroot/$zone; ".
> +        "rm $homedir/$zone"
> +    );
> +  }
> +
> +  $dbh->commit or die $dbh->errstr if $oldAutoCommit;
>    '';
>  }
> 
> @@ -203,15 +259,132 @@
>  Replaces the OLD_RECORD with this one in the database.  If there is an
> error,
>  returns the error, otherwise returns false.
> 
> +If the configuration values (see L<FS::Conf>) I<apachemachine>, and
> +I<apacheroot> exist, the command:
> +
> +    if username and zone change:
> +
> +      rm $old_homedir/$old_zone
> +      mv $apacheroot/$old_zone $apacheroot/$new_zone
> +      chown -R $new_username $apacheroot/$new_zone
> +      ln -s $apacheroot/$new_zone $new_homedir/$new_zone
> +
> +    if only username change:
> +
> +      rm $old_homedir/$old_zone
> +      chown -R $new_username $apacheroot/$new_zone
> +      ln -s $apacheroot/$new_zone $new_homedir/$new_zone
> +
> +    if only zone change:
> +
> +      rm $old_homedir/$old_zone
> +      mv $apacheroot/$old_zone $apacheroot/$new_zone
> +      ln -s $apacheroot/$new_zone $new_homedir/$new_zone
> +
> +I<$zone> is the DNS A record pointed to by I<recnum>
> +I<$username> is the username pointed to by I<usersvc>
> +I<$homedir> is that user's home directory
> +
> +is executed on I<apachemachine> via ssh.  This behaviour can be surpressed
> by
> +setting $FS::svc_www::nossh_hack true.
> +
>  =cut
> 
>  sub replace {
>    my ( $new, $old ) = ( shift, shift );
>    my $error;
> 
> +  local $SIG{HUP} = 'IGNORE';
> +  local $SIG{INT} = 'IGNORE';
> +  local $SIG{QUIT} = 'IGNORE';
> +  local $SIG{TERM} = 'IGNORE';
> +  local $SIG{TSTP} = 'IGNORE';
> +  local $SIG{PIPE} = 'IGNORE';
> +
> +  my $oldAutoCommit = $FS::UID::AutoCommit;
> +  local $FS::UID::AutoCommit = 0;
> +  my $dbh = dbh;
> +
>    $error = $new->SUPER::replace($old);
> -  return $error if $error;
> +  if ( $error ) {
> +    $dbh->rollback if $oldAutoCommit;
> +    return $error if $error;
> +  }
> 
> +  # Gathering the old Data
> +  my $old_domain_record = qsearchs('domain_record', { 'recnum' =>
> $old->recnum } );    # or die ?
> +  my $old_zone = $old_domain_record->reczone;
> +    # or die ?
> +  unless ( $old_zone =~ /\.$/ ) {
> +    my $old_dom_svcnum = $old_domain_record->svcnum;
> +    my $old_svc_domain = qsearchs('svc_domain', { 'svcnum' =>
> $old_dom_svcnum } );
> +      # or die ?
> +    $old_zone .= '.'. $old_svc_domain->domain;
> +  }
> +  my $old_svc_acct = qsearchs('svc_acct', { 'svcnum' => $old->usersvc } );
> +    # or die ?
> +  my $old_username = $old_svc_acct->username;
> +    # or die ?
> +  my $old_homedir = $old_svc_acct->dir;
> +    # or die ?
> +
> +  # Gathering the new Data
> +  my $new_domain_record = qsearchs('domain_record', { 'recnum' =>
> $new->recnum } );    # or die ?
> +  my $new_zone = $new_domain_record->reczone;
> +    # or die ?
> +  unless ( $new_zone =~ /\.$/ ) {
> +    my $new_dom_svcnum = $new_domain_record->svcnum;
> +    my $new_svc_domain = qsearchs('svc_domain', { 'svcnum' =>
> $new_dom_svcnum } );
> +      # or die ?
> +    $new_zone .= '.'. $new_svc_domain->domain;
> +  }
> +  my $new_svc_acct = qsearchs('svc_acct', { 'svcnum' => $new->usersvc } );
> +    # or die ?
> +  my $new_username = $new_svc_acct->username;
> +    # or die ?
> +  my $new_homedir = $new_svc_acct->dir;
> +    # or die ?
> +
> +  if ( $apachemachine
> +       && $apacheroot
> +       && $old_zone
> +       && $old_username
> +       && $old_homedir
> +       && $new_zone
> +       && $new_username
> +       && $new_homedir
> +       && ! $nossh_hack
> +  ) {
> +    # Now lets check which commands are necessary
> +    if ( ($old_homedir ne $new_homedir)
> +         && ($old_username ne $new_username)
> +         && ($old_zone ne $new_zone)
> +    ) {
> +       ssh("root\@$apachemachine",
> +           "rm $old_homedir/$old_zone;".
> +           "mv $apacheroot/$old_zone $apacheroot/$new_zone; ".
> +           "chown -R $new_username $apacheroot/$new_zone; ".
> +           "ln -s $apacheroot/$new_zone $new_homedir/$new_zone"
> +       );
> +    } elsif ( ($old_homedir ne $new_homedir)
> +         && ($old_username ne $new_username)
> +    ) {
> +       ssh("root\@$apachemachine",
> +           "rm $old_homedir/$old_zone;".
> +           "chown -R $new_username $apacheroot/$new_zone; ".
> +           "ln -s $apacheroot/$new_zone $new_homedir/$new_zone"
> +       );
> +    } elsif ( ($old_zone ne $new_zone)
> +    ) {
> +       ssh("root\@$apachemachine",
> +           "rm $old_homedir/$old_zone;".
> +           "mv $apacheroot/$old_zone $apacheroot/$new_zone; ".
> +           "ln -s $apacheroot/$new_zone $new_homedir/$new_zone"
> +       );
> +    }
> +  }
> +
> +  $dbh->commit or die $dbh->errstr if $oldAutoCommit;
>    '';
>  }
> 
> 
> Once I get more aquainted with the job queue I will try to convert it
> into that syntax, but this works for me in the interum.
> 
> Enjoy,
> Steve
> 




More information about the freeside-devel mailing list