#!/usr/bin/perl
# cpanel12 - edit_com/uninstall                   Copyright(c) 2007 cPanel, Inc.
#                                                           All rights Reserved.
# copyright@cpanel.net                                         http://cpanel.net
# This code is subject to the cPanel license. Unauthorized copying is prohibited

use lib '/usr/local/cpanel';
use strict;
use warnings;
use Cpanel::Config ();

our @install_files;
require 'install_files.pl';

my $cpconf = Cpanel::Config::loadcpconf();
if ( !$cpconf->{'root'} || substr( $cpconf->{'root'}, 0, 1 ) ne '/' || !-e $cpconf->{'root'} . '/Cpanel.pm' ) {
    $cpconf->{'root'} = '/usr/local/cpanel';
}

foreach my $file ( reverse @install_files ) {
    my $install_file = substr( $file, 0, 1 ) ne '/' ? $cpconf->{'root'} . '/' . $file : $file;
    next if !-e $install_file;
    unlink $install_file;
    if ( -e $install_file ) {
        print "Failed to uninstall $install_file: $!\n";
    }
    else {
        print "Removed $install_file\n";
    }
}

if ( -x '/usr/local/cpanel/bin/rebuild_sprites' ) {
    system '/usr/local/cpanel/bin/rebuild_sprites';
}

print "Done\n";
