Skip to content

Commit 33489e6

Browse files
authored
Refactor: Actual Budget (#9518)
* Update create_self_signed_cert function * Refactor * Remove old version file check
1 parent 877a25c commit 33489e6

File tree

3 files changed

+17
-25
lines changed

3 files changed

+17
-25
lines changed

ct/actualbudget.sh

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -24,33 +24,32 @@ function update_script() {
2424
check_container_storage
2525
check_container_resources
2626

27-
if [[ ! -f /opt/actualbudget_version.txt ]]; then
27+
if [[ ! -f ~/.actualbudget && ! -f /opt/actualbudget_version.txt ]]; then
2828
msg_error "No ${APP} Installation Found!"
2929
exit
3030
fi
31+
3132
NODE_VERSION="22" setup_nodejs
32-
RELEASE=$(curl -fsSL https://api.github.com/repos/actualbudget/actual/releases/latest | grep "tag_name" | awk '{print substr($2, 3, length($2)-4) }')
33+
RELEASE=$(get_latest_github_release "actualbudget/actual")
3334
if [[ -f /opt/actualbudget-data/config.json ]]; then
34-
if [[ ! -f /opt/actualbudget_version.txt ]] || [[ "${RELEASE}" != "$(cat /opt/actualbudget_version.txt)" ]]; then
35+
if check_for_gh_release "actualbudget" "actualbudget/actual"; then
3536
msg_info "Stopping Service"
3637
systemctl stop actualbudget
3738
msg_ok "Stopped Service"
3839

39-
msg_info "Updating ${APP} to ${RELEASE}"
40+
msg_info "Updating Actual Budget to ${RELEASE}"
4041
$STD npm update -g @actual-app/sync-server
41-
echo "${RELEASE}" >/opt/actualbudget_version.txt
42-
msg_ok "Updated ${APP} to ${RELEASE}"
42+
echo "${RELEASE}" >~/.actualbudget
43+
msg_ok "Updated Actual Budget to ${RELEASE}"
4344

4445
msg_info "Starting Service"
4546
systemctl start actualbudget
4647
msg_ok "Started Service"
4748
msg_ok "Updated successfully!"
48-
else
49-
msg_info "${APP} is already up to date"
5049
fi
5150
else
5251
msg_info "Old Installation Found, you need to migrate your data and recreate to a new container"
53-
msg_info "Please follow the instructions on the ${APP} website to migrate your data"
52+
msg_info "Please follow the instructions on the Actual Budget website to migrate your data"
5453
msg_info "https://actualbudget.org/docs/backup-restore/backup"
5554
exit
5655
fi

install/actualbudget-install.sh

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,12 @@ $STD apt install -y \
1919
g++
2020
msg_ok "Installed Dependencies"
2121

22+
NODE_VERSION="22" setup_nodejs
23+
create_self_signed_cert
24+
2225
msg_info "Installing Actual Budget"
2326
cd /opt
24-
RELEASE=$(curl -fsSL https://api.github.com/repos/actualbudget/actual/releases/latest | grep "tag_name" | awk '{print substr($2, 3, length($2)-4) }')
25-
NODE_VERSION="22" setup_nodejs
27+
RELEASE=$(get_latest_github_release "actualbudget/actual")
2628
mkdir -p /opt/actualbudget-data/{server-files,upload,migrate,user-files,migrations,config}
2729
chown -R root:root /opt/actualbudget-data
2830
chmod -R 755 /opt/actualbudget-data
@@ -42,25 +44,15 @@ cat <<EOF >/opt/actualbudget-data/config.json
4244
"fc00::/7"
4345
],
4446
"https": {
45-
"key": "/opt/actualbudget/selfhost.key",
46-
"cert": "/opt/actualbudget/selfhost.crt"
47+
"key": "/etc/ssl/actualbudget/actualbudget.key",
48+
"cert": "/etc/ssl/actualbudget/actualbudget.crt"
4749
}
4850
}
4951
EOF
50-
5152
mkdir -p /opt/actualbudget
5253
cd /opt/actualbudget || exit
5354
$STD npm install --location=global @actual-app/sync-server
54-
$STD openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout selfhost.key -out selfhost.crt <<EOF
55-
US
56-
California
57-
San Francisco
58-
My Organization
59-
My Unit
60-
localhost
61-
62-
EOF
63-
echo "${RELEASE}" >"/opt/actualbudget_version.txt"
55+
echo "${RELEASE}" >~/.actualbudget
6456
msg_ok "Installed Actual Budget"
6557

6658
msg_info "Creating Service"

misc/tools.func

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1551,7 +1551,8 @@ create_self_signed_cert() {
15511551

15521552
mkdir -p "$CERT_DIR"
15531553
$STD openssl req -new -newkey rsa:2048 -days 365 -nodes -x509 \
1554-
-subj "/C=US/ST=State/L=City/O=Organization/CN=${APP_NAME}" \
1554+
-subj "/CN=${APP_NAME}" \
1555+
-addext "subjectAltName=DNS:${APP_NAME}" \
15551556
-keyout "$CERT_KEY" \
15561557
-out "$CERT_CRT" || {
15571558
msg_error "Failed to create self-signed certificate"

0 commit comments

Comments
 (0)