Added additional variables $g
This commit is contained in:
@@ -35,15 +35,23 @@
|
||||
- name: Switch repository and force synchronization (GUI Native)
|
||||
ansible.builtin.raw: |
|
||||
php -r '
|
||||
require_once("guiconfig.inc");
|
||||
require_once("pkg-utils.inc");
|
||||
require_once("/etc/inc/guiconfig.inc");
|
||||
require_once("/etc/inc/pkg-utils.inc");
|
||||
global $g;
|
||||
$target_repo = "{{ upgrade_target_repo }}";
|
||||
$repos = pkg_list_repos();
|
||||
$found = false;
|
||||
foreach ($repos as $repo) {
|
||||
if ($repo["name"] == $target_repo || $repo["path"] == $target_repo) {
|
||||
if ($repo["name"] == $target_repo) {
|
||||
// Update XML config
|
||||
config_set_path("system/pkg_repo_conf_path", $repo["path"]);
|
||||
pkg_switch_repo(g_get("pkg_repos_path"), $repo["name"]);
|
||||
|
||||
// Explicitly pull the path from the global array to ensure it is not null
|
||||
$base_path = $g["pkg_repos_path"] ?: "/usr/local/share/pfSense/pkg/repos";
|
||||
|
||||
// Force the physical symlink switch
|
||||
pkg_switch_repo($base_path, $repo["name"]);
|
||||
|
||||
write_config("Branch switched to " . $repo["name"] . " via Ansible");
|
||||
update_repos();
|
||||
echo "Successfully switched to " . $repo["name"];
|
||||
|
||||
Reference in New Issue
Block a user