diff options
| author | John Estabrook <jestabro@vyos.io> | 2025-05-09 14:09:36 -0500 |
|---|---|---|
| committer | John Estabrook <jestabro@vyos.io> | 2025-05-12 11:26:41 -0500 |
| commit | d4d8d619a70e81229927bf0268d8c1257fd7e5cd (patch) | |
| tree | ae3595e6c0578731f5bc719fc04db6b063dbe052 | |
| parent | 96b559e44783908874a64d19a27cafe532bbee42 (diff) | |
| download | vyconf-d4d8d619a70e81229927bf0268d8c1257fd7e5cd.tar.gz vyconf-d4d8d619a70e81229927bf0268d8c1257fd7e5cd.zip | |
T7352: add option to load legacy config on start for interoperability
| -rw-r--r-- | src/defaults.ml | 2 | ||||
| -rw-r--r-- | src/defaults.mli | 1 | ||||
| -rw-r--r-- | src/vyconfd.ml | 17 |
3 files changed, 16 insertions, 4 deletions
diff --git a/src/defaults.ml b/src/defaults.ml index 9ce36e5..d8fc484 100644 --- a/src/defaults.ml +++ b/src/defaults.ml @@ -4,6 +4,7 @@ type vyconf_defaults = { socket: string; log_template: string; log_level: string; + legacy_config_path: string; } let defaults = { @@ -12,4 +13,5 @@ let defaults = { socket = "/var/run/vyconfd.sock"; log_template = "$(date) $(name)[$(pid)]: $(message)"; log_level = "notice"; + legacy_config_path = "/opt/vyatta/etc/config/config.boot"; } diff --git a/src/defaults.mli b/src/defaults.mli index 042eced..dc58606 100644 --- a/src/defaults.mli +++ b/src/defaults.mli @@ -4,6 +4,7 @@ type vyconf_defaults = { socket: string; log_template: string; log_level: string; + legacy_config_path: string; } val defaults : vyconf_defaults diff --git a/src/vyconfd.ml b/src/vyconfd.ml index edc4b9d..816ca69 100644 --- a/src/vyconfd.ml +++ b/src/vyconfd.ml @@ -24,6 +24,7 @@ let daemonize = ref true let config_file = ref defaults.config_file let basepath = ref "/" let log_file = ref None +let legacy_config_path = ref false (* Global data *) let sessions : (string, Session.session_data) Hashtbl.t = Hashtbl.create 10 @@ -39,7 +40,9 @@ let args = [ (Printf.sprintf "<string> Configuration file, default is %s" defaults.config_file)); ("--log-file", Arg.String (fun s -> log_file := Some s), "<string> Log file"); ("--base-path", Arg.String (fun s -> basepath := s), "<string> Appliance base path"); - ("--version", Arg.Unit (fun () -> print_endline @@ Version.version_info (); exit 0), "Print version and exit") + ("--version", Arg.Unit (fun () -> print_endline @@ Version.version_info (); exit 0), "Print version and exit"); + ("--legacy-config-path", Arg.Unit (fun () -> legacy_config_path := true), + (Printf.sprintf "Load config file from legacy path %s" defaults.legacy_config_path)); ] let usage = "Usage: " ^ Sys.argv.(0) ^ " [options]" @@ -363,8 +366,14 @@ let () = let dirs = Directories.make !basepath vc in Startup.check_validators_dir dirs; let world = make_world vc dirs in - let config = Startup.load_config_failsafe - (FP.concat vc.config_dir vc.primary_config) - (FP.concat vc.config_dir vc.fallback_config) in + let primary_config = + match !legacy_config_path with + | true -> defaults.legacy_config_path + | false -> (FP.concat vc.config_dir vc.primary_config) + in + let failsafe_config = (FP.concat vc.config_dir vc.fallback_config) in + let config = + Startup.load_config_failsafe primary_config failsafe_config + in let world = Session.{world with running_config=config} in Lwt_main.run @@ main_loop !basepath world () |
