-
Notifications
You must be signed in to change notification settings - Fork 2
/
Virtufile
100 lines (82 loc) · 4.4 KB
/
Virtufile
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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
<?php
Namespace Model ;
class Virtufile extends VirtufileBase {
public $config ;
public function __construct() {
$this->setConfig();
}
private function setConfig() {
$variables = array() ;
require (__DIR__.DIRECTORY_SEPARATOR.'vars'.DIRECTORY_SEPARATOR.'vm.php') ;
$this->setDefaultConfig();
$this->config["vm"]["name"] = 'pharaoh_'.$variables['friendly_app_slug'] ;
$this->config["vm"]["gui_mode"] = "headless" ;
$this->config["vm"]["box"] = "ubuntu16046server-64bit" ;
$this->config["vm"]["box_url"] = "https://repositories.internal.pharaohtools.com/index.php?control=BinaryServer&action=serve&item=ubuntu_ptv&version=18.04.02&group=server-64bit" ;
$random_port_suffix = $variables['random_port_suffix'] ;
$this->config["vm"]["memory"] = "512" ;
$this->config["vm"]["graceful_halt_timeout"] = 15 ;
$this->config["vm"]["ssh_halt_timeout"] = 2 ;
$this->config["network"]["natpf1"][] = "{$this->config["vm"]["name"]}_guestssh,tcp,,22{$random_port_suffix},,22";
$this->config["network"]["natpf1"][] = "{$this->config["vm"]["name"]}_guestweb,tcp,,80{$random_port_suffix},,80";
$this->config["ssh"]["driver"] = "native" ;
$this->config["ssh"]["user"] = "ptv" ;
$this->config["ssh"]["password"] = "ptv" ;
$this->config["ssh"]["target"] = "127.0.0.1" ;
$this->config["ssh"]["port"] = "22{$random_port_suffix}" ;
$this->config["ssh"]["retries"] = "1000" ;
$guest_path = '/opt/'.$variables['full_slug'].'/'.$variables['full_slug'].'/' ;
# Shared folder - This should map to the workstation environment vhost path parent...
$this->config["vm"]["shared_folders"][] =
array(
"name" => "host_".$variables['full_slug'],
"host_path" => getcwd().DS,
"guest_path" => $guest_path,
) ;
# Provisioning
$this->config["vm"]["provision"][] =
[ "provisioner" => "Shell",
"tool" => "shell",
"target" => "guest",
"default" => "GuestAdditions" ];
$this->config["vm"]["provision"][] =
[ "provisioner" => "Shell",
"tool" => "shell",
"target" => "guest",
"default" => "MountShares" ];
$this->config["vm"]["provision"][] =
[ "provisioner" => "Shell",
"tool" => "shell",
"target" => "guest",
"default" => "PTConfigureInit",
"force" => true ];
$i_path = dirname(__FILE__).DS ;
$this->config["vm"]["provision"][] = $this->config["vm"]["provision_up_light"][] =
[ "provisioner" => "PharaohTools",
"tool" => "ptdeploy",
"target" => "host",
"script" => $i_path.'build'.DS.'ptd'.DS.'add-hostfile-entry.dsl.php',
"params" => array("vars" => $i_path.'vars'.DS.'vm.php'), ] ;
$this->config["vm"]["provision_destroy_post"][] =
[ "provisioner" => "PharaohTools", "tool" => "ptdeploy", "target" => "host",
"script" => $i_path.'build'.DS.'ptd'.DS.'remove-hostfile-entry.dsl.php',
"params" => array("vars" => $i_path.'vars'.DS.'vm.php') ] ;
$dsl_params = array('start-dir' => "{$guest_path}",
'vars' => "{$guest_path}vars/vm.php",
'step-times' => 'true',
'step-numbers' => 'true') ;
$this->config["vm"]["provision"][] =
[ "provisioner" => "PharaohTools",
"tool" => "ptconfigure",
"target" => "guest",
"script" => "{$guest_path}build/ptc/development.dsl.php",
"params" => $dsl_params ] ;
$description = (isset($variables['description'])) ? "\n\nPharaoh Tools: {$variables['description']}\n\n" : '' ;
$this->config["vm"]["post_up_message"] = "Your Virtual Machine is running. $description
You now have the following urls:\n\n
http://build.{$variables['domain']}:80{$random_port_suffix}/ - Build Server\n\n
You can SSH into the VM with this:\n\n
ssh -o PreferredAuthentications=password -o PubkeyAuthentication=no {$this->config['ssh']['user']}@127.0.0.1 -p 22{$random_port_suffix}\n
The password is {$this->config['ssh']['password']} \n";
}
}