initial commit
This commit is contained in:
47
scripts/setup-ssl.sh
Normal file
47
scripts/setup-ssl.sh
Normal file
@@ -0,0 +1,47 @@
|
||||
#!/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"
|
||||
Reference in New Issue
Block a user