Refactor: grocy (#6307)

This commit is contained in:
Slaviša Arežina 2025-07-28 22:14:32 +02:00 committed by GitHub
parent 8846915506
commit 89ab0f162c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 16 additions and 30 deletions

View File

@ -27,20 +27,20 @@ function update_script() {
msg_error "No ${APP} Installation Found!" msg_error "No ${APP} Installation Found!"
exit exit
fi fi
php_version=$(php -v | head -n 1 | awk '{print $2}')
if [[ ! $php_version == "8.3"* ]]; then php_ver=$(php -v | head -n 1 | awk '{print $2}')
msg_info "Updating PHP" if [[ ! $php_ver == "8.3"* ]]; then
curl -fsSLo /usr/share/keyrings/deb.sury.org-php.gpg https://packages.sury.org/php/apt.gpg PHP_VERSION="8.3" PHP_MODULE="sqlite3,bz2" PHP_APACHE="yes" setup_php
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 fi
apt-get update
apt-get install -y php8.3 php8.3-cli php8.3-{bz2,curl,mbstring,intl,sqlite3,fpm,gd,zip,xml} RELEASE=$(curl -fsSL https://api.github.com/repos/grocy/grocy/releases/latest | grep "tag_name" | awk '{print substr($2, 3, length($2)-4) }')
systemctl reload apache2 if [[ "${RELEASE}" != "$(cat ~/.grocy 2>/dev/null)" ]] || [[ ! -f ~/.grocy ]]; then
apt autoremove msg_info "Updating ${APP}"
msg_ok "Updated PHP" bash /var/www/html/update.sh
msg_ok "Updated Successfully"
else
msg_ok "No update required. ${APP} is already at ${RELEASE}"
fi fi
msg_info "Updating ${APP}"
bash /var/www/html/update.sh
msg_ok "Updated Successfully"
exit exit
} }

View File

@ -17,23 +17,10 @@ msg_info "Installing Dependencies"
$STD apt-get install -y apt-transport-https $STD apt-get install -y apt-transport-https
msg_ok "Installed Dependencies" msg_ok "Installed Dependencies"
msg_info "Installing PHP8.2" PHP_VERSION="8.3" PHP_MODULE="sqlite3,bz2" PHP_APACHE="yes" setup_php
VERSION="$(awk -F'=' '/^VERSION_CODENAME=/{ print $NF }' /etc/os-release)" fetch_and_deploy_gh_release "grocy" "grocy/grocy" "prebuild" "latest" "/var/www/html" "grocy*.zip"
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"
msg_info "Installing grocy" msg_info "Configuring 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
chown -R www-data:www-data /var/www/html chown -R www-data:www-data /var/www/html
cp /var/www/html/config-dist.php /var/www/html/data/config.php cp /var/www/html/config-dist.php /var/www/html/data/config.php
chmod +x /var/www/html/update.sh chmod +x /var/www/html/update.sh
@ -64,5 +51,4 @@ customize
msg_info "Cleaning up" msg_info "Cleaning up"
$STD apt-get -y autoremove $STD apt-get -y autoremove
$STD apt-get -y autoclean $STD apt-get -y autoclean
rm -rf /root/grocy_${latest}.zip
msg_ok "Cleaned" msg_ok "Cleaned"