From c49b7895a690c329f4af1aa52dcd71cd030533aa Mon Sep 17 00:00:00 2001 From: Joe Carstairs Date: Sun, 8 Jun 2025 08:31:04 +0100 Subject: [PATCH] install.sh collects env vars --- install.sh | 80 ++++++++++++++++++++++++++++++++++--- resticprofile/profiles.toml | 1 - symfony/Dockerfile | 2 +- 3 files changed, 75 insertions(+), 8 deletions(-) diff --git a/install.sh b/install.sh index 10956d8..ef5068b 100755 --- a/install.sh +++ b/install.sh @@ -1,12 +1,80 @@ #!/bin/sh -set -eux -cd ${LIB_DIR:-/lib} -sudo git clone https://git.joeac.net/joeac/joeac.net.git -cd joeac.net -sudo chmod +x uninstall.sh update_and_restart.sh restart.sh -sudo echo << EOF >> ${CRONTABS_DIR:-/etc/cron.d}/joeacnet +install_prerequisite_software () +{ + if [ -n "$(which git)" ] & [ -n "$(which podman)" ] & [ -n "$(which podman-compose)" ] + then + echo "Git, podman and podman-compose are already installed." + elif [ -n "$(which apk)" ] + then + apk update + apk add git podman podman-compose + elif [ -n "$(which apt-get)" ] + then + apt-get update + apt-get install git podman podman-compose -y + elif [ -n "$(which dnf)" ] + then + dnf install git podman podman-compose + elif [ -n "$(which yum)" ] + then + yum install git podman podman-compose + elif [ -n "$(which pacman)" ] + then + pacman -S git podman podman-compose + else + echo "Could not install Git: could not identify package manager." + exit 1 + fi +} + +clone_repository () +{ + cd ${LIB_DIR:-/lib} + git clone https://git.joeac.net/joeac/joeac.net.git + cd joeac.net + chmod +x uninstall.sh update_and_restart.sh restart.sh +} + +add_cron_services () +{ + echo <<- EOF > ${CRONTABS_DIR:-/etc/cron.d}/joeacnet @reboot ${LIB_DIR:-/lib}/joeac.net/restart.sh 10 * * * * ${LIB_DIR:-/lib}/joeac.net/update_and_restart.sh EOF +} + +collect_env_vars () +{ + if [ -z "$AWS_ACCESS_KEY_ID" ] + then + read -p "Backup S3 bucket key ID: " AWS_ACCESS_KEY_ID + fi + if [ -z "$AWS_SECRET_ACCESS_KEY" ] + then + read -sp "Backup S3 bucket secret key: " AWS_SECRET_ACCESS_KEY + fi + if [ -z "$RESTIC_PASSWORD" ] + then + read -sp "Restic repository password: " RESTIC_PASSWORD + fi + if [ -z "$JOEAC_PASSWORD" ] + then + read -sp "Website admin password: " JOEAC_PASSWORD + fi + + APP_ENV=prod + DATABASE_URL="sqlite:///%kernel.project_dir%/var/app.db" + MESSENGER_TRANSPORT_DSN=doctrine://default + + env >> resticprofile/.env + env >> symfony/.env +} + +set -eux +install_prerequisite_software +clone_repository +add_cron_services +set -e +ux +collect_env_vars ./restart.sh diff --git a/resticprofile/profiles.toml b/resticprofile/profiles.toml index 0481362..eb05780 100644 --- a/resticprofile/profiles.toml +++ b/resticprofile/profiles.toml @@ -9,7 +9,6 @@ version = "1" [default] description = "Back up database to BackBlazeB2 S3 Bucket" env-file = ".env" - password-file = "password.txt" repository = "s3:s3.eu-central-003.backblazeb2.com/joeac-net-backup/repo" verbose = 2 diff --git a/symfony/Dockerfile b/symfony/Dockerfile index 53bb1bd..af928a9 100644 --- a/symfony/Dockerfile +++ b/symfony/Dockerfile @@ -2,7 +2,7 @@ FROM docker.io/bitnami/php-fpm:8.4 AS database WORKDIR /app COPY ./composer.* ./symfony.* ./ COPY ./bin ./bin -COPY ./.env.prod ./.env +COPY ./.env ./.env COPY ./config ./config COPY ./migrations ./migrations COPY ./src ./src