-
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.
Improve error detection, add manual script, fixes
- Loading branch information
Showing
5 changed files
with
88 additions
and
13 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,15 +1,16 @@ | ||
FROM ubuntu:20.04 | ||
FROM ubuntu:latest | ||
#FROM certbot/certbot | ||
|
||
# Install cron | ||
# Install cron, certbot, curl and msmtp for sending mail | ||
RUN apt-get update && apt-get install -y certbot cron msmtp curl | ||
RUN rm -rf /var/lib/apt/list | ||
|
||
# Add files | ||
# Add scripts | ||
ADD run.sh /run.sh | ||
ADD runmanual.sh /runmanual.sh | ||
ADD entrypoint.sh /entrypoint.sh | ||
|
||
RUN chmod +x /run.sh /entrypoint.sh | ||
RUN chmod +x /run.sh /runmanual.sh /entrypoint.sh | ||
RUN mkdir /output/ | ||
|
||
ENTRYPOINT /entrypoint.sh |
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
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
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
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 |
---|---|---|
@@ -0,0 +1,57 @@ | ||
#!/bin/bash | ||
# Probably the worst script you have ever seen, feel free to improve :-) | ||
currentDate=`date` | ||
|
||
# Load config | ||
. /settings.conf | ||
|
||
echo | ||
echo "Please enter domain to request certificate" | ||
read SITE | ||
|
||
echo "---------- Manual job started on $currentDate ----------" | ||
|
||
# Re-use code in loop: | ||
echo ------------------- ${SITE} ------------------- | ||
certbot certonly --standalone --preferred-challenges http --http-01-port 80 --renew-by-default --non-interactive --email $EMAIL --rsa-key-size 4096 $TOS -d $SITE | ||
# Check for errors | ||
RESULT=$? | ||
if [ $RESULT -eq 0 ]; then | ||
echo Succesfully requested certificate. | ||
|
||
# Check if folder and certificate files exist. (Does not mean that the last run was succesful) && [ -d "/etc/letsencrypt/live/$SITE/fullchain.pem" ] && [ -d "/etc/letsencrypt/live/$SITE/privkey.pem" ]; | ||
if [ -d "/etc/letsencrypt/live/$SITE/" ]; then | ||
# Cat files to make combined .pem files in the output folder. | ||
cat /etc/letsencrypt/live/$SITE/fullchain.pem /etc/letsencrypt/live/$SITE/privkey.pem > /output/$SITE.pem | ||
chown $RIGHTS /output/$SITE.pem | ||
else | ||
echo -e "\e[1;31mError finding certificate!\e[0m" | ||
fi | ||
|
||
else | ||
echo -e "\e[1;31mError obtaining certificate!\e[0m" | ||
fi | ||
|
||
echo '--------' | ||
echo | ||
echo "Finished requesting certificate manualy" | ||
|
||
echo "Add domain to the domains-file for automatic renewal? y/n" | ||
read RUNADD | ||
|
||
if [ $RUNADD == "y" ]; then | ||
echo "Adding '$SITE' to domain file" | ||
echo $SITE >> /domains.conf | ||
fi | ||
|
||
echo "Run Actions? y/n" | ||
read RUNACTIONS | ||
|
||
if [ $RUNACTIONS == "y" ]; then | ||
echo | ||
echo "Execute configured action: $ACTION" | ||
$ACTION | ||
echo '--------' | ||
echo "End of run" | ||
fi | ||
exit 0 |