Refactor: Snipe-IT (#7081)

* Refactor

* Update snipeit.sh

* Update
This commit is contained in:
Slaviša Arežina
2025-08-23 10:24:57 +02:00
committed by GitHub
parent aece852e10
commit 23f65d0eb7
2 changed files with 17 additions and 22 deletions

View File

@@ -27,20 +27,24 @@ function update_script() {
msg_error "No ${APP} Installation Found!"
exit
fi
RELEASE=$(curl -fsSL https://api.github.com/repos/snipe/snipe-it/releases/latest | grep '"tag_name"' | sed -E 's/.*"tag_name": "v([^"]+).*/\1/')
if [[ ! -f /opt/${APP}_version.txt ]] || [[ "${RELEASE}" != "$(cat /opt/${APP}_version.txt)" ]]; then
if [[ ! -f ~/.snipe-it ]] || [[ "${RELEASE}" != "$(cat ~/.snipe-it 2>/dev/null)" ]]; then
msg_info "Stopping Services"
systemctl stop nginx
msg_ok "Services Stopped"
msg_info "Creating backup"
mv /opt/snipe-it /opt/snipe-it-backup
msg_ok "Backup created"
fetch_and_deploy_gh_release "snipe-it" "snipe/snipe-it" "tarball"
[[ "$(php -v 2>/dev/null)" == PHP\ 8.2* ]] && PHP_VERSION="8.3" PHP_MODULE="common,ctype,ldap,fileinfo,iconv,mysql,soap,xsl" PHP_FPM="YES" setup_php
setup_composer
msg_info "Updating ${APP} to v${RELEASE}"
$STD apt-get update
$STD apt-get -y upgrade
mv /opt/snipe-it /opt/snipe-it-backup
temp_file=$(mktemp)
curl -fsSL "https://github.com/snipe/snipe-it/archive/refs/tags/v${RELEASE}.tar.gz" -o "$temp_file"
tar zxf "$temp_file"
mv "snipe-it-${RELEASE}" /opt/snipe-it
cp /opt/snipe-it-backup/.env /opt/snipe-it/.env
cp -r /opt/snipe-it-backup/public/uploads/ /opt/snipe-it/public/uploads/
cp -r /opt/snipe-it-backup/storage/private_uploads /opt/snipe-it/storage/private_uploads
@@ -55,7 +59,6 @@ function update_script() {
$STD php artisan view:clear
chown -R www-data: /opt/snipe-it
chmod -R 755 /opt/snipe-it
rm -rf "$temp_file"
rm -rf /opt/snipe-it-backup
msg_ok "Updated ${APP}"