This repository has been archived by the owner on Jul 20, 2022. It is now read-only.
generated from homecentr/docker-template
-
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.
fix: Setting gid on certificates (#62)
- Loading branch information
Showing
18 changed files
with
327 additions
and
127 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,5 +1,6 @@ | ||
* text=auto | ||
*.sh eol=lf | ||
**/run eol=lf | ||
*/usr/sbin/* eol=lf | ||
*/services.d/* eol=lf | ||
cron-tick eol=lf |
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 |
---|---|---|
@@ -1,17 +1,15 @@ | ||
#!/usr/bin/env ash | ||
|
||
# Execute certbot | ||
certbot certonly --agree-tos --non-interactive --logs-dir /logs $CERTBOT_ARGS | ||
certbot certonly --agree-tos --non-interactive --work-dir /state/work --config-dir /state/config --logs-dir /logs $CERTBOT_ARGS | ||
|
||
# Fix file permissions | ||
echo "Updating certs ownership to $PUID:${CERTS_GID:-$PGID}" | ||
echo "Updating certs group ownership to gid=${CERTS_GID:-$PGID}" | ||
|
||
chown "$PUID" -R /etc/letsencrypt | ||
chgrp "${CERTS_GID:-$PGID}" -R /etc/letsencrypt | ||
chmod "0750" -R /etc/letsencrypt | ||
# Chmod etc. usually do not follow symlinks when in recursive mode. All files in .../live/... | ||
# are symlinks and hence the target files' permissions must be changed directly. | ||
chgrp "${CERTS_GID:-$PGID}" -R /state/config/archive/*/*.pem | ||
chmod "0640" -R /state/config/archive/*/*.pem | ||
|
||
# Copy files over to /data while preserving the file permissions | ||
cp -p /etc/letsencrypt/live/*/*.pem /data | ||
|
||
# Output the log files to stdout | ||
cat /logs/* | ||
# Copy files over to /certs while preserving the file permissions | ||
cp -p /state/config/live/*/*.pem /certs |
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,29 +1,21 @@ | ||
#!/usr/bin/with-contenv ash | ||
|
||
source homecentr_create_group | ||
source homecentr_set_s6_env_var | ||
source homecentr_get_s6_env_var | ||
|
||
EXEC_USER=$(cat /var/run/s6/container_environment/EXEC_USER) | ||
|
||
if [ "$CERTS_GID" == "0" ] || [ "$CERTS_GID" == "" ] | ||
then | ||
# User doesn't want special group ownership, the group owner of the files will be PGID, skip creating the group | ||
return | ||
fi | ||
|
||
if [ "$CERTS_GID" == "$PGID" ] | ||
then | ||
CERTS_GID=$PGID | ||
fi | ||
|
||
# Check if the group already exists | ||
cat /etc/group | grep ^ssl-readers: > /dev/null | ||
|
||
if [ $? == 0 ] | ||
then | ||
# Group already exists, delete it | ||
delgroup ssl-readers | ||
fi | ||
|
||
# Make sure we really need to create a separate group | ||
if [ "$PGID" != "$CERTS_GID" ] | ||
then | ||
addgroup -g $CERTS_GID ssl-readers | ||
homecentr_create_group "$CERTS_GID" "ssl-readers" | ||
|
||
# Add executing user to the group | ||
addgroup "$EXEC_USER" ssl-readers | ||
fi |
This file was deleted.
Oops, something went wrong.
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,4 @@ | ||
#!/usr/bin/with-contenv ash | ||
|
||
# Check if directory writable as PUID/PGID, this is why it's in a separate script because it's running PUID/PGID context | ||
runas check-dirs-writable |
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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
#!/usr/bin/with-contenv ash | ||
|
||
echo "Executing the certbot immediately to ensure the certificate exists..." | ||
cron-tick-execute | ||
runas cron-tick-execute |
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,28 @@ | ||
#!/usr/bin/env ash | ||
|
||
ls -l / | ||
|
||
SHOULD_EXIT=0 | ||
|
||
if ! test -w "/certs" | ||
then | ||
echo "Directory /certs is not writable by the user $(whoami)!" | ||
SHOULD_EXIT=1 | ||
fi | ||
|
||
if ! test -w "/logs" | ||
then | ||
echo "Directory /logs is not writable by the user $(whoami)!" | ||
SHOULD_EXIT=1 | ||
fi | ||
|
||
if ! test -w "/state" | ||
then | ||
echo "Directory /state is not writable by the user $(whoami)!" | ||
SHOULD_EXIT=1 | ||
fi | ||
|
||
if [ "$SHOULD_EXIT" != "0" ] | ||
then | ||
exit 2 | ||
fi |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
Oops, something went wrong.