Alternc
latest
Alternc logiel libre pour l'hébergement
alternc-ssl.install.php
Go to the documentation of this file.
1
#!/usr/bin/php
2
<?php
3
/*
4
at alternc.install time
5
synchronize the required domain templates with the current install
6
(do they have php52, roundcube, squirrelmail, etc.?)
7
*/
8
if
($argv[1] ==
"templates"
) {
9
// install ssl.conf
10
echo
"[alternc-ssl] Installing ssl.conf template\n"
;
11
copy(
"/etc/alternc/templates/apache2/mods-available/ssl.conf"
,
"/etc/apache2/mods-available/ssl.conf"
);
12
if
(!is_dir(
'/var/run/alternc-ssl'
)) {
13
mkdir(
"/var/run/alternc-ssl"
);
14
}
15
chown(
"/var/run/alternc-ssl"
,
"alterncpanel"
);
16
chgrp(
"/var/run/alternc-ssl"
,
"alterncpanel"
);
17
// replace open_basedir line if necessary :
18
exec(
'sed -i -e "s#:/var/run/alternc#:/var/run#" -e "s#:/run/alternc#:/run#" /etc/alternc/apache2.conf /etc/alternc/templates/alternc/apache2.conf'
);
19
}
20
21
if
($argv[1] ==
"before-reload"
) {
22
// Bootstrap
23
require_once(
"/usr/share/alternc/panel/class/config_nochk.php"
);
24
25
echo
"[alternc-ssl] Installing domaines-types\n"
;
26
$db
->query(
"INSERT IGNORE INTO `domaines_type` (name, description, target, entry, compatibility, enable, only_dns, need_dns, advanced ) VALUES
27
('vhost-ssl', 'Locally hosted forcing HTTPS', 'DIRECTORY', '%SUB% IN A @@PUBLIC_IP@@', 'vhost,url,txt,defmx,defmx2,mx,mx2', 'ALL', 0, 0, 0);"
);
28
29
$db
->query(
"INSERT IGNORE INTO `domaines_type` (name, description, target, entry, compatibility, enable, only_dns, need_dns, advanced ) VALUES
30
('vhost-mixssl', 'Locally hosted HTTP and HTTPS', 'DIRECTORY', '%SUB% IN A @@PUBLIC_IP@@', 'vhost,url,txt,defmx,defmx2,mx,mx2', 'ALL', 0, 0, 1);"
);
31
32
$db
->query(
"INSERT IGNORE INTO `domaines_type` (name, description, target, entry, compatibility, enable, only_dns, need_dns, advanced ) VALUES
33
('panel-ssl', 'HTTPS AlternC panel access', 'NONE', '%SUB% IN A @@PUBLIC_IP@@', 'txt,mx,mx2,defmx,defmx2', 'ALL', 0, 0, 1);"
);
34
35
$db
->query(
"INSERT IGNORE INTO `domaines_type` (name, description, target, entry, compatibility, enable, only_dns, need_dns, advanced ) VALUES
36
('url-ssl', 'URL redirection, HTTP & HTTPS', 'URL', '%SUB% IN A @@PUBLIC_IP@@', 'txt,mx,mx2,defmx,defmx2', 'ALL', 0, 0, 1);"
);
37
38
$db
->query(
"SELECT * FROM domaines_type WHERE name='roundcube';"
);
39
if
(
$db
->next_record()) {
40
$db
->query(
"INSERT IGNORE INTO `domaines_type` (name, description, target, entry, compatibility, enable, only_dns, need_dns, advanced ) VALUES
41
('roundcube-ssl', 'HTTPS Roundcube Webmail', 'NONE', '%SUB% IN A @@PUBLIC_IP@@', 'mx,mx2,defmx,defmx2,txt', 'ALL', 0, 0, 1);"
);
42
}
else
{
43
$db
->query(
"DELETE FROM domaines_type WHERE name='roundcube-ssl';"
);
44
$db
->query(
"UPDATE sub_domaines SET web_action='DELETE' WHERE type='roundcube-ssl';"
);
45
}
46
47
$db
->query(
"SELECT * FROM domaines_type WHERE name='squirrelmail';"
);
48
if
(
$db
->next_record()) {
49
$db
->query(
"INSERT IGNORE INTO `domaines_type` (name, description, target, entry, compatibility, enable, only_dns, need_dns, advanced ) VALUES
50
('squirrelmail-ssl', 'HTTPS Squirrelmail Webmail', 'NONE', '%SUB% IN A @@PUBLIC_IP@@', 'mx,mx2,defmx,defmx2,txt', 'ALL', 0, 0, 1);"
);
51
}
else
{
52
$db
->query(
"DELETE FROM domaines_type WHERE name='squirrelmail-ssl';"
);
53
$db
->query(
"UPDATE sub_domaines SET web_action='DELETE' WHERE type='squirrelmail-ssl';"
);
54
}
55
56
$db
->query(
"SELECT * FROM domaines_type WHERE name='php52';"
);
57
if
(
$db
->next_record()) {
58
$db
->query(
"INSERT IGNORE INTO `domaines_type` (name, description, target, entry, compatibility, enable, only_dns, need_dns, advanced ) VALUES
59
('php52-ssl', 'php52 forcing HTTPS', 'DIRECTORY', '%SUB% IN A @@PUBLIC_IP@@', 'vhost,url,txt,defmx,defmx2,mx,mx2', 'ALL', 0, 0, 0);"
);
60
$db
->query(
"INSERT IGNORE INTO `domaines_type` (name, description, target, entry, compatibility, enable, only_dns, need_dns, advanced ) VALUES
61
('php52-mixssl', 'php52 HTTP and HTTPS', 'DIRECTORY', '%SUB% IN A @@PUBLIC_IP@@', 'vhost,url,txt,defmx,defmx2,mx,mx2', 'ALL', 0, 0, 0);"
);
62
}
else
{
63
$db
->query(
"DELETE FROM domaines_type WHERE name='php52-ssl';"
);
64
$db
->query(
"UPDATE sub_domaines SET web_action='DELETE' WHERE type='php52-ssl';"
);
65
$db
->query(
"DELETE FROM domaines_type WHERE name='php52-mixssl';"
);
66
$db
->query(
"UPDATE sub_domaines SET web_action='DELETE' WHERE type='php52-mixssl';"
);
67
}
68
69
// Enable name-based virtual hosts in Apache2 :
70
$f
= fopen(
"/etc/apache2/ports.conf"
,
"rb"
);
71
if
(!
$f
) {
72
echo
"FATAL: there is no /etc/apache2/ports.conf ! I can't configure name-based virtual hosts\n"
;
73
}
else
{
74
$found
=
false
;
75
while
($s = fgets(
$f
, 1024)) {
76
if
(preg_match(
":^[^#]*NameVirtualHost.*443:"
, $s)) {
77
$found
=
true
;
78
break
;
79
}
80
}
81
fclose(
$f
);
82
if
(!
$found
) {
83
$f
= fopen(
"/etc/apache2/ports.conf"
,
"ab"
);
84
fputs(
$f
,
"\n<IfModule mod_ssl.c>\n NameVirtualHost *:443\n\n</IfModule>\n"
);
85
fclose(
$f
);
86
}
87
}
88
}
// before-reload
$found
$found
Definition:
aws_del.php:29
$f
$f
Definition:
alternc_fix_myadm_users.php:9
$db
global $db
Definition:
bootstrap.php:22
ssl
alternc-ssl.install.php
Generated on Thu Jun 21 2018 12:00:08 for Alternc by
1.8.13