From 89ab0f162c0dfc856b4a82100c4587768f2f161a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Slavi=C5=A1a=20Are=C5=BEina?= <58952836+tremor021@users.noreply.github.com> Date: Mon, 28 Jul 2025 22:14:32 +0200 Subject: [PATCH] Refactor: grocy (#6307) --- ct/grocy.sh | 26 +++++++++++++------------- install/grocy-install.sh | 20 +++----------------- 2 files changed, 16 insertions(+), 30 deletions(-) diff --git a/ct/grocy.sh b/ct/grocy.sh index 15024fc08..38e189324 100644 --- a/ct/grocy.sh +++ b/ct/grocy.sh @@ -27,20 +27,20 @@ function update_script() { msg_error "No ${APP} Installation Found!" exit fi - php_version=$(php -v | head -n 1 | awk '{print $2}') - if [[ ! $php_version == "8.3"* ]]; then - msg_info "Updating PHP" - curl -fsSLo /usr/share/keyrings/deb.sury.org-php.gpg https://packages.sury.org/php/apt.gpg - echo "deb [signed-by=/usr/share/keyrings/deb.sury.org-php.gpg] https://packages.sury.org/php/ bookworm main" >/etc/apt/sources.list.d/php.list - apt-get update - apt-get install -y php8.3 php8.3-cli php8.3-{bz2,curl,mbstring,intl,sqlite3,fpm,gd,zip,xml} - systemctl reload apache2 - apt autoremove - msg_ok "Updated PHP" + + php_ver=$(php -v | head -n 1 | awk '{print $2}') + if [[ ! $php_ver == "8.3"* ]]; then + PHP_VERSION="8.3" PHP_MODULE="sqlite3,bz2" PHP_APACHE="yes" setup_php + fi + + RELEASE=$(curl -fsSL https://api.github.com/repos/grocy/grocy/releases/latest | grep "tag_name" | awk '{print substr($2, 3, length($2)-4) }') + if [[ "${RELEASE}" != "$(cat ~/.grocy 2>/dev/null)" ]] || [[ ! -f ~/.grocy ]]; then + msg_info "Updating ${APP}" + bash /var/www/html/update.sh + msg_ok "Updated Successfully" + else + msg_ok "No update required. ${APP} is already at ${RELEASE}" fi - msg_info "Updating ${APP}" - bash /var/www/html/update.sh - msg_ok "Updated Successfully" exit } diff --git a/install/grocy-install.sh b/install/grocy-install.sh index 1ae332783..d1e888392 100644 --- a/install/grocy-install.sh +++ b/install/grocy-install.sh @@ -17,23 +17,10 @@ msg_info "Installing Dependencies" $STD apt-get install -y apt-transport-https msg_ok "Installed Dependencies" -msg_info "Installing PHP8.2" -VERSION="$(awk -F'=' '/^VERSION_CODENAME=/{ print $NF }' /etc/os-release)" -curl -fsSLo /usr/share/keyrings/deb.sury.org-php.gpg https://packages.sury.org/php/apt.gpg -echo -e "deb [signed-by=/usr/share/keyrings/deb.sury.org-php.gpg] https://packages.sury.org/php/ $VERSION main" >/etc/apt/sources.list.d/php.list -$STD apt-get update -$STD apt-get install -y php8.2 -$STD apt-get install -y libapache2-mod-php8.2 -$STD apt-get install -y php8.2-sqlite3 -$STD apt-get install -y php8.2-gd -$STD apt-get install -y php8.2-intl -$STD apt-get install -y php8.2-mbstring -msg_ok "Installed PHP8.2" +PHP_VERSION="8.3" PHP_MODULE="sqlite3,bz2" PHP_APACHE="yes" setup_php +fetch_and_deploy_gh_release "grocy" "grocy/grocy" "prebuild" "latest" "/var/www/html" "grocy*.zip" -msg_info "Installing grocy" -latest=$(curl -fsSL https://api.github.com/repos/grocy/grocy/releases/latest | grep "tag_name" | awk '{print substr($2, 3, length($2)-4) }') -curl -fsSL "https://github.com/grocy/grocy/releases/download/v${latest}/grocy_${latest}.zip" -o "grocy_${latest}.zip" -$STD unzip grocy_${latest}.zip -d /var/www/html +msg_info "Configuring grocy" chown -R www-data:www-data /var/www/html cp /var/www/html/config-dist.php /var/www/html/data/config.php chmod +x /var/www/html/update.sh @@ -64,5 +51,4 @@ customize msg_info "Cleaning up" $STD apt-get -y autoremove $STD apt-get -y autoclean -rm -rf /root/grocy_${latest}.zip msg_ok "Cleaned"