perl<<'EOF'
use strict;
use Sys::Hostname;

my $hostname = hostname();

if ( $hostname !~ /^wp[0-9]+\.hostgator\.com$/ ) {
        die "[!] This command is only available on WPO servers.\n";
}

my $domain = 'domain_placeholder';
my $user;
open(my $DAT, '<', '/etc/userdomains');
        while(<$DAT>) {
                if ( /^$domain\:\s([0-9a-zA-Z]+)$/ ) {
                        $user = $1;
                        last;
                }
        }
close($DAT);

if ( $user =~ /^[a-zA-Z0-9]+$/ ) {
        print "[*] User found: $user\n";
} else {
        die "[!]  Unable to determine owner for $domain\n";
}

if ( -f "/etc/security/limits.d/gsh-$user.conf" ) {
        die "[!] User already appears to be whitelisted\n";
}

open(my $WAT, '>', "/etc/security/limits.d/gsh-$user.conf");
        print $WAT "$user    -       cpu             UNLIMITED\n";
close($WAT);
print "[*] Conf written for $user:\n";
open(my $DAT, '<', "/etc/security/limits.d/gsh-$user.conf");
        while(<$DAT>) {
                print $_;
        }
close($DAT);
EOF
