On 30/11/2007, at 5.30, Ken Marcus - Precision Web Hosting, Inc. wrote:
> Here is a script that will take a list of sites from a file named
> "sitestoadd.txt" and will restore them to a server. Using this
> script, if you have a problem half way through a restore like a
> memory leak or disconnection problem, you won't have to start all
> over. Just log back in, edit the sitestoadd.txt and start it again.
Couldn't that be handled by restarting cced for every n site?
Eg. for every 20 site
Just found this in my "needs-to-be-tested"-folder
BE AWARE THAT THIS HAS NOT BEEN TESTED IN ANY WAY!!!!
#/usr/bin/perl
$BASEDIR = "/home/restore" ; #The location of restore data
$PREFIX = "groups-" ; # Used to grab the host- & domainname
$SUFFIX = "-public.tar.gz" ; # Used to grab the host- & domainname
$count = 1 ; # Sets the site count to 1
$CCED = 20 ; # Restart the cced for n sites
chdir("$BASEDIR") || die "Cannot chdir to $BASEDIR ($!)" ;
opendir(COUNTSITES, "$BASEDIR") || die "Cannot opendir $BASEDIR: $!" ;
foreach $COUNT (sort readdir(COUNTSITES)) {
if (($COUNT =~ m/^($PREFIX)/) && ($COUNT =~ m/($SUFFIX)$/)) {
$totalcount++;
}
}
closedir(SITES);
print "Importing a total of $totalcount sites ...\n";
opendir(SITES, "$BASEDIR") || die "Cannot opendir $BASEDIR: $!" ;
foreach $SITE (sort readdir(SITES)) {
if (($SITE =~ m/^($PREFIX)/) && ($SITE =~ m/($SUFFIX)$/)) {
$SITE =~ s/${PREFIX}//g ;
$SITE =~ s/${SUFFIX}//g ;
print "Importing site: $SITE ($count/$totalcount)\n";
system ("/usr/sbin/cmuImport -d $BASEDIR -n $SITE") ;
if ($count % $CCED == 0) {
print "Restarting the cced to prevent memory leak on large imports
\n";
system ("/etc/rc.d/init.d/cced.init restart") ;
}
$count++
}
}
closedir(SITES);
print "Importing is now done - Restarting the cced ...\n";
system ("/etc/rc.d/init.d/cced.init restart") ;
system ("/etc/rc.d/init.d/cced.init status") ;