Update actualbudget.sh

This commit is contained in:
CanbiZ 2025-05-06 07:39:35 +02:00
parent dc289bf882
commit 3f8bc362db

View File

@ -45,88 +45,15 @@ function update_script() {
msg_info "Starting ${APP}"
systemctl start actualbudget
msg_ok "Restarted ${APP}"
else
msg_info "${APP} is already up to date"
fi
else
msg_info "Performing full migration to npm-based version (${RELEASE})"
mv /opt/actualbudget /opt/actualbudget_bak
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/ || 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
systemctl stop actualbudget
rm -rf /opt/actualbudget
rm -rf /opt/actualbudget_bak
mkdir -p /opt/actualbudget
cd /opt/actualbudget
$STD npm install --location=global @actual-app/sync-server
mkdir -p /opt/actualbudget-data/{server-files,user-files}
chown -R root:root /opt/actualbudget-data
chmod -R 755 /opt/actualbudget-data
cat <<EOF >/opt/actualbudget-data/config.json
{
"port": 5006,
"hostname": "::",
"serverFiles": "/opt/actualbudget-data/server-files",
"userFiles": "/opt/actualbudget-data/user-files",
"trustedProxies": [
"10.0.0.0/8",
"172.16.0.0/12",
"192.168.0.0/16",
"127.0.0.1/32",
"::1/128",
"fc00::/7"
],
"https": {
"key": "/opt/actualbudget/selfhost.key",
"cert": "/opt/actualbudget/selfhost.crt"
}
}
EOF
if [[ ! -f /opt/actualbudget/selfhost.key ]]; then
openssl req -x509 -nodes -days 365 -newkey rsa:2048 \
-keyout /opt/actualbudget/selfhost.key \
-out /opt/actualbudget/selfhost.crt \
-subj "/C=US/ST=California/L=San Francisco/O=My Organization/OU=My Unit/CN=localhost/emailAddress=myemail@example.com"
fi
cat <<EOF >/etc/systemd/system/actualbudget.service
[Unit]
Description=Actual Budget Service
After=network.target
[Service]
Type=simple
User=root
Group=root
WorkingDirectory=/opt/actualbudget
Environment=ACTUAL_UPLOAD_FILE_SIZE_LIMIT_MB=20
Environment=ACTUAL_UPLOAD_SYNC_ENCRYPTED_FILE_SYNC_SIZE_LIMIT_MB=50
Environment=ACTUAL_UPLOAD_FILE_SYNC_SIZE_LIMIT_MB=20
ExecStart=/usr/bin/actual-server --config /opt/actualbudget-data/config.json
Restart=always
RestartSec=10
[Install]
WantedBy=multi-user.target
EOF
echo "${RELEASE}" >/opt/actualbudget_version.txt
$STD systemctl daemon-reload
systemctl enable actualbudget
systemctl start actualbudget
msg_ok "Migrated and started ${APP} ${RELEASE}"
msg_info "Old Installation Found, you need to migrate your data and recreate to a new container"
msg_info "Please follow the instructions on the ${APP} website to migrate your data"
msg_info "https://actualbudget.org/docs/backup-restore/backup"
exit 1
fi
msg_ok "Update done"
exit
}