diff --git a/entrypoint.sh b/entrypoint.sh index db29415..165f86a 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -38,7 +38,7 @@ fi # (directories are already created in Dockerfile with proper ownership) touch /var/log/prosody/prosody.log /var/log/prosody/prosody.err 2>/dev/null || true -# Copy Let's Encrypt certificate to prosody certs directory +# Copy Let's Encrypt certificate to prosody certs directory if available CERT_PATH="/etc/prosody/certs/xmpp.guschin.info.crt" KEY_PATH="/etc/prosody/certs/xmpp.guschin.info.key" LETSENCRYPT_CERT="/etc/prosody/certs/letsencrypt/fullchain.pem" @@ -51,11 +51,16 @@ if [ -f "$LETSENCRYPT_CERT" ] && [ -f "$LETSENCRYPT_KEY" ]; then chmod 644 "$CERT_PATH" chmod 600 "$KEY_PATH" chown prosody:prosody "$CERT_PATH" "$KEY_PATH" + echo "Let's Encrypt certificate successfully installed" +elif [ ! -f "$CERT_PATH" ] || [ ! -f "$KEY_PATH" ]; then + echo "Let's Encrypt certificate not found, generating self-signed certificate..." + openssl req -x509 -newkey rsa:4096 -keyout "$KEY_PATH" -out "$CERT_PATH" \ + -days 365 -nodes -subj "/CN=xmpp.guschin.info" + chmod 600 "$KEY_PATH" + chmod 644 "$CERT_PATH" + chown prosody:prosody "$CERT_PATH" "$KEY_PATH" else - echo "ERROR: Let's Encrypt certificates not found at:" - echo " Certificate: $LETSENCRYPT_CERT" - echo " Private Key: $LETSENCRYPT_KEY" - exit 1 + echo "Using existing certificates" fi echo "Starting Prosody..."