Skip to content

Commit

Permalink
Script Update: SnipeIT (#641)
Browse files Browse the repository at this point in the history
  • Loading branch information
michelroegl-brunner authored Dec 3, 2024
1 parent 6d307f0 commit df99c30
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 26 deletions.
54 changes: 29 additions & 25 deletions ct/snipeit.sh
Original file line number Diff line number Diff line change
Expand Up @@ -58,32 +58,36 @@ header_info
check_container_storage
check_container_resources
if [[ ! -d /opt/snipe-it ]]; then msg_error "No ${APP} Installation Found!"; exit; fi
msg_info "Updating ${APP} LXC"
apt-get update &>/dev/null
apt-get -y upgrade &>/dev/null
mv /opt/snipe-it /opt/snipe-it-backup
cd /opt
RELEASE=$(curl -s https://api.github.com/repos/snipe/snipe-it/releases/latest | grep "tag_name" | awk '{print substr($2, 3, length($2)-4) }')
wget -q "https://github.com/snipe/snipe-it/archive/refs/tags/v${RELEASE}.zip" &>/dev/null
unzip -q v${RELEASE}.zip
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
cd /opt/snipe-it/
export COMPOSER_ALLOW_SUPERUSER=1
composer install --no-dev --prefer-source &>/dev/null
composer dump-autoload &>/dev/null
php artisan migrate --force &>/dev/null
php artisan config:clear &>/dev/null
php artisan route:clear &>/dev/null
php artisan cache:clear &>/dev/null
php artisan view:clear &>/dev/null
chown -R www-data: /opt/snipe-it
chmod -R 755 /opt/snipe-it
rm -rf /opt/v${RELEASE}.zip
rm -rf /opt/snipe-it-backup
msg_ok "Updated ${APP} LXC"
if [[ ! -f /opt/${APP}_version.txt ]] || [[ "${RELEASE}" != "$(cat /opt/${APP}_version.txt)" ]]; then
msg_info "Updating ${APP} to v${RELEASE}"
apt-get update &>/dev/null
apt-get -y upgrade &>/dev/null
mv /opt/snipe-it /opt/snipe-it-backup
cd /opt
wget -q "https://github.com/snipe/snipe-it/archive/refs/tags/v${RELEASE}.zip" &>/dev/null
unzip -q v${RELEASE}.zip
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
cd /opt/snipe-it/
export COMPOSER_ALLOW_SUPERUSER=1
composer install --no-dev --prefer-source &>/dev/null
composer dump-autoload &>/dev/null
php artisan migrate --force &>/dev/null
php artisan config:clear &>/dev/null
php artisan route:clear &>/dev/null
php artisan cache:clear &>/dev/null
php artisan view:clear &>/dev/null
chown -R www-data: /opt/snipe-it
chmod -R 755 /opt/snipe-it
rm -rf /opt/v${RELEASE}.zip
rm -rf /opt/snipe-it-backup
msg_ok "Updated ${APP} LXC"
else
msg_ok "No update required. ${APP} is already at v${RELEASE}."
fi
exit
}

Expand Down
1 change: 1 addition & 0 deletions install/snipeit-install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ msg_ok "Set up database"
msg_info "Installing Snipe-IT"
cd /opt
RELEASE=$(curl -s https://api.github.com/repos/snipe/snipe-it/releases/latest | grep "tag_name" | awk '{print substr($2, 3, length($2)-4) }')
echo "${RELEASE}" >"/opt/${APPLICATION}_version.txt"
wget -q "https://github.com/snipe/snipe-it/archive/refs/tags/v${RELEASE}.zip"
unzip -q v${RELEASE}.zip
mv snipe-it-${RELEASE} /opt/snipe-it
Expand Down
2 changes: 1 addition & 1 deletion json/snipeit.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"type": "ct",
"updateable": true,
"privileged": false,
"interface_port": 3000,
"interface_port": 80,
"documentation": "https://snipe-it.readme.io/docs/overview",
"website": "https://snipeitapp.com/",
"logo": "https://raw.githubusercontent.com/snipe/snipe-it/refs/heads/master/public/img/snipe-logo-bug.png",
Expand Down

0 comments on commit df99c30

Please sign in to comment.