diff --git a/ajax/networking/save_net_dev_config.php b/ajax/networking/save_net_dev_config.php index af79cfb4..c718ae9b 100644 --- a/ajax/networking/save_net_dev_config.php +++ b/ajax/networking/save_net_dev_config.php @@ -71,7 +71,7 @@ if (isset($_POST['interface'])) { if (!empty($rule) ) exec('echo \''.$rule.'\' | sudo /usr/bin/tee -a '.$udevfile); } $ret=print_r($ret,true); - $jsonData = ['return'=>0,'output'=>['Udev rules changed for device '.$dev ] ]; + $jsonData = ['return'=>0,'output'=>['Settings changed for device '.$dev ] ]; echo json_encode($jsonData); return; } diff --git a/includes/dashboard.php b/includes/dashboard.php index aaae3188..39934239 100755 --- a/includes/dashboard.php +++ b/includes/dashboard.php @@ -24,6 +24,24 @@ function DisplayDashboard(&$extraFooterScripts) $status->showMessages(); return; } + + // ------------------------- Button pressed to switch client on/off --------------------------------------------------------- + $switchedOn = false; + if (!RASPI_MONITOR_ENABLED) { + if (isset($_POST['ifdown_wlan0'])) { + // Pressed stop button + $status->addMessage(sprintf(_('Interface is going %s.'), _('down')), 'warning'); + setClientState("down"); + $status->addMessage(sprintf(_('Interface is now %s.'), _('down')), 'success'); + } elseif (isset($_POST['ifup_wlan0'])) { + // Pressed start button + $status->addMessage(sprintf(_('Interface is going %s.'), _('up')), 'warning'); + setClientState("up"); + $status->addMessage(sprintf(_('Interface is now %s.'), _('up')), 'success'); + $switchedOn = true; + } + } + // ----------------------------- INFOS ABOUT THE ACCESS POINT ------------------------------------------------------------- @@ -112,36 +130,8 @@ function DisplayDashboard(&$extraFooterScripts) if ($interfaceState === 'UP') { $classMsgDevicestatus = 'success'; } - if (!RASPI_MONITOR_ENABLED) { - if (isset($_POST['ifdown_wlan0'])) { - // Pressed stop button - if ($interfaceState === 'UP') { - $status->addMessage(sprintf(_('Interface is going %s.'), _('down')), 'warning'); - setClientState("down"); -// exec('sudo /usr/local/sbin/switchClientState.sh down'); - $status->addMessage(sprintf(_('Interface is now %s.'), _('down')), 'success'); - } elseif ($interfaceState === 'unknown') { - $status->addMessage(_('Interface state unknown.'), 'danger'); - } else { - $status->addMessage(sprintf(_('Interface already %s.'), _('down')), 'warning'); - } - } elseif (isset($_POST['ifup_wlan0'])) { - // Pressed start button - if ($interfaceState === 'DOWN') { - $status->addMessage(sprintf(_('Interface is going %s.'), _('up')), 'warning'); - setClientState("up"); -// exec('sudo /usr/local/sbin/switchClientState.sh up'); - exec('sudo ip -s a f label ' . $raspi_client); - $status->addMessage(sprintf(_('Interface is now %s.'), _('up')), 'success'); - } elseif ($interfaceState === 'unknown') { - $status->addMessage(_('Interface state unknown.'), 'danger'); - } else { - $status->addMessage(sprintf(_('Interface already %s.'), _('up')), 'warning'); - } - } else { - $status->addMessage(sprintf(_('Interface is %s.'), strtolower($interfaceState)), $classMsgDevicestatus); - } - } + + if ($switchedOn) exec('sudo ip -s a f label ' . $raspi_client); // brought in from template $arrHostapdConf = parse_ini_file(RASPI_CONFIG.'/hostapd.ini'); diff --git a/installers/raspap.sudoers b/installers/raspap.sudoers index 246deefa..4c3b5b68 100644 --- a/installers/raspap.sudoers +++ b/installers/raspap.sudoers @@ -49,5 +49,4 @@ www-data ALL=(ALL) NOPASSWD:/usr/local/sbin/onoff_huawei_hilink.sh * www-data ALL=(ALL) NOPASSWD:/bin/sed -i * /etc/wvdial.conf www-data ALL=(ALL) NOPASSWD:/bin/sed -i * /etc/udev/rules.d/80-raspap-net-devices.rules www-data ALL=(ALL) NOPASSWD:/usr/bin/tee -a /etc/udev/rules.d/80-raspap-net-devices.rules - - +www-data ALL=(ALL) NOPASSWD:/usr/local/sbin/switchClientState.sh *