48 lines
1.1 KiB
Bash
48 lines
1.1 KiB
Bash
#!/usr/bin/env bash
|
|
|
|
set -e
|
|
|
|
if [ ! -f ".env" ]; then
|
|
echo "[ERROR] .env file not found. Skipping SSL setup."
|
|
exit 1
|
|
fi
|
|
|
|
source .env
|
|
|
|
if [[ ! "$GITEA_EXTERNAL_URL" == https://* ]]; then
|
|
echo "[INFO] HTTPS not enabled in GITEA_EXTERNAL_URL. Skipping SSL setup."
|
|
exit 0
|
|
fi
|
|
|
|
if [[ -z "$SSL_CERT_PATH" || -z "$SSL_KEY_PATH" ]]; then
|
|
echo "[INFO] SSL_CERT_PATH or SSL_KEY_PATH not set. Skipping SSL copy."
|
|
exit 0
|
|
fi
|
|
|
|
if [ ! -f "$SSL_CERT_PATH" ]; then
|
|
echo "[ERROR] Certificate file not found: $SSL_CERT_PATH"
|
|
exit 1
|
|
fi
|
|
|
|
if [ ! -f "$SSL_KEY_PATH" ]; then
|
|
echo "[ERROR] Key file not found: $SSL_KEY_PATH"
|
|
exit 1
|
|
fi
|
|
|
|
echo "[INFO] Preparing Gitea SSL directory..."
|
|
|
|
mkdir -p ${GITEA_DATA_PATH}/gitea/https
|
|
|
|
echo "[INFO] Copying SSL certificates..."
|
|
|
|
cp "$SSL_CERT_PATH" ${GITEA_DATA_PATH}/gitea/https/cert.pem
|
|
cp "$SSL_KEY_PATH" ${GITEA_DATA_PATH}/gitea/https/key.pem
|
|
|
|
chmod 600 ${GITEA_DATA_PATH}/gitea/https/key.pem
|
|
|
|
echo "[SUCCESS] SSL certificates copied."
|
|
|
|
echo "Gitea will load them from:"
|
|
echo " /data/https/cert.pem"
|
|
echo " /data/https/key.pem"
|