aboutsummaryrefslogtreecommitdiffstats
path: root/config/lightsquid/lightsquid.inc
diff options
context:
space:
mode:
authorjim-p <jimp@pfsense.org>2015-02-10 14:34:45 -0500
committerjim-p <jimp@pfsense.org>2015-02-10 14:34:45 -0500
commitd09b446a62d3e6cb3f5ea4ef4cb5391050bf226e (patch)
tree17fac8045f17bc0f1d2f17ca5b2d2b4a8437b54f /config/lightsquid/lightsquid.inc
parent65b006785bead6b2361eed28d546444593a30ded (diff)
downloadpfsense-packages-d09b446a62d3e6cb3f5ea4ef4cb5391050bf226e.tar.gz
pfsense-packages-d09b446a62d3e6cb3f5ea4ef4cb5391050bf226e.tar.bz2
pfsense-packages-d09b446a62d3e6cb3f5ea4ef4cb5391050bf226e.zip
Various fixes for lightsquid on 2.2
Diffstat (limited to 'config/lightsquid/lightsquid.inc')
-rw-r--r--config/lightsquid/lightsquid.inc42
1 files changed, 37 insertions, 5 deletions
diff --git a/config/lightsquid/lightsquid.inc b/config/lightsquid/lightsquid.inc
index 4b31bc30..399e0572 100644
--- a/config/lightsquid/lightsquid.inc
+++ b/config/lightsquid/lightsquid.inc
@@ -45,8 +45,11 @@ switch ($pfs_version) {
case "2.0":
define('LIGHTSQUID_BASE','/usr/local');
break;
- default:
+ case "2.1":
define('LIGHTSQUID_BASE', '/usr/pbi/lightsquid-' . php_uname("m"));
+ break;
+ default:
+ define('LIGHTSQUID_BASE', '/usr/pbi/lightsquid-' . php_uname("m") . '/local');
}
define ('CMD_PKGDELETE', 'pkg_delete lightsquid-1.7.1');
@@ -117,19 +120,38 @@ function lightsquid_install() {
// create lightsquid report catalog
if (!file_exists(LS_REPORTPATH)) {
update_log("lightsquid_install: Create report dir " . LS_REPORTPATH);
- mwexec("mkdir -p " . LS_REPORTPATH);
+ mwexec("/bin/mkdir -p " . LS_REPORTPATH);
}
// install templates
$lstpl_file = "/var/tmp/lightsquid_tpl.tbz";
if (file_exists($lstpl_file)) {
- mwexec("tar zxvf $lstpl_file -C " . LS_TEMPLATEPATH);
+ mwexec("/usr/bin/tar zxvf $lstpl_file -C " . LS_TEMPLATEPATH);
update_log("lightsquid_install: Install templates from $lstpl_file");
}
# check perl
- if (!file_exists("/usr/bin/perl"))
- mwexec("ln -s /usr/local/bin/perl /usr/bin/perl");
+ $perl_path = '/usr/bin/perl';
+
+ /* Clean up a bad perl link. */
+ ls_cleanup_bad_link($perl_path);
+
+ if (!file_exists("/usr/bin/perl")) {
+ if (is_executable('/usr/local/bin/perl')) {
+ symlink('/usr/local/bin/perl', '/usr/bin/perl');
+ } elseif (is_executable(LIGHTSQUID_BASE . '/bin/perl')) {
+ symlink(LIGHTSQUID_BASE . '/bin/perl', '/usr/bin/perl');
+ }
+ }
+ if (!is_dir('/usr/local/lib/perl5') && is_dir(LIGHTSQUID_BASE . '/lib/perl5')) {
+ symlink(LIGHTSQUID_BASE . '/lib/perl5', '/usr/local/lib/perl5');
+ }
+ if (!is_dir('/usr/local/etc/lightsquid') && is_dir(LS_CONFIGPATH)) {
+ symlink(LS_CONFIGPATH, '/usr/local/etc/lightsquid');
+ }
+ if (!is_dir('/usr/local/www/lightsquid') && is_dir(LS_WWWPATH)) {
+ symlink(LS_WWWPATH, '/usr/local/www/lightsquid');
+ }
update_log("lightsquid_install: stopped");
}
@@ -436,4 +458,14 @@ function ls_get_real_interface_address($iface)
return array($ip, long2ip(hexdec($netmask)));
}
+/* If a path is a symlink but the target is missing, remove the link. */
+function ls_cleanup_bad_link($link) {
+ if (file_exists($link) && is_link($link)) {
+ $target = readlink($link);
+ if (!file_exists($target) || !is_executable($target)) {
+ unlink($link);
+ }
+ }
+}
+
?> \ No newline at end of file