<?php /* Yeah, it's a hack If you are looking to change some details of the actual deploy, change the deploy method code in ploy itself. This file is just a web wrapper. */ ignore_user_abort(true); set_time_limit(0); include '../ploy.php'; $ploy = new Ploy(); $log_file = __DIR__ . "/logs/ploy-{$ploy->rev}.txt"; $ploy->ini_file = '../ploy.ini'; $ploy->user = '******'; $ploy->home = "/var/lib/nginx"; $ploy->log->loud = true; $ploy->config(); // This is a local script that sets $vpnuser // Substitute your own here include './vpnuser.php'; // Create a MySQL user and password and use it here if (!($m = mysql_connect('localhost', 'root'))) { echo "Unable to connect to MySQL<br>\n"; exit; } mysql_select_db('ploy'); $res = mysql_query("select * from ploys order by ts desc limit 5"); while ($row = mysql_fetch_assoc($res)) { $last5[] = $row; }
private function options(&$argv) { // Code borrowed from mpartap at gmx dot net via http://php.net/getopt $parameters = array('v' => 'verbose', 'q' => 'quiet', 'h' => 'help', 'c:' => 'config:', 'u:' => 'user', 'p' => 'prompt', 't:' => 'tmpdir'); $options = getopt(implode('', array_keys($parameters)), $parameters); $pruneargv = array(); foreach ($options as $option => $value) { foreach ($argv as $key => $chunk) { $regex = '/^' . (isset($option[1]) ? '--' : '-') . $option . '/'; if ($chunk == $value && $argv[$key - 1][0] == '-' || preg_match($regex, $chunk)) { array_push($pruneargv, $key); } } } while ($key = array_pop($pruneargv)) { unset($argv[$key]); } $argv = array_values($argv); // Re-number if (isset($options['h']) || isset($options['help']) || empty($argv[1])) { Ploy::usage(); exit; } if (isset($options['q']) || isset($options['quiet'])) { $this->log->quiet = true; } if (isset($options['v']) || isset($options['verbose'])) { $this->log->loud = true; } if (isset($options['p']) || isset($options['prompt'])) { $this->prompt = true; } if (isset($options['t'])) { $this->tmpdir = $options['t']; } if (isset($options['tmpdir'])) { $this->tmpdir = $options['tmpdir']; } if (isset($options['c'])) { $this->ini_file = $options['c']; } if (isset($options['config'])) { $this->ini_file = $options['config']; } else { if ($tmp = getenv('PLOYINI')) { $this->ini_file = $tmp; } } if (!is_readable($this->ini_file)) { $this->log->error("Unable to load Ploy configuration from {$this->ini_file}."); } if (isset($options['u'])) { $this->user = $options['u']; } else { if (isset($options['user'])) { $this->user = $options['user']; } else { if (!empty($_SERVER['SUDO_USER'])) { $this->user = $_SERVER['SUDO_USER']; } else { if (!empty($_SERVER['USER'])) { $this->user = $_SERVER['USER']; } else { $this->log->error("Unable to determine local user - please use -u <user>"); } } } } if (!empty($_SERVER['HOME'])) { if (basename($_SERVER['HOME']) == $this->user) { $this->home = $_SERVER['HOME']; } else { $this->home = dirname($_SERVER['HOME']) . '/' . $this->user; } } else { $this->home = "/home/" . $this->user; } }