From 1a34fcba2d78e829f21ee8c73a89202ed5c6a018 Mon Sep 17 00:00:00 2001 From: William Brawner Date: Sat, 30 Oct 2021 00:58:28 +0000 Subject: [PATCH] Convert new-domain to a shell script The Python script was swallowing the input and output and causing it to stall, so instead of learning more Python to make it work, I opted to hack together a shell script that accomplished the same task. --- new-domain | 28 +++++++++++----------------- 1 file changed, 11 insertions(+), 17 deletions(-) diff --git a/new-domain b/new-domain index 7de8a92..9b7a42e 100755 --- a/new-domain +++ b/new-domain @@ -1,22 +1,16 @@ -#!/usr/bin/env python3 +#!/usr/bin/env sh -from os.path import exists -from subprocess import run, PIPE -import sys +INI_FILE="/root/digitalocean.ini" -ini_file = '/root/digitalocean.ini' -if not exists(ini_file): - print("ERROR: digitalocean credentials not present at " + ini_file) +if [ ! -f $INI_FILE ]; then + echo "ERROR: digitalocean credentials not present at $INI_FILE" + exit 1 +fi -cmd = ['certbot', 'certonly', - '--dns-digitalocean', - '--dns-digitalocean-credentials', - ini_file, - '--dns-digitalocean-propagation-seconds', - '90', - ] +CMD="certbot certonly --dns-digitalocean --dns-digitalocean-credentials $INI_FILE --dns-digitalocean-propagation-seconds 90" -for domain in sys.argv[1:]: - cmd.extend(['-d', domain]) +for domain in "$@"; do + CMD="$CMD -d $domain" +done -print(run(cmd, stdout=PIPE, stderr=PIPE).stdout.decode('utf=8')) +eval $CMD