% vim set ft=prolog :- use_module(library(files)). :- use_module(library(format)). :- use_module(library(lists)). :- use_module(bgp, [ create_firewall/0]). print_warnings([]). print_warnings([W|Ws]) :- format("Warning: ~s~n", [W]), print_warnings(Ws). print_warnings :- findall(W, bgp:warning(W), BgpWs), findall(W, firewall:warning(W), FwWs), append(BgpWs, FwWs, Ws), length(Ws, L), ( L > 0 -> format("Found ~w warning(s):~n", [L]), print_warnings(Ws) ; format("No warnings!~n", []) ). rm_rf(Dir) :- directory_files(Dir, Files), path_segments(Dir, Ps), rm_rf_files(Ps, Files). rm_rf_files(_, []). rm_rf_files(Parents, [D|Dir]) :- % format("rm_rf_files Parents=~w, D=~w, Dir=~w~n", [Parents,D,Dir]), append(Parents, [D], PathS), path_segments(Path, PathS), ( directory_exists(Path) -> % format("down ~s~n", [Path]), directory_files(Path, Files), % format("files ~w~n", [Files]), rm_rf_files(PathS, Files), format("rmdir ~s~n", [Path]), delete_directory(Path) ; format("rm ~s~n", [Path]), delete_file(Path) ), rm_rf_files(Parents, Dir). main :- bgp:create_firewall, print_warnings, bgp:bird_config(BirdDict), rm_rf("host_vars"), yaml_write(current_output, BirdDict).