Skip to content

Commit 50963e0

Browse files
ActualBudget: Update Script with new Repo (#2907)
* ActualBudget: Update Script with new Repo * syntax + formatting * Update actualbudget.sh * Update ct/actualbudget.sh Co-authored-by: Michel Roegl-Brunner <[email protected]> --------- Co-authored-by: Michel Roegl-Brunner <[email protected]>
1 parent e0f6511 commit 50963e0

File tree

1 file changed

+81
-2
lines changed

1 file changed

+81
-2
lines changed

ct/actualbudget.sh

Lines changed: 81 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,88 @@ function update_script() {
2626

2727
if [[ ! -d /opt/actualbudget ]]; then
2828
msg_error "No ${APP} Installation Found!"
29-
exit 1
29+
exit
30+
fi
31+
32+
RELEASE=$(curl -s https://api.github.com/repos/actualbudget/actual/releases/latest | grep "tag_name" | awk '{print substr($2, 3, length($2)-4) }')
33+
if [[ ! -f /opt/actualbudget_version.txt ]] || [[ "${RELEASE}" != "$(cat /opt/actualbudget_version.txt)" ]]; then
34+
msg_info "Stopping ${APP}"
35+
systemctl stop actualbudget
36+
msg_ok "${APP} Stopped"
37+
38+
msg_info "Updating ${APP} to ${RELEASE}"
39+
cd /tmp
40+
wget -q https://github.com/actualbudget/actual/archive/refs/tags/v${RELEASE}.tar.gz
41+
42+
mv /opt/actualbudget /opt/actualbudget_bak
43+
tar -xzf "v${RELEASE}.tar.gz"
44+
mv actual-${RELEASE} /opt/actualbudget
45+
46+
mkdir -p /opt/actualbudget-data/{server-files,upload,migrate,user-files,migrations,config}
47+
for dir in server-files .migrate user-files migrations; do
48+
if [[ -d /opt/actualbudget_bak/$dir ]]; then
49+
mv /opt/actualbudget_bak/$dir/* /opt/actualbudget-data/$dir/ || true
50+
fi
51+
done
52+
if [[ -f /opt/actualbudget-data/migrate/.migrations ]]; then
53+
sed -i 's/null/1732656575219/g' /opt/actualbudget-data/migrate/.migrations
54+
sed -i 's/null/1732656575220/g' /opt/actualbudget-data/migrate/.migrations
55+
fi
56+
if [[ -f /opt/actualbudget/server-files/account.sqlite ]] && [[ ! -f /opt/actualbudget-data/server-files/account.sqlite ]]; then
57+
mv /opt/actualbudget/server-files/account.sqlite /opt/actualbudget-data/server-files/account.sqlite
58+
fi
59+
60+
if [[ -f /opt/actualbudget_bak/.env ]]; then
61+
mv /opt/actualbudget_bak/.env /opt/actualbudget-data/.env
62+
else
63+
cat <<EOF >/opt/actualbudget-data/.env
64+
ACTUAL_UPLOAD_DIR=/opt/actualbudget-data/upload
65+
ACTUAL_DATA_DIR=/opt/actualbudget-data
66+
ACTUAL_SERVER_FILES_DIR=/opt/actualbudget-data/server-files
67+
ACTUAL_USER_FILES=/opt/actualbudget-data/user-files
68+
PORT=5006
69+
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"
70+
ACTUAL_HTTPS_KEY=/opt/actualbudget/selfhost.key
71+
ACTUAL_HTTPS_CERT=/opt/actualbudget/selfhost.crt
72+
EOF
73+
fi
74+
cd /opt/actualbudget
75+
$STD yarn workspaces focus @actual-app/sync-server --production
76+
echo "${RELEASE}" >/opt/actualbudget_version.txt
77+
msg_ok "Updated ${APP}"
78+
79+
msg_info "Starting ${APP}"
80+
cat <<EOF >/etc/systemd/system/actualbudget.service
81+
[Unit]
82+
Description=Actual Budget Service
83+
After=network.target
84+
85+
[Service]
86+
Type=simple
87+
User=root
88+
Group=root
89+
WorkingDirectory=/opt/actualbudget
90+
EnvironmentFile=/opt/actualbudget-data/.env
91+
ExecStart=/usr/bin/yarn start:server
92+
Restart=always
93+
RestartSec=10
94+
95+
[Install]
96+
WantedBy=multi-user.target
97+
EOF
98+
99+
systemctl daemon-reload
100+
systemctl start actualbudget
101+
msg_ok "Started ${APP}"
102+
103+
msg_info "Cleaning Up"
104+
rm -rf /opt/actualbudget_bak
105+
rm -rf "/tmp/v${RELEASE}.tar.gz"
106+
msg_ok "Cleaned"
107+
msg_ok "Updated Successfully"
108+
else
109+
msg_ok "No update required. ${APP} is already at ${RELEASE}"
30110
fi
31-
msg_error "Due to major changes in the Actual Budget repository, we are currently unable to provide updates. Please check back later."
32111
exit
33112
}
34113

0 commit comments

Comments
 (0)