-
Notifications
You must be signed in to change notification settings - Fork 0
/
Virtufile
executable file
·121 lines (101 loc) · 5.7 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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
<?php
Namespace Model ;
class Virtufile extends VirtufileBase {
public $config ;
public function __construct() {
ini_set('display_errors', 0) ;
error_reporting(E_ALL & ~E_NOTICE);
$this->setConfig();
}
private function setConfig() {
$variables = array() ;
require (__DIR__.DIRECTORY_SEPARATOR.'vars'.DIRECTORY_SEPARATOR.'vm.php') ;
// var_dump('vfile vars', __DIR__.DIRECTORY_SEPARATOR.'vars'.DIRECTORY_SEPARATOR.'vm.php', $variables) ;
$this->setDefaultConfig();
$this->config["vm"]["name"] = 'iso_php_example_application' ;
// $this->config["vm"]["name"] = strtolower(basename(dirname(__FILE__))) ;
$this->config["vm"]["gui_mode"] = "gui" ;
$bu = 'https://repositories.internal.pharaohtools.com/index.php?control=BinaryServer&action=serve&item=iso_php_virtualize_boxes_-_ubuntu_16.04_server' ;
$this->config["vm"]["box_url"] = $bu ;
$this->config["vm"]["box"] = "isophpexampleapp" ;
$random_port_suffix = '78' ;
$this->config["vm"]["cpus"] = "2" ;
$this->config["vm"]["memory"] = "8192" ;
$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["network"]["natpf1"][] = "{$this->config["vm"]["name"]}_guestmobile,tcp,,88{$random_port_suffix},,8000";
$this->config["network"]["natpf1"][] = "{$this->config["vm"]["name"]}_guestsocket,tcp,,3000,,3000";
$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" ;
# Shared folder - This should map to the workstation environment vhost path parent...
$this->config["vm"]["shared_folders"][] =
array(
"name" => "host_www",
"host_path" => getcwd().DIRECTORY_SEPARATOR,
"guest_path" => "/var/www/hostshare/",
"symlinks" => "enable"
) ;
# Provisioning
$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' => "/var/www/hostshare",
'vars' => '/var/www/hostshare/vars/vm.php',
'step-times' => 'true',
'step-numbers' => 'true') ;
$this->config["vm"]["provision"][] =
[ "provisioner" => "PharaohTools",
"tool" => "ptconfigure",
"target" => "guest",
"script" => "/var/www/hostshare/build/ptc/development.dsl.php",
"params" => $dsl_params ] ;
$this->config["vm"]["provision"][] =
[ "provisioner" => "PharaohTools",
"tool" => "ptconfigure",
"target" => "guest",
"script" => "/var/www/hostshare/build/ptc/build-web-client-application.dsl.php",
"params" => array_merge($dsl_params, ['uniter_build_level' => 'production']) ] ;
$this->config["vm"]["provision"][] =
[ "provisioner" => "PharaohTools",
"tool" => "ptconfigure",
"target" => "guest",
"script" => "/var/www/hostshare/build/ptc/build-web-server-application.dsl.php",
"params" => $dsl_params ] ;
$description = (isset($variables['description'])) ? "\n\n{$variables['description']}\n\n" : '' ;
$this->config["vm"]["post_up_message"] = "Your ISOPHP Virtualize Box has been brought up. $description
You now have the following urls:\n\n
http://build.{$variables['domain']}:80{$random_port_suffix}/ - Build Server\n
http://www.{$variables['domain']}:80{$random_port_suffix}/ - Web Client Application\n
http://www.{$variables['domain']}:88{$random_port_suffix}/ - Mobile Application Web Emulator \n
http://server.{$variables['domain']}:80{$random_port_suffix}/ - Web Server Application\n
http://server.{$variables['domain']}:80{$random_port_suffix}/php_lite_admin/phpliteadmin.php - DB Admin Application\n\n
You can SSH into the VM with this:\n\n
ssh {$this->config['ssh']['user']}@127.0.0.1 -p22{$random_port_suffix} - SSH Connection\n
The password is {$this->config['ssh']['password']} \n";
}
}