diff --git a/app/neato_init.php b/app/neato_init.php index 42404f3..a3a6b3d 100644 --- a/app/neato_init.php +++ b/app/neato_init.php @@ -29,9 +29,36 @@ if (is_cli() === false) { exit(1); } -function getOSInformation() { +function get_Windows_version() { + $os_info = php_uname(); + + // Regular expression pattern to extract version and build number + $pattern = '/Windows\sNT\s(\d+\.\d+).*build\s(\d+)/'; + + // Perform the regular expression match + preg_match($pattern, $os_info, $matches); + + // Check if the match was successful + if ($matches && count($matches) >= 3) { + // Extracted version and build number + $version = $matches[1]; + $build_number = $matches[2]; + + // Return as an array + return ['version' => $version, 'build' => $build_number]; + } else { + // Return an empty array or handle the case when information is not found + return []; + } +} + +function get_OS_information() { if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') { - return ['name' => 'Windows']; + // Get Windows version information + $windows_version = get_Windows_version(); + $build = $windows_version['build'] ?? false; + $version = $windows_version['version'] ?? false; + return ['name' => 'Windows', 'id' => 'win', 'build'=>$build, 'version_id'=>$version, 'id_like'=>'Windows']; } if (false == function_exists("shell_exec") || false == is_readable("/etc/os-release")) { @@ -39,21 +66,21 @@ function getOSInformation() { } $os = shell_exec('cat /etc/os-release'); - $listIds = preg_match_all('/.*=/', $os, $matchListIds); - $listIds = $matchListIds[0]; + $list_ids = preg_match_all('/.*=/', $os, $match_list_ids); + $list_ids = $match_list_ids[0]; - $listVal = preg_match_all('/=.*/', $os, $matchListVal); - $listVal = $matchListVal[0]; + $list_val = preg_match_all('/=.*/', $os, $match_list_val); + $list_val = $match_list_val[0]; - array_walk($listIds, function(&$v, $k) { + array_walk($list_ids, function(&$v, $k) { $v = strtolower(str_replace('=', '', $v)); }); - array_walk($listVal, function(&$v, $k) { + array_walk($list_val, function(&$v, $k) { $v = preg_replace('/=|"/', '', $v); }); - return array_combine($listIds, $listVal); + return array_combine($list_ids, $list_val); } function is_string_found(string $data, string $find): bool { @@ -68,7 +95,7 @@ function get_right(string $str, int $length): string { return substr($str, -$length); } -$os = getOSInformation(); +$os = get_OS_information(); $osVer = (isset($os['version_id'])) ? $os['version_id'] : false; $codeName = (isset($os['version_codename'])) ? $os['version_codename'] : false; -$os_like = (isset($os['id_like'])) ? $os['id_like'] : false; +$os_like = (isset($os['id_like'])) ? $os['id_like'] : false; \ No newline at end of file diff --git a/build/install_neato.sh b/build/install_neato.sh index 77a8236..8c0dffa 100755 --- a/build/install_neato.sh +++ b/build/install_neato.sh @@ -21,7 +21,8 @@ fi /usr/bin/mv neatoDeploy.phar /opt/neatoDeployments/ /usr/bin/mv neato_deploy.sh /opt/neatoDeployments/ /usr/bin/mv make-sums.sh /opt/neatoDeployments/ -/usr/bin/cp config_files/deploy_*.php /opt/neatoDeployments/ +/usr/bin/mv config_files/deploy_*.php /opt/neatoDeployments/ +/usr/bin/rmdir config_files pushd /opt/neatoDeployments