Refactor: Actual Budget (#9518)
* Update create_self_signed_cert function * Refactor * Remove old version file check
This commit is contained in:
parent
877a25c0cc
commit
33489e607b
@ -24,33 +24,32 @@ function update_script() {
|
||||
check_container_storage
|
||||
check_container_resources
|
||||
|
||||
if [[ ! -f /opt/actualbudget_version.txt ]]; then
|
||||
if [[ ! -f ~/.actualbudget && ! -f /opt/actualbudget_version.txt ]]; then
|
||||
msg_error "No ${APP} Installation Found!"
|
||||
exit
|
||||
fi
|
||||
|
||||
NODE_VERSION="22" setup_nodejs
|
||||
RELEASE=$(curl -fsSL https://api.github.com/repos/actualbudget/actual/releases/latest | grep "tag_name" | awk '{print substr($2, 3, length($2)-4) }')
|
||||
RELEASE=$(get_latest_github_release "actualbudget/actual")
|
||||
if [[ -f /opt/actualbudget-data/config.json ]]; then
|
||||
if [[ ! -f /opt/actualbudget_version.txt ]] || [[ "${RELEASE}" != "$(cat /opt/actualbudget_version.txt)" ]]; then
|
||||
if check_for_gh_release "actualbudget" "actualbudget/actual"; then
|
||||
msg_info "Stopping Service"
|
||||
systemctl stop actualbudget
|
||||
msg_ok "Stopped Service"
|
||||
|
||||
msg_info "Updating ${APP} to ${RELEASE}"
|
||||
msg_info "Updating Actual Budget to ${RELEASE}"
|
||||
$STD npm update -g @actual-app/sync-server
|
||||
echo "${RELEASE}" >/opt/actualbudget_version.txt
|
||||
msg_ok "Updated ${APP} to ${RELEASE}"
|
||||
echo "${RELEASE}" >~/.actualbudget
|
||||
msg_ok "Updated Actual Budget to ${RELEASE}"
|
||||
|
||||
msg_info "Starting Service"
|
||||
systemctl start actualbudget
|
||||
msg_ok "Started Service"
|
||||
msg_ok "Updated successfully!"
|
||||
else
|
||||
msg_info "${APP} is already up to date"
|
||||
fi
|
||||
else
|
||||
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 "Please follow the instructions on the Actual Budget website to migrate your data"
|
||||
msg_info "https://actualbudget.org/docs/backup-restore/backup"
|
||||
exit
|
||||
fi
|
||||
|
||||
@ -19,10 +19,12 @@ $STD apt install -y \
|
||||
g++
|
||||
msg_ok "Installed Dependencies"
|
||||
|
||||
NODE_VERSION="22" setup_nodejs
|
||||
create_self_signed_cert
|
||||
|
||||
msg_info "Installing Actual Budget"
|
||||
cd /opt
|
||||
RELEASE=$(curl -fsSL https://api.github.com/repos/actualbudget/actual/releases/latest | grep "tag_name" | awk '{print substr($2, 3, length($2)-4) }')
|
||||
NODE_VERSION="22" setup_nodejs
|
||||
RELEASE=$(get_latest_github_release "actualbudget/actual")
|
||||
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
|
||||
@ -42,25 +44,15 @@ cat <<EOF >/opt/actualbudget-data/config.json
|
||||
"fc00::/7"
|
||||
],
|
||||
"https": {
|
||||
"key": "/opt/actualbudget/selfhost.key",
|
||||
"cert": "/opt/actualbudget/selfhost.crt"
|
||||
"key": "/etc/ssl/actualbudget/actualbudget.key",
|
||||
"cert": "/etc/ssl/actualbudget/actualbudget.crt"
|
||||
}
|
||||
}
|
||||
EOF
|
||||
|
||||
mkdir -p /opt/actualbudget
|
||||
cd /opt/actualbudget || exit
|
||||
$STD npm install --location=global @actual-app/sync-server
|
||||
$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"
|
||||
echo "${RELEASE}" >~/.actualbudget
|
||||
msg_ok "Installed Actual Budget"
|
||||
|
||||
msg_info "Creating Service"
|
||||
|
||||
@ -1551,7 +1551,8 @@ create_self_signed_cert() {
|
||||
|
||||
mkdir -p "$CERT_DIR"
|
||||
$STD openssl req -new -newkey rsa:2048 -days 365 -nodes -x509 \
|
||||
-subj "/C=US/ST=State/L=City/O=Organization/CN=${APP_NAME}" \
|
||||
-subj "/CN=${APP_NAME}" \
|
||||
-addext "subjectAltName=DNS:${APP_NAME}" \
|
||||
-keyout "$CERT_KEY" \
|
||||
-out "$CERT_CRT" || {
|
||||
msg_error "Failed to create self-signed certificate"
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user