2018-06-24 15:04:55 +00:00
|
|
|
#!/usr/bin/php
|
|
|
|
<?php
|
|
|
|
/*
|
|
|
|
function called by a sysadmin when (s)he want to reload all
|
|
|
|
certificate configured for all subdomains, including system services.
|
|
|
|
launch as root as :
|
|
|
|
/usr/lib/alternc/reload-certs <enter>
|
|
|
|
system services WILL BE RELOADED
|
|
|
|
*/
|
|
|
|
|
|
|
|
// Bootstrap
|
|
|
|
require_once("/usr/share/alternc/panel/class/config_nochk.php");
|
|
|
|
|
|
|
|
if (!isset($ssl)) {
|
|
|
|
echo "OUPS: reload-certs launched, but ssl module not installed, exiting\n";
|
|
|
|
exit();
|
|
|
|
}
|
|
|
|
|
|
|
|
if (posix_getuid()!=0) {
|
|
|
|
echo "This script MUST be launched as root, it should be able to overwrite files in /etc/ssl/private\n";
|
|
|
|
exit(-1);
|
|
|
|
}
|
|
|
|
|
|
|
|
// force reloading all valid certificates in the proper vhosts :
|
|
|
|
variable_set('last_certificate_id',0);
|
|
|
|
|
|
|
|
$ssl->cron_new_certs();
|
|
|
|
|
|
|
|
// forcibly reload all services (new certificates may apply)
|
|
|
|
$services=array("postfix","dovecot","proftpd","apache2");
|
|
|
|
|
|
|
|
foreach($services as $service) {
|
2018-06-24 17:02:11 +00:00
|
|
|
passthru("service $service status",&$ret);
|
|
|
|
if ($ret!=0) {
|
|
|
|
echo "$service not running, restarting\n";
|
|
|
|
passthru("service $service restart");
|
|
|
|
echo "Done...\n";
|
|
|
|
} else {
|
|
|
|
echo "$service running, reloading\n";
|
|
|
|
passthru("service $service reload");
|
|
|
|
echo "Done...\n";
|
|
|
|
};
|
2018-06-24 15:04:55 +00:00
|
|
|
}
|
|
|
|
|