Alternc  latest
Alternc logiel libre pour l'hébergement
reload-certs
Go to the documentation of this file.
1 #!/usr/bin/php
2 <?php
3 /*
4  function called by a sysadmin when (s)he want to reload all
5  certificate configured for all subdomains, including system services.
6  launch as root as :
7  /usr/lib/alternc/reload-certs <enter>
8  system services WILL BE RELOADED
9 */
10 
11 // Bootstrap
12 require_once("/usr/share/alternc/panel/class/config_nochk.php");
13 
14 if (!isset($ssl)) {
15  echo "OUPS: reload-certs launched, but ssl module not installed, exiting\n";
16  exit();
17 }
18 
19 if (posix_getuid()!=0) {
20  echo "This script MUST be launched as root, it should be able to overwrite files in /etc/ssl/private\n";
21  exit(-1);
22 }
23 
24 // force reloading all valid certificates in the proper vhosts :
25 variable_set('last_certificate_id',0);
26 
27 $ssl->cron_new_certs();
28 
29 // forcibly reload all services (new certificates may apply)
30 $services=array("postfix","dovecot","proftpd","apache2");
31 
32 foreach($services as $service) {
33  passthru("service $service status",$ret);
34  if ($ret!=0) {
35  echo "$service not running, restarting\n";
36  passthru("service $service restart");
37  echo "Done...\n";
38  } else {
39  echo "$service running, reloading\n";
40  passthru("service $service reload");
41  echo "Done...\n";
42  };
43 }
44