diff --git a/README.md b/README.md index cbd30ce..cf998de 100644 --- a/README.md +++ b/README.md @@ -27,7 +27,10 @@ Runtime configuration is loaded by systemd from: /etc/org-backend/org-backend.env ``` -Create that file once on the server from `misc/org-backend.env.example` and -fill in the production values. The Gitea deploy step installs an updated -example file to `/etc/org-backend/org-backend.env.example`, but it does not -overwrite the real env file. +Create that file once on the server with the production values required by the +app. The Gitea deploy step verifies that it exists, but it does not create or +overwrite it. + +The live systemd unit at `/etc/systemd/system/org-backend.service` is managed +as a symlink to `misc/org-backend.service`, so the project copy is the source of +truth. diff --git a/misc/org-backend.env.example b/misc/org-backend.env.example deleted file mode 100644 index 430b560..0000000 --- a/misc/org-backend.env.example +++ /dev/null @@ -1,23 +0,0 @@ -# Copy this file to /etc/org-backend/org-backend.env on the server and fill in -# production values. This file is safe to commit only with placeholder values. - -SERVER_PORT=9010 - -SPRING_DATASOURCE_URL=jdbc:postgresql://127.0.0.1:5432/org_web -SPRING_DATASOURCE_USERNAME=zaine -SPRING_DATASOURCE_PASSWORD=shakkal123 -SPRING_DATASOURCE_DRIVER_CLASS_NAME=org.postgresql.Driver -SPRING_JPA_SHOW_SQL=false - -CALIBRE_DB_PATH=/home/zaine/master-folder/projects/calibre/library/metadata.db - -JWT_SECRET=change-me-to-a-long-random-secret-at-least-32-characters -JWT_EXPIRATION_MS=86400000 - -ZONE_BUILD_DIR=/home/zaine/master-folder/org_files/org_web -ZONE_BUILD_LOG=/home/zaine/master-folder/org_files/org_web/org-web-build.log -ORGROAM_BUILD_DIR=/home/zaine/master-folder/org_files/org_roam -ORGROAM_BUILD_LOG=/home/zaine/master-folder/org_files/org_roam/orgroam-build.log -EMACS_RUN_DIR=/home/zaine -EMACS_RUN_LOG=/home/zaine/logs/emacs.log -COMBINED_RUN_LOG=/home/zaine/logs/combined.log diff --git a/scripts/deploy-systemd.sh b/scripts/deploy-systemd.sh index bb52c43..374a9a8 100755 --- a/scripts/deploy-systemd.sh +++ b/scripts/deploy-systemd.sh @@ -5,14 +5,12 @@ APP_HOME="${APP_HOME:-/home/zaine/master-folder/projects/java_projects/org_backe SERVICE_NAME="${SERVICE_NAME:-org-backend.service}" SYSTEMCTL_TIMEOUT="${SYSTEMCTL_TIMEOUT:-120}" ENV_FILE="${ENV_FILE:-/etc/org-backend/org-backend.env}" -ENV_EXAMPLE_FILE="${ENV_EXAMPLE_FILE:-/etc/org-backend/org-backend.env.example}" SOURCE_DIR="$(pwd)" SOURCE_JAR="${SOURCE_DIR}/target/org-backend.jar" APP_TARGET_DIR="${APP_HOME}/target" APP_JAR="${APP_TARGET_DIR}/org-backend.jar" SOURCE_SERVICE="${SOURCE_DIR}/misc/${SERVICE_NAME}" -SOURCE_ENV_EXAMPLE="${SOURCE_DIR}/misc/org-backend.env.example" SYSTEMD_SERVICE="/etc/systemd/system/${SERVICE_NAME}" run_sudo() { @@ -33,11 +31,6 @@ if [[ ! -f "${SOURCE_SERVICE}" ]]; then exit 1 fi -if [[ ! -f "${SOURCE_ENV_EXAMPLE}" ]]; then - echo "Missing env example file: ${SOURCE_ENV_EXAMPLE}" >&2 - exit 1 -fi - mkdir -p "${APP_TARGET_DIR}" if [[ "$(realpath "${SOURCE_JAR}")" != "$(realpath -m "${APP_JAR}")" ]]; then @@ -50,18 +43,15 @@ fi echo "Checking sudo access" run_sudo true -echo "Installing env example to ${ENV_EXAMPLE_FILE}" -run_sudo install -d -m 0755 "$(dirname "${ENV_FILE}")" -run_sudo install -m 0640 "${SOURCE_ENV_EXAMPLE}" "${ENV_EXAMPLE_FILE}" - echo "Checking runtime env file at ${ENV_FILE}" if ! run_sudo test -f "${ENV_FILE}"; then - echo "Missing ${ENV_FILE}. Create it from ${ENV_EXAMPLE_FILE} and fill in the production values." >&2 + echo "Missing ${ENV_FILE}. Create it on the server with the production values required by the app." >&2 exit 1 fi -echo "Installing systemd unit to ${SYSTEMD_SERVICE}" -run_sudo install -m 0644 "${SOURCE_SERVICE}" "${SYSTEMD_SERVICE}" +echo "Linking project systemd unit to ${SYSTEMD_SERVICE}" +run_sudo rm -f "${SYSTEMD_SERVICE}" +run_sudo ln -s "${SOURCE_SERVICE}" "${SYSTEMD_SERVICE}" echo "Reloading systemd" run_sudo systemctl daemon-reload