-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathssh-test.php
More file actions
55 lines (53 loc) · 1.6 KB
/
Copy pathssh-test.php
File metadata and controls
55 lines (53 loc) · 1.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="robots" content="noindex">
<title>Simple PHP Git deploy script</title>
<style>
body { padding: 0 1em; background: #222; color: #fff; }
h2, .error { color: #c33; }
.prompt { color: #6be234; }
.command { color: #729fcf; }
.output { color: #999; }
</style>
</head>
<body>
<pre>
Checking the environment ...
Running as <b><?php echo trim(shell_exec('whoami')); ?></b>.
<?php
$requiredBinaries = array('git', 'rsync');
if (defined('BACKUP_DIR') && BACKUP_DIR !== false) {
$requiredBinaries[] = 'tar';
if (!is_dir(BACKUP_DIR) || !is_writable(BACKUP_DIR)) {
die(sprintf('<div class="error">BACKUP_DIR `%s` does not exists or is not writeable.</div>', BACKUP_DIR));
}
}
if (defined('USE_COMPOSER') && USE_COMPOSER === true) {
$requiredBinaries[] = 'composer --no-ansi';
}
foreach ($requiredBinaries as $command) {
$path = trim(shell_exec('which '.$command));
if ($path == '') {
die(sprintf('<div class="error"><b>%s</b> not available. It needs to be installed on the server for this script to work.</div>', $command));
} else {
$version = explode("\n", shell_exec($command.' --version'));
printf('<b>%s</b> : %s'."\n"
, $path
, $version[0]
);
}
}
$tmp = array();
$command = 'eval `ssh-agent -s`;/usr/bin/expect /var/www/deploy/ssh.sh;ssh-add -l';
exec($command.' 2>&1', $tmp, $return_code); // Execute the command
echo "<pre>";
var_dump($tmp);
echo "</pre>";
/*
$tmp = array();
exec("ssh-add 2>&1", $tmp, $return_code);
echo "<pre>";
var_dump($tmp);
echo "</pre>";*/