Revision ee6e6011
Added by Jim Pingle about 12 years ago
usr/local/www/status_services.php | ||
---|---|---|
38 | 38 |
##|-PRIV |
39 | 39 |
|
40 | 40 |
require_once("guiconfig.inc"); |
41 |
require_once("captiveportal.inc"); |
|
42 | 41 |
require_once("service-utils.inc"); |
43 |
require_once("openvpn.inc"); |
|
44 |
require_once("ipsec.inc"); |
|
45 |
require_once("vpn.inc"); |
|
46 |
require_once("vslb.inc"); |
|
47 | 42 |
require_once("shortcuts.inc"); |
48 | 43 |
|
49 | 44 |
if($_GET['mode'] == "restartservice" and !empty($_GET['service'])) { |
50 |
switch($_GET['service']) { |
|
51 |
case 'radvd': |
|
52 |
services_radvd_configure(); |
|
53 |
break; |
|
54 |
case 'captiveportal': |
|
55 |
$zone = $_GET['zone']; |
|
56 |
killbypid("{$g['varrun_path']}/lighty-{$zone}-CaptivePortal.pid"); |
|
57 |
killbypid("{$g['varrun_path']}/lighty-{$zone}-CaptivePortal-SSL.pid"); |
|
58 |
captiveportal_init_webgui_zonename($zone); |
|
59 |
break; |
|
60 |
case 'ntpd': |
|
61 |
case 'openntpd': |
|
62 |
system_ntp_configure(); |
|
63 |
break; |
|
64 |
case 'bsnmpd': |
|
65 |
services_snmpd_configure(); |
|
66 |
break; |
|
67 |
case 'dnsmasq': |
|
68 |
services_dnsmasq_configure(); |
|
69 |
break; |
|
70 |
case 'dhcpd': |
|
71 |
services_dhcpd_configure(); |
|
72 |
break; |
|
73 |
case 'igmpproxy': |
|
74 |
services_igmpproxy_configure(); |
|
75 |
break; |
|
76 |
case 'miniupnpd': |
|
77 |
upnp_action('restart'); |
|
78 |
break; |
|
79 |
case 'racoon': |
|
80 |
vpn_ipsec_force_reload(); |
|
81 |
break; |
|
82 |
case 'openvpn': |
|
83 |
$vpnmode = $_GET['vpnmode']; |
|
84 |
if ($vpnmode == "server" || $vpnmode == "client") { |
|
85 |
$id = $_GET['id']; |
|
86 |
$configfile = "{$g['varetc_path']}/openvpn/{$vpnmode}{$id}.conf"; |
|
87 |
if (file_exists($configfile)) |
|
88 |
openvpn_restart_by_vpnid($vpnmode, $id); |
|
89 |
} |
|
90 |
break; |
|
91 |
case 'relayd': |
|
92 |
relayd_configure(true); |
|
93 |
break; |
|
94 |
default: |
|
95 |
restart_service($_GET['service']); |
|
96 |
break; |
|
97 |
} |
|
98 |
$savemsg = sprintf(gettext("%s has been restarted."),htmlspecialchars($_GET['service'])); |
|
45 |
$savemsg = service_control_restart($_GET['service'], $_GET); |
|
99 | 46 |
sleep(5); |
100 | 47 |
} |
101 | 48 |
|
102 | 49 |
if($_GET['mode'] == "startservice" and !empty($_GET['service'])) { |
103 |
switch($_GET['service']) { |
|
104 |
case 'radvd': |
|
105 |
services_radvd_configure(); |
|
106 |
break; |
|
107 |
case 'captiveportal': |
|
108 |
$zone = $_GET['zone']; |
|
109 |
captiveportal_init_webgui_zonename($zone); |
|
110 |
break; |
|
111 |
case 'ntpd': |
|
112 |
case 'openntpd': |
|
113 |
system_ntp_configure(); |
|
114 |
break; |
|
115 |
case 'bsnmpd': |
|
116 |
services_snmpd_configure(); |
|
117 |
break; |
|
118 |
case 'dnsmasq': |
|
119 |
services_dnsmasq_configure(); |
|
120 |
break; |
|
121 |
case 'dhcpd': |
|
122 |
services_dhcpd_configure(); |
|
123 |
break; |
|
124 |
case 'igmpproxy': |
|
125 |
services_igmpproxy_configure(); |
|
126 |
break; |
|
127 |
case 'miniupnpd': |
|
128 |
upnp_action('start'); |
|
129 |
break; |
|
130 |
case 'racoon': |
|
131 |
vpn_ipsec_force_reload(); |
|
132 |
break; |
|
133 |
case 'openvpn': |
|
134 |
$vpnmode = $_GET['vpnmode']; |
|
135 |
if (($vpnmode == "server") || ($vpnmode == "client")) { |
|
136 |
$id = $_GET['id']; |
|
137 |
$configfile = "{$g['varetc_path']}/openvpn/{$vpnmode}{$id}.conf"; |
|
138 |
if (file_exists($configfile)) |
|
139 |
openvpn_restart_by_vpnid($vpnmode, $id); |
|
140 |
} |
|
141 |
break; |
|
142 |
case 'relayd': |
|
143 |
relayd_configure(); |
|
144 |
break; |
|
145 |
default: |
|
146 |
start_service($_GET['service']); |
|
147 |
break; |
|
148 |
} |
|
149 |
$savemsg = sprintf(gettext("%s has been started."),htmlspecialchars($_GET['service'])); |
|
50 |
$savemsg = service_control_start($_GET['service'], $_GET); |
|
150 | 51 |
sleep(5); |
151 | 52 |
} |
152 | 53 |
|
153 | 54 |
/* stop service */ |
154 | 55 |
if($_GET['mode'] == "stopservice" && !empty($_GET['service'])) { |
155 |
switch($_GET['service']) { |
|
156 |
case 'radvd': |
|
157 |
killbypid("{$g['varrun_path']}/radvd.pid"); |
|
158 |
break; |
|
159 |
case 'captiveportal': |
|
160 |
$zone = $_GET['zone']; |
|
161 |
killbypid("{$g['varrun_path']}/lighty-{$zone}-CaptivePortal.pid"); |
|
162 |
killbypid("{$g['varrun_path']}/lighty-{$zone}-CaptivePortal-SSL.pid"); |
|
163 |
break; |
|
164 |
case 'ntpd': |
|
165 |
killbyname("ntpd"); |
|
166 |
break; |
|
167 |
case 'openntpd': |
|
168 |
killbyname("openntpd"); |
|
169 |
break; |
|
170 |
case 'bsnmpd': |
|
171 |
killbypid("{$g['varrun_path']}/snmpd.pid"); |
|
172 |
break; |
|
173 |
case 'choparp': |
|
174 |
killbyname("choparp"); |
|
175 |
break; |
|
176 |
case 'dhcpd': |
|
177 |
killbyname("dhcpd"); |
|
178 |
break; |
|
179 |
case 'dhcrelay': |
|
180 |
killbypid("{$g['varrun_path']}/dhcrelay.pid"); |
|
181 |
break; |
|
182 |
case 'dnsmasq': |
|
183 |
killbypid("{$g['varrun_path']}/dnsmasq.pid"); |
|
184 |
break; |
|
185 |
case 'igmpproxy': |
|
186 |
killbyname("igmpproxy"); |
|
187 |
break; |
|
188 |
case 'miniupnpd': |
|
189 |
upnp_action('stop'); |
|
190 |
break; |
|
191 |
case 'sshd': |
|
192 |
killbyname("sshd"); |
|
193 |
break; |
|
194 |
case 'racoon': |
|
195 |
exec("killall -9 racoon"); |
|
196 |
break; |
|
197 |
case 'openvpn': |
|
198 |
$vpnmode = $_GET['vpnmode']; |
|
199 |
if (($vpnmode == "server") or ($vpnmode == "client")) { |
|
200 |
$id = $_GET['id']; |
|
201 |
$pidfile = "{$g['varrun_path']}/openvpn_{$vpnmode}{$id}.pid"; |
|
202 |
killbypid($pidfile); |
|
203 |
} |
|
204 |
break; |
|
205 |
case 'relayd': |
|
206 |
mwexec('pkill relayd'); |
|
207 |
break; |
|
208 |
default: |
|
209 |
stop_service($_GET['service']); |
|
210 |
break; |
|
211 |
} |
|
212 |
$savemsg = sprintf(gettext("%s has been stopped."), htmlspecialchars($_GET['service'])); |
|
56 |
$savemsg = service_control_stop($_GET['service'], $_GET); |
|
213 | 57 |
sleep(5); |
214 | 58 |
} |
215 | 59 |
|
Also available in: Unified diff
Move these service control functions into service-utils.inc so they may be re-used.