diff options
author | Trygve Laugstøl <trygvis@inamo.no> | 2023-11-23 12:07:48 +0100 |
---|---|---|
committer | Trygve Laugstøl <trygvis@inamo.no> | 2023-11-23 12:07:48 +0100 |
commit | ba29b490ffddd28bb09235a1bd0e99df73bfa064 (patch) | |
tree | ef52db9a12e88810aec1b019a3fe2f8dde2c27e8 | |
parent | 2583897e4c5cbe56525365206c2a64bcd0c75e5f (diff) | |
download | prolog-firewall-ba29b490ffddd28bb09235a1bd0e99df73bfa064.tar.gz prolog-firewall-ba29b490ffddd28bb09235a1bd0e99df73bfa064.tar.bz2 prolog-firewall-ba29b490ffddd28bb09235a1bd0e99df73bfa064.tar.xz prolog-firewall-ba29b490ffddd28bb09235a1bd0e99df73bfa064.zip |
wip
-rw-r--r-- | 7/main.pl | 26 |
1 files changed, 26 insertions, 0 deletions
@@ -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). |