From 0fb62fe4d86f3e140bd989d3a3aca2d76c395549 Mon Sep 17 00:00:00 2001 From: Gregor Kleen Date: Sun, 24 Jan 2016 12:10:16 +0100 Subject: simp_le test --- custom/simp_le.nix | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 custom/simp_le.nix (limited to 'custom/simp_le.nix') diff --git a/custom/simp_le.nix b/custom/simp_le.nix new file mode 100644 index 00000000..ed85fc51 --- /dev/null +++ b/custom/simp_le.nix @@ -0,0 +1,18 @@ +{ stdenv, simp_le +, util-linux +}: +dir: +domain: + +let + script = bulitins.toFile "cert.sh" '' + cd $dir + ${simp_le}/bin/simp_le -d ${domain}:/srv/www/acme/${domain}/ \ + --email "phikeebaogobaegh@141.li" \ + -f account_key.json \ + -f cert.pem \ + -f fullchain.pem \ + -f key.pem + ''; +in + "${stdenv}/bin/bash ${script} ${dir} ${domain} > ${util-linux}/bin/logger -p auth.info" -- cgit v1.2.3 From 94508ad6f57ad38f13cb08629b96179ffc100a19 Mon Sep 17 00:00:00 2001 From: Gregor Kleen Date: Sun, 24 Jan 2016 12:10:35 +0100 Subject: typo --- custom/simp_le.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'custom/simp_le.nix') diff --git a/custom/simp_le.nix b/custom/simp_le.nix index ed85fc51..f975bdb2 100644 --- a/custom/simp_le.nix +++ b/custom/simp_le.nix @@ -5,7 +5,7 @@ dir: domain: let - script = bulitins.toFile "cert.sh" '' + script = bulitin.toFile "cert.sh" '' cd $dir ${simp_le}/bin/simp_le -d ${domain}:/srv/www/acme/${domain}/ \ --email "phikeebaogobaegh@141.li" \ -- cgit v1.2.3 From 48860df6ff917274a837c8470ff8aa6784c5bcf0 Mon Sep 17 00:00:00 2001 From: Gregor Kleen Date: Sun, 24 Jan 2016 12:10:49 +0100 Subject: typo --- custom/simp_le.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'custom/simp_le.nix') diff --git a/custom/simp_le.nix b/custom/simp_le.nix index f975bdb2..537cb915 100644 --- a/custom/simp_le.nix +++ b/custom/simp_le.nix @@ -5,7 +5,7 @@ dir: domain: let - script = bulitin.toFile "cert.sh" '' + script = builtins.toFile "cert.sh" '' cd $dir ${simp_le}/bin/simp_le -d ${domain}:/srv/www/acme/${domain}/ \ --email "phikeebaogobaegh@141.li" \ -- cgit v1.2.3 From 3600019a6db787978b5996819fc6cad6d1832236 Mon Sep 17 00:00:00 2001 From: Gregor Kleen Date: Sun, 24 Jan 2016 12:11:23 +0100 Subject: typo --- custom/simp_le.nix | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'custom/simp_le.nix') diff --git a/custom/simp_le.nix b/custom/simp_le.nix index 537cb915..83582c24 100644 --- a/custom/simp_le.nix +++ b/custom/simp_le.nix @@ -1,5 +1,5 @@ { stdenv, simp_le -, util-linux +, eject }: dir: domain: @@ -15,4 +15,4 @@ let -f key.pem ''; in - "${stdenv}/bin/bash ${script} ${dir} ${domain} > ${util-linux}/bin/logger -p auth.info" + "${stdenv}/bin/bash ${script} ${dir} ${domain} > ${eject}/bin/logger -p auth.info" -- cgit v1.2.3 From f6e28e7f6cc4709ed677efd2231c38ed31b71418 Mon Sep 17 00:00:00 2001 From: Gregor Kleen Date: Sun, 24 Jan 2016 12:14:19 +0100 Subject: writeText instead of toFile --- custom/simp_le.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'custom/simp_le.nix') diff --git a/custom/simp_le.nix b/custom/simp_le.nix index 83582c24..f5b2232f 100644 --- a/custom/simp_le.nix +++ b/custom/simp_le.nix @@ -5,7 +5,7 @@ dir: domain: let - script = builtins.toFile "cert.sh" '' + script = stdenv.lib.writeText "cert.sh" '' cd $dir ${simp_le}/bin/simp_le -d ${domain}:/srv/www/acme/${domain}/ \ --email "phikeebaogobaegh@141.li" \ -- cgit v1.2.3 From 49dc2220c842c2f5b0c330a0ae6448087d7e4bce Mon Sep 17 00:00:00 2001 From: Gregor Kleen Date: Sun, 24 Jan 2016 12:15:00 +0100 Subject: typo --- custom/simp_le.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'custom/simp_le.nix') diff --git a/custom/simp_le.nix b/custom/simp_le.nix index f5b2232f..590b3cac 100644 --- a/custom/simp_le.nix +++ b/custom/simp_le.nix @@ -5,7 +5,7 @@ dir: domain: let - script = stdenv.lib.writeText "cert.sh" '' + script = stdenv.writeText "cert.sh" '' cd $dir ${simp_le}/bin/simp_le -d ${domain}:/srv/www/acme/${domain}/ \ --email "phikeebaogobaegh@141.li" \ -- cgit v1.2.3 From 3765ee37aca35d4173f583f039e18486e2eb1b5d Mon Sep 17 00:00:00 2001 From: Gregor Kleen Date: Sun, 24 Jan 2016 12:15:28 +0100 Subject: wrong namespace --- custom/simp_le.nix | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'custom/simp_le.nix') diff --git a/custom/simp_le.nix b/custom/simp_le.nix index 590b3cac..2b2de3fa 100644 --- a/custom/simp_le.nix +++ b/custom/simp_le.nix @@ -1,11 +1,12 @@ -{ stdenv, simp_le +{ stdenv, writeText +, simp_le , eject }: dir: domain: let - script = stdenv.writeText "cert.sh" '' + script = writeText "cert.sh" '' cd $dir ${simp_le}/bin/simp_le -d ${domain}:/srv/www/acme/${domain}/ \ --email "phikeebaogobaegh@141.li" \ -- cgit v1.2.3 From 2c2adb123227bac3f63726d3a232a270ebb4174d Mon Sep 17 00:00:00 2001 From: Gregor Kleen Date: Sun, 24 Jan 2016 12:19:31 +0100 Subject: shell & directory creation --- custom/simp_le.nix | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'custom/simp_le.nix') diff --git a/custom/simp_le.nix b/custom/simp_le.nix index 2b2de3fa..5d502817 100644 --- a/custom/simp_le.nix +++ b/custom/simp_le.nix @@ -1,4 +1,5 @@ { stdenv, writeText +, bash , simp_le , eject }: @@ -7,6 +8,7 @@ domain: let script = writeText "cert.sh" '' + mkdir -p $dir cd $dir ${simp_le}/bin/simp_le -d ${domain}:/srv/www/acme/${domain}/ \ --email "phikeebaogobaegh@141.li" \ @@ -16,4 +18,4 @@ let -f key.pem ''; in - "${stdenv}/bin/bash ${script} ${dir} ${domain} > ${eject}/bin/logger -p auth.info" + "${bash}/bin/bash ${script} ${dir} ${domain} > ${eject}/bin/logger -p auth.info" -- cgit v1.2.3 From 3deb5a33ee217240ac87bc627007c7aa1c58b007 Mon Sep 17 00:00:00 2001 From: Gregor Kleen Date: Sun, 24 Jan 2016 12:21:44 +0100 Subject: typos --- custom/simp_le.nix | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'custom/simp_le.nix') diff --git a/custom/simp_le.nix b/custom/simp_le.nix index 5d502817..4082612e 100644 --- a/custom/simp_le.nix +++ b/custom/simp_le.nix @@ -8,8 +8,8 @@ domain: let script = writeText "cert.sh" '' - mkdir -p $dir - cd $dir + mkdir -p ${dir} + cd ${dir} ${simp_le}/bin/simp_le -d ${domain}:/srv/www/acme/${domain}/ \ --email "phikeebaogobaegh@141.li" \ -f account_key.json \ @@ -18,4 +18,4 @@ let -f key.pem ''; in - "${bash}/bin/bash ${script} ${dir} ${domain} > ${eject}/bin/logger -p auth.info" + "${bash}/bin/bash ${script} > ${eject}/bin/logger -p auth.info" -- cgit v1.2.3 From 94346f25829ba066e571dc951a6621e001d518d8 Mon Sep 17 00:00:00 2001 From: Gregor Kleen Date: Sun, 24 Jan 2016 12:26:20 +0100 Subject: better nginx conf --- custom/simp_le.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'custom/simp_le.nix') diff --git a/custom/simp_le.nix b/custom/simp_le.nix index 4082612e..2143dfad 100644 --- a/custom/simp_le.nix +++ b/custom/simp_le.nix @@ -7,7 +7,7 @@ dir: domain: let - script = writeText "cert.sh" '' + script = writeText "${domain}.sh" '' mkdir -p ${dir} cd ${dir} ${simp_le}/bin/simp_le -d ${domain}:/srv/www/acme/${domain}/ \ -- cgit v1.2.3 From 46c75cd0b819c724a859d6ed4b65c01d2c12d225 Mon Sep 17 00:00:00 2001 From: Gregor Kleen Date: Sun, 24 Jan 2016 12:28:41 +0100 Subject: now with ssl --- custom/simp_le.nix | 1 + 1 file changed, 1 insertion(+) (limited to 'custom/simp_le.nix') diff --git a/custom/simp_le.nix b/custom/simp_le.nix index 2143dfad..114a6028 100644 --- a/custom/simp_le.nix +++ b/custom/simp_le.nix @@ -16,6 +16,7 @@ let -f cert.pem \ -f fullchain.pem \ -f key.pem + [[ -e key.pem ]] && ln -s key.pem privkey.pem ''; in "${bash}/bin/bash ${script} > ${eject}/bin/logger -p auth.info" -- cgit v1.2.3 From edadb8332a43f10520fbfabcaf007717a724a9fd Mon Sep 17 00:00:00 2001 From: Gregor Kleen Date: Sun, 24 Jan 2016 12:33:43 +0100 Subject: overwrite old privkey.pem files --- custom/simp_le.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'custom/simp_le.nix') diff --git a/custom/simp_le.nix b/custom/simp_le.nix index 114a6028..9ff98364 100644 --- a/custom/simp_le.nix +++ b/custom/simp_le.nix @@ -16,7 +16,7 @@ let -f cert.pem \ -f fullchain.pem \ -f key.pem - [[ -e key.pem ]] && ln -s key.pem privkey.pem + [[ -e key.pem ]] && ln -s -f key.pem privkey.pem ''; in "${bash}/bin/bash ${script} > ${eject}/bin/logger -p auth.info" -- cgit v1.2.3 From 5ee3e5bfbe1b4c76e4e7b73bb8781a225cf71dba Mon Sep 17 00:00:00 2001 From: Gregor Kleen Date: Sun, 24 Jan 2016 12:34:14 +0100 Subject: actually log everything --- custom/simp_le.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'custom/simp_le.nix') diff --git a/custom/simp_le.nix b/custom/simp_le.nix index 9ff98364..4caf50ce 100644 --- a/custom/simp_le.nix +++ b/custom/simp_le.nix @@ -19,4 +19,4 @@ let [[ -e key.pem ]] && ln -s -f key.pem privkey.pem ''; in - "${bash}/bin/bash ${script} > ${eject}/bin/logger -p auth.info" + "${bash}/bin/bash ${script} 2>&1 | ${eject}/bin/logger -p auth.info" -- cgit v1.2.3 From a2b53ca94318207687dabc033e6b346088711d25 Mon Sep 17 00:00:00 2001 From: Gregor Kleen Date: Sun, 24 Jan 2016 12:45:09 +0100 Subject: old cert backups --- custom/simp_le.nix | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'custom/simp_le.nix') diff --git a/custom/simp_le.nix b/custom/simp_le.nix index 4caf50ce..30341179 100644 --- a/custom/simp_le.nix +++ b/custom/simp_le.nix @@ -8,8 +8,14 @@ domain: let script = writeText "${domain}.sh" '' + #!${bash}/bin/bash + mkdir -p ${dir} cd ${dir} + mkdir -p /root/ssl_archive/$(date +'%Y-%m-%d')-${domain} + for f in account_key.json cert.pem fullchain.pem key.pem privkey.pem; do + [[ -e $f ]] && mv $f /root/ssl_archive/$(date +'%Y-%m-%d')-${domain} + done ${simp_le}/bin/simp_le -d ${domain}:/srv/www/acme/${domain}/ \ --email "phikeebaogobaegh@141.li" \ -f account_key.json \ @@ -19,4 +25,4 @@ let [[ -e key.pem ]] && ln -s -f key.pem privkey.pem ''; in - "${bash}/bin/bash ${script} 2>&1 | ${eject}/bin/logger -p auth.info" + "${script} 2>&1 | ${eject}/bin/logger -p auth.info" -- cgit v1.2.3 From fccd19527d271d8c323860e45f4337abd6398dc8 Mon Sep 17 00:00:00 2001 From: Gregor Kleen Date: Sun, 24 Jan 2016 12:46:23 +0100 Subject: shebang wont work --- custom/simp_le.nix | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'custom/simp_le.nix') diff --git a/custom/simp_le.nix b/custom/simp_le.nix index 30341179..45d7a5ca 100644 --- a/custom/simp_le.nix +++ b/custom/simp_le.nix @@ -8,8 +8,6 @@ domain: let script = writeText "${domain}.sh" '' - #!${bash}/bin/bash - mkdir -p ${dir} cd ${dir} mkdir -p /root/ssl_archive/$(date +'%Y-%m-%d')-${domain} @@ -25,4 +23,4 @@ let [[ -e key.pem ]] && ln -s -f key.pem privkey.pem ''; in - "${script} 2>&1 | ${eject}/bin/logger -p auth.info" + "${bash}/bin/bash ${script} 2>&1 | ${eject}/bin/logger -p auth.info" -- cgit v1.2.3 From 89c7daa75a9e67eaaf36fb17d8498de64e71e359 Mon Sep 17 00:00:00 2001 From: Gregor Kleen Date: Sun, 24 Jan 2016 12:49:01 +0100 Subject: restore from backup on simp_le fail --- custom/simp_le.nix | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'custom/simp_le.nix') 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: let script = writeText "${domain}.sh" '' + backupDir=/root/ssl_archive/$(date +'%Y-%m-%d')-${domain} mkdir -p ${dir} cd ${dir} - mkdir -p /root/ssl_archive/$(date +'%Y-%m-%d')-${domain} + mkdir -p $backupDir for f in account_key.json cert.pem fullchain.pem key.pem privkey.pem; do - [[ -e $f ]] && mv $f /root/ssl_archive/$(date +'%Y-%m-%d')-${domain} + [[ -e $f ]] && mv $f $backupDir done ${simp_le}/bin/simp_le -d ${domain}:/srv/www/acme/${domain}/ \ --email "phikeebaogobaegh@141.li" \ -f account_key.json \ -f cert.pem \ -f fullchain.pem \ - -f key.pem + -f key.pem || { rm *; mv $backupDir/* . && rmdir $backupDir } [[ -e key.pem ]] && ln -s -f key.pem privkey.pem ''; in -- cgit v1.2.3 From 724fa9257742c92bbe5550ece6fd657bc24edf8a Mon Sep 17 00:00:00 2001 From: Gregor Kleen Date: Sun, 24 Jan 2016 12:50:48 +0100 Subject: typo --- custom/simp_le.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'custom/simp_le.nix') diff --git a/custom/simp_le.nix b/custom/simp_le.nix index 94adb44d..fb68eb02 100644 --- a/custom/simp_le.nix +++ b/custom/simp_le.nix @@ -20,7 +20,7 @@ let -f account_key.json \ -f cert.pem \ -f fullchain.pem \ - -f key.pem || { rm *; mv $backupDir/* . && rmdir $backupDir } + -f key.pem || { rm *; mv $backupDir/* . && rmdir $backupDir; } [[ -e key.pem ]] && ln -s -f key.pem privkey.pem ''; in -- cgit v1.2.3 From f281e1d83d49dc467569c74c37fd51c2cbe32838 Mon Sep 17 00:00:00 2001 From: Gregor Kleen Date: Sun, 24 Jan 2016 12:52:54 +0100 Subject: not hardlinking bash --- custom/simp_le.nix | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'custom/simp_le.nix') diff --git a/custom/simp_le.nix b/custom/simp_le.nix index fb68eb02..f90abc71 100644 --- a/custom/simp_le.nix +++ b/custom/simp_le.nix @@ -1,5 +1,4 @@ { stdenv, writeText -, bash , simp_le , eject }: @@ -24,4 +23,4 @@ let [[ -e key.pem ]] && ln -s -f key.pem privkey.pem ''; in - "${bash}/bin/bash ${script} 2>&1 | ${eject}/bin/logger -p auth.info" + "bash ${script} 2>&1 | ${eject}/bin/logger -p auth.info" -- cgit v1.2.3 From ab39f049c6d2467ca8e133493ff6f07775c6dd50 Mon Sep 17 00:00:00 2001 From: Gregor Kleen Date: Sun, 24 Jan 2016 12:54:56 +0100 Subject: better use of wildcards --- custom/simp_le.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'custom/simp_le.nix') diff --git a/custom/simp_le.nix b/custom/simp_le.nix index f90abc71..7478bcbf 100644 --- a/custom/simp_le.nix +++ b/custom/simp_le.nix @@ -19,7 +19,7 @@ let -f account_key.json \ -f cert.pem \ -f fullchain.pem \ - -f key.pem || { rm *; mv $backupDir/* . && rmdir $backupDir; } + -f key.pem || { for f in *; do rm $f; done; mv $backupDir/* . && rmdir $backupDir; } [[ -e key.pem ]] && ln -s -f key.pem privkey.pem ''; in -- cgit v1.2.3 From 260d6d41a7eab55a051a5a8497f7bae2c9538006 Mon Sep 17 00:00:00 2001 From: Gregor Kleen Date: Sun, 24 Jan 2016 13:06:19 +0100 Subject: better backup dirs --- custom/simp_le.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'custom/simp_le.nix') diff --git a/custom/simp_le.nix b/custom/simp_le.nix index 7478bcbf..686533a6 100644 --- a/custom/simp_le.nix +++ b/custom/simp_le.nix @@ -7,7 +7,7 @@ domain: let script = writeText "${domain}.sh" '' - backupDir=/root/ssl_archive/$(date +'%Y-%m-%d')-${domain} + backupDir=/root/ssl_archive/$(date +'%Y-%m-%d')-$$-${domain} mkdir -p ${dir} cd ${dir} mkdir -p $backupDir -- cgit v1.2.3