MinecraftServerControl / mscs

Powerful command-line control for UNIX and Linux powered Minecraft servers
https://minecraftservercontrol.github.io
BSD 2-Clause "Simplified" License
479 stars 61 forks source link

Notify user when an update to MSCS is available #319

Open Roflicide opened 1 year ago

Roflicide commented 1 year ago

Hi,

This PR adds a feature that notifies the user if an update to MSCS is available. By default, the check will occur every 7 days (let me know if you think it should be something else), but this duration can be configured by adding mscs-update-check-duration property to the mscs.properties file and setting it to a value of your choice (in days; set value less than 1 to disable update checking).

Here's a summary of how this feature technically works:

  1. In the makefile command, it creates a link from the user's MSCS home directory to the MSCS download directory called mscs_install_dir. I put this line of code in the update portion of the makefile (instead of the install portion), so when users update to this version the link will be created.
  2. Then, if the check for updates feature is enabled (by setting the mscs-update-check-duration to greater than 0), the checkForMSCSUpdates function is executed, which just cd's to the install directory (using the link the makefile created) and does a git fetch --dry-run--if this has 0 output, theres no updates, otherwise there is an update available. If an update is available, it displays a link to our documentation page on how to update.
  3. Then, a temporary file is written (called.mscs-last-update-check) that stores the date of the last update. Once this period has elapsed, the update-check command is called again.
  4. The checkForMSCSUpdates function can also be called manually by running mscs check-for-mscs-updates.

Changes to documentation required:

We could technically extend this PR to automatically doing the update as well, but it would require additional complexity and error checking (especially if the user followed the manual install); whereas with just checking for updates, regardless if the user did the Makefile install or the manual install, this PR should still work since both types of installs involves git cloneing this repository.

I tried to test this as thoroughly as possible, but additional testing would be greatly appreciated.

Thanks, Michael

sandain commented 1 year ago

This assumes that the git method was used for install. I also periodically release tarballs, and this method wouldn't work for this.

Perhaps we should add a version file that the script could refer to.

zanix commented 1 year ago

We could ping the GitHub API and see what the latest tag or release is

zanix commented 1 year ago

https://api.github.com/repos/MinecraftServerControl/mscs/releases

Grab tag_name and pass it to download the specific tag https://github.com/MinecraftServerControl/mscs/releases/download/$tag_name/$tag_name.zip

Or we could use the latest download link

Or not upgrade in place and just notify

zanix commented 1 year ago

I just noticed there is a tarball_url and zipball_url in the API, that's probably the easiest to grab the download or even output the URL or use html_url for the link to the page.