summaryrefslogtreecommitdiffstats
path: root/lib/App/BorgRestore/Settings.pm
diff options
context:
space:
mode:
Diffstat (limited to 'lib/App/BorgRestore/Settings.pm')
-rw-r--r--lib/App/BorgRestore/Settings.pm33
1 files changed, 33 insertions, 0 deletions
diff --git a/lib/App/BorgRestore/Settings.pm b/lib/App/BorgRestore/Settings.pm
new file mode 100644
index 0000000..7416c54
--- /dev/null
+++ b/lib/App/BorgRestore/Settings.pm
@@ -0,0 +1,33 @@
+package App::BorgRestore::Settings;
+use v5.10;
+use strict;
+use warnings;
+
+use App::BorgRestore::Helper;
+
+our $borg_repo = "";
+our $cache_path_base = sprintf("%s/borg-restore.pl", $ENV{XDG_CACHE_HOME} // $ENV{HOME}."/.cache");
+our @backup_prefixes = (
+ {regex => "^/", replacement => ""},
+);
+
+my @configfiles = (
+ sprintf("%s/borg-restore.cfg", $ENV{XDG_CONFIG_HOME} // $ENV{HOME}."/.config"),
+ "/etc/borg-restore.cfg",
+);
+
+for my $configfile (@configfiles) {
+ $configfile = App::BorgRestore::Helper::untaint($configfile, qr/.*/);
+ if (-e $configfile) {
+ unless (my $return = do $configfile) {
+ die "couldn't parse $configfile: $@" if $@;
+ die "couldn't do $configfile: $!" unless defined $return;
+ die "couldn't run $configfile" unless $return;
+ }
+ }
+}
+$cache_path_base = App::BorgRestore::Helper::untaint($cache_path_base, qr/.*/);
+
+1;
+
+__END__