-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.php
More file actions
132 lines (94 loc) · 3.68 KB
/
Copy pathinstall.php
File metadata and controls
132 lines (94 loc) · 3.68 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
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
122
123
124
125
126
127
128
129
130
<?php
class Install {
/*** change to your need ***/
private $wwwRoot = "";
/******/
private $env = '.env';
private $zipFile = 'inventorycontrol-master.zip';
private $isWin = false;
private $update = false;
public function __construct() {
if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') {
$this->isWin = true;
}
}
public function install() {
if($this->wwwRoot == "") {
echo "No docment root given!\n\n";
return false;
}
if(!file_exists($this->zipFile)) {
echo "File $this->zipFile do not exist in the current directory!\n\n";
return false;
}
if($this->isWin == false) {
$icrootPath = $this->wwwRoot . '/inventorycontrol/';
$this->extract();
$this->renameDir();
$this->copyDir();
$this->copyEnvFile();
$this->generteKey($icrootPath);
$this->migrate($icrootPath);
$this->changeOwner($icrootPath);
$this->storageLink($icrootPath);
$this->message();
return true;
} else {
echo "Windows not yet supported!\n";
echo "You have to install it manualy!\n";
return false;
}
}
private function extract() {
$retCode = exec("unzip $this->zipFile", $retArr, $retVal);
echo "extract: $retCode\n\n";
}
private function renameDir() {
$retCode = rename('inventorycontrol-master', 'inventorycontrol');
echo "renameDir: $retCode\n\n";
}
private function copyDir() {
$dest = $this->wwwRoot . '/inventorycontrol';
$retCode = exec("mv inventorycontrol $dest");
//$retCode = rename('./inventorycontrol', $this->wwwRoot . "/inventorycontrol");
echo "copyDir: $retCode\n\n";
}
private function copyEnvFile() {
$retCode = copy($this->env, $this->wwwRoot . "/inventorycontrol/$this->env");
echo "copyEnvFile: $retCode\n\n";
}
private function generteKey($icrootpath) {
$command = "php " . $icrootpath . "artisan key:generate";
//echo "The command: " . $command . "\n";
$retCode = exec($command, $retArr, $retVal);
echo "generteKey: $retCode\n\n";
}
private function migrate($icrootpath) {
$command = "php " . $icrootpath . "artisan migrate";
echo "Type yes to proceed the migration\n";
$retCode = exec($command, $retArr, $retVal);
echo "migrate: $retCode\n\n";
}
private function storageLink($icrootPath) {
$command = "php " . $icrootPath . "artisan storage:link";
$retCode = exec($command, $retArr, $retVal);
echo "storageLink: $retCode\n\n";
}
private function changeOwner($icrootPath) {
$command = "chmod -R 755 $icrootPath";
$retCode = exec($command, $retArr, $retVal);
echo "changeMod: $retCode\n\n";
$command = "chown -R www-data:www-data $icrootPath";
$retCode = exec($command, $retArr, $retVal);
echo "changeOwner: $retCode\n\n";
}
private function message() {
echo "Add the cron job for couter reset.\n";
echo "The command have to be called from $this->wwwRoot/inventorycontrol directory.\n";
echo "weekly: php artisan weeklyreset:cron\n";
echo "monthly: php artisan monthlyreset:cron\n";
echo "yearly: php artisan yearlyreset:cron\n";
}
}
$install = new Install;
$install->install();