From 8e1ce1476e6248dad850c0436eaa19164b0c1f4c Mon Sep 17 00:00:00 2001 From: Elijah Perrault Date: Fri, 11 Mar 2011 21:53:04 -0700 Subject: [PATCH] auto.pid saves to the correct location and CertFP works. --- bin/auto | 18 ++++++++++++++++-- lib/Lib/Auto.pm | 7 ++++--- 2 files changed, 20 insertions(+), 5 deletions(-) diff --git a/bin/auto b/bin/auto index f987709..57ead01 100755 --- a/bin/auto +++ b/bin/auto @@ -19,7 +19,7 @@ use DBI; use Class::Unload; use FindBin qw($Bin); our $Bin = $Bin; ## no critic qw(NamingConventions::Capitalization Variables::ProhibitPackageVars) -our %bin; +our (%bin, $UPREFIX); BEGIN { $bin{cwd} = getcwd; if (!-e "$Bin/../build/syswide") { @@ -38,6 +38,7 @@ BEGIN { $bin{bld} = "$Bin/../build"; $bin{lng} = "$Bin/../lang"; } + $UPREFIX = 1; } else { # Must be a standard install. @@ -46,6 +47,7 @@ BEGIN { $bin{lib} = "$Bin/../lib"; $bin{bld} = "$Bin/../build"; $bin{lng} = "$Bin/../lang"; + $UPREFIX = 0; } unshift @INC, $bin{lib}; @@ -119,6 +121,14 @@ if ($BFVER[0] ne VER.q{.}.SVER.q{.}.REV.RSTAGE."\n") { } undef @BFVER; +# Check build path setup. +our $SYSWIDE; +open my $BFPATH, '<', "$bin{bld}/syswide" or say 'Cannot start: Broken build.' and exit; +my @BFPATH = <$BFPATH>; +close $BFPATH or say 'Cannot start: Broken build.' and exit; +if ($BFPATH[0] eq "1\n") { $SYSWIDE = 1 } +else { $SYSWIDE = 0 } + # Set signal handlers. local $SIG{TERM} = \&Lib::Auto::signal_term; local $SIG{INT} = \&Lib::Auto::signal_int; @@ -405,7 +415,11 @@ if (!$DEBUG) { $APID = fork; if ($APID != 0) { alog '* Successfully forked into the background. Process ID: '.$APID; - open my $FPID, '>', "$Bin/auto.pid" or exit; + # Figure out where to throw auto.pid. + my $pidfile; + if ($UPREFIX) { $pidfile = "$bin{cwd}/auto.pid" } + else { $pidfile = "$Bin/auto.pid" } + open my $FPID, '>', $pidfile or exit; print {$FPID} "$APID\n" or exit; close $FPID or exit; exit; diff --git a/lib/Lib/Auto.pm b/lib/Lib/Auto.pm index 27b62d1..b4c9dd1 100644 --- a/lib/Lib/Auto.pm +++ b/lib/Lib/Auto.pm @@ -183,10 +183,10 @@ sub ircsock { if ($cdata->{'certfp'}[0] eq 1) { $conndata{'SSL_use_cert'} = 1; if (defined $cdata->{'certfp_cert'}[0]) { - $conndata{'SSL_cert_file'} = "$Auto::Bin/../etc/certs/".$cdata->{'certfp_cert'}[0]; + $conndata{'SSL_cert_file'} = "$Auto::bin{etc}/certs/".$cdata->{'certfp_cert'}[0]; } if (defined $cdata->{'certfp_key'}[0]) { - $conndata{'SSL_key_file'} = "$Auto::Bin/../etc/certs/".$cdata->{'certfp_key'}[0]; + $conndata{'SSL_key_file'} = "$Auto::bin{etc}/certs/".$cdata->{'certfp_key'}[0]; } if (defined $cdata->{'certfp_pass'}[0]) { $conndata{'SSL_passwd_cb'} = sub { return $cdata->{'certfp_pass'}[0]; }; @@ -239,7 +239,8 @@ sub ircsock { # Shutdown. hook_add('on_shutdown', 'shutdown.core_cleanup', sub { if (defined $Auto::DB) { $Auto::DB->disconnect; } - if (-e "$Auto::Bin/auto.pid") { unlink "$Auto::Bin/auto.pid"; } + if ($Auto::UPREFIX) { if (-e "$Auto::bin{cwd}/auto.pid") { unlink "$Auto::bin{cwd}/auto.pid"; } } + else { if (-e "$Auto::Bin/auto.pid") { unlink "$Auto::Bin/auto.pid"; } } return 1; });