summaryrefslogtreecommitdiff
path: root/7/main.pl
diff options
context:
space:
mode:
Diffstat (limited to '7/main.pl')
-rw-r--r--7/main.pl26
1 files changed, 26 insertions, 0 deletions
diff --git a/7/main.pl b/7/main.pl
index 579f74f..684708f 100644
--- a/7/main.pl
+++ b/7/main.pl
@@ -1,3 +1,6 @@
+% vim set ft=prolog
+
+:- use_module(library(files)).
:- use_module(library(format)).
:- use_module(library(lists)).
@@ -19,8 +22,31 @@ print_warnings :-
; 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).