new structure
parent
58481157c7
commit
d2bf6f6f8b
|
@ -0,0 +1,22 @@
|
|||
#!/usr/bin/env perl
|
||||
|
||||
package Nipe::Helper;
|
||||
|
||||
sub new {
|
||||
print "
|
||||
\r\Core Commands
|
||||
\r==============
|
||||
\r\tCommand Description
|
||||
\r\t------- -----------
|
||||
\r\tinstall Install dependencies
|
||||
\r\tstart Start routing
|
||||
\r\tstop Stop routing
|
||||
\r\trestart Restart the Nipe process
|
||||
\r\tstatus See status
|
||||
|
||||
\rCopyright (c) 2015 - 2020 | Heitor Gouvêa\n\n";
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
1;
|
|
@ -0,0 +1,45 @@
|
|||
#!/usr/bin/env perl
|
||||
|
||||
package Nipe::Install;
|
||||
|
||||
use Nipe::Device;
|
||||
|
||||
sub new {
|
||||
my $operationalSystem = Nipe::Device -> getSystem();
|
||||
|
||||
system ("sudo mkdir -p /etc/tor");
|
||||
|
||||
if ($operationalSystem eq "debian") {
|
||||
system ("sudo apt-get install tor iptables");
|
||||
system ("sudo cp .configs/debian-torrc /etc/tor/torrc");
|
||||
}
|
||||
|
||||
elsif ($operationalSystem eq "fedora") {
|
||||
system ("sudo dnf install tor iptables");
|
||||
system ("sudo cp .configs/fedora-torrc /etc/tor/torrc");
|
||||
}
|
||||
|
||||
elsif ($operationalSystem eq "centos") {
|
||||
system ("sudo yum install epel-release tor iptables");
|
||||
system ("sudo cp .configs/centos-torrc /etc/tor/torrc");
|
||||
}
|
||||
|
||||
else {
|
||||
system ("sudo pacman -S tor iptables");
|
||||
system ("sudo cp .configs/arch-torrc /etc/tor/torrc");
|
||||
}
|
||||
|
||||
system ("sudo chmod 644 /etc/tor/torrc");
|
||||
|
||||
if (-e "/etc/init.d/tor") {
|
||||
system ("sudo /etc/init.d/tor stop > /dev/null");
|
||||
}
|
||||
|
||||
else {
|
||||
system ("sudo systemctl stop tor");
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
1;
|
|
@ -0,0 +1,15 @@
|
|||
#!/usr/bin/env perl
|
||||
|
||||
package Nipe::Restart;
|
||||
|
||||
use Nipe::Stop;
|
||||
use Nipe::Start;
|
||||
|
||||
sub new {
|
||||
Nipe::Stop -> new();
|
||||
Nipe::Start -> new();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
1;
|
|
@ -1,6 +1,6 @@
|
|||
#!/usr/bin/env perl
|
||||
|
||||
package Nipe::CheckIp;
|
||||
package Nipe::Status;
|
||||
|
||||
use JSON;
|
||||
use LWP::UserAgent;
|
15
nipe.pl
15
nipe.pl
|
@ -5,8 +5,10 @@ use Switch;
|
|||
use lib "./lib/";
|
||||
use Nipe::Stop;
|
||||
use Nipe::Start;
|
||||
use Nipe::CheckIp;
|
||||
use Nipe::Functions;
|
||||
use Nipe::Status;
|
||||
use Nipe::Helper;
|
||||
use Nipe::Restart;
|
||||
use Nipe::Install;
|
||||
|
||||
sub main {
|
||||
my $command = $ARGV[0];
|
||||
|
@ -19,17 +21,16 @@ sub main {
|
|||
Nipe::Start -> new();
|
||||
}
|
||||
case "status" {
|
||||
Nipe::CheckIp -> new();
|
||||
Nipe::Status -> new();
|
||||
}
|
||||
case "restart" {
|
||||
Nipe::Stop -> new();
|
||||
Nipe::Start -> new();
|
||||
Nipe::Restart -> new();
|
||||
}
|
||||
case "install" {
|
||||
Nipe::Functions -> install();
|
||||
Nipe::Install -> new();
|
||||
}
|
||||
|
||||
Nipe::Functions -> help();
|
||||
Nipe::Helper -> new();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue