root/tags/omega-1.0.0-rc3/engine/ispcp-serv-mngr

Revision 765, 7.0 kB (checked in by raphael, 1 year ago)

Fixed #586: deleting domain-alias does not work when domain has ftp accounts
Fixed #589: wrong image names
Added comments support to the tr() function
Replaced all ISPCP with ispCP
Fixed #417: Add gender field
Fixed a missing double percent sign
Fixed #594: Blank page on Add Admin
Fixed #588: $rs not always defined
Added missing user_gui_props entry for primary administrator
Added postgrey, AMaViS and spamassassin to the server_ports list
Updated es_ES.po (thanks to Albert Garcia)

Line 
1 #!/usr/bin/perl
2
3 # ispCP ω (OMEGA) a Virtual Hosting Control Panel
4 # Copyright (c) 2001-2006 by moleSoftware GmbH
5 # http://www.molesoftware.com
6 # Copyright (c) 2006-2007 by isp Control Panel
7 # http://isp-control.net
8 #
9 #
10 # License:
11 #    This program is free software; you can redistribute it and/or
12 #    modify it under the terms of the MPL Mozilla Public License
13 #    as published by the Free Software Foundation; either version 1.1
14 #    of the License, or (at your option) any later version.
15 #
16 #    This program is distributed in the hope that it will be useful,
17 #    but WITHOUT ANY WARRANTY; without even the implied warranty of
18 #    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19 #    MPL Mozilla Public License for more details.
20 #
21 #    You may have received a copy of the MPL Mozilla Public License
22 #    along with this program.
23 #
24 #    An on-line copy of the MPL Mozilla Public License can be found
25 #    http://www.mozilla.org/MPL/MPL-1.1.html
26 #
27 #
28 # The ISPCP ω Home Page is at:
29 #
30 #    http://isp-control.net
31 #
32
33 use FindBin;
34 use lib "$FindBin::Bin/";
35 require 'ispcp_common_code.pl';
36
37 use strict;
38
39 use warnings;
40
41 sub serv_mngr_start_up {
42
43     my ($rs, $rdata) = (undef, undef);
44
45     push_el(\@main::el, 'serv_mngr_start_up()', 'Starting...');
46
47     # checking for master process;
48
49     $rs = check_master();
50
51     return $rs if ($rs != 0);
52
53     # Let's clear Execution Logs, if any.
54
55     if (-e $main::ispcp_serv_mngr_el) {
56
57         $rs = del_file($main::ispcp_serv_mngr_el);
58
59         return $rs if ($rs != 0);
60
61     }
62
63     # config check;
64
65     $rs = get_conf();
66
67     return $rs if ($rs != 0);
68
69     # license request check;
70
71     #($rs, $rdata) = license_request();
72
73     #return $rs if ($rs != 0);
74
75     #
76     # License conditions must be stand here;
77     #
78
79     # sql check;
80
81     #
82     # getting initial data also must be done here;
83     #
84
85     my $sql = "
86         SELECT
87                 domain_id,
88                 domain_name,
89                 domain_gid,
90                 domain_uid,
91                 domain_admin_id,
92                 domain_created_id,
93                 domain_created,
94                 domain_last_modified,
95                 domain_mailacc_limit,
96                 domain_ftpacc_limit,
97                 domain_traffic_limit,
98                 domain_sqld_limit,
99                 domain_sqlu_limit,
100                 domain_status,
101                 domain_alias_limit,
102                 domain_subd_limit,
103                 domain_ip_id,
104                 domain_disk_limit,
105                 domain_disk_usage,
106                 domain_php,
107                 domain_cgi
108         FROM
109                 domain
110     ";
111
112     ($rs, $rdata) = doSQL($sql);
113
114     return $rs if ($rs != 0);
115
116     $main::changed_dmn_cnt = $ARGV[0]."";
117
118     $main::changed_sub_cnt = $ARGV[1]."";
119
120     $main::changed_als_cnt = $ARGV[2]."";
121
122     $main::changed_mail_cnt = $ARGV[3]."";
123
124     push_el(\@main::el, 'serv_mngr_start_up()', 'Ending...');
125
126     return 0;
127
128 }
129
130 sub serv_mngr_shut_down {
131
132     my $rs = undef;
133
134     push_el(\@main::el, 'serv_mngr_shut_down()', 'Starting...');
135
136     push_el(\@main::el, 'serv_mngr_shut_down()', 'Ending...');
137
138     return 0;
139
140 }
141
142 sub restart_httpd {
143
144     my ($cmd, $rs, $rdata) = (undef, undef, undef);
145
146     push_el(\@main::el, 'restart_httpd()', 'Starting...');
147
148     $cmd = $main::cfg{'CMD_HTTPD'};
149
150     sys_command_rs("$cmd stop");
151
152     sleep(5);
153
154     sys_command_rs("$cmd start");
155
156     sleep(5);
157
158     push_el(\@main::el, 'restart_httpd()', 'Ending...');
159
160 }
161
162 sub check_httpd {
163
164     my ($cmd, $rs, $rdata) = (undef, undef, undef);
165
166     push_el(\@main::el, 'check_httpd()', 'Starting...');
167
168     $cmd = "export COLUMNS=120;$main::cfg{'CMD_PS'} aux | $main::cfg{'CMD_AWK'} '\$0 ~/$main::cfg{'APACHE_NAME'}/ {print \$0}' | $main::cfg{'CMD_WC'} | $main::cfg{'CMD_AWK'} '{print \$1}' 1>/tmp/httpd-run-check.stdout";
169
170     $rs = sys_command($cmd);
171
172     return ($rs, 0) if ($rs != 0);
173
174     ($rs, $rdata) = get_file("/tmp/httpd-run-check.stdout");
175
176     return ($rs, 0) if ($rs != 0);
177
178     push_el(\@main::el, 'check_httpd()', 'Ending...');
179
180     chop($rdata);
181
182     my $pids = $rdata;
183
184     ($rs, $rdata) = del_file("/tmp/httpd-run-check.stdout");
185
186     return ($rs, 0) if ($rs != 0);
187
188     return (0, $pids);
189
190 }
191
192 sub serv_mngr_engine {
193
194     my ($cmd, $rs, $rdata) = (undef, undef, undef);
195
196     push_el(\@main::el, 'serv_mngr_engine()', 'Starting...');
197
198
199     if ($main::changed_mail_cnt > 0 || $main::changed_dmn_cnt > 0 || $main::changed_sub_cnt > 0) {
200
201         if ($main::cfg{'CMD_MTA'} ne 'no') {
202
203             $cmd = $main::cfg{'CMD_MTA'};
204
205             sys_command_rs("$cmd stop");
206
207         }
208
209         if ($main::cfg{'CMD_AUTHD'} ne 'no') {
210
211             $cmd = $main::cfg{'CMD_AUTHD'};
212
213             sys_command_rs("$cmd stop");
214
215         }
216
217                 if ($main::cfg{'CMD_AMAVIS'} ne 'no') {
218
219                         $cmd = $main::cfg{'CMD_AMAVIS'};
220
221                         sys_command_rs("$cmd stop");
222
223                 }
224
225
226         if ($main::cfg{'CMD_IMAP'} ne 'no') {
227
228             $cmd = $main::cfg{'CMD_IMAP'};
229
230             sys_command_rs("$cmd stop");
231
232         }
233
234         if ($main::cfg{'CMD_POP'} ne 'no') {
235
236             $cmd = $main::cfg{'CMD_POP'};
237
238             sys_command_rs("$cmd stop");
239
240         }
241
242     }
243
244     if ($main::changed_dmn_cnt > 0 || $main::changed_sub_cnt > 0 || $main::changed_als_cnt > 0) {
245
246         if ($main::cfg{'CMD_NAMED'} ne 'no') {
247
248             $cmd = $main::cfg{'CMD_NAMED'};
249
250             sys_command_rs("$cmd restart");
251
252         }
253
254     }
255
256     if ($main::changed_mail_cnt > 0 || $main::changed_dmn_cnt > 0 ||
257         $main::changed_sub_cnt > 0 || $main::changed_als_cnt > 0) {
258
259         if ($main::cfg{'CMD_MTA'} ne 'no') {
260
261             $cmd = $main::cfg{'CMD_MTA'};
262
263             sys_command_rs("$cmd start");
264
265         }
266
267
268         if ($main::cfg{'CMD_AUTHD'} ne 'no') {
269
270             $cmd = $main::cfg{'CMD_AUTHD'};
271
272             sys_command_rs("$cmd start");
273
274         }
275
276                 if ($main::cfg{'CMD_AMAVIS'} ne 'no') {
277
278                 $cmd = $main::cfg{'CMD_AMAVIS'};
279
280                 sys_command_rs("$cmd start");
281
282                 }
283
284         if ($main::cfg{'CMD_IMAP'} ne 'no') {
285
286             $cmd = $main::cfg{'CMD_IMAP'};
287
288             sys_command_rs("$cmd start");
289
290         }
291
292         if ($main::cfg{'CMD_POP'} ne 'no') {
293
294             $cmd = $main::cfg{'CMD_POP'};
295
296             sys_command_rs("$cmd start");
297
298         }
299
300     }
301
302     if ($main::changed_dmn_cnt > 0 || $main::changed_sub_cnt > 0 || $main::changed_als_cnt > 0) {
303
304         if ($main::cfg{'CMD_HTTPD'} ne 'no') {
305
306             $cmd = $main::cfg{'CMD_HTTPD'};
307
308             sys_command_rs("$cmd restart");
309
310             sleep(3);
311
312         }
313
314         if ($main::cfg{'CMD_HTTPD'} ne 'no') {
315
316             ($rs, $rdata) = check_httpd();
317
318             return $rs if ($rs != 0);
319
320             if ($rdata == 0) {
321
322                 my $i = 1;
323
324                 do {
325
326                     restart_httpd();
327
328                     ($rs, $rdata) = check_httpd();
329
330                     return $rs if ($rs != 0);
331
332                     $i++;
333
334                 } while ($rdata == 0 && $i <= $main::cfg{'APACHE_RESTART_TRY'});
335             }
336
337         }
338
339     }
340
341     push_el(\@main::el, 'serv_mngr_engine()', 'Ending...');
342
343     return 0;
344
345 }
346
347 my $rs = undef;
348
349 $rs = serv_mngr_start_up();
350
351 if ($rs != 0) {
352
353     dump_el(\@main::el, $main::ispcp_serv_mngr_el);
354
355     serv_mngr_shut_down();
356
357     exit 1;
358
359 }
360
361 $rs = serv_mngr_engine();
362
363 if ($rs != 0) {
364
365     dump_el(\@main::el, $main::ispcp_serv_mngr_el);
366
367     serv_mngr_shut_down();
368
369     exit 1;
370
371 }
372
373 $rs = serv_mngr_shut_down();
374
375 if ($rs != 0) {
376
377     dump_el(\@main::el, $main::ispcp_serv_mngr_el);
378
379     exit 1;
380
381 }
382
383 exit 0;
Note: See TracBrowser for help on using the browser.