From b7e951fc1a11baa70b7f683e7b9bf23dddeceb0b Mon Sep 17 00:00:00 2001 From: James Polley Date: Tue, 20 May 2025 03:18:18 +1000 Subject: [PATCH] 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 --- ct/kimai.sh | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/ct/kimai.sh b/ct/kimai.sh index cfc0f01a7..41ec61eee 100644 --- a/ct/kimai.sh +++ b/ct/kimai.sh @@ -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/