ProxmoxVE/ct/firefly.sh

85 lines
2.5 KiB
Bash
Raw Normal View History

2024-11-30 15:35:50 +00:00
#!/usr/bin/env bash
2024-11-30 18:59:17 +00:00
source <(curl -s https://raw.githubusercontent.com/community-scripts/ProxmoxVE/main/misc/build.func)
2024-11-30 15:35:50 +00:00
# Copyright (c) 2021-2024 community-scripts ORG
2024-12-26 18:24:00 +00:00
# Author: quantumryuu
2024-11-30 15:35:50 +00:00
# License: MIT
# https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE
2024-12-26 18:24:00 +00:00
# Source: https://firefly-iii.org/
2024-11-30 15:35:50 +00:00
2024-12-26 18:24:00 +00:00
# App Default Values
2024-11-30 15:38:47 +00:00
APP="Firefly"
2024-12-26 18:24:00 +00:00
var_tags="finance"
2024-11-30 15:35:50 +00:00
var_cpu="1"
2024-11-30 15:36:51 +00:00
var_ram="1024"
2024-12-26 18:24:00 +00:00
var_disk="2"
2024-11-30 15:35:50 +00:00
var_os="debian"
var_version="12"
2024-12-26 18:24:00 +00:00
var_unprivileged="1"
# App Output & Base Settings
header_info "$APP"
base_settings
# Core
2024-11-30 15:35:50 +00:00
variables
color
catch_errors
function update_script() {
header_info
check_container_storage
check_container_resources
2024-11-30 18:49:41 +00:00
if [[ ! -d /opt/firefly ]]; then
2024-11-30 15:35:50 +00:00
msg_error "No ${APP} Installation Found!"
exit
fi
2024-11-30 17:47:51 +00:00
RELEASE=$(curl -s https://api.github.com/repos/firefly-iii/firefly-iii/releases/latest | grep "tag_name" | awk '{print substr($2, 3, length($2)-4)}')
2024-11-30 15:35:50 +00:00
if [[ ! -f /opt/${APP}_version.txt ]] || [[ "${RELEASE}" != "$(cat /opt/${APP}_version.txt)" ]]; then
2024-11-30 16:30:47 +00:00
msg_info "Stopping Apache2"
systemctl stop apache2
msg_ok "Stopped Apache2"
2024-11-30 15:35:50 +00:00
msg_info "Updating ${APP} to v${RELEASE}"
2024-11-30 18:49:41 +00:00
cp /opt/firefly/.env /opt/.env
cp -r /opt/firefly/storage /opt/storage
2024-12-26 18:24:00 +00:00
rm -rf /opt/firefly/*
2024-11-30 15:35:50 +00:00
cd /opt
2024-11-30 17:47:51 +00:00
wget -q "https://github.com/firefly-iii/firefly-iii/releases/download/v${RELEASE}/FireflyIII-v${RELEASE}.tar.gz"
2024-11-30 18:49:41 +00:00
tar -xzf FireflyIII-v${RELEASE}.tar.gz -C /opt/firefly --exclude='storage'
cd /opt/firefly
2024-12-26 18:24:00 +00:00
composer install --no-dev --no-interaction &>/dev/null
2024-11-30 18:49:41 +00:00
php artisan migrate --seed --force &>/dev/null
php artisan firefly:decrypt-all &>/dev/null
2024-11-30 16:30:47 +00:00
php artisan cache:clear &>/dev/null
php artisan view:clear &>/dev/null
2024-11-30 18:49:41 +00:00
php artisan firefly:upgrade-database &>/dev/null
php artisan firefly:laravel-passport-keys &>/dev/null
2024-11-30 18:55:36 +00:00
chown -R www-data:www-data /opt/firefly
chmod -R 775 /opt/firefly/storage
2024-12-26 18:24:00 +00:00
echo "${RELEASE}" >"/opt/${APP}_version.txt"
2024-11-30 15:35:50 +00:00
msg_ok "Updated ${APP} to v${RELEASE}"
2024-11-30 16:30:47 +00:00
msg_info "Starting Apache2"
systemctl start apache2
msg_ok "Started Apache2"
2024-11-30 15:35:50 +00:00
msg_info "Cleaning up"
2024-11-30 18:15:47 +00:00
rm -rf /opt/FireflyIII-v${RELEASE}.tar.gz
2024-11-30 15:35:50 +00:00
msg_ok "Cleaned"
msg_ok "Updated Successfully"
else
msg_ok "No update required. ${APP} is already at v${RELEASE}."
fi
exit
}
start
build_container
description
msg_ok "Completed Successfully!\n"
2024-12-26 18:24:00 +00:00
echo -e "${CREATING}${GN}${APP} setup has been successfully initialized!${CL}"
echo -e "${INFO}${YW} Access it using the following URL:${CL}"
echo -e "${TAB}${GATEWAY}${BGN}http://${IP}${CL}"