forked from litespeedtech/ols-docker-env
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Test acme script and persistent certs
- Loading branch information
1 parent
58ac393
commit e7be6ff
Showing
2 changed files
with
86 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,87 @@ | ||
#!/usr/bin/env bash | ||
EMAIL='' | ||
NO_EMAIL='' | ||
INSTAL='' | ||
|
||
docker-compose exec litespeed su -c "/root/.acme.sh/acme.sh --issue -d ${1} -w /var/www/vhosts/${1}/html/" | ||
help_message(){ | ||
echo 'Command [-domain XX] [-php lsphpXX]' | ||
echo 'Example: acme.sh -domain ' | ||
} | ||
|
||
check_input(){ | ||
if [ -z "${1}" ]; then | ||
help_message | ||
echo "${1}" | ||
exit 1 | ||
fi | ||
} | ||
|
||
ck_acme(){ | ||
if ! docker-compose exec litespeed su -c "test -f /root/acme/acme.sh"; then | ||
echo "It seems like you didn't install /root/acme/acme.sh, please run bin/acme.sh --install" | ||
exit 1 | ||
fi | ||
} | ||
|
||
install_acme(){ | ||
if [ ! -z ${NO_EMAIL} ]; then | ||
docker-compose exec litespeed su -c "cd;\ | ||
wget https://raw.githubusercontent.com/Neilpang/acme.sh/master/acme.sh; chmod 755 acme.sh; \ | ||
./acme.sh --install \ | ||
--cert-home ~/.acme.sh/certs; \ | ||
rm ~/acme.sh" | ||
else | ||
if [ -z ${EMAIL} ]; then | ||
echo "Error: You didn't specify the email you want to receive lets encrypt notifications on. Please add --email EMAIL" | ||
else | ||
docker-compose exec litespeed su -c "cd;\ | ||
wget https://raw.githubusercontent.com/Neilpang/acme.sh/master/acme.sh; chmod 755 acme.sh; \ | ||
./acme.sh --install \ | ||
--cert-home ~/.acme.sh/certs \ | ||
--accountemail ${EMAIL}; \ | ||
rm ~/acme.sh" | ||
fi | ||
fi | ||
|
||
} | ||
|
||
|
||
main(){ | ||
if [ -z "${INSTALL}" ]; then | ||
ck_acme | ||
else | ||
install_acme ${EMAIL} ${NO_EMAIL} | ||
fi | ||
} | ||
|
||
check_input ${1} | ||
while [ ! -z "${1}" ]; do | ||
case ${1} in | ||
-[hH] | -help | --help) | ||
help_message | ||
exit 1 | ||
;; | ||
-domain | -d ) shift | ||
check_input "${1}" | ||
DOMAIN="${1}" | ||
;; | ||
--install ) | ||
#check_input "${1}" | ||
INSTALL=true | ||
;; | ||
--email ) shift | ||
check_input "${1}" | ||
EMAIL="${1}" | ||
;; | ||
--no-email ) shift | ||
NO_EMAIL=true | ||
;; | ||
*) | ||
help_message | ||
exit 1 | ||
;; | ||
esac | ||
shift | ||
done | ||
|
||
main |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters