Commit 89179ee7 authored by Franco Fichtner's avatar Franco Fichtner

services: why not embed the pidfile in the service array?

parent 19174b41
...@@ -2568,6 +2568,7 @@ function services_get() ...@@ -2568,6 +2568,7 @@ function services_get()
$pconfig = array(); $pconfig = array();
$pconfig['name'] = "ntpd"; $pconfig['name'] = "ntpd";
$pconfig['description'] = gettext("NTP clock sync"); $pconfig['description'] = gettext("NTP clock sync");
$pconfig['pidfile'] = '/var/run/ntpd.pid';
$services[] = $pconfig; $services[] = $pconfig;
$iflist = array(); $iflist = array();
...@@ -2590,6 +2591,7 @@ function services_get() ...@@ -2590,6 +2591,7 @@ function services_get()
$pconfig = array(); $pconfig = array();
$pconfig['name'] = "dhcrelay6"; $pconfig['name'] = "dhcrelay6";
$pconfig['description'] = gettext("DHCPv6 Relay"); $pconfig['description'] = gettext("DHCPv6 Relay");
$pconfig['pidfile'] = '/var/run/dhcrelay6.pid';
$services[] = $pconfig; $services[] = $pconfig;
} }
...@@ -2632,6 +2634,7 @@ function services_get() ...@@ -2632,6 +2634,7 @@ function services_get()
$pconfig = array(); $pconfig = array();
$pconfig['name'] = "ipsec"; $pconfig['name'] = "ipsec";
$pconfig['description'] = gettext("IPsec VPN"); $pconfig['description'] = gettext("IPsec VPN");
$pconfig['pidfile'] = '/var/run/charon.pid';
$services[] = $pconfig; $services[] = $pconfig;
} }
...@@ -2652,6 +2655,7 @@ function services_get() ...@@ -2652,6 +2655,7 @@ function services_get()
$pconfig['id'] = $id; $pconfig['id'] = $id;
$pconfig['vpnid'] = $setting['vpnid']; $pconfig['vpnid'] = $setting['vpnid'];
$pconfig['description'] = gettext("OpenVPN") . " ".$mode.": ".htmlspecialchars($setting['description']); $pconfig['description'] = gettext("OpenVPN") . " ".$mode.": ".htmlspecialchars($setting['description']);
$pconfig['pidfile'] = "/var/run/openvpn_{$mode}{$settings['vpnid']}.pid";
$services[] = $pconfig; $services[] = $pconfig;
} }
} }
...@@ -2685,11 +2689,19 @@ function services_get() ...@@ -2685,11 +2689,19 @@ function services_get()
} }
} }
if ($enabled) { if ($enabled) {
$services[] = array('name'=>'captiveportal', 'description' => gettext("Captive Portal")); $services[] = array(
'pidfile' => '/var/run/lighttpd-api-dispatcher.pid',
'description' => gettext('Captive Portal'),
'name' => 'captiveportal',
);
} }
} }
$services[] = array('name'=>'configd', 'description' => gettext("System Configuration Daemon")); $services[] = array(
'description' => gettext('System Configuration Daemon'),
'pidfile' => '/var/run/configd.pid',
'name' => 'configd',
);
return $services; return $services;
} }
...@@ -2716,31 +2728,11 @@ function service_name_compare($a, $b) { ...@@ -2716,31 +2728,11 @@ function service_name_compare($a, $b) {
function get_service_status($service) function get_service_status($service)
{ {
switch ($service['name']) { if (isset($service['pidfile'])) {
case 'openvpn': return isvalidpid($service['pidfile']);
$running = isvalidpid("/var/run/openvpn_{$service['mode']}{$service['vpnid']}.pid");
break;
case 'dhcrelay6':
$running = isvalidpid('/var/run/dhcrelay6.pid');
break;
case 'ipsec':
$running = isvalidpid('/var/run/charon.pid');
break;
case 'ntpd':
$running = isvalidpid('/var/run/ntpd.pid');
break;
case 'configd':
$running = isvalidpid('/var/run/configd.pid');
break;
case 'captiveportal':
$running = isvalidpid('/var/run/lighttpd-api-dispatcher.pid');
break;
default:
$running = is_process_running($service['name']);
break;
} }
return $running; return is_process_running($service['name']);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment