From 99cffa5c874571b62ecc0cb4957d5e0060815aaf Mon Sep 17 00:00:00 2001 From: =?utf8?q?Rapha=C3=ABl=20Gertz?= Date: Wed, 1 Mar 2017 11:02:57 +0100 Subject: [PATCH] Add directory creation --- letscron | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/letscron b/letscron index 2a68110..e315a42 100755 --- a/letscron +++ b/letscron @@ -23,8 +23,9 @@ use warnings; use filetest 'access'; # Load dependancies -use Carp qw(carp); +use Carp qw(carp confess); use DateTime; +use File::Path qw(make_path); use File::stat qw(stat); use File::Spec; use File::Slurp qw(read_file write_file); @@ -91,6 +92,19 @@ foreach (@{$config->{certificates}}) { next; } + # Check that key directory exists + if (! -d KEY_DIR) { + # Create all paths + make_path(KEY_DIR, {error => \my $err}); + if (@$err) { + map { + my ($file, $msg) = %$_; + carp ($file eq '' ? '' : $file.': ').$msg if ($debug); + } @$err; + confess 'make_path failed'; + } + } + # Unlink if is a symlink if (-l KEY_DIR.DS.SERVER_KEY) { unless(unlink(KEY_DIR.DS.SERVER_KEY)) { -- 2.41.1