Skip to content
Snippets Groups Projects
Forked from opentrafficshaper / opentrafficshaper
389 commits behind the upstream repository.
opentrafficshaperd 6.49 KiB
#!/usr/bin/perl
# Main OpenTrafficShaper program
# Copyright (C) 2007-2013, AllWorldIT
# 
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

use strict;
use warnings;


# Set the dirs we look for library files in
use lib('/usr/local/lib/opentrafficshaper-1.0','/usr/lib/opentrafficshaper-1.0',
		'/usr/lib64/opentrafficshaper-1.0','opentrafficshaper','awitpt');

# System stuff we need
use Config::IniFiles;
use Getopt::Long;
use POE;
use POSIX qw(setsid);
use Time::HiRes qw(time);

# Our own stuff
use opentrafficshaper::version;
use opentrafficshaper::logger;


# Main config
my $globals;
# We just create the logger first, its only using STDERR here
my $logger = new opentrafficshaper::logger;


#
# MAIN
#
$logger->log(LOG_NOTICE,"[MAIN] OpenTrafficShaper v".VERSION." - Copyright (c) 2007-2013, AllWorldIT");
parseCfgCmdLine();
init();

$logger->log(LOG_NOTICE,"[MAIN] Starting...");
POE::Kernel->run();
exit;





# Function to parse our config and commandline
sub parseCfgCmdLine
{

	# Set defaults
	my $cfg;
	$cfg->{'config_file'} = "/etc/opentrafficshaper.conf";

#	$cfg->{'timeout'} = 120;
#	$cfg->{'background'} = "yes";
#	$cfg->{'pid_file'} = "/var/run/opentrafficshaper/opentrafficshaperd.pid";
#	$cfg->{'log_level'} = 2;