-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathInstaller.php
More file actions
63 lines (55 loc) · 1.41 KB
/
Installer.php
File metadata and controls
63 lines (55 loc) · 1.41 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
56
57
58
59
60
61
62
63
<?php
class Installer
{
/**
* For Composer post-create-project-cmd
*
* @return void
*/
public static function postCreateProject()
{
self::processChmod();
self::processLn();
}
/**
* Make command for Deployer
*
* @return void
*/
public static function processChmod()
{
$result = chmod(__DIR__ . '/deployer', 0755);
if ($result) {
echo "chmod deployer success.\n";
} else {
echo "chmod deployer failed.\n";
}
}
/**
* Make command for Deployer
*
* @return void
*/
public static function processLn()
{
$binDir = '/usr/bin';
$ln = "{$binDir}/deployer";
if (!is_dir($binDir)) {
echo "{$binDir} doesn't exist for {$ln}.\n";
return;
}
if (file_exists($ln)) {
echo "{$ln} already exist.\n";
return;
}
$cmd = "sudo ln -s " . __DIR__ . "/deployer {$binDir}/deployer";
exec($cmd);
if (file_exists($ln)) {
echo "Make deployer in {$binDir} success.\n";
echo "You could run by command: `$ deployer`\n";
} else {
echo "Make deployer in {$binDir} failed.\n";
echo "You could manual execute `$cmd`\n";
}
}
}