-
Notifications
You must be signed in to change notification settings - Fork 25
/
imscp-autoinstall
executable file
·206 lines (169 loc) · 6.78 KB
/
imscp-autoinstall
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
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
#!/usr/bin/perl
# i-MSCP - internet Multi Server Control Panel
# Copyright 2010 - 2011 by internet Multi Server Control Panel
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#
# @category i-MSCP
# @copyright 2010 - 2011 by i-MSCP | http://i-mscp.net
# @author Daniel Andreca <[email protected]>
# @version SVN: $Id$
# @link http://i-mscp.net i-MSCP Home Site
# @license http://www.gnu.org/licenses/gpl-2.0.html GPL v2
#####################################################################################
# Script description:
#
# This script is responsible to build the i-MSCP tree into a temporary folder from
# the upstream archive. This script can optionnaly installing all i-MSCP dependencies
# and launch the i-MSCP setup/update script. It attemp to detect the target
# distribution, process backup taskq and save the current GUI working data in update
# mode before doing any changes on the files system. In case the target distribution
# cannot be detected, the script exit with a specific error message.
use strict;
use warnings;
use FindBin;
use lib "$FindBin::Bin";
use lib "$FindBin::Bin/engine/PerlLib";
use lib "$FindBin::Bin/engine/PerlVendor";
umask(027);
use iMSCP::Debug;
use iMSCP::Dialog;
use iMSCP::SO;
use iMSCP::Config;
use iMSCP::Dir;
newDebug('imscp-build.log');
require "$FindBin::Bin/library/autoinstall-methods.pl";
use iMSCP::Requirements;
iMSCP::Requirements->new()->user();
if(preInstall()){
error("Unable to install pre-required packages");
exit 1;
}
# Entering in silent mode
silent(1);
iMSCP::Dialog->factory()->infobox("\\ZuDetecting the target distribution\\Zn");
my $SO = iMSCP::SO->new();
my $rs = $SO->getSO();
exit $rs if $rs;
# Display the i-MSCP README file
use iMSCP::File;
my $file = iMSCP::File->new(filename => $FindBin::Bin.'/README');
my $content = $file->get() or fatal("Unable to find the $FindBin::Bin/README file.");
iMSCP::Dialog->factory()->msgbox($content);
if(
iMSCP::Dialog->factory()->yesno(
"\nThe Installer detected that you are using $SO->{Distribution} $SO->{CodeName}. Is this ok?"
)
) {
error(
"Sorry, the installer failing to detect your distribution.\n\n" .
"Note: For now, only Debian like operating systems are supported."
);
exit 1;
}
my $defaultConf = "$FindBin::Bin/configs/" . lc($SO->{Distribution}) . "/imscp.conf";
tie %main::defaultConf, 'iMSCP::Config','fileName' => $defaultConf;
# A supported distribution was detected
use iMSCP::Stepper;
my @steps = (
[\&installDependencies, "Installing all required $SO->{Distribution} packages for i-MSCP"],
[\&testRequirements, 'Testing i-MSCP requirements'],
[\&processConfFile, "Loading $SO->{Distribution} specific variables"],
[\&processSpecificConfFile, 'Processing distribution specific configuration files'],
[\&buildImscpDaemon, 'Building i-MSCP daemon'],
[\&installEngine, 'Installing engine files'],
[\&installGui, 'Installing GUI files'],
[\&InstallDistMaintainerScripts, 'Installing distribution maintainer scripts'],
[\&finishBuild, 'Processing post-build tasks'],
[\&cleanUpTmp, 'Processing cleanup tasks']
);
my $step = 1;
for (@steps) {
$rs = step($_->[0], $_->[1], scalar @steps, $step);
exit $rs if $rs;
$step++;
}
iMSCP::Dialog->factory()->endGauge() if iMSCP::Dialog->factory()->needGauge();
my @warnings = getMessageByType('WARNING');
my @errors = getMessageByType('ERROR');
my $msg;
if (@errors > 0 || @warnings > 0) {
$msg = "\n\\Z".(@errors > 0 ? 1 : 3 )."Build step finished but with ".
(@errors > 0 ? 'errors' : 'warnings') . ":\\Zn\n";
$msg .= "\nWARNINGS:\n".join("\n", @warnings)."\n" if @warnings > 0;
$msg .= "\nERRORS:\n".join("\n", @errors)."\n" if @errors > 0;
iMSCP::Dialog->factory()->set('defaultno', '');
} else {
$msg = "\n\\Z2 -> Build step finished without errors\n";
}
$msg .= "\nDo you want to continue the i-MSCP installation?";
unless(iMSCP::Dialog->factory()->yesno($msg)) {
iMSCP::Dialog->factory()->set('defaultno', undef);
require "$FindBin::Bin/engine/setup/imscp-setup-methods.pl";
@steps = (
[\&doImscpBackup, 'Backup existing installation'],
[\&saveGuiWorkingData, 'Saving GUI working data'],
[\&installTmp, 'Installing new i-MSCP files in final destination'],
[\&setup_start_up, 'Prepare i-MSCP setup/update'],
[\&setup_engine, 'Processing i-MSCP setup/update']
);
$step = 1;
for (@steps){
$rs = step($_->[0], $_->[1], scalar @steps, $step);
exit $rs if $rs;
$step++;
}
iMSCP::Dialog->factory()->endGauge() if iMSCP::Dialog->factory()->needGauge();
iMSCP::Dialog->factory()->msgbox("i-MSCP $main::defaultConf{Version} was successfully installed on your system.");
iMSCP::Dialog->factory()->infobox("Removing temporary files...");
$rs = removeTmp();
exit $rs;
} else {
# Nuxwin review recommendation:
# I think this part must be because in future, we will support another
# distributions such as openSUSE where the install process can be different.
# I think the better is to provide link to our wiki based on the distro name
# when a howto (for manual install/update) is available.
iMSCP::Dialog->factory()->msgbox(
"To continue setup run from console\n\n".
"1. Purge all GUI sessions files\n\n".
"\t# rm -Rf /var/www/imscp/gui/data/sessions\n\n".
"2. Backup needed files\n\n".
"\t# cp -Rfv /var/www/imscp/gui/data /tmp/imscp/var/www/imscp/gui\n".
"\t# cp -Rfv /var/www/imscp/gui/public/tools/webmail/data ".
"/tmp/imscp/var/www/imscp/gui/public/tools/webmail\n\n".
"3. Delete old directories:\n\n".
"\t# rm -Rf /var/www/imscp/{daemon,engine,gui}\n\n".
"4. Copy directories into your system (you may make backups)\n\n".
"\t# cp -R /tmp/imscp/* / \n\n".
"5. Clean tmp\n\n".
"\t# rm -R /tmp/imscp\n\n".
"6. Now it's time to update your installation.".
"Change into the engine directory\n\n".
"\t# cd /var/www/imscp/engine/setup\n\n".
"7. Start the engine update\n\n".
"\t# perl imscp-setup\n\n".
"8. Update i-MSCP step-by-step\n\n".
"If you get no error, all went good; if you get one, look at ".
"http://forum.i-mscp.net to solve the problem."
);
}
0;
END{
my $exitCode = $?;
my $logdir = $main::defaultConf{LOG_DIR} || '/tmp';
iMSCP::Dir->new(dirname => $logdir)->make() unless -d $logdir;
$? = $exitCode;
}