diff options
author | Gregor Kleen <gkleen@yggdrasil.li> | 2016-01-24 12:49:01 +0100 |
---|---|---|
committer | Gregor Kleen <gkleen@yggdrasil.li> | 2016-01-24 12:49:01 +0100 |
commit | 89c7daa75a9e67eaaf36fb17d8498de64e71e359 (patch) | |
tree | 515faa7f33dfdfd18ded0f5e0a11f8c5cac594e6 | |
parent | 8a205da9cf2f89792a468abda275483d8b762b3a (diff) | |
download | nixos-89c7daa75a9e67eaaf36fb17d8498de64e71e359.tar nixos-89c7daa75a9e67eaaf36fb17d8498de64e71e359.tar.gz nixos-89c7daa75a9e67eaaf36fb17d8498de64e71e359.tar.bz2 nixos-89c7daa75a9e67eaaf36fb17d8498de64e71e359.tar.xz nixos-89c7daa75a9e67eaaf36fb17d8498de64e71e359.zip |
restore from backup on simp_le fail
-rw-r--r-- | custom/simp_le.nix | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/custom/simp_le.nix b/custom/simp_le.nix index 45d7a5ca..94adb44d 100644 --- a/custom/simp_le.nix +++ b/custom/simp_le.nix | |||
@@ -8,18 +8,19 @@ domain: | |||
8 | 8 | ||
9 | let | 9 | let |
10 | script = writeText "${domain}.sh" '' | 10 | script = writeText "${domain}.sh" '' |
11 | backupDir=/root/ssl_archive/$(date +'%Y-%m-%d')-${domain} | ||
11 | mkdir -p ${dir} | 12 | mkdir -p ${dir} |
12 | cd ${dir} | 13 | cd ${dir} |
13 | mkdir -p /root/ssl_archive/$(date +'%Y-%m-%d')-${domain} | 14 | mkdir -p $backupDir |
14 | for f in account_key.json cert.pem fullchain.pem key.pem privkey.pem; do | 15 | for f in account_key.json cert.pem fullchain.pem key.pem privkey.pem; do |
15 | [[ -e $f ]] && mv $f /root/ssl_archive/$(date +'%Y-%m-%d')-${domain} | 16 | [[ -e $f ]] && mv $f $backupDir |
16 | done | 17 | done |
17 | ${simp_le}/bin/simp_le -d ${domain}:/srv/www/acme/${domain}/ \ | 18 | ${simp_le}/bin/simp_le -d ${domain}:/srv/www/acme/${domain}/ \ |
18 | --email "phikeebaogobaegh@141.li" \ | 19 | --email "phikeebaogobaegh@141.li" \ |
19 | -f account_key.json \ | 20 | -f account_key.json \ |
20 | -f cert.pem \ | 21 | -f cert.pem \ |
21 | -f fullchain.pem \ | 22 | -f fullchain.pem \ |
22 | -f key.pem | 23 | -f key.pem || { rm *; mv $backupDir/* . && rmdir $backupDir } |
23 | [[ -e key.pem ]] && ln -s -f key.pem privkey.pem | 24 | [[ -e key.pem ]] && ln -s -f key.pem privkey.pem |
24 | ''; | 25 | ''; |
25 | in | 26 | in |