Are you used to apt-get updates with ownCloud but hesitated to make the switch to Nextcloud because Nextcloud doesn’t provide updates via apt-get? Or are you just comfortable with apt-get becuase it takes care of everything for you? Whatever the reason is, now you don’t have to hesitate anymore, we did it – we automated the update process! As the official provider of the Nextcloud VM, we want it to be as “hazzle free” as possible to use, and one of the things that many people has asked about are automatic updates from the shell to be able to add them as a cronjob in Linux. We wrote a similar guide for ownCloud before.
Before we made the update script you first had to check if a new version was available, download the package, make a backup of your old config files, replace the old Nextcloud instance with the new then run the upgrade command via occ or upgrade via your browser… pheew, that’s just to much. If you ask us, it should be easy, so we made it easy. To make it even easier and be be certain that you always get the latest version of the script we made another script that fetches the latest version of ‘nextcloud_update.sh‘ so you don’t have to fetch it manually every time you want to get a new version. To run it, just type this command in your CLI:
$~: sudo bash /var/scripts/update.sh
It really couldn’t be more simple.
Just do something like this if you want it to be fully automatic, not even typing the command:
$~: crontab -u root -e
And add this line
0 5 * * 1 /var/scripts/update.sh
This will run the script every Monday at 05:00 (24 hr). Make sure to get the latest update script before you add it as a cronjob. And also, make sure everything works before you put it in production, even though we made the script failsafe things could go wrong, so do this with caution.
The key to the automation is the $NCVERSION variable as it fetches the latest release from Nextlouds download page and then compares it to the $CURRENTVERSION and if the new version are newer than the current version, the update takes place. If not, well, the script just ends because there is nothing to do.
Another thing you could do basically is to re-use the $NCVERSION and $CURRENTVERSION variables in a separate bash script to check if there is a new version available every day, and when there is, trigger the update script in a cronjob to upgrade your Nextcloud installation. Maybe we’ll add such a script later on, if you want it just ask.
Other updates we made
Except that we also integrated SpreedMe into the Nextcloud VM with some indirect help from the nextcloud-snap guys like @oparoz and @kyrofa who also develops the spreedme-snap. The implementation is quite easy and uses the spreedme-snap to setup the app and the VM takes care of the details like generating a secret-key, setting up Apache and installing the client app. You will get a question if you want to install it in our startup script for Nextcloud 11 and for the VPS users we implemented a question in the install script instead. You can find the latest script here.
Of course we always improve on the Nextcloud VM to make it even better and easier to use every day. We’d love for you to join our team! If you think bash and shell scripting is fun, or if you want to learn more, visit us at: https://github.com/nextcloud/vm and make your first PR. See you there! :)