1
0
mirror of https://github.com/community-scripts/ProxmoxVE.git synced 2025-03-08 13:19:05 +00:00

Breaking: Actual Budget Script (HTTPS / DB Migration / New Structure) - Read Description (#2496)

This commit is contained in:
CanbiZ 2025-02-20 12:18:00 +01:00 committed by GitHub
parent 4aa84c265d
commit ba41bcd561
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 55 additions and 32 deletions

View File

@ -1,6 +1,5 @@
#!/usr/bin/env bash
source <(curl -s https://raw.githubusercontent.com/community-scripts/ProxmoxVE/main/misc/build.func)
# Copyright (c) 2021-2025 tteck
# Author: tteck (tteckster)
# License: MIT | https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE
@ -43,36 +42,44 @@ function update_script() {
wget -q "https://github.com/actualbudget/actual-server/archive/refs/tags/v${RELEASE}.tar.gz"
mv /opt/actualbudget /opt/actualbudget_bak
tar -xzf "v${RELEASE}.tar.gz" >/dev/null 2>&1
tar -xzf "v${RELEASE}.tar.gz" &>/dev/null
mv *ctual-server-* /opt/actualbudget
if [[ ! -d /opt/actualbudget-data ]]; then
mkdir -p /opt/actualbudget-data/server-files
mkdir -p /opt/actualbudget-data/{server-files,upload,migrate,user-files,migrations,config}
for dir in server-files .migrate user-files migrations; do
if [[ -d /opt/actualbudget_bak/$dir ]]; then
mv /opt/actualbudget_bak/$dir/* /opt/actualbudget-data/$dir/ 2>/dev/null || true
fi
done
if [[ -f /opt/actualbudget-data/migrate/.migrations ]]; then
sed -i 's/null/1732656575219/g' /opt/actualbudget-data/migrate/.migrations
sed -i 's/null/1732656575220/g' /opt/actualbudget-data/migrate/.migrations
fi
if [[ -f /opt/actualbudget/server-files/account.sqlite ]] && [[ ! -f /opt/actualbudget-data/server-files/account.sqlite ]]; then
mv /opt/actualbudget/server-files/account.sqlite /opt/actualbudget-data/server-files/account.sqlite
fi
rm -rf /opt/actualbudget/.env
if [[ ! -f /opt/actualbudget_bak/.env ]]; then
cat <<EOF > /opt/actualbudget_bak/.env
ACTUAL_UPLOAD_DIR=/opt/actualbudget/server-files
if [[ -f /opt/actualbudget_bak/.env ]]; then
mv /opt/actualbudget_bak/.env /opt/actualbudget-data/.env
else
cat <<EOF > /opt/actualbudget-data/.env
ACTUAL_UPLOAD_DIR=/opt/actualbudget-data/upload
ACTUAL_DATA_DIR=/opt/actualbudget-data
ACTUAL_SERVER_FILES_DIR=/opt/actualbudget/server-files
ACTUAL_SERVER_FILES_DIR=/opt/actualbudget-data/server-files
ACTUAL_USER_FILES=/opt/actualbudget-data/user-files
PORT=5006
ACTUAL_TRUSTED_PROXIES="10.0.0.0/8,172.16.0.0/12,192.168.0.0/16,127.0.0.1/32,::1/128,fc00::/7"
ACTUAL_HTTPS_KEY=/opt/actualbudget/selfhost.key
ACTUAL_HTTPS_CERT=/opt/actualbudget/selfhost.crt
EOF
fi
mv /opt/actualbudget_bak/.env /opt/actualbudget/
if [[ -d /opt/actualbudget_bak/server-files ]] && [[ -n $(ls -A /opt/actualbudget_bak/server-files 2>/dev/null) ]]; then
mv /opt/actualbudget_bak/server-files/* /opt/actualbudget/server-files/
fi
if [[ -d /opt/actualbudget_bak/.migrate ]]; then
mv /opt/actualbudget_bak/.migrate /opt/actualbudget/
fi
cd /opt/actualbudget
yarn install &>/dev/null
echo "${RELEASE}" > /opt/actualbudget_version.txt
msg_ok "Updated ${APP}"
msg_info "Starting ${APP}"
cat <<EOF >/etc/systemd/system/actualbudget.service
cat <<EOF > /etc/systemd/system/actualbudget.service
[Unit]
Description=Actual Budget Service
After=network.target
@ -82,7 +89,7 @@ Type=simple
User=root
Group=root
WorkingDirectory=/opt/actualbudget
EnvironmentFile=/opt/actualbudget/.env
EnvironmentFile=/opt/actualbudget-data/.env
ExecStart=/usr/bin/yarn start
Restart=always
RestartSec=10
@ -90,6 +97,8 @@ RestartSec=10
[Install]
WantedBy=multi-user.target
EOF
systemctl daemon-reload
systemctl start actualbudget
msg_ok "Started ${APP}"
@ -111,4 +120,4 @@ description
msg_ok "Completed Successfully!\n"
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}:5006${CL}"
echo -e "${TAB}${GATEWAY}${BGN}https://${IP}:5006${CL}"

View File

@ -1,9 +1,9 @@
#!/usr/bin/env bash
# Copyright (c) 2021-2025 tteck
# Author: tteck (tteckster)
# License: MIT
# https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE
# Copyright (c) 2021-2025 community-scripts ORG
# Author: MickLesk (CanbiZ)
# License: MIT | https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE
# Source: https://actualbudget.org/
source /dev/stdin <<< "$FUNCTIONS_FILE_PATH"
color
@ -41,18 +41,32 @@ RELEASE=$(curl -s https://api.github.com/repos/actualbudget/actual/releases/late
wget -q https://github.com/actualbudget/actual-server/archive/refs/tags/v${RELEASE}.tar.gz
tar -xzf v${RELEASE}.tar.gz
mv *ctual-server-* /opt/actualbudget
mkdir -p /opt/actualbudget/server-files
mkdir -p /opt/actualbudget-data
chown -R root:root /opt/actualbudget/server-files
chmod 755 /opt/actualbudget/server-files
cat <<EOF > /opt/actualbudget/.env
ACTUAL_UPLOAD_DIR=/opt/actualbudget/server-files
mkdir -p /opt/actualbudget-data/{server-files,upload,migrate,user-files,migrations,config}
chown -R root:root /opt/actualbudget-data
chmod -R 755 /opt/actualbudget-data
cat <<EOF > /opt/actualbudget-data/.env
ACTUAL_UPLOAD_DIR=/opt/actualbudget-data/upload
ACTUAL_DATA_DIR=/opt/actualbudget-data
ACTUAL_SERVER_FILES_DIR=/opt/actualbudget/server-files
ACTUAL_SERVER_FILES_DIR=/opt/actualbudget-data/server-files
ACTUAL_USER_FILES=/opt/actualbudget-data/user-files
PORT=5006
ACTUAL_TRUSTED_PROXIES="10.0.0.0/8,172.16.0.0/12,192.168.0.0/16,127.0.0.1/32,::1/128,fc00::/7"
ACTUAL_HTTPS_KEY=/opt/actualbudget/selfhost.key
ACTUAL_HTTPS_CERT=/opt/actualbudget/selfhost.crt
EOF
cd /opt/actualbudget
$STD yarn install
$STD openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout selfhost.key -out selfhost.crt <<EOF
US
California
San Francisco
My Organization
My Unit
localhost
myemail@example.com
EOF
echo "${RELEASE}" >"/opt/actualbudget_version.txt"
msg_ok "Installed Actual Budget"
@ -67,7 +81,7 @@ Type=simple
User=root
Group=root
WorkingDirectory=/opt/actualbudget
EnvironmentFile=/opt/actualbudget/.env
EnvironmentFile=/opt/actualbudget-data/.env
ExecStart=/usr/bin/yarn start
Restart=always
RestartSec=10