| Line 84... |
Line 84... |
| 84 |
}
|
84 |
}
|
| 85 |
|
85 |
|
| 86 |
//fonction pour faire une action (start,stop,restart) sur un service
|
86 |
//fonction pour faire une action (start,stop,restart) sur un service
|
| 87 |
function serviceExec($service, $action){
|
87 |
function serviceExec($service, $action){
|
| 88 |
if (($action == "start")||($action == "stop")||($action == "restart")){
|
88 |
if (($action == "start")||($action == "stop")||($action == "restart")){
|
| 89 |
exec("sudo /sbin/service $service $action",$retval, $retstatus);
|
89 |
exec("sudo /bin/systemctl $action $service",$retval, $retstatus);
|
| 90 |
if ($service == "sshd"){
|
90 |
if ($service == "sshd"){
|
| 91 |
if ($action == "start"){
|
91 |
if ($action == "start"){
|
| 92 |
exec("sudo /bin/systemctl enable $service.service");
|
92 |
exec("sudo /bin/systemctl enable $service");
|
| 93 |
file_put_contents(CONF_FILE, str_replace('SSH=off', 'SSH=on', file_get_contents(CONF_FILE)));
|
93 |
file_put_contents(CONF_FILE, str_replace('SSH=off', 'SSH=on', file_get_contents(CONF_FILE)));
|
| 94 |
exec ("sudo /usr/local/bin/alcasar-iptables.sh");
|
94 |
exec ("sudo /usr/local/bin/alcasar-iptables.sh");
|
| 95 |
}
|
95 |
}
|
| 96 |
if ($action == "stop"){
|
96 |
if ($action == "stop"){
|
| 97 |
exec("sudo /sbin/systemctl disable $service.service");
|
97 |
exec("sudo /sbin/systemctl disable $service");
|
| 98 |
file_put_contents(CONF_FILE, str_replace('SSH=on', 'SSH=off', file_get_contents(CONF_FILE)));
|
98 |
file_put_contents(CONF_FILE, str_replace('SSH=on', 'SSH=off', file_get_contents(CONF_FILE)));
|
| 99 |
exec ("sudo /usr/local/bin/alcasar-iptables.sh");
|
99 |
exec ("sudo /usr/local/bin/alcasar-iptables.sh");
|
| 100 |
}
|
100 |
}
|
| 101 |
}
|
101 |
}
|
| 102 |
return $retstatus;
|
102 |
return $retstatus;
|