Skip to content

Commit

Permalink
Safely remove certificates folder
Browse files Browse the repository at this point in the history
  • Loading branch information
cruizba committed Oct 15, 2020
1 parent 0463230 commit f73bafd
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ services:
- MAX_PORT=65535

nginx:
image: openvidu/openvidu-proxy:4.0.0-dev3
image: openvidu/openvidu-proxy:4.0.0-dev4
restart: on-failure
network_mode: host
volumes:
Expand Down
11 changes: 6 additions & 5 deletions openvidu-server/docker/openvidu-proxy/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -68,22 +68,23 @@ printf "\n ======================================="
printf "\n"

printf "\n Configure %s domain..." "${DOMAIN_OR_PUBLIC_IP}"
OLD_DOMAIN_OR_PUBLIC_IP=$(grep "${DOMAIN_OR_PUBLIC_IP}" "${CERTIFICATES_CONF}" | cut -f1 -d$'\t')
CERTIFICATED_OLD_CONFIG=$(grep "${DOMAIN_OR_PUBLIC_IP}" "${CERTIFICATES_CONF}" | cut -f2 -d$'\t')
OLD_DOMAIN_OR_PUBLIC_IP=$(head -n 1 "${CERTIFICATES_CONF}" | cut -f1 -d$'\t')
CERTIFICATED_OLD_CONFIG=$(head -n 1 "${CERTIFICATES_CONF}" | cut -f2 -d$'\t')

printf "\n - New configuration: %s" "${CERTIFICATE_TYPE}"
printf "\n - New configuration: %s %s" "${CERTIFICATE_TYPE}" "${DOMAIN_OR_PUBLIC_IP}"

if [ -z "${CERTIFICATED_OLD_CONFIG}" ]; then
printf "\n - Old configuration: none"
else
printf "\n - Old configuration: %s" "${CERTIFICATED_OLD_CONFIG}"
printf "\n - Old configuration: %s %s" "${CERTIFICATED_OLD_CONFIG}" "${OLD_DOMAIN_OR_PUBLIC_IP}"

if [ "${CERTIFICATED_OLD_CONFIG}" != "${CERTIFICATE_TYPE}" ] || \
[ "${OLD_DOMAIN_OR_PUBLIC_IP}" != "${DOMAIN_OR_PUBLIC_IP}" ]; then

printf "\n - Restarting configuration... Removing old certificated..."
# Remove certificate folder safely
find "${CERTIFICATES_FOLDER:?}" -mindepth 1 -delete
# Recreate certificates folder
rm -rf "${CERTIFICATES_FOLDER:?}"
mkdir -p "${CERTIFICATES_LIVE_FOLDER}"
touch "${CERTIFICATES_CONF}"
fi
Expand Down

0 comments on commit f73bafd

Please sign in to comment.