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
|
INI_FILE="/root/digitalocean.ini"
|
||||||
from subprocess import run, PIPE
|
|
||||||
import sys
|
|
||||||
|
|
||||||
ini_file = '/root/digitalocean.ini'
|
if [ ! -f $INI_FILE ]; then
|
||||||
if not exists(ini_file):
|
echo "ERROR: digitalocean credentials not present at $INI_FILE"
|
||||||
print("ERROR: digitalocean credentials not present at " + ini_file)
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
cmd = ['certbot', 'certonly',
|
CMD="certbot certonly --dns-digitalocean --dns-digitalocean-credentials $INI_FILE --dns-digitalocean-propagation-seconds 90"
|
||||||
'--dns-digitalocean',
|
|
||||||
'--dns-digitalocean-credentials',
|
|
||||||
ini_file,
|
|
||||||
'--dns-digitalocean-propagation-seconds',
|
|
||||||
'90',
|
|
||||||
]
|
|
||||||
|
|
||||||
for domain in sys.argv[1:]:
|
for domain in "$@"; do
|
||||||
cmd.extend(['-d', domain])
|
CMD="$CMD -d $domain"
|
||||||
|
done
|
||||||
|
|
||||||
print(run(cmd, stdout=PIPE, stderr=PIPE).stdout.decode('utf=8'))
|
eval $CMD
|
||||||
|
|
Loading…
Reference in a new issue