mscs
mscs copied to clipboard
Notify user when an update to MSCS is available
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:
- 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 theupdate
portion of themakefile
(instead of theinstall
portion), so when users update to this version the link will be created. - Then, if the check for updates feature is enabled (by setting the
mscs-update-check-duration
to greater than 0), thecheckForMSCSUpdates
function is executed, which justcd's
to the install directory (using the link themakefile
created) and does agit 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. - 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. - The
checkForMSCSUpdates
function can also be called manually by runningmscs check-for-mscs-updates
.
Changes to documentation required:
- Update command reference to include
mscs check-for-mscs-updates
- Update
mscs.properties
documentation to includemscs-update-check-duration
- Update manual setup instructions to instruct user to create a symlink called
mscs_install_dir
from their MSCS home to their download directory.
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 clone
ing this repository.
I tried to test this as thoroughly as possible, but additional testing would be greatly appreciated.
Thanks, Michael
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.
We could ping the GitHub API and see what the latest tag or release is
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
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.