|
| 1 | +#!/usr/bin/env bash |
| 2 | +source <(curl -fsSL https://raw.githubusercontent.com/community-scripts/ProxmoxVED/main/misc/build.func) |
| 3 | +# Copyright (c) 2021-2025 community-scripts ORG |
| 4 | +# Author: MickLesk (CanbiZ) |
| 5 | +# License: MIT | https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE |
| 6 | +# Source: https://actualbudget.org/ |
| 7 | + |
| 8 | +APP="Actual Budget" |
| 9 | +var_tags="finance" |
| 10 | +var_cpu="2" |
| 11 | +var_ram="2048" |
| 12 | +var_disk="4" |
| 13 | +var_os="debian" |
| 14 | +var_version="12" |
| 15 | +var_unprivileged="1" |
| 16 | + |
| 17 | +header_info "$APP" |
| 18 | +variables |
| 19 | +color |
| 20 | +catch_errors |
| 21 | + |
| 22 | +function update_script() { |
| 23 | + header_info |
| 24 | + check_container_storage |
| 25 | + check_container_resources |
| 26 | + |
| 27 | + if [[ ! -d /opt/actualbudget ]]; then |
| 28 | + msg_error "No ${APP} Installation Found!" |
| 29 | + exit |
| 30 | + fi |
| 31 | + NODE_VERSION="22" |
| 32 | + install_node_and_modules |
| 33 | + RELEASE=$(curl -fsSL https://api.github.com/repos/actualbudget/actual/releases/latest | grep "tag_name" | awk '{print substr($2, 3, length($2)-4) }') |
| 34 | + if [[ -f /opt/actualbudget-data/config.json ]]; then |
| 35 | + if [[ ! -f /opt/actualbudget_version.txt ]] || [[ "${RELEASE}" != "$(cat /opt/actualbudget_version.txt)" ]]; then |
| 36 | + msg_info "Stopping ${APP}" |
| 37 | + systemctl stop actualbudget |
| 38 | + msg_ok "${APP} Stopped" |
| 39 | + |
| 40 | + msg_info "Updating ${APP} to ${RELEASE}" |
| 41 | + $STD npm update -g @actual-app/sync-server |
| 42 | + echo "${RELEASE}" >/opt/actualbudget_version.txt |
| 43 | + msg_ok "Updated ${APP} to ${RELEASE}" |
| 44 | + |
| 45 | + msg_info "Starting ${APP}" |
| 46 | + systemctl start actualbudget |
| 47 | + msg_ok "Restarted ${APP}" |
| 48 | + fi |
| 49 | + else |
| 50 | + msg_info "Performing full migration to npm-based version (${RELEASE})" |
| 51 | + systemctl stop actualbudget |
| 52 | + rm -rf /opt/actualbudget |
| 53 | + rm -rf /opt/actualbudget_bak |
| 54 | + mkdir -p /opt/actualbudget |
| 55 | + cd /opt/actualbudget |
| 56 | + $STD npm install --location=global @actual-app/sync-server |
| 57 | + |
| 58 | + mkdir -p /opt/actualbudget-data/{server-files,user-files} |
| 59 | + chown -R root:root /opt/actualbudget-data |
| 60 | + chmod -R 755 /opt/actualbudget-data |
| 61 | + cat <<EOF >/opt/actualbudget-data/config.json |
| 62 | +{ |
| 63 | + "port": 5006, |
| 64 | + "hostname": "::", |
| 65 | + "serverFiles": "/opt/actualbudget-data/server-files", |
| 66 | + "userFiles": "/opt/actualbudget-data/user-files", |
| 67 | + "trustedProxies": [ |
| 68 | + "10.0.0.0/8", |
| 69 | + "172.16.0.0/12", |
| 70 | + "192.168.0.0/16", |
| 71 | + "127.0.0.1/32", |
| 72 | + "::1/128", |
| 73 | + "fc00::/7" |
| 74 | + ], |
| 75 | + "https": { |
| 76 | + "key": "/opt/actualbudget/selfhost.key", |
| 77 | + "cert": "/opt/actualbudget/selfhost.crt" |
| 78 | + } |
| 79 | +} |
| 80 | +EOF |
| 81 | + |
| 82 | + if [[ ! -f /opt/actualbudget/selfhost.key ]]; then |
| 83 | + openssl req -x509 -nodes -days 365 -newkey rsa:2048 \ |
| 84 | + -keyout /opt/actualbudget/selfhost.key \ |
| 85 | + -out /opt/actualbudget/selfhost.crt \ |
| 86 | + -subj "/C=US/ST=California/L=San Francisco/O=My Organization/OU=My Unit/CN=localhost/[email protected]" |
| 87 | + fi |
| 88 | + cat <<EOF >/etc/systemd/system/actualbudget.service |
| 89 | +[Unit] |
| 90 | +Description=Actual Budget Service |
| 91 | +After=network.target |
| 92 | +
|
| 93 | +[Service] |
| 94 | +Type=simple |
| 95 | +User=root |
| 96 | +Group=root |
| 97 | +WorkingDirectory=/opt/actualbudget |
| 98 | +Environment=ACTUAL_UPLOAD_FILE_SIZE_LIMIT_MB=20 |
| 99 | +Environment=ACTUAL_UPLOAD_SYNC_ENCRYPTED_FILE_SYNC_SIZE_LIMIT_MB=50 |
| 100 | +Environment=ACTUAL_UPLOAD_FILE_SYNC_SIZE_LIMIT_MB=20 |
| 101 | +ExecStart=/usr/bin/actual-server --config /opt/actualbudget-data/config.json |
| 102 | +Restart=always |
| 103 | +RestartSec=10 |
| 104 | +
|
| 105 | +[Install] |
| 106 | +WantedBy=multi-user.target |
| 107 | +EOF |
| 108 | + |
| 109 | + echo "${RELEASE}" >/opt/actualbudget_version.txt |
| 110 | + $STD systemctl daemon-reload |
| 111 | + systemctl enable actualbudget |
| 112 | + systemctl start actualbudget |
| 113 | + msg_ok "Migrated and started ${APP} ${RELEASE}" |
| 114 | + fi |
| 115 | + |
| 116 | + msg_ok "Update done" |
| 117 | + exit |
| 118 | +} |
| 119 | + |
| 120 | +start |
| 121 | +build_container |
| 122 | +description |
| 123 | + |
| 124 | +msg_ok "Completed Successfully!\n" |
| 125 | +echo -e "${CREATING}${GN}${APP} setup has been successfully initialized!${CL}" |
| 126 | +echo -e "${INFO}${YW} Access it using the following URL:${CL}" |
| 127 | +echo -e "${TAB}${GATEWAY}${BGN}https://${IP}:5006${CL}" |
0 commit comments