Go Back   HowtoForge Forums | HowtoForge - Linux Howtos and Tutorials > ISPConfig 3 > Installation/Configuration

Do you like HowtoForge? Please consider supporting us by becoming a subscriber.
Reply
 
Thread Tools Display Modes
  #1  
Old 3rd July 2012, 14:53
ochorocho ochorocho is offline
Member
 
Join Date: Jul 2012
Posts: 30
Thanks: 2
Thanked 3 Times in 3 Posts
Default ISPconfig cleanup skript for unused webs?

Hello,

we're using ISPconfig for about 1 year now. It works really good, and satisfied our needs. :-)

Now, we wanted do cleanup a little bit. This means deleting webs!
In the web interface the webs are gone, but the folders including all data is still remain on the server.

Is there a skript to clean this up, like i saw one for ISPC2 ?

THX!

cheers,
ochorocho
Reply With Quote
Sponsored Links
  #2  
Old 3rd July 2012, 15:17
till till is offline
Super Moderator
 
Join Date: Apr 2005
Location: Lüneburg, Germany
Posts: 36,791
Thanks: 840
Thanked 5,612 Times in 4,423 Posts
Default

There is no cleanup script required as ispconfig deletes the webs as soon as you delete them in the interface. If thats not the case on your server, then the server cronjob is stopped or failed to process the changes. If there are jobs stuck in the jobqueue (see monitor), then enable debugging as described in the FAQ.
__________________
Till Brehm
--
Get ISPConfig support and the ISPConfig 3 manual from ispconfig.org.
Reply With Quote
  #3  
Old 3rd May 2014, 12:40
bvbmedia bvbmedia is offline
Junior Member
 
Join Date: Apr 2012
Location: Netherlands
Posts: 9
Thanks: 0
Thanked 1 Time in 1 Post
Send a message via Skype™ to bvbmedia
Default Script for retrieving orphan webfolders

I also had this issue. The symlinks we're removed but not the web folder.

So made a script that compares the /var/www folder against /var/clients/client1 to see which folders are orphan. Maybe it is useful to you.

/shopcvs/scripts/server/webserver_vhost_cleaner.php --continue=1 --summarize_disk_usage=1

SCAN FOR ORPHAN VHOSTS
Developed by BVB Media (http://www.bvbmedia.nl)
--------------------------
continue: 1
summarize_disk_usage: 1
--------------------------

Active vhosts: 18
Orphan vhosts: 44

The following folders can be deleted (but of course take care and do at your own risk).
/var/www/clients/client1/web116
/var/www/clients/client1/web120
/var/www/clients/client1/web124
/var/www/clients/client1/web96
/var/www/clients/client1/web130
/var/www/clients/client1/web107
/var/www/clients/client1/web122
/var/www/clients/client1/web140
/var/www/clients/client1/web135
/var/www/clients/client1/web18_bak_2012_12_04
/var/www/clients/client1/web117
/var/www/clients/client1/web136
/var/www/clients/client1/web137
/var/www/clients/client1/web128
/var/www/clients/client1/web133
/var/www/clients/client1/web34_bak_2012_12_05
/var/www/clients/client1/web141
/var/www/clients/client1/web142
/var/www/clients/client1/web103
/var/www/clients/client1/web95
/var/www/clients/client1/web129
/var/www/clients/client1/web102
/var/www/clients/client1/web59_bak_2012_12_05
/var/www/clients/client1/web134
/var/www/clients/client1/web118
/var/www/clients/client1/web123
/var/www/clients/client1/web26_bak_2012_12_04
/var/www/clients/client1/web139
/var/www/clients/client1/web1_bak_2012_11_28
/var/www/clients/client1/web1
/var/www/clients/client1/web138
/var/www/clients/client1/web125
/var/www/clients/client1/web126
/var/www/clients/client1/web108
/var/www/clients/client1/web60_bak_2012_12_05
/var/www/clients/client1/web119
/var/www/clients/client1/web29_bak_2012_12_04
/var/www/clients/client1/web105
/var/www/clients/client1/web57_bak_2012_12_05
/var/www/clients/client1/web30_bak_2012_12_04
/var/www/clients/client1/web106
/var/www/clients/client1/web54_bak_2012_12_05
/var/www/clients/client1/web13
/var/www/clients/client1/web127

Total size: 1129196652 Bytes (1077MB)

PHP code:

PHP Code:
#!/usr/bin/php
<?php
//####################################
//           developed by:           #
// Bas van Beek (bvbmedia@gmail.com  #
// (c)opyright to BVB Media BV 2014  #
//####################################
set_time_limit(186400);
ignore_user_abort(true);
function 
doPrint($content) {
    global 
$stats;
    
$stats['log'].=$content;
    return 
$content;
}

function 
clearvalue($input) {
    
$input=preg_replace("/\r|\n$/is"''$input);
    return 
$input;
}

function 
clearscreen($out=true) {
    
$clearscreen=chr(27)."[H".chr(27)."[2J";
    
fwrite(STDOUT$clearscreen);
}

function 
read($stopchar) {
    
$fp=fopen("php://stdin""r");
    
$in=fread($fp1); // Start the loop
    
$output='';
    while (
$in!=$stopchar) {
        
$output=$output.$in;
        
$in=fread($fp1);
    }
    
fclose($fp);
    return 
$output;
}

function 
multiple_choice($array$print_selected=1) {
    
// Display the choices
    
foreach ($array as $choice=>$value) {
        
fwrite(STDOUT"\t$choice: $value\n");
    }
    
// Loop until they enter 'q' for Quit
    
do {
        
// A character from STDIN, ignoring whitespace characters
        
do {
            
$selection=clearvalue(fgets(STDIN));
        } while (
trim($selection)=='');
        if (
array_key_exists($selection$array)) {
            if (
$print_selected) {
                
fwrite(STDOUT"{$array[$selection]} selected\n");
            }
            
$selected=$array[$selection];
            return 
$selected;
            break;
        }
    } while (
$selection!='q');
}

clearscreen();
echo 
'SCAN FOR ORPHAN VHOSTS'."\n";
echo 
'Developed by BVB Media (http://www.bvbmedia.nl)'."\n";
echo 
'--------------------------'."\n";
$commands_array=array();
if (
count($argv)>1) {
    foreach (
$argv as $key=>$value) {
        if (
$value=='--help') {
            
$string="Example:\n";
            
$string.="/shopcvs/scripts/server/webserver_vhost_cleaner.php --continue=1 --summarize_disk_usage=1\n";
            
fwrite(STDOUT$string);
            exit(
0);
        }
        if (
preg_match("/^--/"$value)) {
            
preg_match("/^--(.*?)\=(.*?)$/"$value$results);
            
$commands_array[$results[1]]=$results[2];
        }
    }
    
$needed_vars=array();
    
$needed_vars[]='continue';
    
$halt=0;
    foreach (
$needed_vars as $needed_var) {
        if (!
array_key_exists($needed_var$commands_array)) {
            
fwrite(STDOUT$needed_var." is not specified\n");
            
$halt=1;
        }
    }
    if (
$halt) {
        
fwrite(STDOUT"Script aborted.\n");
        exit(
0);
    }
    foreach (
$commands_array as $key2=>$value2) {
        
fwrite(STDOUT$key2.": ".$value2."\n");
    }
} else {
    die();
}
echo 
'--------------------------'."\n";
$stats=array();
$stats['activeVhosts']=0;
$stats['orphanVhosts']=0;
$stats['diskUsage']=0;

$path='/var/www';
$records=array();

$excludeFolders=array();
$excludeFolders[]='.';
$excludeFolders[]='..';
$excludeFolders[]='backup';
$excludeFolders[]='clients';
$excludeFolders[]='mysql';
if (
$handle=opendir($path)) {
    while (
false!==($entry=readdir($handle))) {
        if (!
in_array($entry$excludeFolders)) {
            if (
is_link($path.'/'.$entry)) {
                
// symlink
                
$records['symlinks'][$entry]=$path.'/'.$entry;
                
$readlink=readlink($path.'/'.$entry);
                if (
$readlink) {
                    
$readlink=substr($readlink0strlen($readlink)-1);
                    
$records['symlinks_targets'][]=$readlink;
                    
$stats['activeVhosts']++;
                }
            }
        }
    }
    
closedir($handle);
}
$path='/var/www/clients/client1';
if (
$handle=opendir($path)) {
    while (
false!==($entry=readdir($handle))) {
        if (!
in_array($entry$excludeFolders)) {
            if (!
is_link($path.'/'.$entry)) {
                
$records['folders'][$entry]=$path.'/'.$entry;
            }
        }
    }
    
closedir($handle);
}
foreach (
$records['folders'] as $folder) {
    if (!
in_array($folder$records['symlinks_targets'])) {
        
$records['foldersToDelete'][]=$folder;
        
$stats['orphanVhosts']++;
    }
}
echo 
"\n";
echo 
'Active vhosts: '.$stats['activeVhosts']."\n";
echo 
'Orphan vhosts: '.$stats['orphanVhosts']."\n";
if (!
$records['foldersToDelete']) {
    echo 
"\n".'Everything is clean. No orphan vhosts found.'."\n";
} else {
    echo 
"\n".'The following folders can be deleted (but of course take care and do at your own risk).'."\n";
    foreach (
$records['foldersToDelete'] as $folder) {
        echo 
$folder."\n";
        if (
$commands_array['summarize_disk_usage']) {
            
$command="du -bs ".$folder."|cut -d \\/ -f 1";
            
$size=exec($command);
            
$stats['diskUsage']+=$size;
        }
    }
    if (
$stats['diskUsage']) {
        echo 
"\n".'Total size: '.$stats['diskUsage'].' Bytes ('.round(($stats['diskUsage']/1024/1024), 0).'MB)'."\n";
    }
}
?>
__________________
Best regards,

Bas van Beek
BVB Media / TYPO3 Multishop

http://www.bvbmedia.nl
http://www.typo3multishop.com

Last edited by bvbmedia; 3rd May 2014 at 12:41. Reason: typo
Reply With Quote
Reply

Bookmarks

Tags
cleanup, ispconfig 3, websites

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Relay access denied when using SMTP to external recipients Kamran Shah Installation/Configuration 111 14th May 2014 19:10
ISPConfig on Debian 6 with optional PHP 5.2 for single webs Croydon Installation/Configuration 3 6th September 2011 17:35
Control Panel - E-mail Tab is empty domi-nik General 15 14th April 2011 19:17
chroot SSH IspConfig2 kextra1 General 4 20th January 2011 19:41
ISPConfig 3.0.1 released till General 36 29th March 2009 15:30


All times are GMT +2. The time now is 11:46.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2014, vBulletin Solutions, Inc.