Various unrelated fixes to kimai update script (#4549)

* Ensure lsb-release is installed

Fixes 4548

* Change to use same syntax as check for composer

There's a proposed solution to #4247 (which doesn't seem to have been committed - I'll fix that in a moment). I've changed the test I'm using to match that suggestion.

* Re-install composer

See #4550

* Try to catch download errors

During troubleshooting of another error, I ran into a condition where downloading the new version failed. It seems that this is because the earlier call to get the $RELEASE had failed.

This change is an attempt to catch download errors, and alert the user, and to not rm the existing install until we know the download worked.

* Re-install php-fpm

I missed in the earlier commit that this wasn't getting reinstalled
This commit is contained in:
James Polley 2025-05-20 03:18:18 +10:00 committed by GitHub
parent f735e37b15
commit b7e951fc1a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -23,6 +23,9 @@ function update_script() {
header_info
check_container_storage
check_container_resources
if ! command -v lsb_release; then
apt install -y lsb-release
fi
if [[ ! -d /opt/kimai ]]; then
msg_error "No ${APP} Installation Found!"
exit
@ -36,8 +39,8 @@ function update_script() {
$STD apt-get update
$STD apt-get remove -y php"${CURRENT_PHP//./}"*
$STD apt-get install -y \
php8.4 \
php8.4-{gd,mysql,mbstring,bcmath,xml,curl,zip,intl} \
php8.4 composer \
php8.4-{gd,mysql,mbstring,bcmath,xml,curl,zip,intl,fpm} \
libapache2-mod-php8.4
msg_ok "Migrated PHP $CURRENT_PHP to 8.4"
fi
@ -58,9 +61,13 @@ function update_script() {
msg_ok "Backup completed"
msg_info "Updating ${APP} to ${RELEASE}"
rm -rf /opt/kimai
trap "echo Unable to download release file for version ${RELEASE}; try again later" ERR
set -e
curl -fsSL "https://github.com/kimai/kimai/archive/refs/tags/${RELEASE}.zip" -o $(basename "https://github.com/kimai/kimai/archive/refs/tags/${RELEASE}.zip")
unzip -q "${RELEASE}".zip
set +e
trap - ERR
rm -rf /opt/kimai
mv kimai-"${RELEASE}" /opt/kimai
[ -d "$BACKUP_DIR/var" ] && cp -r "$BACKUP_DIR/var" /opt/kimai/
[ -f "$BACKUP_DIR/.env" ] && cp "$BACKUP_DIR/.env" /opt/kimai/