setup_postgressql_db and cp instead of mv

This commit is contained in:
Johann Grobe 2025-11-23 16:43:01 +01:00
parent c976d30e41
commit 88f45ee18b
2 changed files with 28 additions and 28 deletions

View File

@ -36,8 +36,8 @@ function update_script() {
msg_ok "Stopped Service" msg_ok "Stopped Service"
msg_info "Creating Backup" msg_info "Creating Backup"
mv /opt/endurain/.env /opt/env.backup cp /opt/endurain/.env /opt/env.backup
mv /opt/endurain/frontend/app/dist/env.js /opt/env.js.backup cp /opt/endurain/frontend/app/dist/env.js /opt/env.js.backup
msg_ok "Backup Created" msg_ok "Backup Created"
CLEAN_INSTALL=1 fetch_and_deploy_gh_release "endurain" "joaovitoriasilva/endurain" "tarball" "latest" "/opt/endurain" CLEAN_INSTALL=1 fetch_and_deploy_gh_release "endurain" "joaovitoriasilva/endurain" "tarball" "latest" "/opt/endurain"
@ -48,14 +48,22 @@ function update_script() {
/opt/endurain/{docs,example.env,screenshot_01.png} \ /opt/endurain/{docs,example.env,screenshot_01.png} \
/opt/endurain/docker* \ /opt/endurain/docker* \
/opt/endurain/*.yml /opt/endurain/*.yml
<<<<<<< HEAD
mv /opt/env.backup /opt/endurain/.env mv /opt/env.backup /opt/endurain/.env
msg_ok "Prepared Update" msg_ok "Prepared Update"
=======
cp /opt/env.backup /opt/endurain/.env
rm /opt/env.backup
msg_ok "Update prepared"
>>>>>>> 5fbe83a8 (setup_postgressql_db and cp instead of mv)
msg_info "Updating Frontend" msg_info "Updating Frontend"
cd /opt/endurain/frontend/app cd /opt/endurain/frontend/app
$STD npm ci $STD npm ci
$STD npm run build $STD npm run build
mv /opt/env.js.backup /opt/endurain/frontend/app/dist/env.js cp /opt/env.js.backup /opt/endurain/frontend/app/dist/env.js
rm /opt/env.js.backup
msg_ok "Frontend Updated" msg_ok "Frontend Updated"
msg_info "Updating Backend" msg_info "Updating Backend"

View File

@ -14,7 +14,7 @@ network_check
update_os update_os
msg_info "Installing Dependencies" msg_info "Installing Dependencies"
$STD apt-get install -y default-libmysqlclient-dev build-essential pkg-config $STD apt install -y default-libmysqlclient-dev build-essential pkg-config
msg_ok "Installed Dependencies" msg_ok "Installed Dependencies"
PYTHON_VERSION="3.13" setup_uv PYTHON_VERSION="3.13" setup_uv
@ -24,17 +24,9 @@ PG_VERSION="17" PG_MODULES="postgis,contrib" setup_postgresql
fetch_and_deploy_gh_release "endurain" "joaovitoriasilva/endurain" "tarball" "latest" "/opt/endurain" fetch_and_deploy_gh_release "endurain" "joaovitoriasilva/endurain" "tarball" "latest" "/opt/endurain"
msg_info "Setting up Endurain" msg_info "Setting up Endurain"
DB_NAME=enduraindb PG_DB_NAME="enduraindb" PG_DB_USER="endurain" PG_DB_GRANT_SUPERUSER="true" setup_postgresql_db
DB_USER=endurain PG_DB_HOST=localhost
DB_PASS=$(openssl rand -base64 18 | tr -dc 'a-zA-Z0-9' | head -c13) PG_DB_PORT=5432
DB_PORT=5432
DB_HOST=localhost
$STD sudo -u postgres psql -c "CREATE ROLE $DB_USER WITH LOGIN PASSWORD '$DB_PASS';"
$STD sudo -u postgres psql -c "CREATE DATABASE $DB_NAME WITH OWNER $DB_USER ENCODING 'UTF8' TEMPLATE template0;"
$STD sudo -u postgres psql -c "ALTER ROLE $DB_USER SET client_encoding TO 'utf8';"
$STD sudo -u postgres psql -c "ALTER ROLE $DB_USER SET default_transaction_isolation TO 'read committed';"
$STD sudo -u postgres psql -c "ALTER ROLE $DB_USER SET timezone TO 'UTC';"
cd /opt/endurain cd /opt/endurain
rm -rf \ rm -rf \
@ -48,7 +40,7 @@ IP=$(hostname -I | awk '{print $1}')
ENDURAIN_HOST=http://${IP}:8080 ENDURAIN_HOST=http://${IP}:8080
cat <<EOF > /opt/endurain/.env cat <<EOF > /opt/endurain/.env
DB_PASSWORD=${DB_PASS} DB_PASSWORD=${PG_DB_PASS}
SECRET_KEY=${SECRET_KEY} SECRET_KEY=${SECRET_KEY}
FERNET_KEY=${FERNET_KEY} FERNET_KEY=${FERNET_KEY}
@ -57,16 +49,16 @@ TZ=Europe/Berlin
ENDURAIN_HOST=${ENDURAIN_HOST} ENDURAIN_HOST=${ENDURAIN_HOST}
BEHIND_PROXY=false BEHIND_PROXY=false
POSTGRES_DB=${DB_NAME} POSTGRES_DB=${PG_DB_NAME}
POSTGRES_USER=${DB_USER} POSTGRES_USER=${PG_DB_USER}
PGDATA=/var/lib/postgresql/${DB_NAME} PGDATA=/var/lib/postgresql/${PG_DB_NAME}
DB_DATABASE=${DB_NAME} DB_DATABASE=${PG_DB_NAME}
DB_USER=${DB_USER} DB_USER=${PG_DB_USER}
DB_PORT=${DB_PORT} DB_PORT=${PG_DB_PORT}
DB_HOST=${DB_HOST} DB_HOST=${PG_DB_HOST}
DATABASE_URL=postgresql+psycopg://${DB_USER}:${DB_PASS}@${DB_HOST}:${DB_PORT}/${DB_NAME} DATABASE_URL=postgresql+psycopg://${PG_DB_USER}:${PG_DB_PASS}@${PG_DB_HOST}:${PG_DB_PORT}/${PG_DB_NAME}
BACKEND_DIR="/opt/endurain/backend/app" BACKEND_DIR="/opt/endurain/backend/app"
FRONTEND_DIR="/opt/endurain/frontend/app/dist" FRONTEND_DIR="/opt/endurain/frontend/app/dist"
@ -95,10 +87,10 @@ msg_ok "Built Frontend"
msg_info "Setting up Backend" msg_info "Setting up Backend"
cd /opt/endurain/backend cd /opt/endurain/backend
$STD uv tool install poetry uv tool install poetry
$STD uv tool update-shell uv tool update-shell
$STD export PATH="/root/.local/bin:$PATH" export PATH="/root/.local/bin:$PATH"
$STD poetry self add poetry-plugin-export poetry self add poetry-plugin-export
$STD poetry export -f requirements.txt --output requirements.txt --without-hashes $STD poetry export -f requirements.txt --output requirements.txt --without-hashes
$STD uv venv $STD uv venv
$STD uv pip install -r requirements.txt $STD uv pip install -r requirements.txt