mirror of
https://github.com/unraid/webgui.git
synced 2026-01-04 00:19:57 -06:00
51 lines
1.6 KiB
PHP
51 lines
1.6 KiB
PHP
#!/usr/bin/php -q
|
|
<?PHP
|
|
/* Copyright 2005-2025, Lime Technology
|
|
* Copyright 2012-2025, Bergware International.
|
|
*
|
|
* This program is free software; you can redistribute it and/or
|
|
* modify it under the terms of the GNU General Public License version 2,
|
|
* as published by the Free Software Foundation.
|
|
*
|
|
* The above copyright notice and this permission notice shall be included in
|
|
* all copies or substantial portions of the Software.
|
|
*/
|
|
?>
|
|
<?
|
|
$docroot = $_SERVER['DOCUMENT_ROOT'] ?: "/usr/local/emhttp";
|
|
require_once "$docroot/plugins/dynamix/include/Wrappers.php";
|
|
|
|
$arg = $argv[1] ?? '';
|
|
$ini = '/var/local/emhttp/wireless.ini';
|
|
$cfg = '/boot/config/wireless.cfg';
|
|
$wifi = (array)@parse_ini_file($cfg,true);
|
|
$port = array_key_first($wifi);
|
|
$text = ["PORT=\"$port\""];
|
|
if (!$arg) {
|
|
foreach ($wifi as $network => $block) {
|
|
if ($network == $port) continue;
|
|
if ($block['GROUP'] == 'active') {
|
|
$text[] = "SSID=\"$network\"";
|
|
unset($block['GROUP']);
|
|
foreach ($block as $key => $value) $text[] = "$key=\"$value\"";
|
|
}
|
|
}
|
|
} elseif (!in_array($arg,['no','yes'])) {
|
|
foreach ($wifi as $network => $block) {
|
|
if ($network == $port) continue;
|
|
if ($block['GROUP'] == 'saved' && $network == $arg) {
|
|
$text[] = "SSID=\"$network\"";
|
|
unset($block['GROUP']);
|
|
foreach ($block as $key => $value) $text[] = "$key=\"$value\"";
|
|
}
|
|
}
|
|
}
|
|
exec("/etc/rc.d/rc.wireless stop");
|
|
if ($arg == 'yes') {
|
|
exec("/etc/rc.d/rc.wireless start &>/dev/null &");
|
|
} elseif (count($text)>2) {
|
|
file_put_contents_atomic($ini,implode("\n",$text)."\n");
|
|
exec("/etc/rc.d/rc.wireless join &>/dev/null &");
|
|
}
|
|
?>
|