Skip to content

Commit 9aa5ab1

Browse files
committed
add list and renew
1 parent 243e0b2 commit 9aa5ab1

File tree

4 files changed

+50
-26
lines changed

4 files changed

+50
-26
lines changed

.gitignore

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,7 @@
1111
# Output of the go coverage tool, specifically when used with LiteIDE
1212
*.out
1313

14-
# Dependency directories (remove the comment below to include it)
15-
# vendor/
14+
keys/
15+
vendor/
16+
certbot/
17+
.secrets/

Dockerfile

Lines changed: 3 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,8 @@
1-
FROM alpine:latest
2-
ENV USER=certbot
3-
ENV UID=1017
4-
ENV GID=1017
1+
FROM python:3-slim
52

6-
RUN apk update && apk add --no-cache certbot
7-
RUN pip3 install --upgrade --no-cache-dir pip
8-
RUN pip3 install --no-cache-dir certbot-dns-digitalocean
9-
RUN mkdir /opt/certbot
103
ADD apps.sh /usr/local/bin/apps.sh
11-
RUN chmod +x /usr/local/bin/apps.sh
12-
13-
RUN addgroup -g $GID -S $USER
14-
RUN adduser \
15-
--disabled-password \
16-
--gecos "" \
17-
--home "/opt/certbot/" \
18-
--ingroup "$USER" \
19-
--no-create-home \
20-
--uid "$UID" \
21-
"$USER"
22-
23-
USER certbot
4+
RUN pip install --no-cache-dir certbot certbot-dns-digitalocean && \
5+
chmod +x /usr/local/bin/apps.sh
246

257
WORKDIR /opt/certbot/
268

apps.sh

100644100755
Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,14 @@ cli_help(){
2424
cat << "EOF"
2525
2626
--help printing this options
27+
--list list certificate
2728
--new create certificate
2829
--renew renew certificate
2930
3031
EOF
3132
}
3233

33-
# main program
34+
# main script
3435

3536
cli_banner
3637

@@ -50,14 +51,21 @@ case $1 in
5051

5152
--renew|d)
5253
read -p 'Your Renew Domain : ' DOMAIN
53-
certbot certonly \
54+
certbot renew \
5455
--work-dir /opt/certbot \
5556
--logs-dir /opt/certbot \
5657
--config-dir /opt/certbot \
5758
--dns-digitalocean \
5859
--dns-digitalocean-propagation-seconds 10 \
5960
--dns-digitalocean-credentials ~/.secrets/config.ini \
60-
-d "$DOMAIN"
61+
--cert-name "$DOMAIN"
62+
;;
63+
64+
--list|d)
65+
certbot certificates \
66+
--work-dir /opt/certbot \
67+
--logs-dir /opt/certbot \
68+
--config-dir /opt/certbot
6169
;;
6270

6371
*)

docert.sh

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
#!/usr/bin/env bash
2+
3+
DOCERT="docker run --rm -ti -v $(pwd)/.secrets/:/root/.secrets/ -v $(pwd)/certbot/:/opt/certbot/ devboxid/docert"
4+
COMMAND="$1"
5+
6+
cli_help(){
7+
cat << "EOF"
8+
9+
+-----------------------------------+
10+
| TASK | TASK USAGE FOR |
11+
+-----------------------------------+
12+
| list | list certificate |
13+
| new | create certificate |
14+
| renew | renew certificate |
15+
+-----------------------------------+
16+
17+
EOF
18+
}
19+
20+
if [[ ! -z "$COMMAND" ]]; then
21+
if [[ "$COMMAND" != "list" ]] || [[ "$COMMAND" != "new" ]] || [[ "$COMMAND" != "renew" ]]; then
22+
cli_help
23+
fi
24+
else
25+
cli_help
26+
read -p 'Type your task : ' TASK
27+
clear
28+
$DOCERT "--$TASK"
29+
fi
30+
31+
# change permission on generated certificate
32+
sudo chown -R "$USER" certbot

0 commit comments

Comments
 (0)