|
1
|
|
|
<?php |
|
2
|
|
|
/* |
|
3
|
|
|
* MikoPBX - free phone system for small business |
|
4
|
|
|
* Copyright © 2017-2023 Alexey Portnov and Nikolay Beketov |
|
5
|
|
|
* |
|
6
|
|
|
* This program is free software: you can redistribute it and/or modify |
|
7
|
|
|
* it under the terms of the GNU General Public License as published by |
|
8
|
|
|
* the Free Software Foundation; either version 3 of the License, or |
|
9
|
|
|
* (at your option) any later version. |
|
10
|
|
|
* |
|
11
|
|
|
* This program is distributed in the hope that it will be useful, |
|
12
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
13
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
14
|
|
|
* GNU General Public License for more details. |
|
15
|
|
|
* |
|
16
|
|
|
* You should have received a copy of the GNU General Public License along with this program. |
|
17
|
|
|
* If not, see <https://www.gnu.org/licenses/>. |
|
18
|
|
|
*/ |
|
19
|
|
|
|
|
20
|
|
|
namespace MikoPBX\Core\System\Configs; |
|
21
|
|
|
|
|
22
|
|
|
|
|
23
|
|
|
use MikoPBX\Core\System\Processes; |
|
24
|
|
|
use MikoPBX\Core\System\Util; |
|
25
|
|
|
|
|
26
|
|
|
/** |
|
27
|
|
|
* Class VMWareToolsConf |
|
28
|
|
|
* |
|
29
|
|
|
* Represents the VMWareTools configuration. |
|
30
|
|
|
* |
|
31
|
|
|
* @package MikoPBX\Core\System\Configs |
|
32
|
|
|
*/ |
|
33
|
|
|
class VMWareToolsConf |
|
34
|
|
|
{ |
|
35
|
|
|
/** |
|
36
|
|
|
* Configure and start VMWareTools. |
|
37
|
|
|
* |
|
38
|
|
|
* @return bool |
|
39
|
|
|
*/ |
|
40
|
|
|
public function configure(): bool |
|
41
|
|
|
{ |
|
42
|
|
|
Processes::killByName("vmtoolsd"); |
|
43
|
|
|
|
|
44
|
|
|
$conf = "[logging]\n" |
|
45
|
|
|
. "log = false\n" |
|
46
|
|
|
. "vmtoolsd.level = none\n" |
|
47
|
|
|
. ";vmsvc.data = /dev/null\n" |
|
48
|
|
|
. "vmsvc.level = none\n"; |
|
49
|
|
|
|
|
50
|
|
|
$dirVM = '/etc/vmware-tools'; |
|
51
|
|
|
if (!file_exists($dirVM)) { |
|
52
|
|
|
Util::mwMkdir($dirVM); |
|
53
|
|
|
} |
|
54
|
|
|
|
|
55
|
|
|
file_put_contents("{$dirVM}/tools.conf", $conf); |
|
56
|
|
|
$vmtoolsdPath = Util::which('vmtoolsd'); |
|
57
|
|
|
$result = Processes::mwExec("{$vmtoolsdPath} --background=/var/run/vmtoolsd.pid > /dev/null 2> /dev/null"); |
|
58
|
|
|
|
|
59
|
|
|
return $result === 0; |
|
60
|
|
|
} |
|
61
|
|
|
} |