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  mkdir("/var/run/alternc-ssl");
13  chown("/var/run/alternc-ssl","alterncpanel");
14  chgrp("/var/run/alternc-ssl","alterncpanel");
15  // replace open_basedir line if necessary :
16  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');
17 }
18 
19 if ($argv[1] == "before-reload") {
20  // Bootstrap
21  require_once("/usr/share/alternc/panel/class/config_nochk.php");
22 
23  echo "[alternc-ssl] Installing domaines-types\n";
24  $db->query("INSERT IGNORE INTO `domaines_type` (name, description, target, entry, compatibility, enable, only_dns, need_dns, advanced ) VALUES
25  ('vhost-ssl', 'Locally hosted forcing HTTPS', 'DIRECTORY', '%SUB% IN A @@PUBLIC_IP@@', 'vhost,url,txt,defmx,defmx2,mx,mx2', 'ALL', 0, 0, 0);");
26 
27  $db->query("INSERT IGNORE INTO `domaines_type` (name, description, target, entry, compatibility, enable, only_dns, need_dns, advanced ) VALUES
28  ('vhost-mixssl', 'Locally hosted HTTP and HTTPS', 'DIRECTORY', '%SUB% IN A @@PUBLIC_IP@@', 'vhost,url,txt,defmx,defmx2,mx,mx2', 'ALL', 0, 0, 1);");
29 
30  $db->query("INSERT IGNORE INTO `domaines_type` (name, description, target, entry, compatibility, enable, only_dns, need_dns, advanced ) VALUES
31  ('panel-ssl', 'HTTPS AlternC panel access', 'NONE', '%SUB% IN A @@PUBLIC_IP@@', 'txt,mx,mx2,defmx,defmx2', 'ALL', 0, 0, 1);");
32 
33  $db->query("INSERT IGNORE INTO `domaines_type` (name, description, target, entry, compatibility, enable, only_dns, need_dns, advanced ) VALUES
34  ('url-ssl', 'URL redirection, HTTP & HTTPS', 'URL', '%SUB% IN A @@PUBLIC_IP@@', 'txt,mx,mx2,defmx,defmx2', 'ALL', 0, 0, 1);");
35 
36  $db->query("SELECT * FROM domaines_type WHERE name='roundcube';");
37  if ($db->next_record()) {
38  $db->query("INSERT IGNORE INTO `domaines_type` (name, description, target, entry, compatibility, enable, only_dns, need_dns, advanced ) VALUES
39  ('roundcube-ssl', 'HTTPS Roundcube Webmail', 'NONE', '%SUB% IN A @@PUBLIC_IP@@', 'mx,mx2,defmx,defmx2,txt', 'ALL', 0, 0, 1);");
40  } else {
41  $db->query("DELETE FROM domaines_type WHERE name='roundcube-ssl';");
42  $db->query("UPDATE sub_domaines SET web_action='DELETE' WHERE type='roundcube-ssl';");
43  }
44 
45  $db->query("SELECT * FROM domaines_type WHERE name='squirrelmail';");
46  if ($db->next_record()) {
47  $db->query("INSERT IGNORE INTO `domaines_type` (name, description, target, entry, compatibility, enable, only_dns, need_dns, advanced ) VALUES
48  ('squirrelmail-ssl', 'HTTPS Squirrelmail Webmail', 'NONE', '%SUB% IN A @@PUBLIC_IP@@', 'mx,mx2,defmx,defmx2,txt', 'ALL', 0, 0, 1);");
49  } else {
50  $db->query("DELETE FROM domaines_type WHERE name='squirrelmail-ssl';");
51  $db->query("UPDATE sub_domaines SET web_action='DELETE' WHERE type='squirrelmail-ssl';");
52  }
53 
54  $db->query("SELECT * FROM domaines_type WHERE name='php52';");
55  if ($db->next_record()) {
56  $db->query("INSERT IGNORE INTO `domaines_type` (name, description, target, entry, compatibility, enable, only_dns, need_dns, advanced ) VALUES
57  ('php52-ssl', 'php52 forcing HTTPS', 'DIRECTORY', '%SUB% IN A @@PUBLIC_IP@@', 'vhost,url,txt,defmx,defmx2,mx,mx2', 'ALL', 0, 0, 0);");
58  $db->query("INSERT IGNORE INTO `domaines_type` (name, description, target, entry, compatibility, enable, only_dns, need_dns, advanced ) VALUES
59  ('php52-mixssl', 'php52 HTTP and HTTPS', 'DIRECTORY', '%SUB% IN A @@PUBLIC_IP@@', 'vhost,url,txt,defmx,defmx2,mx,mx2', 'ALL', 0, 0, 0);");
60  } else {
61  $db->query("DELETE FROM domaines_type WHERE name='php52-ssl';");
62  $db->query("UPDATE sub_domaines SET web_action='DELETE' WHERE type='php52-ssl';");
63  $db->query("DELETE FROM domaines_type WHERE name='php52-mixssl';");
64  $db->query("UPDATE sub_domaines SET web_action='DELETE' WHERE type='php52-mixssl';");
65  }
66 
67 } // before-reload
global $db
Definition: bootstrap.php:22