-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstall.php
170 lines (121 loc) · 3.84 KB
/
install.php
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
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
<?PHP
/*
* CmsTool Installer
*
* Install.php handles the installation of the CmsTool. The result will be a full
* installation of the CmsTool plugins and a template of a website. That way you
* can start working directly on the project.
*
* Be aware that the installer has 2 steps, after running this script you need
* to run install2.php otherwise the installation won't be complete.
*
*/
//login with ssh to the webserver
//move to the root folder of your application, most of the time: accountsname/domainname.com/
//enter command:
//git clone git://github.com/lucfranken/CmsToolInstaller.git
//CHECK THE RESULT!: You now should have: accountsname/domainname.com/CmsToolInstaller/install.php
//IF NOT DO NOT PROCEED, REMOVE ALL and try again
//run the install.php script
echo 'CmsToolInstaller starting step 1/2'."\n\n";
//check this can only be run from CLI
if(PHP_SAPI != 'cli') {
die('Install only directly on server allowed.');
}
/*
* Works with structure as explained above only
*
*/
//directory from which the installer is started
$currentDir=dirname(__FILE__);
if(basename($currentDir)!='CmsToolInstaller') {
die('Run this script from directory CmsToolInstaller');
}
//ROOT directories as explained above
$hostingDir=realpath($currentDir.'/../../').'/';
$domainDir=realpath($currentDir.'/../').'/';
//specific directories
$sshDir=$hostingDir.'.ssh/';
$pluginsDir=$domainDir.'pluginsmanaged/';
//temporary directory to clone cakephp in
$tmpCakeDir=$domainDir.'caketmp/';
//Application directory to put the template in
$appDir=$domainDir.'app/';
//Directory of the installer (will be removed after installation)
$installerDir=$domainDir.'CmsToolInstaller/';
echo 'CmsToolInstaller will be installing in:
'.$domainDir."\n\n";
/*
* Check and configure directories
*
*
*/
echo 'SSH directory setup in: '.$sshDir."\n\n";
@mkdir($sshDir);
if(!is_dir($sshDir)) {
var_dump($sshDir);
die('SSH Directory is not available at this path');
}
/*
* SSH SETUP
*
*
*/
if(!file_exists($sshDir.'github.pub')) {
echo 'GitHub SSH key not available so generating'."\n\n";
//install ssh key
$command='ssh-keygen -t rsa -N "" -f '.$sshDir.'github';
shell_exec($command);
//copy config file
copy('sshconfig/config', $sshDir.'config');
echo 'SSH key generated!'."\n\n";
echo 'The following key needs to be added to the GitHub account:'."\n\n";
echo file_get_contents($sshDir.'github.pub')."\n\n";
}
/*
* CakePHP SETUP
*
* We install CakePHP from the GitHub account into a tmp folder. From that
* folder we move the needed directories for our setup.
*
* We create an app_example directory but we suggest using a pre-defined template
* installation with all CMS presets defined.
*
*
*/
if(!is_dir($domainDir.'lib')) {
echo 'Start downloading and installation of CakePHP'."\n\n";
$command='git clone git://github.com/cakephp/cakephp.git '.$tmpCakeDir;
shell_exec($command);
//move lib folder to definitive location
shell_exec('mv '.$tmpCakeDir.'lib'.' '.$domainDir.'lib');
//move htaccess file
shell_exec('mv '.$tmpCakeDir.'.htaccess'.' '.$domainDir.'.htaccess');
//remove the tmp CakePHP folder
shell_exec('rm -Rf '.$tmpCakeDir);
echo 'Installation of CakePHP done'."\n\n";
}
/*
* Create plugins directory
*
* Creates a directory and readme for the plugins.
*
*/
@mkdir($pluginsDir);
//write a note that no one should install plugins here manually
file_put_contents($pluginsDir.'README.txt', 'WARNING: Do not install plugins here manually, plugins in here are automatically installed.');
echo 'Created plugins directory'."\n\n";
/*
* Finalize and inform user
*
*
*/
echo 'CmsToolInstaller
Installation complete. Congratulations!
Your next steps:
1. Add following SSH key to the account
';
echo file_get_contents($sshDir.'github.pub');
echo '
2. After adding the key run php install2.php for installation of the first plugins.
';