From 8839ad512773924ea3e321ec89767d70f009ef96 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Slavi=C5=A1a=20Are=C5=BEina?= <58952836+tremor021@users.noreply.github.com> Date: Tue, 30 Dec 2025 08:31:20 +0100 Subject: [PATCH] Refactor (#10421) --- ct/firefly.sh | 10 +++------ frontend/public/json/firefly.json | 2 +- install/firefly-install.sh | 35 +++++++++---------------------- 3 files changed, 14 insertions(+), 33 deletions(-) diff --git a/ct/firefly.sh b/ct/firefly.sh index 1b45666fe..ed4fec85e 100644 --- a/ct/firefly.sh +++ b/ct/firefly.sh @@ -11,7 +11,7 @@ var_cpu="${var_cpu:-1}" var_ram="${var_ram:-1024}" var_disk="${var_disk:-2}" var_os="${var_os:-debian}" -var_version="${var_version:-12}" +var_version="${var_version:-13}" var_unprivileged="${var_unprivileged:-1}" header_info "$APP" @@ -73,17 +73,13 @@ function update_script() { msg_ok "Updated Firefly" if [[ "${IMPORTER_INSTALLED:-0}" -eq 1 ]]; then + CLEAN_INSTALL=1 fetch_and_deploy_gh_release "dataimporter" "firefly-iii/data-importer" "prebuild" "latest" "/opt/firefly/dataimporter" "DataImporter-v*.tar.gz" + msg_info "Updating Firefly Importer" - IMPORTER_RELEASE=$(curl -fsSL https://api.github.com/repos/firefly-iii/data-importer/releases/latest | grep tag_name | cut -d '"' -f 4 | sed 's/v//') - rm -rf /opt/firefly/dataimporter - mkdir -p /opt/firefly/dataimporter - curl -fsSL "https://github.com/firefly-iii/data-importer/releases/download/v${IMPORTER_RELEASE}/DataImporter-v${IMPORTER_RELEASE}.tar.gz" -o "/opt/DataImporter.tar.gz" - tar -xzf /opt/DataImporter.tar.gz -C /opt/firefly/dataimporter if [[ -f /opt/dataimporter.env ]]; then cp /opt/dataimporter.env /opt/firefly/dataimporter/.env fi chown -R www-data:www-data /opt/firefly/dataimporter - rm -f /opt/DataImporter.tar.gz msg_ok "Updated Firefly Importer" fi systemctl start apache2 diff --git a/frontend/public/json/firefly.json b/frontend/public/json/firefly.json index abb963557..70bb49b98 100644 --- a/frontend/public/json/firefly.json +++ b/frontend/public/json/firefly.json @@ -23,7 +23,7 @@ "ram": 1024, "hdd": 2, "os": "debian", - "version": "12" + "version": "13" } } ], diff --git a/install/firefly-install.sh b/install/firefly-install.sh index db3e5bd1d..dae35b126 100644 --- a/install/firefly-install.sh +++ b/install/firefly-install.sh @@ -16,24 +16,10 @@ update_os PHP_VERSION="8.4" PHP_APACHE="YES" PHP_MODULE="mysql" setup_php setup_composer setup_mariadb -LOCAL_IP=$(hostname -I | awk '{print $1}') - -msg_info "Setting up database" -DB_NAME=firefly -DB_USER=firefly -DB_PASS=$(openssl rand -base64 18 | tr -dc 'a-zA-Z0-9' | head -c13) -$STD mariadb -u root -e "CREATE DATABASE $DB_NAME;" -$STD mariadb -u root -e "CREATE USER '$DB_USER'@'localhost' IDENTIFIED BY '$DB_PASS';" -mariadb -u root -e "GRANT ALL ON $DB_NAME.* TO '$DB_USER'@'localhost'; FLUSH PRIVILEGES;" -{ - echo "Firefly-Credentials" - echo "Firefly Database User: $DB_USER" - echo "Firefly Database Password: $DB_PASS" - echo "Firefly Database Name: $DB_NAME" -} >>~/firefly.creds -msg_ok "Set up database" - +MARIADB_DB_NAME="firefly" MARIADB_DB_USER="firefly" setup_mariadb_db +import_local_ip fetch_and_deploy_gh_release "firefly" "firefly-iii/firefly-iii" "prebuild" "latest" "/opt/firefly" "FireflyIII-*.zip" +fetch_and_deploy_gh_release "dataimporter" "firefly-iii/data-importer" "prebuild" "latest" "/opt/firefly/dataimporter" "DataImporter-v*.tar.gz" msg_info "Configuring Firefly III (Patience)" chown -R www-data:www-data /opt/firefly @@ -41,22 +27,19 @@ chmod -R 775 /opt/firefly/storage cd /opt/firefly cp .env.example .env sed -i "s/DB_HOST=.*/DB_HOST=localhost/" /opt/firefly/.env -sed -i "s/DB_PASSWORD=.*/DB_PASSWORD=$DB_PASS/" /opt/firefly/.env +sed -i "s/DB_PASSWORD=.*/DB_PASSWORD=$MARIADB_DB_PASS/" /opt/firefly/.env $STD composer install --no-dev --no-plugins --no-interaction $STD php artisan firefly:upgrade-database $STD php artisan firefly:correct-database $STD php artisan firefly:report-integrity $STD php artisan firefly:laravel-passport-keys -IMPORTER_RELEASE=$(curl -fsSL https://api.github.com/repos/firefly-iii/data-importer/releases/latest | grep "tag_name" | awk '{print substr($2, 3, length($2)-4)}') -mkdir -p /opt/firefly/dataimporter -cd /opt -curl -fsSL "https://github.com/firefly-iii/data-importer/releases/download/v${IMPORTER_RELEASE}/DataImporter-v${IMPORTER_RELEASE}.tar.gz" -o "DataImporter-v${IMPORTER_RELEASE}.tar.gz" -tar -xzf "DataImporter-v${IMPORTER_RELEASE}.tar.gz" -C /opt/firefly/dataimporter +msg_ok "Configured Firefly III" + +msg_info "Configuring Data Importer" cp /opt/firefly/dataimporter/.env.example /opt/firefly/dataimporter/.env sed -i "s#FIREFLY_III_URL=#FIREFLY_III_URL=http://${LOCAL_IP}#g" /opt/firefly/dataimporter/.env chown -R www-data:www-data /opt/firefly -rm -rf "/opt/DataImporter-v${IMPORTER_RELEASE}.tar.gz" -msg_ok "Configured Firefly III" +msg_ok "Configured Data Importer" msg_info "Creating Service" cat </etc/apache2/sites-available/firefly.conf @@ -69,6 +52,8 @@ cat </etc/apache2/sites-available/firefly.conf AllowOverride All Require all granted + + RedirectMatch 301 ^/dataimporter$ /dataimporter/ Alias /dataimporter/ /opt/firefly/dataimporter/public/