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.
This commit is contained in:
parent
3a14466c6c
commit
1a34fcba2d
1 changed files with 11 additions and 17 deletions
28
new-domain
28
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
|
||||
|
|
Loading…
Reference in a new issue