Use Path::Class for path and file name construction consistently

This commit is contained in:
Oliver Gorwits
2013-02-24 21:14:53 +00:00
parent edfb0f3e24
commit 981383c307
5 changed files with 13 additions and 10 deletions

View File

@@ -2,11 +2,12 @@
use strict;
use warnings FATAL => 'all';
use Path::Class 'file';
BEGIN {
eval "use Daemon::Control";
if ($@) {
exec("$ENV{HOME}/bin/localenv", $0, @ARGV);
exec(file($ENV{HOME}, 'bin', 'localenv'), $0, @ARGV);
}
}
@@ -14,12 +15,12 @@ use Path::Class;
my $log_dir = dir($ENV{HOME}, 'logs');
mkdir $log_dir if ! -d $log_dir;
my $program = "$ENV{HOME}/bin/netdisco-daemon-fg";
my $program = file($ENV{HOME}, 'bin', 'netdisco-daemon-fg');
Daemon::Control->new({
name => 'Netdisco Daemon',
program => ($ENV{NETDISCO_DAEMON} || $program),
pid_file => "$ENV{HOME}/netdisco-daemon.pid",
pid_file => file($ENV{HOME}, 'netdisco-daemon.pid'),
stderr_file => file($log_dir, 'netdisco-daemon.log'),
stdout_file => file($log_dir, 'netdisco-daemon.log'),
})->run;

View File

@@ -14,6 +14,7 @@ use Term::ReadLine;
use Archive::Extract;
use HTTP::Tiny;
use Try::Tiny;
use Path::Class 'file';
=head1 netdisco-deploy
@@ -108,7 +109,7 @@ sub deploy_oui {
sub deploy_mibs {
my $url = 'http://downloads.sourceforge.net/project/netdisco/netdisco-mibs/latest-snapshot/netdisco-mibs-snapshot.tar.gz';
my $file = "$ENV{HOME}/netdisco-mibs-snapshot.tar.gz";
my $file = file($ENV{HOME}, 'netdisco-mibs-snapshot.tar.gz');
my $resp = HTTP::Tiny->new->mirror($url, $file);
if ($resp->{success}) {

View File

@@ -2,23 +2,23 @@
use strict;
use warnings FATAL => 'all';
use Path::Class;
BEGIN {
eval "use Daemon::Control";
if ($@) {
exec("$ENV{HOME}/bin/localenv", $0, @ARGV);
exec(file($ENV{HOME}, 'bin', 'localenv'), $0, @ARGV);
}
}
use Path::Class;
my $log_dir = dir($ENV{HOME}, 'logs');
mkdir $log_dir if ! -d $log_dir;
Daemon::Control->new({
name => 'Netdisco Web',
program => 'plackup',
program_args => ["$ENV{HOME}/bin/netdisco-web-fg"],
pid_file => "$ENV{HOME}/netdisco-web.pid",
program_args => [file($ENV{HOME}, 'bin', 'netdisco-web-fg')],
pid_file => file($ENV{HOME}, 'netdisco-web.pid'),
stderr_file => file($log_dir, 'netdisco-web.log'),
stdout_file => file($log_dir, 'netdisco-web.log'),
})->run;