[BlueOnyx:12661] Re: Auto suspend vhosts

Michael Stauber mstauber at blueonyx.it
Fri Mar 29 18:51:48 -05 2013


Hi Marcello,

> I need to make automatic vhost suspension for customers who does not
> pay bills after the expiration date of the domain.
> 
> My idea was to build up a small MySQL DB which stores information about
> domains hosted by my BO server and through PHP scripts, CRON and shell
> commands I should suspend that vhost.
> 
> I've tried different commands like cmodvsite, but there is no way to set
> a host suspended.

Yeah. The shell tools are missing that option.

> Can i do something via PHP using CCED?

Yes, but only from PHP pages within AdmServ.

Here is a really quick and dirty Perl-Script that can suspend/unsuspend
Vsites:

-----------------------------------------------------------------
#!/usr/bin/perl -I/usr/sausalito/perl
# $Id: vsitesuspend.pl
# Copyright 2006-2013 Solarspeed Limited. All rights reserved.

use CCE;
$cce = new CCE;
@opts = grep /^\w+/, @ARGV;
$switch_o = $opts[0];
$switch_n = $opts[1];

print "\n";
print "vsitesuspend.pl\n";
print "======================\n\n";
print "Author: Michael Stauber\n\n";
print "This script can suspend/unsuspend Vsites. \n\n";

if ($switch_o eq "" || $switch_n eq "") {
        print "To use it, run it with the following parameters:\n\n";
        print $0 . " [0|1] fqdn\n\n";
        exit 1;
} elsif (($switch_o == "0") || ($switch_o == "1")) {
        print "Setting suspend of Vsite $switch_n to $switch_o. \n\n";
        $cce->connectuds();
        &feedthemonster;
        $cce->bye('SUCCESS');
        exit(0);
} else {
        print "Aborting without doing anything ...\n\n";
        exit 1;
}

sub feedthemonster {
    (@oids) = $cce->find('Vsite', { 'fqdn' => $switch_n });
    if ($#oids == -1) {
        print "No Vsite named $switch_n could be found.\n\n";
        exit(1);
    }
    else {
        for $object (@oids) {
                ($ok, $rec) = $cce->get($object);
                ($ok) = $cce->set($object, '',{
                    'suspend' => $switch_o
                });
        }
    }
}

exit;
-----------------------------------------------------------------

It doesn't do much error checking, but gets the job done.

Command line usage would be:

Suspend of www.testing.com:
./vsitesuspend.pl 1 www.testing.com

Unsuspend of www.testing.com:
./vsitesuspend.pl 0 www.testing.com


-- 
With best regards

Michael Stauber



More information about the Blueonyx mailing list