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_storage
|
||||||
check_container_resources
|
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!"
|
msg_error "No ${APP} Installation Found!"
|
||||||
exit
|
exit
|
||||||
fi
|
fi
|
||||||
|
|
||||||
NODE_VERSION="22" setup_nodejs
|
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-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"
|
msg_info "Stopping Service"
|
||||||
systemctl stop actualbudget
|
systemctl stop actualbudget
|
||||||
msg_ok "Stopped Service"
|
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
|
$STD npm update -g @actual-app/sync-server
|
||||||
echo "${RELEASE}" >/opt/actualbudget_version.txt
|
echo "${RELEASE}" >~/.actualbudget
|
||||||
msg_ok "Updated ${APP} to ${RELEASE}"
|
msg_ok "Updated Actual Budget to ${RELEASE}"
|
||||||
|
|
||||||
msg_info "Starting Service"
|
msg_info "Starting Service"
|
||||||
systemctl start actualbudget
|
systemctl start actualbudget
|
||||||
msg_ok "Started Service"
|
msg_ok "Started Service"
|
||||||
msg_ok "Updated successfully!"
|
msg_ok "Updated successfully!"
|
||||||
else
|
|
||||||
msg_info "${APP} is already up to date"
|
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
msg_info "Old Installation Found, you need to migrate your data and recreate to a new container"
|
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"
|
msg_info "https://actualbudget.org/docs/backup-restore/backup"
|
||||||
exit
|
exit
|
||||||
fi
|
fi
|
||||||
|
|||||||
@ -19,10 +19,12 @@ $STD apt install -y \
|
|||||||
g++
|
g++
|
||||||
msg_ok "Installed Dependencies"
|
msg_ok "Installed Dependencies"
|
||||||
|
|
||||||
|
NODE_VERSION="22" setup_nodejs
|
||||||
|
create_self_signed_cert
|
||||||
|
|
||||||
msg_info "Installing Actual Budget"
|
msg_info "Installing Actual Budget"
|
||||||
cd /opt
|
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) }')
|
RELEASE=$(get_latest_github_release "actualbudget/actual")
|
||||||
NODE_VERSION="22" setup_nodejs
|
|
||||||
mkdir -p /opt/actualbudget-data/{server-files,upload,migrate,user-files,migrations,config}
|
mkdir -p /opt/actualbudget-data/{server-files,upload,migrate,user-files,migrations,config}
|
||||||
chown -R root:root /opt/actualbudget-data
|
chown -R root:root /opt/actualbudget-data
|
||||||
chmod -R 755 /opt/actualbudget-data
|
chmod -R 755 /opt/actualbudget-data
|
||||||
@ -42,25 +44,15 @@ cat <<EOF >/opt/actualbudget-data/config.json
|
|||||||
"fc00::/7"
|
"fc00::/7"
|
||||||
],
|
],
|
||||||
"https": {
|
"https": {
|
||||||
"key": "/opt/actualbudget/selfhost.key",
|
"key": "/etc/ssl/actualbudget/actualbudget.key",
|
||||||
"cert": "/opt/actualbudget/selfhost.crt"
|
"cert": "/etc/ssl/actualbudget/actualbudget.crt"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
mkdir -p /opt/actualbudget
|
mkdir -p /opt/actualbudget
|
||||||
cd /opt/actualbudget || exit
|
cd /opt/actualbudget || exit
|
||||||
$STD npm install --location=global @actual-app/sync-server
|
$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
|
echo "${RELEASE}" >~/.actualbudget
|
||||||
US
|
|
||||||
California
|
|
||||||
San Francisco
|
|
||||||
My Organization
|
|
||||||
My Unit
|
|
||||||
localhost
|
|
||||||
myemail@example.com
|
|
||||||
EOF
|
|
||||||
echo "${RELEASE}" >"/opt/actualbudget_version.txt"
|
|
||||||
msg_ok "Installed Actual Budget"
|
msg_ok "Installed Actual Budget"
|
||||||
|
|
||||||
msg_info "Creating Service"
|
msg_info "Creating Service"
|
||||||
|
|||||||
@ -1551,7 +1551,8 @@ create_self_signed_cert() {
|
|||||||
|
|
||||||
mkdir -p "$CERT_DIR"
|
mkdir -p "$CERT_DIR"
|
||||||
$STD openssl req -new -newkey rsa:2048 -days 365 -nodes -x509 \
|
$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" \
|
-keyout "$CERT_KEY" \
|
||||||
-out "$CERT_CRT" || {
|
-out "$CERT_CRT" || {
|
||||||
msg_error "Failed to create self-signed certificate"
|
msg_error "Failed to create self-signed certificate"
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user