check if nipe.pl is run by root

exit with error message otherwise
master
Slavik Svyrydiuk 2020-06-07 13:15:27 +02:00
parent 9e628df1a3
commit 54aa817802
No known key found for this signature in database
GPG Key ID: E9BD8C827FB23D9E
1 changed files with 6 additions and 5 deletions

11
nipe.pl
View File

@ -13,11 +13,12 @@ use Nipe::Utils::Helper;
use Nipe::Utils::Install;
sub main {
my $argument = $ARGV[0];
die "$0 must be run as root" if $> != 0;
my $argument = $ARGV[0];
if ($argument) {
my $commands = {
stop => "Nipe::Engine::Stop",
stop => "Nipe::Engine::Stop",
start => "Nipe::Engine::Start",
status => "Nipe::Utils::Status",
restart => "Nipe::Engine::Restart",
@ -32,16 +33,16 @@ sub main {
print $exec;
}
}
catch {
print "\n[!] ERROR: this command could not be run\n\n";
};
return 1;
}
return print Nipe::Utils::Helper -> new();
}
main();
exit;
exit;