diff --git a/src/etc/inc/service-utils.inc b/src/etc/inc/service-utils.inc
deleted file mode 100644
index b0611fab4..000000000
--- a/src/etc/inc/service-utils.inc
+++ /dev/null
@@ -1,572 +0,0 @@
- $setting) {
- if (isset($setting['enable'])) {
- $pconfig = array();
- $pconfig['name'] = "captiveportal";
- $pconfig['zone'] = $zone;
- $pconfig['description'] = gettext("Captive Portal") . ": ".htmlspecialchars($setting['zone']);
- $services[] = $pconfig;
- }
- }
- }
-
- $iflist = array();
- $ifdescrs = get_configured_interface_list();
- foreach ($ifdescrs as $if) {
- $oc = $config['interfaces'][$if];
- if ($oc['if'] && (!link_interface_to_bridge($if)))
- $iflist[$if] = $if;
- }
-
- if (isset($config['dhcrelay']['enable'])) {
- $pconfig = array();
- $pconfig['name'] = "dhcrelay";
- $pconfig['description'] = gettext("DHCP Relay");
- $services[] = $pconfig;
- }
-
- if (isset($config['dhcrelay6']['enable'])) {
- $pconfig = array();
- $pconfig['name'] = "dhcrelay6";
- $pconfig['description'] = gettext("DHCPv6 Relay");
- $services[] = $pconfig;
- }
-
- if (is_dhcp_server_enabled()) {
- $pconfig = array();
- $pconfig['name'] = "dhcpd";
- $pconfig['description'] = gettext("DHCP Service");
- $services[] = $pconfig;
- }
-
- $gateways_arr = return_gateways_array();
- if (is_apinger_enabled() && is_array($gateways_arr)) {
- $pconfig = array();
- $pconfig['name'] = "apinger";
- $pconfig['description'] = gettext("Gateway Monitoring Daemon");
- $services[] = $pconfig;
- }
-
- if (isset($config['snmpd']['enable'])) {
- $pconfig = array();
- $pconfig['name'] = "bsnmpd";
- $pconfig['description'] = gettext("SNMP Service");
- $services[] = $pconfig;
- }
-
- if (isset($config['igmpproxy']['igmpentry']) && is_array($config['igmpproxy']['igmpentry']) && (count($config['igmpproxy']['igmpentry']) > 0)) {
- $pconfig = array();
- $pconfig['name'] = "igmpproxy";
- $pconfig['description'] = gettext("IGMP proxy");
- $services[] = $pconfig;
- }
-
- if (isset($config['installedpackages']['miniupnpd']) && $config['installedpackages']['miniupnpd']['config'][0]['enable']) {
- $pconfig = array();
- $pconfig['name'] = "miniupnpd";
- $pconfig['description'] = gettext("UPnP Service");
- $services[] = $pconfig;
- }
-
- if (isset($config['ipsec']['enable'])) {
- $pconfig = array();
- $pconfig['name'] = "ipsec";
- $pconfig['description'] = gettext("IPsec VPN");
- $services[] = $pconfig;
- }
-
- if (isset($config['system']['ssh']['enabled'])) {
- $pconfig = array();
- $pconfig['name'] = 'sshd';
- $pconfig['description'] = gettext('Secure Shell Daemon');
- $services[] = $pconfig;
- }
-
- foreach (array('server', 'client') as $mode) {
- if (isset($config['openvpn']["openvpn-{$mode}"])) {
- foreach ($config['openvpn']["openvpn-{$mode}"] as $id => $setting) {
- if (!isset($setting['disable'])) {
- $pconfig = array();
- $pconfig['name'] = "openvpn";
- $pconfig['mode'] = $mode;
- $pconfig['id'] = $id;
- $pconfig['vpnid'] = $setting['vpnid'];
- $pconfig['description'] = gettext("OpenVPN") . " ".$mode.": ".htmlspecialchars($setting['description']);
- $services[] = $pconfig;
- }
- }
- }
- }
-
- if (isset($config['load_balancer']['virtual_server']) && isset($config['load_balancer']['lbpool']) && count($config['load_balancer']['virtual_server']) && count($config['load_balancer']['lbpool'])) {
- $pconfig = array();
- $pconfig['name'] = "relayd";
- $pconfig['description'] = gettext("Server load balancing daemon");
- $services[] = $pconfig;
- }
-
- if (isset($config['OPNsense']['proxy']['general']['enabled']) && $config['OPNsense']['proxy']['general']['enabled'] == 1) {
- $services[] = array('name'=>'squid', 'description' => gettext("Proxy server"));
- }
- if (isset($config['OPNsense']['IDS']['general']['enabled']) && $config['OPNsense']['IDS']['general']['enabled'] == 1) {
- $services[] = array('name'=>'suricata', 'description' => gettext("Intrusion Detection"));
- }
- return $services;
- }
-
-}
-
-if (!function_exists('find_service_by_name')) {
-
- function find_service_by_name($name) {
- $services = get_services();
- foreach ($services as $service)
- if ($service["name"] == $name)
- return $service;
- return array();
- }
-
-}
-
-if (!function_exists('find_service_by_openvpn_vpnid')) {
-
- function find_service_by_openvpn_vpnid($vpnid) {
- $services = get_services();
- foreach ($services as $service)
- if (($service["name"] == "openvpn") && isset($service["vpnid"]) && ($service["vpnid"] == $vpnid))
- return $service;
- return array();
- }
-
-
-}
-
-if (!function_exists('find_service_by_cp_zone')) {
-
-
- function find_service_by_cp_zone($zone) {
- $services = get_services();
- foreach ($services as $service)
- if (($service["name"] == "captiveportal") && isset($service["zone"]) && ($service["zone"] == $zone))
- return $service;
- return array();
- }
-
-
-}
-
-if (!function_exists('service_name_compare')) {
-
-
- function service_name_compare($a, $b) {
- if (strtolower($a['name']) == strtolower($b['name']))
- return 0;
- return (strtolower($a['name']) < strtolower($b['name'])) ? -1 : 1;
- }
-
-
-}
-
-
-if (!function_exists('get_service_status')) {
-
-
- function get_service_status($service) {
- global $g;
- switch ($service['name']) {
- case "openvpn":
- $running = isvalidpid("/var/run/openvpn_{$service['mode']}{$service['vpnid']}.pid");
- break;
- case "captiveportal":
- $running = isvalidpid("/var/run/lighty-{$service['zone']}-CaptivePortal.pid");
- if (isset($config['captiveportal'][$service['zone']]['httpslogin']))
- $running = $running && isvalidpid("/var/run/lighty-{$service['zone']}-CaptivePortal-SSL.pid");
- break;
- case "vhosts-http":
- $running = isvalidpid("/var/run/vhosts-http.pid");
- break;
- case "dhcrelay6":
- $running = isvalidpid("/var/run/dhcrelay6.pid");
- break;
- case 'ipsec':
- $running = isvalidpid("/var/run/charon.pid");
- break;
- default:
- $running = is_process_running($service['name']);
- }
- return $running;
- }
-
-
-}
-
-if (!function_exists('get_service_status_icon')) {
-
-
- function get_service_status_icon($service, $withtext = true, $smallicon = false) {
- global $g;
- $output = "";
- if(get_service_status($service)) {
- $statustext = gettext("Running");
- $output .= ' ';
- } else {
- $statustext = gettext("Stopped") ;
- $output .= ' ';
-
- }
- return $output;
- }
-
-
-}
-
-if (!function_exists('get_service_control_links')) {
-
-
- function get_service_control_links($service, $addname = false) {
- global $g;
- $output = "";
- $stitle = ($addname) ? $service['name'] . " " : "";
- if(get_service_status($service)) {
- switch ($service['name']) {
- case "openvpn":
- $output .= "";
- break;
- case "captiveportal":
- $output .= "";
- break;
- default:
- $output .= "";
- }
- $output .= "\n";
- switch ($service['name']) {
- case "openvpn":
- $output .= "";
- break;
- case "captiveportal":
- $output .= "";
- break;
- default:
- $output .= "";
- break;
- }
- $output .= "";
- $output .= "";
- } else {
- switch ($service['name']) {
- case "openvpn":
- $output .= "";
- break;
- case "captiveportal":
- $output .= "";
- break;
- default:
- $output .= "";
- break;
- }
- $output .= "\n";
- }
- return $output;
- }
-
-
-}
-
-if (!function_exists('service_control_start')) {
-
-
- function service_control_start($name, $extras) {
- global $g;
- switch($name) {
- case 'radvd':
- services_radvd_configure();
- break;
- case 'captiveportal':
- captiveportal_configure();
- break;
- case 'ntpd':
- system_ntp_configure();
- break;
- case 'apinger':
- setup_gateways_monitor();
- break;
- case 'bsnmpd':
- services_snmpd_configure();
- break;
- case 'dhcrelay':
- services_dhcrelay_configure();
- break;
- case 'dhcrelay6':
- services_dhcrelay6_configure();
- break;
- case 'dnsmasq':
- services_dnsmasq_configure();
- break;
- case 'dhcpd':
- services_dhcpd_configure();
- break;
- case 'igmpproxy':
- services_igmpproxy_configure();
- break;
- case 'miniupnpd':
- upnp_action('start');
- break;
- case 'ipsec':
- vpn_ipsec_force_reload();
- break;
- case 'sshd':
- configd_run("sshd restart");
- break;
- case 'openvpn':
- $vpnmode = isset($extras['vpnmode']) ? htmlspecialchars($extras['vpnmode']) : htmlspecialchars($extras['mode']);
- if (($vpnmode == "server") || ($vpnmode == "client")) {
- $id = isset($extras['vpnid']) ? htmlspecialchars($extras['vpnid']) : htmlspecialchars($extras['id']);
- $configfile = "/var/etc/openvpn/{$vpnmode}{$id}.conf";
- if (file_exists($configfile))
- openvpn_restart_by_vpnid($vpnmode, $id);
- }
- break;
- case 'relayd':
- relayd_configure();
- break;
- case 'squid':
- configd_run("proxy start");
- break;
- case 'suricata':
- configd_run("ids start");
- break;
- default:
- log_error(gettext("Could not start unknown service `%s'", $name));
- break;
- }
- return sprintf(gettext("%s has been started."),htmlspecialchars($name));
- }
-
-}
-
-if (!function_exists('service_control_stop')) {
-
-
- function service_control_stop($name, $extras) {
- global $g;
- switch($name) {
- case 'radvd':
- killbypid("/var/run/radvd.pid");
- break;
- case 'captiveportal':
- $zone = htmlspecialchars($extras['zone']);
- killbypid("/var/run/lighty-{$zone}-CaptivePortal.pid");
- killbypid("/var/run/lighty-{$zone}-CaptivePortal-SSL.pid");
- break;
- case 'ntpd':
- killbyname("ntpd");
- break;
- case 'apinger':
- killbypid("/var/run/apinger.pid");
- break;
- case 'bsnmpd':
- killbypid("/var/run/snmpd.pid");
- break;
- case 'choparp':
- killbyname("choparp");
- break;
- case 'dhcpd':
- killbyname("dhcpd");
- break;
- case 'dhcrelay':
- killbypid("/var/run/dhcrelay.pid");
- break;
- case 'dhcrelay6':
- killbypid("/var/run/dhcrelay6.pid");
- break;
- case 'dnsmasq':
- killbypid("/var/run/dnsmasq.pid");
- break;
- case 'unbound':
- killbypid("/var/run/unbound.pid");
- break;
- case 'igmpproxy':
- killbyname("igmpproxy");
- break;
- case 'miniupnpd':
- upnp_action('stop');
- break;
- case 'sshd':
- killbyname("sshd");
- break;
- case 'ipsec':
- exec("/usr/local/sbin/ipsec stop");
- break;
- case 'openvpn':
- $vpnmode = htmlspecialchars($extras['vpnmode']);
- if (($vpnmode == "server") or ($vpnmode == "client")) {
- $id = htmlspecialchars($extras['id']);
- $pidfile = "/var/run/openvpn_{$vpnmode}{$id}.pid";
- killbypid($pidfile);
- }
- break;
- case 'relayd':
- mwexec('pkill relayd');
- break;
- case 'squid':
- configd_run("proxy stop");
- break;
- case 'suricata':
- configd_run("ids stop");
- break;
- default:
- log_error(gettext("Could not stop unknown service `%s'", $name));
- break;
- }
- return sprintf(gettext("%s has been stopped."), htmlspecialchars($name));
- }
-
-
-}
-
-if (!function_exists('service_control_restart')) {
-
-
- function service_control_restart($name, $extras) {
- global $g;
- switch($name) {
- case 'radvd':
- services_radvd_configure();
- break;
- case 'captiveportal':
- captiveportal_configure();
- break;
- case 'ntpd':
- system_ntp_configure();
- break;
- case 'apinger':
- killbypid("/var/run/apinger.pid");
- setup_gateways_monitor();
- break;
- case 'bsnmpd':
- services_snmpd_configure();
- break;
- case 'dhcrelay':
- services_dhcrelay_configure();
- break;
- case 'dhcrelay6':
- services_dhcrelay6_configure();
- break;
- case 'dnsmasq':
- services_dnsmasq_configure();
- break;
- case 'unbound':
- services_unbound_configure();
- break;
- case 'dhcpd':
- services_dhcpd_configure();
- break;
- case 'igmpproxy':
- services_igmpproxy_configure();
- break;
- case 'miniupnpd':
- upnp_action('restart');
- break;
- case 'ipsec':
- vpn_ipsec_force_reload();
- break;
- case 'sshd':
- configd_run("sshd restart");
- break;
- case 'openvpn':
- $vpnmode = htmlspecialchars($extras['vpnmode']);
- if ($vpnmode == "server" || $vpnmode == "client") {
- $id = htmlspecialchars($extras['id']);
- $configfile = "/var/etc/openvpn/{$vpnmode}{$id}.conf";
- if (file_exists($configfile))
- openvpn_restart_by_vpnid($vpnmode, $id);
- }
- break;
- case 'relayd':
- relayd_configure(true);
- break;
- case 'squid':
- configd_run("proxy restart");
- break;
- case 'suricata':
- configd_run("ids restart");
- break;
- default:
- log_error(gettext("Could not restart unknown service `%s'", $name));
- break;
- }
- return sprintf(gettext("%s has been restarted."),htmlspecialchars($name));
- }
-}
diff --git a/src/etc/inc/services.inc b/src/etc/inc/services.inc
index 847b80b12..f01e67b21 100644
--- a/src/etc/inc/services.inc
+++ b/src/etc/inc/services.inc
@@ -2406,3 +2406,256 @@ function install_cron_job($command, $active=false, $minute="0", $hour="*", $mont
}
configure_cron();
}
+
+function get_services() {
+ global $config;
+ $services = array();
+
+ /* Add services that are in the base.
+ *
+ */
+ if (is_radvd_enabled()) {
+ $pconfig = array();
+ $pconfig['name'] = "radvd";
+ $pconfig['description'] = gettext("Router Advertisement Daemon");
+ $services[] = $pconfig;
+ }
+
+ if (isset($config['dnsmasq']['enable'])) {
+ $pconfig = array();
+ $pconfig['name'] = "dnsmasq";
+ $pconfig['description'] = gettext("DNS Forwarder");
+ $services[] = $pconfig;
+ }
+
+ if (isset($config['unbound']['enable'])) {
+ $pconfig = array();
+ $pconfig['name'] = "unbound";
+ $pconfig['description'] = gettext("Unbound DNS Forwarder");
+ $services[] = $pconfig;
+ }
+
+ $pconfig = array();
+ $pconfig['name'] = "ntpd";
+ $pconfig['description'] = gettext("NTP clock sync");
+ $services[] = $pconfig;
+
+ if (isset($config['captiveportal']) && is_array($config['captiveportal'])) {
+ foreach ($config['captiveportal'] as $zone => $setting) {
+ if (isset($setting['enable'])) {
+ $pconfig = array();
+ $pconfig['name'] = "captiveportal";
+ $pconfig['zone'] = $zone;
+ $pconfig['description'] = gettext("Captive Portal") . ": ".htmlspecialchars($setting['zone']);
+ $services[] = $pconfig;
+ }
+ }
+ }
+
+ $iflist = array();
+ $ifdescrs = get_configured_interface_list();
+ foreach ($ifdescrs as $if) {
+ $oc = $config['interfaces'][$if];
+ if ($oc['if'] && (!link_interface_to_bridge($if)))
+ $iflist[$if] = $if;
+ }
+
+ if (isset($config['dhcrelay']['enable'])) {
+ $pconfig = array();
+ $pconfig['name'] = "dhcrelay";
+ $pconfig['description'] = gettext("DHCP Relay");
+ $services[] = $pconfig;
+ }
+
+ if (isset($config['dhcrelay6']['enable'])) {
+ $pconfig = array();
+ $pconfig['name'] = "dhcrelay6";
+ $pconfig['description'] = gettext("DHCPv6 Relay");
+ $services[] = $pconfig;
+ }
+
+ if (is_dhcp_server_enabled()) {
+ $pconfig = array();
+ $pconfig['name'] = "dhcpd";
+ $pconfig['description'] = gettext("DHCP Service");
+ $services[] = $pconfig;
+ }
+
+ $gateways_arr = return_gateways_array();
+ if (is_apinger_enabled() && is_array($gateways_arr)) {
+ $pconfig = array();
+ $pconfig['name'] = "apinger";
+ $pconfig['description'] = gettext("Gateway Monitoring Daemon");
+ $services[] = $pconfig;
+ }
+
+ if (isset($config['snmpd']['enable'])) {
+ $pconfig = array();
+ $pconfig['name'] = "bsnmpd";
+ $pconfig['description'] = gettext("SNMP Service");
+ $services[] = $pconfig;
+ }
+
+ if (isset($config['igmpproxy']['igmpentry']) && is_array($config['igmpproxy']['igmpentry']) && (count($config['igmpproxy']['igmpentry']) > 0)) {
+ $pconfig = array();
+ $pconfig['name'] = "igmpproxy";
+ $pconfig['description'] = gettext("IGMP proxy");
+ $services[] = $pconfig;
+ }
+
+ if (isset($config['installedpackages']['miniupnpd']) && $config['installedpackages']['miniupnpd']['config'][0]['enable']) {
+ $pconfig = array();
+ $pconfig['name'] = "miniupnpd";
+ $pconfig['description'] = gettext("UPnP Service");
+ $services[] = $pconfig;
+ }
+
+ if (isset($config['ipsec']['enable'])) {
+ $pconfig = array();
+ $pconfig['name'] = "ipsec";
+ $pconfig['description'] = gettext("IPsec VPN");
+ $services[] = $pconfig;
+ }
+
+ if (isset($config['system']['ssh']['enabled'])) {
+ $pconfig = array();
+ $pconfig['name'] = 'sshd';
+ $pconfig['description'] = gettext('Secure Shell Daemon');
+ $services[] = $pconfig;
+ }
+
+ foreach (array('server', 'client') as $mode) {
+ if (isset($config['openvpn']["openvpn-{$mode}"])) {
+ foreach ($config['openvpn']["openvpn-{$mode}"] as $id => $setting) {
+ if (!isset($setting['disable'])) {
+ $pconfig = array();
+ $pconfig['name'] = "openvpn";
+ $pconfig['mode'] = $mode;
+ $pconfig['id'] = $id;
+ $pconfig['vpnid'] = $setting['vpnid'];
+ $pconfig['description'] = gettext("OpenVPN") . " ".$mode.": ".htmlspecialchars($setting['description']);
+ $services[] = $pconfig;
+ }
+ }
+ }
+ }
+
+ if (isset($config['load_balancer']['virtual_server']) && isset($config['load_balancer']['lbpool']) && count($config['load_balancer']['virtual_server']) && count($config['load_balancer']['lbpool'])) {
+ $pconfig = array();
+ $pconfig['name'] = "relayd";
+ $pconfig['description'] = gettext("Server load balancing daemon");
+ $services[] = $pconfig;
+ }
+
+ if (isset($config['OPNsense']['proxy']['general']['enabled']) && $config['OPNsense']['proxy']['general']['enabled'] == 1) {
+ $services[] = array('name'=>'squid', 'description' => gettext("Proxy server"));
+ }
+ if (isset($config['OPNsense']['IDS']['general']['enabled']) && $config['OPNsense']['IDS']['general']['enabled'] == 1) {
+ $services[] = array('name'=>'suricata', 'description' => gettext("Intrusion Detection"));
+ }
+ return $services;
+}
+
+
+function find_service_by_openvpn_vpnid($vpnid) {
+ $services = get_services();
+ foreach ($services as $service)
+ if (($service["name"] == "openvpn") && isset($service["vpnid"]) && ($service["vpnid"] == $vpnid))
+ return $service;
+ return array();
+}
+
+
+function service_name_compare($a, $b) {
+ if (strtolower($a['name']) == strtolower($b['name']))
+ return 0;
+ return (strtolower($a['name']) < strtolower($b['name'])) ? -1 : 1;
+}
+
+
+function get_service_status($service) {
+ global $g;
+ switch ($service['name']) {
+ case "openvpn":
+ $running = isvalidpid("/var/run/openvpn_{$service['mode']}{$service['vpnid']}.pid");
+ break;
+ case "captiveportal":
+ $running = isvalidpid("/var/run/lighty-{$service['zone']}-CaptivePortal.pid");
+ if (isset($config['captiveportal'][$service['zone']]['httpslogin']))
+ $running = $running && isvalidpid("/var/run/lighty-{$service['zone']}-CaptivePortal-SSL.pid");
+ break;
+ case "vhosts-http":
+ $running = isvalidpid("/var/run/vhosts-http.pid");
+ break;
+ case "dhcrelay6":
+ $running = isvalidpid("/var/run/dhcrelay6.pid");
+ break;
+ case 'ipsec':
+ $running = isvalidpid("/var/run/charon.pid");
+ break;
+ default:
+ $running = is_process_running($service['name']);
+ }
+ return $running;
+}
+
+
+function get_service_status_icon($service, $withtext = true, $smallicon = false) {
+ global $g;
+ $output = "";
+ if(get_service_status($service)) {
+ $statustext = gettext("Running");
+ $output .= ' ';
+ } else {
+ $statustext = gettext("Stopped") ;
+ $output .= ' ';
+ }
+ return $output;
+}
+
+
+function get_service_control_links($service, $addname = false) {
+ global $g;
+ $output = "";
+ $stitle = ($addname) ? $service['name'] . " " : "";
+ if(get_service_status($service)) {
+ switch ($service['name']) {
+ case "openvpn":
+ $output .= "";
+ break;
+ case "captiveportal":
+ $output .= "";
+ break;
+ default:
+ $output .= "";
+ }
+ $output .= "\n";
+ switch ($service['name']) {
+ case "openvpn":
+ $output .= "";
+ break;
+ case "captiveportal":
+ $output .= "";
+ break;
+ default:
+ $output .= "";
+ break;
+ }
+ $output .= "";
+ $output .= "";
+ } else {
+ switch ($service['name']) {
+ case "openvpn":
+ $output .= "";
+ break;
+ case "captiveportal":
+ $output .= "";
+ break;
+ default:
+ $output .= "";
+ break;
+ }
+ $output .= "\n";
+ }
+ return $output;
+}
diff --git a/src/etc/inc/unbound.inc b/src/etc/inc/unbound.inc
index 7064a0ebe..389e70dfc 100644
--- a/src/etc/inc/unbound.inc
+++ b/src/etc/inc/unbound.inc
@@ -29,6 +29,7 @@
/* include all configuration functions */
require_once("config.inc");
require_once("functions.inc");
+require_once("util.inc");
/* Optimize Unbound for environment */
function unbound_optimization() {
@@ -376,7 +377,6 @@ function sync_unbound_service() {
unbound_remote_control_setup();
unbound_generate_config();
do_as_unbound_user("start");
- require_once("service-utils.inc");
if (is_process_running("unbound"))
do_as_unbound_user("restore_cache");
diff --git a/src/www/fbegin.inc b/src/www/fbegin.inc
index af1c0741d..4c386f1a2 100644
--- a/src/www/fbegin.inc
+++ b/src/www/fbegin.inc
@@ -30,9 +30,26 @@
require_once("globals.inc");
require_once("functions.inc");
require_once("shortcuts.inc");
-require_once("service-utils.inc");
+require_once("services.inc");
require_once("script/load_phalcon.php");
+function find_service_by_name($name) {
+ $services = get_services();
+ foreach ($services as $service)
+ if ($service["name"] == $name)
+ return $service;
+ return array();
+}
+
+function find_service_by_cp_zone($zone) {
+ $services = get_services();
+ foreach ($services as $service)
+ if (($service["name"] == "captiveportal") && isset($service["zone"]) && ($service["zone"] == $zone))
+ return $service;
+ return array();
+}
+
+
/* Determine automated help URL. Should output the page name and
parameters separately */
$uri_split = "";
diff --git a/src/www/shortcuts.inc b/src/www/shortcuts.inc
index 24bf00be7..828d3d611 100644
--- a/src/www/shortcuts.inc
+++ b/src/www/shortcuts.inc
@@ -111,7 +111,11 @@ function get_shortcut_status_link($shortcut_section, $addspace = true, $service
$link = $shortcuts[$shortcut_section]['status'];
break;
default:
- $link = $shortcuts[$shortcut_section]['status'];
+ if (isset($shortcuts[$shortcut_section]['status'])) {
+ $link = $shortcuts[$shortcut_section]['status'];
+ } else {
+ $link = null;
+ }
break;
}
if(!empty($link))
diff --git a/src/www/status_openvpn.php b/src/www/status_openvpn.php
index 52b67e62d..f9a809eed 100644
--- a/src/www/status_openvpn.php
+++ b/src/www/status_openvpn.php
@@ -35,7 +35,7 @@ $shortcut_section = "openvpn";
require_once("guiconfig.inc");
require_once("openvpn.inc");
require_once("shortcuts.inc");
-require_once("service-utils.inc");
+require_once("services.inc");
/* Handle AJAX */
if($_GET['action']) {
diff --git a/src/www/status_services.php b/src/www/status_services.php
index 3d606ef91..49ba70b76 100644
--- a/src/www/status_services.php
+++ b/src/www/status_services.php
@@ -27,7 +27,7 @@
*/
require_once("guiconfig.inc");
-require_once("service-utils.inc");
+require_once("services.inc");
require_once("shortcuts.inc");
$service_name = '';
@@ -49,6 +49,221 @@ if (!empty($service_name)) {
sleep(5);
}
+function service_control_start($name, $extras) {
+ global $g;
+ switch($name) {
+ case 'radvd':
+ services_radvd_configure();
+ break;
+ case 'captiveportal':
+ captiveportal_configure();
+ break;
+ case 'ntpd':
+ system_ntp_configure();
+ break;
+ case 'apinger':
+ setup_gateways_monitor();
+ break;
+ case 'bsnmpd':
+ services_snmpd_configure();
+ break;
+ case 'dhcrelay':
+ services_dhcrelay_configure();
+ break;
+ case 'dhcrelay6':
+ services_dhcrelay6_configure();
+ break;
+ case 'dnsmasq':
+ services_dnsmasq_configure();
+ break;
+ case 'dhcpd':
+ services_dhcpd_configure();
+ break;
+ case 'igmpproxy':
+ services_igmpproxy_configure();
+ break;
+ case 'miniupnpd':
+ upnp_action('start');
+ break;
+ case 'ipsec':
+ vpn_ipsec_force_reload();
+ break;
+ case 'sshd':
+ configd_run("sshd restart");
+ break;
+ case 'openvpn':
+ $vpnmode = isset($extras['vpnmode']) ? htmlspecialchars($extras['vpnmode']) : htmlspecialchars($extras['mode']);
+ if (($vpnmode == "server") || ($vpnmode == "client")) {
+ $id = isset($extras['vpnid']) ? htmlspecialchars($extras['vpnid']) : htmlspecialchars($extras['id']);
+ $configfile = "/var/etc/openvpn/{$vpnmode}{$id}.conf";
+ if (file_exists($configfile))
+ openvpn_restart_by_vpnid($vpnmode, $id);
+ }
+ break;
+ case 'relayd':
+ relayd_configure();
+ break;
+ case 'squid':
+ configd_run("proxy start");
+ break;
+ case 'suricata':
+ configd_run("ids start");
+ break;
+ default:
+ log_error(gettext("Could not start unknown service `%s'", $name));
+ break;
+ }
+ return sprintf(gettext("%s has been started."),htmlspecialchars($name));
+}
+
+
+function service_control_stop($name, $extras) {
+ global $g;
+ switch($name) {
+ case 'radvd':
+ killbypid("/var/run/radvd.pid");
+ break;
+ case 'captiveportal':
+ $zone = htmlspecialchars($extras['zone']);
+ killbypid("/var/run/lighty-{$zone}-CaptivePortal.pid");
+ killbypid("/var/run/lighty-{$zone}-CaptivePortal-SSL.pid");
+ break;
+ case 'ntpd':
+ killbyname("ntpd");
+ break;
+ case 'apinger':
+ killbypid("/var/run/apinger.pid");
+ break;
+ case 'bsnmpd':
+ killbypid("/var/run/snmpd.pid");
+ break;
+ case 'choparp':
+ killbyname("choparp");
+ break;
+ case 'dhcpd':
+ killbyname("dhcpd");
+ break;
+ case 'dhcrelay':
+ killbypid("/var/run/dhcrelay.pid");
+ break;
+ case 'dhcrelay6':
+ killbypid("/var/run/dhcrelay6.pid");
+ break;
+ case 'dnsmasq':
+ killbypid("/var/run/dnsmasq.pid");
+ break;
+ case 'unbound':
+ killbypid("/var/run/unbound.pid");
+ break;
+ case 'igmpproxy':
+ killbyname("igmpproxy");
+ break;
+ case 'miniupnpd':
+ upnp_action('stop');
+ break;
+ case 'sshd':
+ killbyname("sshd");
+ break;
+ case 'ipsec':
+ exec("/usr/local/sbin/ipsec stop");
+ break;
+ case 'openvpn':
+ $vpnmode = htmlspecialchars($extras['vpnmode']);
+ if (($vpnmode == "server") or ($vpnmode == "client")) {
+ $id = htmlspecialchars($extras['id']);
+ $pidfile = "/var/run/openvpn_{$vpnmode}{$id}.pid";
+ killbypid($pidfile);
+ }
+ break;
+ case 'relayd':
+ mwexec('pkill relayd');
+ break;
+ case 'squid':
+ configd_run("proxy stop");
+ break;
+ case 'suricata':
+ configd_run("ids stop");
+ break;
+ default:
+ log_error(gettext("Could not stop unknown service `%s'", $name));
+ break;
+ }
+ return sprintf(gettext("%s has been stopped."), htmlspecialchars($name));
+}
+
+
+function service_control_restart($name, $extras) {
+ global $g;
+ switch($name) {
+ case 'radvd':
+ services_radvd_configure();
+ break;
+ case 'captiveportal':
+ captiveportal_configure();
+ break;
+ case 'ntpd':
+ system_ntp_configure();
+ break;
+ case 'apinger':
+ killbypid("/var/run/apinger.pid");
+ setup_gateways_monitor();
+ break;
+ case 'bsnmpd':
+ services_snmpd_configure();
+ break;
+ case 'dhcrelay':
+ services_dhcrelay_configure();
+ break;
+ case 'dhcrelay6':
+ services_dhcrelay6_configure();
+ break;
+ case 'dnsmasq':
+ services_dnsmasq_configure();
+ break;
+ case 'unbound':
+ services_unbound_configure();
+ break;
+ case 'dhcpd':
+ services_dhcpd_configure();
+ break;
+ case 'igmpproxy':
+ services_igmpproxy_configure();
+ break;
+ case 'miniupnpd':
+ upnp_action('restart');
+ break;
+ case 'ipsec':
+ vpn_ipsec_force_reload();
+ break;
+ case 'sshd':
+ configd_run("sshd restart");
+ break;
+ case 'openvpn':
+ $vpnmode = htmlspecialchars($extras['vpnmode']);
+ if ($vpnmode == "server" || $vpnmode == "client") {
+ $id = htmlspecialchars($extras['id']);
+ $configfile = "/var/etc/openvpn/{$vpnmode}{$id}.conf";
+ if (file_exists($configfile))
+ openvpn_restart_by_vpnid($vpnmode, $id);
+ }
+ break;
+ case 'relayd':
+ relayd_configure(true);
+ break;
+ case 'squid':
+ configd_run("proxy restart");
+ break;
+ case 'suricata':
+ configd_run("ids restart");
+ break;
+ default:
+ log_error(gettext("Could not restart unknown service `%s'", $name));
+ break;
+ }
+ return sprintf(gettext("%s has been restarted."),htmlspecialchars($name));
+}
+
+
$pgtitle = array(gettext("Status"),gettext("Services"));
include("head.inc");
diff --git a/src/www/widgets/widgets/services_status.widget.php b/src/www/widgets/widgets/services_status.widget.php
index 4cacd41b7..a98794103 100644
--- a/src/www/widgets/widgets/services_status.widget.php
+++ b/src/www/widgets/widgets/services_status.widget.php
@@ -32,7 +32,7 @@ $nocsrf = true;
require_once("guiconfig.inc");
require_once("captiveportal.inc");
-require_once("service-utils.inc");
+require_once("services.inc");
require_once("ipsec.inc");
require_once("vpn.inc");
require_once("widgets/include/services_status.inc");