diff options
author | Andinus <andinus@nand.sh> | 2020-10-11 19:35:47 +0530 |
---|---|---|
committer | Andinus <andinus@nand.sh> | 2020-10-11 20:09:48 +0530 |
commit | 67543995fc041a0bb77820b3bb74fab1bf1c3ab3 (patch) | |
tree | 20acdd69f5c2d4bb750131c0d7aea6553c22494b | |
parent | 44d2fb9a47b45c693860f5e2e27b1218ee488c84 (diff) | |
download | leo-67543995fc041a0bb77820b3bb74fab1bf1c3ab3.tar.gz |
Remove obsolete code, add extra config options
-rwxr-xr-x | leo.pl | 31 | ||||
-rw-r--r-- | share/leo.conf | 4 |
2 files changed, 21 insertions, 14 deletions
diff --git a/leo.pl b/leo.pl index ccdc758..0041b5b 100755 --- a/leo.pl +++ b/leo.pl @@ -33,14 +33,9 @@ $config = Config::Tiny->read( $config_file ) # Reading config file. -my $ymd = ymd(); # YYYY-MM-DD. -my $backup_dir = $config->{_}->{backup_dir} || "/tmp/backups"; -$backup_dir .= "/$ymd"; - -path($backup_dir)->mkpath; # Create backup directory. - -my $gpg_fingerprint = $config->{_}->{gpg_fingerprint}; -my $gpg_bin = $config->{_}->{gpg_bin}; +foreach my $key (sort keys $config->{_}->%*) { + $options{$key} = $config->{_}->{$key}; +} my %profile; @@ -51,6 +46,15 @@ foreach my $section (sort keys $config->%*) { } } +my $ymd = ymd(); # YYYY-MM-DD. +my $backup_dir = $options{backup_dir} || "/tmp/backups"; +$backup_dir .= "/$ymd"; + +path($backup_dir)->mkpath; # Create backup directory. + +my $gpg_fingerprint = $options{gpg_fingerprint}; +my $gpg_bin = $options{gpg_bin}; + # Print help. HelpMessage() and exit 0 if scalar @ARGV == 0 or $options{help}; @@ -128,27 +132,26 @@ sub HelpMessage { Profile:}; foreach my $prof (sort keys %profile) { - next if substr($prof, 0, 1) eq "."; # Profiles starting with a - # dot will have alias. print " $prof\n"; print " $_\n" foreach $profile{$prof}->@*; } print qq{ Options: --encrypt }; - print "[Enabled]" if $ENV{LEO_ENCRYPT}; + print "[Enabled]" if $options{encrypt}; print qq{ Encrypt files with $gpg_fingerprint\n --sign }; - print "[Enabled]" if $ENV{LEO_SIGN}; + print "[Enabled]" if $options{sign}; print qq{ Sign files with $gpg_fingerprint\n --delete }; - print "[Enabled]" if $ENV{LEO_DELETE}; + print "[Enabled]" if $options{delete}; print qq{ Delete the tar file after running $gpg_bin\n --verbose - --help}; + --help +}; } sub tar_create { run3 ["/bin/tar", "cf", @_]; } diff --git a/share/leo.conf b/share/leo.conf index d909446..a0280a7 100644 --- a/share/leo.conf +++ b/share/leo.conf @@ -3,6 +3,10 @@ backup_dir = /home/andinus/backups gpg_fingerprint = D9AE4AEEE1F1B3598E81D9DFB67D55D482A799FD gpg_bin = gpg2 +encrypt=1 +sign=1 +delete=1 + # Profile names in []. [journal] # Paths to backup. '=' after path is important. |