Files
instance-setup-stuff/gitea_server-setup

34 lines
1017 B
Bash

#!/bin/bash
echo -e "\n[+] setting up gitea\n\n-------\n"
# shellcheck source=gitea_server-env
. "${HOME}"/"${USER}"-env
mkdir -p "${VOLUME_PATH}"/{data,config,postgres}
envsubst <"${HOME}"/"${USER}"-compose_template.yaml >"${HOME}"/"${USER}"-compose.yaml
sudo docker compose -f "${HOME}"/"${USER}"-compose.yaml up -d
echo "[+] preparing to restore from backup..."
sleep 5
sudo docker compose -f "${HOME}"/"${USER}"-compose.yaml stop gitea
mkdir -p "${VOLUME_PATH}"/restore_files
rclone copy "${BUCKET_PATH}" "${VOLUME_PATH}"/restore_files
echo "[+] restoring from backup..."
cp -fr "${VOLUME_PATH}"/restore_files/config "${VOLUME_PATH}"
cp -fr "${VOLUME_PATH}"/restore_files/data "${VOLUME_PATH}"
chown -R "${PUID}":"${PGID}" "${VOLUME_PATH}"/config "${VOLUME_PATH}"/data
cat "${VOLUME_PATH}"/restore_files/db.out | sudo docker exec -i gitea-postgres psql -qXU gitea
echo "[+] restarting..."
sudo docker compose -f "${HOME}"/"${USER}"-compose.yaml restart
# cleanup
rm -rf "${VOLUME_PATH}"/restore_files