Skip to content

Commit 89ab0f1

Browse files
authored
Refactor: grocy (#6307)
1 parent 8846915 commit 89ab0f1

2 files changed

Lines changed: 16 additions & 30 deletions

File tree

ct/grocy.sh

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -27,20 +27,20 @@ function update_script() {
2727
msg_error "No ${APP} Installation Found!"
2828
exit
2929
fi
30-
php_version=$(php -v | head -n 1 | awk '{print $2}')
31-
if [[ ! $php_version == "8.3"* ]]; then
32-
msg_info "Updating PHP"
33-
curl -fsSLo /usr/share/keyrings/deb.sury.org-php.gpg https://packages.sury.org/php/apt.gpg
34-
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
35-
apt-get update
36-
apt-get install -y php8.3 php8.3-cli php8.3-{bz2,curl,mbstring,intl,sqlite3,fpm,gd,zip,xml}
37-
systemctl reload apache2
38-
apt autoremove
39-
msg_ok "Updated PHP"
30+
31+
php_ver=$(php -v | head -n 1 | awk '{print $2}')
32+
if [[ ! $php_ver == "8.3"* ]]; then
33+
PHP_VERSION="8.3" PHP_MODULE="sqlite3,bz2" PHP_APACHE="yes" setup_php
34+
fi
35+
36+
RELEASE=$(curl -fsSL https://api.github.com/repos/grocy/grocy/releases/latest | grep "tag_name" | awk '{print substr($2, 3, length($2)-4) }')
37+
if [[ "${RELEASE}" != "$(cat ~/.grocy 2>/dev/null)" ]] || [[ ! -f ~/.grocy ]]; then
38+
msg_info "Updating ${APP}"
39+
bash /var/www/html/update.sh
40+
msg_ok "Updated Successfully"
41+
else
42+
msg_ok "No update required. ${APP} is already at ${RELEASE}"
4043
fi
41-
msg_info "Updating ${APP}"
42-
bash /var/www/html/update.sh
43-
msg_ok "Updated Successfully"
4444
exit
4545
}
4646

install/grocy-install.sh

Lines changed: 3 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -17,23 +17,10 @@ msg_info "Installing Dependencies"
1717
$STD apt-get install -y apt-transport-https
1818
msg_ok "Installed Dependencies"
1919

20-
msg_info "Installing PHP8.2"
21-
VERSION="$(awk -F'=' '/^VERSION_CODENAME=/{ print $NF }' /etc/os-release)"
22-
curl -fsSLo /usr/share/keyrings/deb.sury.org-php.gpg https://packages.sury.org/php/apt.gpg
23-
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
24-
$STD apt-get update
25-
$STD apt-get install -y php8.2
26-
$STD apt-get install -y libapache2-mod-php8.2
27-
$STD apt-get install -y php8.2-sqlite3
28-
$STD apt-get install -y php8.2-gd
29-
$STD apt-get install -y php8.2-intl
30-
$STD apt-get install -y php8.2-mbstring
31-
msg_ok "Installed PHP8.2"
20+
PHP_VERSION="8.3" PHP_MODULE="sqlite3,bz2" PHP_APACHE="yes" setup_php
21+
fetch_and_deploy_gh_release "grocy" "grocy/grocy" "prebuild" "latest" "/var/www/html" "grocy*.zip"
3222

33-
msg_info "Installing grocy"
34-
latest=$(curl -fsSL https://api.github.com/repos/grocy/grocy/releases/latest | grep "tag_name" | awk '{print substr($2, 3, length($2)-4) }')
35-
curl -fsSL "https://github.com/grocy/grocy/releases/download/v${latest}/grocy_${latest}.zip" -o "grocy_${latest}.zip"
36-
$STD unzip grocy_${latest}.zip -d /var/www/html
23+
msg_info "Configuring grocy"
3724
chown -R www-data:www-data /var/www/html
3825
cp /var/www/html/config-dist.php /var/www/html/data/config.php
3926
chmod +x /var/www/html/update.sh
@@ -64,5 +51,4 @@ customize
6451
msg_info "Cleaning up"
6552
$STD apt-get -y autoremove
6653
$STD apt-get -y autoclean
67-
rm -rf /root/grocy_${latest}.zip
6854
msg_ok "Cleaned"

0 commit comments

Comments
 (0)