forked from mklkj/php-node-composer-npm
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstall_deployer.php
39 lines (28 loc) · 848 Bytes
/
install_deployer.php
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
<?php
$version = $_ENV['DEPLOYER_VERSION'];
echo "Downloading Deployer manifest file...\n";
$manifest = json_decode(file_get_contents('https://deployer.org/manifest.json'), true);
$sha1 = $url = null;
foreach ($manifest as $manifestEntry)
{
if ($manifestEntry['version'] == $version)
{
$sha1 = $manifestEntry['sha1'];
$url = $manifestEntry['url'];
break;
}
}
if (null == $sha1)
{
throw new Exception("Deployer version `$version` not found in manifest.");
}
echo "Downloading Deployer version $version...\n";
file_put_contents("/bin/dep", fopen($url, 'r'));
echo "Checking downloaded file...\n";
if (sha1_file("/bin/dep") != $sha1)
{
throw new Exception("Deployer download seems to be corrupt.");
}
echo "Making Deployer writeable...\n";
exec('chmod +x /bin/dep');
echo "Deployer installed.\n";