Subversion Repositories ALCASAR

Rev

Rev 2926 | Rev 2934 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log

Rev 2926 Rev 2931
Line 153... Line 153...
153
// Doing an action on a service (start,stop or restart)
153
// Doing an action on a service (start,stop or restart)
154
function serviceExec($service, $action){
154
function serviceExec($service, $action){
155
	if (($action == "start")||($action == "stop")||($action == "restart")){
155
	if (($action == "start")||($action == "stop")||($action == "restart")){
156
		if ($service != "wifi4eu") { exec("sudo /usr/bin/systemctl $action ".escapeshellarg($service), $retval, $retstatus); }
156
		if ($service != "wifi4eu") { exec("sudo /usr/bin/systemctl $action ".escapeshellarg($service), $retval, $retstatus); }
157
		if ($service == "wifi4eu"){
157
		if ($service == "wifi4eu"){
158
			if ($action == "stop"){
-
 
159
				file_put_contents(CONF_FILE, str_replace('WIFI4EU=on', 'WIFI4EU=off', file_get_contents(CONF_FILE)));
158
			if ($action == "stop"){  // see POST fonction (below) to start this service
160
//				exec("sudo /usr/local/bin/alcasar-wifi4eu.sh -off");
159
				exec("sudo /usr/local/bin/alcasar-wifi4eu.sh -off");
161
				}
160
				}
162
			}
161
			}
163
		if ($service == "sshd"){ 
162
		if ($service == "sshd"){ 
164
			if ($action == "start"){
163
			if ($action == "start"){
165
				exec("sudo /usr/bin/systemctl enable ".escapeshellarg($service)); // in order to keep that conf for SSH at next reboot
164
				//exec("sudo /usr/bin/systemctl enable ".escapeshellarg($service));
166
				file_put_contents(CONF_FILE, str_replace('SSH=off', 'SSH=on', file_get_contents(CONF_FILE)));
165
				file_put_contents(CONF_FILE, str_replace('SSH=off', 'SSH=on', file_get_contents(CONF_FILE))); // in order to keep that conf for SSH at next reboot
167
				exec("sudo /usr/local/bin/alcasar-iptables.sh");
166
				exec("sudo /usr/local/bin/alcasar-iptables.sh");
168
				}
167
				}
169
			if ($action == "stop"){
168
			if ($action == "stop"){
170
				exec("sudo /usr/bin/systemctl disable ".escapeshellarg($service));  // in order to keep that conf for SSH at next reboot
169
				//exec("sudo /usr/bin/systemctl disable ".escapeshellarg($service));
171
				file_put_contents(CONF_FILE, str_replace('SSH=on', 'SSH=off', file_get_contents(CONF_FILE)));
170
				file_put_contents(CONF_FILE, str_replace('SSH=on', 'SSH=off', file_get_contents(CONF_FILE)));
172
				exec("sudo /usr/local/bin/alcasar-iptables.sh");
171
				exec("sudo /usr/local/bin/alcasar-iptables.sh");
173
				}
172
				}
174
			}
173
			}
175
		return $retstatus;
174
		return $retstatus;
Line 205... Line 204...
205
}
204
}
206
//-------------------------------
205
//-------------------------------
207
// WIFI4EU
206
// WIFI4EU
208
//-------------------------------
207
//-------------------------------
209
if (isset($_POST['wifi4eu'])){
208
if (isset($_POST['wifi4eu'])){
210
	file_put_contents(CONF_FILE, str_replace('WIFI4EU=off', 'WIFI4EU=on', file_get_contents(CONF_FILE)));
209
	//file_put_contents(CONF_FILE, preg_replace('/^WIFI4EU_CODE=*/', 'WIFI4EU_CODE='.$_POST['wifi4eu'], file_get_contents(CONF_FILE)));
211
//	file_put_contents(CONF_FILE, preg_replace('^WIFI4EU_CODE=*', 'WIFI4EU_code=$_POST[\'wifi4eu\']', file_get_contents(CONF_FILE)));
210
	file_put_contents(CONF_FILE, preg_replace('/^WIFI4EU_CODE=.*/', 'WIFI4EU_CODE=REXY', file_get_contents(CONF_FILE)));
212
//	exec("sudo /usr/local/bin/alcasar-wifi4eu.sh -on");
211
	exec("sudo /usr/local/bin/alcasar-wifi4eu.sh -on");
213
}
212
}
214
//-------------------------------
213
//-------------------------------
215
// Actions on system
214
// Actions on system
216
//-------------------------------
215
//-------------------------------
217
if (isset($_POST['choix'])){
216
if (isset($_POST['choix'])){