File: //scripts.20110531.215904.25158/unpkgacct
#!/usr/bin/perl
# cpanel4 - scripts Copyright(c) 1997-2002 cPanel, Inc..
# All rights Reserved.
# copyright@cpanel.net http://cpanel.net
# This code is subject to the cpanel license. Unauthorized copying is prohibited
require 5.006;
$|=1;
$user = $ARGV[0];
if (!getpwnam($user) && !enXim($user)) {
print "Invalid Account\n";
exit;
}
$mntpoint = $ARGV[1];
if ($mntpoint eq "") {
$mntpoint = getmntpoint();
}
if (-d "$mntpoint/cpmove-${user}" && ! -l "$mntpoint/cpmove-${user}") {
system("rm","-rf","$mntpoint/cpmove-${user}");
}
if (-d "$mntpoint/cpmove-${user}-split" && ! -l "$mntpoint/cpmove-${user}-split") {
system("rm","-rf","$mntpoint/cpmove-${user}-split");
}
if (-f "$mntpoint/cpmove-${user}.tar.gz" && ! -l "$mntpoint/cpmove-${user}.tar.gz") {
system("rm","-rf","$mntpoint/cpmove-${user}.tar.gz");
}
if (-f "$mntpoint/cpmove-${user}.tar" && ! -l "$mntpoint/cpmove-${user}.tar") {
system("rm","-rf","$mntpoint/cpmove-${user}.tar");
}
if (! -d '/usr/local/cpanel') {
system('rm', '-rf', '/etc/trueuserdomains');
}
## case 34397 deprecation: use Cpanel::Filesys::getmntpoint
sub getmntpoint {
my($homedir);
my($homematch);
open(CONF,"/etc/wwwacct.conf");
while(<CONF>) {
$_ =~ s/\n//g;
if ($_ !~ /^;/) {
if ($_ =~ /HOMEDIR/) {
(undef,$homedir) = split(/ /, $_);
}
if ($_ =~ /HOMEMATCH/) {
(undef,$homematch) = split(/ /, $_);
}
}
}
close(CONF);
$homedir =~ s/\/$//g;
## case 34397: mark for deprecation
$disk = `df`;
my $max = 0;
my $mnt = "/";
my(@DISK) = split(/\n/, $disk);
my $addline = '';
foreach $line (@DISK) {
if ($line !~ /[\s|\t]+/) {
$addline = $line;
$addline =~ s/\n//g;
next;
}
if ($line =~ /^\/dev/ || $addline ne "") {
$line =~ s/\n//g;
$line =~ / (\d*)\s*\d*\%\s*(\S+)$/;
my $free = $1;
my $mount = $2;
my $assess = 1;
if ( ($mount eq "/") && ($homedir eq 0) ) {
$assess = 0;
}
$free = int($free);
$max = int($max);
if ( ($max < $free) && ($assess eq 1) && ($mount =~ /$homematch/ || $mount eq "/") ) {
$max = $free;
if ($mount eq "/") {
$mount = $homedir;
}
$mnt = $mount;
}
}
}
if ($mnt eq "" || $mnt eq "/") { $mnt = '/home'; }
return($mnt);
}
sub enXim {
($enxim_user) = @_;
return $enxim_user if $enxim_user =~ /site\d+/;
$found = 0;
opendir(VH,"/home/virtual");
@FILES=grep(/^site/,readdir(VH));
closedir(VH);
foreach my $xsite (@FILES) {
my ($ul,$dns);
my $sitedir = '/home/virtual/' . $xsite . "/fst";
open(DNS,"$sitedir/etc/passwd");
chomp($ul = <DNS>);
($muser,undef,$muid,undef) = split(/:/, $ul);
close(DNS);
if ($muser eq $enxim_user) { $found = 1; last }
}
return $found;
}