diff --git a/.github/workflows/test_docker_debian_codename_sub.yml b/.github/workflows/test_docker_debian_codename_sub.yml index f804784ef..95e94a2ee 100644 --- a/.github/workflows/test_docker_debian_codename_sub.yml +++ b/.github/workflows/test_docker_debian_codename_sub.yml @@ -144,10 +144,10 @@ jobs: fail-fast: false matrix: username: ['pi'] - test_script: ['run_installation_tests.sh', 'run_installation_tests2.sh', 'run_installation_tests3.sh'] + test_script: ['run_installation_classic.sh', 'run_installation_tests2.sh', 'run_installation_tests3.sh', 'run_installation_staticip_dhcpcd.sh', 'run_installation_autohotspot_dhcpcd.sh', 'run_installation_autohotspot_NetworkManager.sh'] include: - username: 'hans' - test_script: 'run_installation_tests.sh' + test_script: 'run_installation_classic.sh' steps: diff --git a/ci/Dockerfile.debian b/ci/Dockerfile.debian index eb545e6b3..15384e782 100644 --- a/ci/Dockerfile.debian +++ b/ci/Dockerfile.debian @@ -84,6 +84,7 @@ FROM test-user as test-code ARG GIT_BRANCH ARG GIT_URL +ENV CI_RUNNING=true ENV GIT_BRANCH=$GIT_BRANCH GIT_URL=$GIT_URL COPY --chown=root:$TEST_USER_GROUP --chmod=770 packages.txt packages-raspberrypi.txt ./ diff --git a/htdocs/inc.setWifi.php b/htdocs/inc.setWifi.php index a7a77987f..691e8a247 100755 --- a/htdocs/inc.setWifi.php +++ b/htdocs/inc.setWifi.php @@ -1,112 +1,83 @@ $post_value ) { + $tempPOST = $_POST; + $_POST=array(); //clear + foreach ( $tempPOST as $post_key => $post_value ) { + unset($temp_ssid); + unset($temp_pass); + unset($temp_prio); if ( substr(trim($post_key), 0, 9) == "WIFIssid_" ) { - $WIFIssid = trim($post_value); + $temp_ssid = trim($post_value); $post_key = "WIFIpass_".substr(trim($post_key), 9); - $post_value = $_POST[$post_key]; - $WIFIpass = trim($post_value); + $post_value = $tempPOST[$post_key]; + $temp_pass = trim($post_value); $post_key = "WIFIprio_".substr(trim($post_key), 9); - $post_value = $_POST[$post_key]; - $WIFIprio = trim($post_value); + $post_value = $tempPOST[$post_key]; + $temp_prio = trim($post_value); - if ( isset($WIFIssid) && $WIFIssid != "") { - if(isset($WIFIpass) && strlen($WIFIpass) >= 8) { - $networks[$WIFIssid] = $WIFIpass; - } - if(isset($WIFIprio) && $WIFIprio != "") { - $priorities[$WIFIssid] = $WIFIprio; + if (isset($temp_ssid) && $temp_ssid != "" && isset($temp_pass) && strlen($temp_pass) >= 8) { + if(!isset($temp_prio) || !is_numeric($temp_prio)) { + $temp_prio = 0; } + $exec .= "add_wireless_network wlan0 ".$temp_ssid." ".$temp_pass." ".$temp_prio."\n"; } } } - $_POST=array(); //clear - // make multiline bash - $exec = "bash -e <<'END'\n"; - $exec .= "echo 'ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev\nupdate_config=1\ncountry=DE\n\n' | sudo tee /etc/wpa_supplicant/wpa_supplicant.conf\n"; - foreach ( $networks as $WIFIssid => $WIFIpass ) { - $WIFIprio = $priorities[$WIFIssid]; - if (strlen($WIFIpass) < 64) { - $WIFIpass = trim(exec("wpa_passphrase '".$WIFIssid."' '".$WIFIpass."' | grep -v -F '#psk' | grep -F 'psk' | cut -d= -f2")); + $exec .= "END\n"; + exec("sudo bash -c '". $exec . "'"); +} + +/* +* get all configured wifis +*/ +$network_confs_shell = shell_exec("sudo bash -c 'source ".$conf['scripts_abs']."/helperscripts/inc.networkHelper.sh && get_wireless_networks'"); +$network_confs = explode(' ',$network_confs_shell); + +$networks = array(); +foreach($network_confs as $line){ + unset($temp_ssid); + unset($temp_pass); + unset($temp_prio); + unset($temp_active); + + $network_conf = explode(':',$line); + $temp_ssid = trim($network_conf[0]); + $temp_pass = trim($network_conf[1]); + $temp_prio = trim($network_conf[2]); + $temp_active = isset($active_essid) && $temp_ssid == $active_essid; + + if(isset($temp_ssid) && $temp_ssid != "" && isset($temp_pass) && $temp_pass != "") { + if(!isset($temp_prio) || !is_numeric($temp_prio)) { + $temp_prio = 0; + } + $temp_entry = array($temp_ssid => [ $temp_pass, $temp_prio, $temp_active ]); + # use different methods to have the same behavior: the data of the first appearance are kept, following will be ignored + if($temp_active) { + $networks = array_merge($temp_entry, $networks); + } else { + $networks = $networks + $temp_entry; } - $exec .= "echo 'network={\n\tssid=\"".$WIFIssid."\"\n\tpsk=".$WIFIpass."\n\tpriority=".$WIFIprio."\n}' | sudo tee -a /etc/wpa_supplicant/wpa_supplicant.conf\n"; } - - $exec .= "sudo chown root:netdev /etc/wpa_supplicant/wpa_supplicant.conf\n"; - $exec .= "sudo chmod 664 /etc/wpa_supplicant/wpa_supplicant.conf\n"; - $exec .= "END\n"; - exec($exec); } +unset($temp_ssid); +unset($temp_pass); +unset($temp_prio); + ?> -