Jeremy Davis's picture

I just discovered that Aleksand posted on GitHub asking about how to update Snipe-IT. Rather than answer there, I thought I'd post here instead.

Please note that this only applies to a v16.x server, future releases (i.e. v17.0 or later) should be easy as the line line of this post... (TBC)

Reading the upgrade docs, it looks like git install is preferred. Unfortunately, our v16.x Snipe-IT appliance uses tarball install, so we could use the manual upgrade path. As git install is preferable, I'm aiming to move the appliance to a git install, so now is a good time to switch your server to git install too, so let's do that. This will basically be what the docs note, but we'll use the custom TurnKey tools.

First SSH in as root (or use Webshell - don't use the shell in Webmin! - it's not a proper interactive shell).

First run a backup. If you're using TKLBAM, then:

tklbam-backup --full-backup now

If you're not using TKLBAM or you want a local backup as well, then create a local backup like this (using TurnKey's PHP artisan wrapper):

turnkey-artisan snipeit:backup

Then rename the current Snipe-IT directory and clone the latest version via git:

cd /var/www
mv snipe-it snipe-it-backup
git clone https://github.com/snipe/snipe-it

Now fix permissions, enter the snipe-it dir and install dependencies with composer:

chown -R www-data:www-data snipe-it
cd snipe-it
turnkey-composer install --no-dev --prefer-source

That will likely take a little while. When it's done, copy in the required old files:

cp -R ../snipe-it-backup/public/uploads/* public/uploads
cp -R ../snipe-it-backup/storage/private_uploads/* storage/private_uploads
cp -R ../snipe-it-backup/storage/app/backups/* storage/app/backups
cp -R ../snipe-it-backup/.env ./
cp -R ../snipe-it-backup/storage/oauth-private.key storage/oauth-private.key
cp -R ../snipe-it-backup/storage/oauth-public.key storage/oauth-public.key

Then finally, you can run the update itself (migrate DB, clear cache, etc). Unfortunately this command is a little convoluted, but perhaps we'll write a helper script for that too in the future?:

runuser - www-data -s /bin/bash -c "cd /var/www/snipe-it && php upgrade.php"

Once you've done that, all future updates can be done via this same command. Although to make your life marginally easier, you could just make a helper script. We might do that for future releases... Here's what I would suggest:

cat > /usr/local/bin/turnkey-snipe-it-upgrade 

From now on, you can just run:

turnkey-snipe-it-upgrade
Forum: 
L. Arnold's picture

What can be done to make information like this easy to find on different Apps would be great.

I have worked through a few upgrades (Joomla was one,  Magento another)..  but having a general path on any/all apps would be more than fantastic.  I know that is difficult but it really makes a difference in terms of users assessments of reliability and long term usability.

I hate to be a broken record. I know that I sometimes am.

Jeremy Davis's picture

Yes I agree. Unfortunately it all takes time and I don't always have the time. Plus, this appliance was/is particularly easy. Most of my post was copy/paste direct from their docs (with a little adjustment for our custom helper scripts) and the Snipe-IT devs provides a pretty powerful upgrade script that does most of the heavy lifting.

It'd be great if you could document your upgrades when you next do one. AN/dor if you get stuck, please do ask and I'm more than happy to do what I can to help.

As for organising, I added some tags which hopefully might make it easier to find. But perhaps we should add pages to the wiki? My only reservation is that there are already some out of date pages (which already desperately need an update) in the wiki and I don't want to just make that problem worse. Writing and maintaining docs is a full time job in and of itself really... Having said that, perhaps we could add a page for snipe-it and just link to this thread?! (Then it would be clear how old it is and how relevant it might be?! WHat do you think?

Jeremy Davis's picture

Assuming that you are running the TurnKey Linux Snipe-IT appliance, then you now need to set a domain. If you installed Snipe-IT via some other method (i.e. not a TurnKey appliance), then the solution below will almost certainly not help!

It is now required to set the "domain" (if you want to access via IP address, then you'll need to set the IP address as the domain). If you have an earlier version of our appliance, then you'll need to download the latest update of the Snipe-IT inithook.

Be sure to backup before downloading and running this inithook, just in case something goes wrong. Get the script and run like this:

script=usr/lib/inithooks/bin/snipe-it.py
url=https://raw.githubusercontent.com/turnkeylinux-apps/snipe-it/master/overlay/$script
wget -O /$script $url
chmod +x /$script
./$script
Jeremy Davis's picture

Yes, these need to be run within an interactive terminal. SSH via a native client is the best option IMO, but Webshell (via https on port 12320) is another option. If you are running your TurnKey server as some sort of VM, then using the terminal directly is likely another option. Note that Webmin's terminal isn't a complete interactive terminal, so won't work for this (or any other operation that requires interaction).

Having said all that, IMO SSH is the best way to go. I'm a Linux user and just use the built-in OpenSSH client CLI tool within a local terminal. If you are using Mac OSX, then you should already have the OpenSSH client too. If you're on Windows, you'll need to install an SSH client. A few common/popular ones are:

  • OpenSSH - pure CLI; run within a CMD window,
  • PuTTY - GUI terminal, and
  • WinSCP - GUI terminal, remote SFTP file manager and text editor.

Once connected to your server, then you should be able to simply copy paste those instructions into the terminal (note that to paste in PuTTY, use right mouse click).

If you have any troubles and/or further questions, please let me know.

Jeremy Davis's picture

Why are you using an IP address instead of the github domain? I think you are confused.

It's not possible for an IP address to get a valid SSL cert, that's why you're getting that error. And it looks like you ar trying to download the script from yourself?! You need to SSH into your server, run the code exactly as I posted it earlier in this thread. That will download a script from GitHub, then run it. The script will be interactive and one of the steps, it will ask for a domain.

Ideally you should use a domain for your server, but if you don't want to and want to just access your Snipe-IT server web UI via IP address (i.e. type in IP in web browser address bar), then instead of a domain, input the IP address (in the interactive script - when it asks for domain).

Hopefully that clears things up a bit...?!

Anand's picture

Hi, I have used the above commands perfectly and finally got errors. It says the current version of Php 7.3 doesn't support, when i used the following one "
turnkey-composer install --no-dev --prefer-source
"
Jeremy Davis's picture

Please share the error message. Otherwise, I have no idea what might be going wrong.

Add new comment