diff --git a/lib/Nipe/Helper.pm b/lib/Nipe/Helper.pm new file mode 100644 index 0000000..73455d3 --- /dev/null +++ b/lib/Nipe/Helper.pm @@ -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; \ No newline at end of file diff --git a/lib/Nipe/Install.pm b/lib/Nipe/Install.pm new file mode 100644 index 0000000..bdec86f --- /dev/null +++ b/lib/Nipe/Install.pm @@ -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; \ No newline at end of file diff --git a/lib/Nipe/Restart.pm b/lib/Nipe/Restart.pm new file mode 100644 index 0000000..448f40a --- /dev/null +++ b/lib/Nipe/Restart.pm @@ -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; \ No newline at end of file diff --git a/lib/Nipe/CheckIp.pm b/lib/Nipe/Status.pm similarity index 96% rename from lib/Nipe/CheckIp.pm rename to lib/Nipe/Status.pm index 65e6d67..84c0d2c 100644 --- a/lib/Nipe/CheckIp.pm +++ b/lib/Nipe/Status.pm @@ -1,6 +1,6 @@ #!/usr/bin/env perl -package Nipe::CheckIp; +package Nipe::Status; use JSON; use LWP::UserAgent; diff --git a/nipe.pl b/nipe.pl index 585b991..49b3dc2 100755 --- a/nipe.pl +++ b/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(); } }