mirror of
https://github.com/community-scripts/ProxmoxVE
synced 2026-09-24 06:05:35 +00:00
Fix Semaphore BoltDB migration
This commit is contained in:
+42
-23
@@ -32,42 +32,61 @@ function update_script() {
|
||||
exit
|
||||
fi
|
||||
|
||||
if check_for_gh_release "semaphore" "semaphoreui/semaphore"; then
|
||||
if [[ -f /opt/semaphore/semaphore_db.bolt ]]; then
|
||||
msg_warn "WARNING: Due to bugs with BoltDB database, update script will move your application"
|
||||
msg_warn "to use SQLite database instead. Make sure you have a backup of your data!"
|
||||
echo ""
|
||||
read -r -p "${TAB3}Do you want to continue? (y/N): " CONFIRM
|
||||
if [[ ! "$CONFIRM" =~ ^[Yy]$ ]]; then
|
||||
exit 0
|
||||
else
|
||||
msg_info "Moving from BoltDB to SQLite"
|
||||
sed -i \
|
||||
-e 's|"bolt": {|"sqlite": {|' \
|
||||
-e 's|/semaphore_db.bolt"|/database.sqlite"|' \
|
||||
-e '/semaphore_db.bolt/d' \
|
||||
-e '/"dialect"/d' \
|
||||
-e '/^ },$/a\ "dialect": "sqlite",' \
|
||||
/opt/semaphore/config.json
|
||||
msg_ok "Moved from BoltDB to SQLite"
|
||||
fi
|
||||
# Outside the release check on purpose: a container left behind by the old
|
||||
# order already carries the newest version, so the check would skip it.
|
||||
local migrated=0
|
||||
if [[ -f /opt/semaphore/semaphore_db.bolt ]]; then
|
||||
msg_warn "WARNING: Due to bugs with BoltDB database, update script will move your application"
|
||||
msg_warn "to use SQLite database instead. Make sure you have a backup of your data!"
|
||||
echo ""
|
||||
read -r -p "${TAB3}Do you want to continue? (y/N): " CONFIRM
|
||||
if [[ ! "$CONFIRM" =~ ^[Yy]$ ]]; then
|
||||
exit 0
|
||||
fi
|
||||
|
||||
msg_info "Stopping Service"
|
||||
systemctl stop semaphore
|
||||
msg_ok "Stopped Service"
|
||||
|
||||
fetch_and_deploy_gh_release "semaphore" "semaphoreui/semaphore" "binary" "latest" "/opt/semaphore" "semaphore_*_linux_$(arch_resolve).deb"
|
||||
msg_info "Moving from BoltDB to SQLite"
|
||||
sed -i \
|
||||
-e 's|"bolt": {|"sqlite": {|' \
|
||||
-e 's|/semaphore_db.bolt"|/database.sqlite"|' \
|
||||
-e '/semaphore_db.bolt/d' \
|
||||
-e '/"dialect"/d' \
|
||||
-e '/^ },$/a\ "dialect": "sqlite",' \
|
||||
/opt/semaphore/config.json
|
||||
msg_ok "Moved from BoltDB to SQLite"
|
||||
|
||||
if [[ -f /opt/semaphore/semaphore_db.bolt ]]; then
|
||||
$STD semaphore migrate --from-boltdb /opt/semaphore/semaphore_db.bolt --config /opt/semaphore/config.json
|
||||
rm -f /opt/semaphore/semaphore_db.bolt
|
||||
# 2.19 dropped BoltDB along with the migration flag, so this has to run on
|
||||
# the last release that still has it.
|
||||
fetch_and_deploy_gh_release "semaphore" "semaphoreui/semaphore" "binary" "v2.18.30" "/opt/semaphore" "semaphore_*_linux_$(arch_resolve).deb"
|
||||
|
||||
msg_info "Migrating BoltDB to SQLite"
|
||||
if ! $STD semaphore migrate --from-boltdb /opt/semaphore/semaphore_db.bolt --config /opt/semaphore/config.json; then
|
||||
msg_error "Migration failed - semaphore_db.bolt was kept, run the update again to retry"
|
||||
exit 1
|
||||
fi
|
||||
rm -f /opt/semaphore/semaphore_db.bolt
|
||||
msg_ok "Migrated BoltDB to SQLite"
|
||||
migrated=1
|
||||
fi
|
||||
|
||||
if check_for_gh_release "semaphore" "semaphoreui/semaphore"; then
|
||||
msg_info "Stopping Service"
|
||||
systemctl stop semaphore
|
||||
msg_ok "Stopped Service"
|
||||
|
||||
fetch_and_deploy_gh_release "semaphore" "semaphoreui/semaphore" "binary" "latest" "/opt/semaphore" "semaphore_*_linux_$(arch_resolve).deb"
|
||||
|
||||
msg_info "Starting Service"
|
||||
systemctl start semaphore
|
||||
msg_ok "Started Service"
|
||||
msg_ok "Updated successfully!"
|
||||
elif ((migrated)); then
|
||||
msg_info "Starting Service"
|
||||
systemctl start semaphore
|
||||
msg_ok "Started Service"
|
||||
fi
|
||||
exit
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user