#!/usr/bin/env php . * * @package LibreNMS * @link http://librenms.org * @copyright 2017 Tony Murray * @author Tony Murray */ $install_dir = realpath(__DIR__ . '/..'); chdir($install_dir); $use_https = true; // Set up proxy if needed, check git config for proxies too if ($proxy = getenv("HTTPS_PROXY") ?: getenv("https_proxy")) { $use_https = true; } elseif ($proxy = getenv("HTTP_PROXY") ?: getenv("http_proxy")) { $use_https = false; } elseif ($proxy = trim(shell_exec('git config --global --get https.proxy'))) { putenv("HTTPS_PROXY=$proxy"); $use_https = true; } elseif ($proxy = trim(shell_exec('git config --global --get http.proxy'))) { putenv("HTTP_PROXY=$proxy"); $use_https = false; } $exec = false; $path_exec = shell_exec("which composer 2> /dev/null"); if (!empty($path_exec)) { $exec = trim($path_exec); } elseif (is_file($install_dir . '/composer.phar')) { $exec = 'php ' . $install_dir . '/composer.phar'; } else { if ($proxy) { $stream_default_opts = array( ($use_https ? 'https' : 'http') => array( 'proxy' => str_replace(array('http://', 'https://'), 'tcp://', $proxy), 'request_fulluri' => true, ) ); stream_context_set_default($stream_default_opts); } // Download composer.phar (code from the composer web site) $good_sha = trim(@file_get_contents(($use_https ? 'https' : 'http') . '://composer.github.io/installer.sig')); // Download composer.phar (code from the composer web site) @copy(($use_https ? 'https' : 'http') . '://getcomposer.org/installer', 'composer-setup.php'); if (!empty($good_sha) && @hash_file('SHA384', 'composer-setup.php') === $good_sha) { // Installer verified shell_exec('php composer-setup.php'); $exec = 'php ' . $install_dir . '/composer.phar'; } else { echo "Corrupted download.\n"; } @unlink('composer-setup.php'); } if ($exec) { passthru("$exec " . implode(' ', array_splice($argv, 1)) . ' 2>&1'); } else { echo "Composer not available, please manually install composer.\n"; }