Raised This Month: $51 Target: $400
 12% 

Plugin auto update


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
ghostdlr
Senior Member
Join Date: Aug 2010
Old 01-15-2023 , 15:22   Plugin auto update
Reply With Quote #1

I want to make my plugin auto update because i'm actively developing it and it's impossible to contact all users and ask them to download a new version every time I change something.

My idea is this:
1. Check an api URL and get the version of the latest plugin
2. Compare that version with the current plugin version
3. Download the plugin in a temporary location
4. Do a MD5 hash check to see if the download is ok
5. Replace the old plugin with the new plugin

So far I managed to do the first 3 steps but I cannot replace or delete the old plugin.

delete_file function doesn't work
rename_file only makes a copy of the file instead of renaming it

Is there any other way to do it?

Last edited by ghostdlr; 01-15-2023 at 16:26.
ghostdlr is offline
deprale
Senior Member
Join Date: Oct 2018
Location: Leeds
Old 01-15-2023 , 20:50   Re: Plugin auto update
Reply With Quote #2

delete_file function doesn't work, do you have the permissions necessary for that? does your user own the directory/plugins?


The easiest way would be to do it via easyhttp or curl and github, this way you don't actually have to host anything, download the VERSION file check if the content is higher than ur plugin_version string, then use delete_file on the plugin, then download it. But you have to MAKE SURE the server doesn't crash suddenly, or map change happens, so you have to find a way to only update when the plugin won't have it's execution interrupted suddenly.
__________________

Last edited by deprale; 01-15-2023 at 20:50.
deprale is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 01-16-2023 , 00:56   Re: Plugin auto update
Reply With Quote #3

Someone wrote a plugin to do this generically IIRC. If you find that one it'll probably have everything that you need. Also, this type of thing easily creates a backdoor into the server so the feature should probably be togglable and default to off.
__________________
fysiks is offline
ghostdlr
Senior Member
Join Date: Aug 2010
Old 01-16-2023 , 05:45   Re: Plugin auto update
Reply With Quote #4

Quote:
Originally Posted by deprale View Post
delete_file function doesn't work, do you have the permissions necessary for that? does your user own the directory/plugins?


The easiest way would be to do it via easyhttp or curl and github, this way you don't actually have to host anything, download the VERSION file check if the content is higher than ur plugin_version string, then use delete_file on the plugin, then download it. But you have to MAKE SURE the server doesn't crash suddenly, or map change happens, so you have to find a way to only update when the plugin won't have it's execution interrupted suddenly.
I already used amxx easy http to download the plugin but it doesn't replace the old one.

I'm testing on windows so there should be permissions. I can download or copy files, but I cannot delete or replace.

Any idea why?
ghostdlr is offline
ghostdlr
Senior Member
Join Date: Aug 2010
Old 01-16-2023 , 06:10   Re: Plugin auto update
Reply With Quote #5

I managed to do it eventually (downloading file with amxx easy http), exactly with the steps mentioned above:
1. Check an api URL and get the version of the latest plugin and an md5 hash
2. Compare that version with the current plugin version
3. Download the plugin in a temporary location
4. Do a MD5 hash check to see if the download is ok
5. Replace the old plugin with the new plugin

Last edited by ghostdlr; 01-16-2023 at 11:25.
ghostdlr is offline
Abhinash
Senior Member
Join Date: Jan 2015
Location: India,kolkata
Old 01-18-2023 , 15:22   Re: Plugin auto update
Reply With Quote #6

Quote:
Originally Posted by ghostdlr View Post
I managed to do it eventually (downloading file with amxx easy http), exactly with the steps mentioned above:
1. Check an api URL and get the version of the latest plugin and an md5 hash
2. Compare that version with the current plugin version
3. Download the plugin in a temporary location
4. Do a MD5 hash check to see if the download is ok
5. Replace the old plugin with the new plugin
Mind sharing your code ?
Abhinash is offline
bigdaddy424
Senior Member
Join Date: Oct 2021
Location: Jupiter
Old 01-18-2023 , 15:29   Re: Plugin auto update
Reply With Quote #7

black rose did this years back
__________________
bigdaddy424 is offline
lexzor
Veteran Member
Join Date: Nov 2020
Old 01-18-2023 , 19:59   Re: Plugin auto update
Reply With Quote #8

what is the purpose of getting md5 hash?
lexzor is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 01-18-2023 , 22:27   Re: Plugin auto update
Reply With Quote #9

Quote:
Originally Posted by lexzor View Post
what is the purpose of getting md5 hash?
I use it personally just to test for random errors in the downloaded file.
__________________
fysiks is offline
lexzor
Veteran Member
Join Date: Nov 2020
Old 01-19-2023 , 04:32   Re: Plugin auto update
Reply With Quote #10

how? i don't know this error check can be done by a md5 hash. it is supposed to be made by comparing both md5 hash file of the original file from host and downloaded file?

Last edited by lexzor; 01-19-2023 at 04:43.
lexzor is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 05:11.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode