AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Unapproved Plugins (https://forums.alliedmods.net/forumdisplay.php?f=109)
-   -   Plugin Autoupdater (https://forums.alliedmods.net/showthread.php?t=91992)

MikeJS 05-08-2009 12:44

Plugin Autoupdater
 
3 Attachment(s)
Allows plugin writers to add a few lines of code to their plugin to let it update itself.

Requires the Socket Extension.

Thanks to exvel for a seemingly endless stream of bug reports and p3tsin and Matthias Vance for help with downloading files.

Cvars:
sm_autoupdate_binary (1) - Download binaries?
sm_autoupdate_source (1) - Download sources?
sm_autoupdate_gamedata (1) - Download gamedata files?
sm_autoupdate_other (1) - Download other files?
sm_autoupdate_backup (1) - Save backups of old versions? When set to 1, saves backups of old versions to addons/sourcemod/plugins/disabled/backups

Commands:
sm_autoupdate_check [filename/idx] - Checks for updates but doesn't download anything. Leave idx blank to check all plugins. (logs results to sourcemod/logs/autoupdate.log)
sm_autoupdate_download [filename/idx] - Checks for updates and downloads them. Leave idx blank to update all plugins. (logs results to sourcemod/logs/autoupdate.log)
sm_autoupdate_list - Returns the list of plugins that will be updated.
sm_autoupdate_rem <filename/idx> - Stops a plugin being autoupdated. Get idx from sm_autoupdate_list.
sm_autoupdate_block_add <filename> - Adds a plugin to the block list. Plugins in the block list won't be added to the autoupdate list. (eg sm_autoupdate_block_add autoupdate.smx)
sm_autoupdate_block_rem <filename/idx> - Removes a plugin from the block list.
sm_autoupdate_block_list - Lists blocked plugins.

Todo:
Translation support

Making your plugin autoupdate:
Include autoupdate in your plugin and use the AutoUpdate_AddPlugin()/AutoUpdate_RemovePlugin() natives.
Example plugin:
PHP Code:

#pragma semicolon 1
#include <sourcemod>
#undef REQUIRE_PLUGIN
#include <autoupdate>
#define PL_VERSION "1.0"
public OnPluginStart() {
    
RegConsoleCmd("testau"Command_test);
}
public 
OnAllPluginsLoaded() {
    if(
LibraryExists("pluginautoupdate")) {
        
// only register myself if the autoupdater is loaded
        // AutoUpdate_AddPlugin(const String:url[], const String:file[], const String:version[])
        
AutoUpdate_AddPlugin("127.0.0.1""/plugins.xml"PL_VERSION);
    }
}
public 
OnPluginEnd() {
    if(
LibraryExists("pluginautoupdate")) {
        
// I don't need updating anymore
        // AutoUpdate_RemovePlugin(Handle:plugin=INVALID_HANDLE) - don't specifiy plugin to remove calling plugin
        
AutoUpdate_RemovePlugin();
    }
}
public 
Action:Command_test(clientargs) {
    
PrintToChatAll("Version %s"PL_VERSION);


127.0.0.1/plugins.xml looks like:
Code:

<plugin>
        <version>1.1</version>
        <changes>Changed version number.</changes>
        <binary>/auexample.smx</binary>
        <source>/auexample.sp</source>
        <gamedata>/folder/auexample.games.txt</gamedata>
        <other dir="newdir">/newfile.txt,/folder/newfile2.txt</other>
        <other dir="newdir2">/newfile3.txt</other>
</plugin>

Directory for <other> is relative to the mod folder.

When sm_autoupdate_download is ran, the plugin will try to download 127.0.0.1/auexample.smx, 127.0.0.1/auexample.sp, 127.0.0.1/folder/auexample.games.txt and so on.
You do not need to add gamedata/source/other. (you only need the version, but what use would that be?)


The plugin doesn't update itself because if I didn't keep making stupid mistakes it wouldn't need to :D

mattressfish 05-08-2009 12:59

Re: Plugin Autoupdater
 
Wow, this is AWESOME. Good work!

exvel 05-08-2009 13:33

Re: Plugin Autoupdater
 
So I need a hosting for making a such plugin that is able to autoupdate, right?
Also if answer: yes, you can write a manual of how to post your plugin in free svn service or something like google code.

MikeJS 05-08-2009 14:02

Re: Plugin Autoupdater
 
Quote:

Originally Posted by exvel (Post 823654)
So I need a hosting for making a such plugin that is able to autoupdate, right?
Also if answer: yes, you can write a manual of how to post your plugin in free svn service or something like google code.

You do. I'm not sure how google code works, sorry. You should be able to use any free host though.

exvel 05-08-2009 14:06

Re: Plugin Autoupdater
 
Quote:

Originally Posted by MikeJS (Post 823668)
You do. I'm not sure how google code works, sorry. You should be able to use any free host though.

I've just created my first project on google code and it seems that it is perfectly suitable. All links are direct so I think it is a perfect place for uploading plugins. :)

p.s. anyway, good job +karma

exvel 05-08-2009 14:07

Re: Plugin Autoupdater
 
What should I write here? New version number or update description?
Quote:

<changes>Changed version number.</changes>

exvel 05-08-2009 14:09

Re: Plugin Autoupdater
 
Also about a suggestion that is already in your ToDo list. Custom files tag:
Quote:

<custom="directory_file_to_put_in">/some_file</custom>
I think it could be the best way.

p.s.
google code example: http://code.google.com/p/showhealth/downloads/list

MikeJS 05-08-2009 14:32

Re: Plugin Autoupdater
 
Quote:

Originally Posted by exvel (Post 823674)
What should I write here? New version number or update description?

Update description.

Quote:

Originally Posted by exvel (Post 823675)
Also about a suggestion that is already in your ToDo list. Custom files tag:

I think it could be the best way.

So something like this?
Code:

<other dir="sounds">annoying1.mp3,annoying2.mp3,annoying3.mp3</other>
<other dir="materials">overlay\overlay.vtf,overlay\overlay.vmt</other>


exvel 05-08-2009 14:45

Re: Plugin Autoupdater
 
Yeap this is very close to what I expected but this would be looks better I think:

Code:

<other dir="sounds">annoying1.mp3</other>
<other dir="sounds">annoying2.mp3</other>
<other dir="sounds">annoying3.mp3</other>

Also I've tested autoupdater and got an error:
Code:

sm_autoupdate_check
L 05/08/2009 - 22:42:19: [autoupdate.smx] Socket error: 1 (#11004)
sm_autoupdate_list
showhealth.smx ver 1.0.0
Autoupdating 1 plugin.

p.s. my plugin's source: http://showhealth.googlecode.com/files/showhealth.sp

MikeJS 05-08-2009 15:03

Re: Plugin Autoupdater
 
Try AutoUpdate_AddPlugin("showhealth.googlecode.c om", "/files/version.xml", PLUGIN_VERSION);

edit: I don't know why it's adding a space :|

exvel 05-08-2009 15:09

Re: Plugin Autoupdater
 
Quote:

Originally Posted by MikeJS (Post 823703)
Try AutoUpdate_AddPlugin("showhealth.googlecode.c om", "/files/version.xml", PLUGIN_VERSION);

edit: I don't know why it's adding a space :|

Ok, I changed to this:
PHP Code:

AutoUpdate_AddPlugin("showhealth.googlecode.com""/files/version.xml"PLUGIN_VERSION); 

Now it connects but can't find a file or something like that:
Code:

sm_autoupdate_check
L 05/08/2009 - 23:07:19: [SM] Native "WritePackString" reported: Invalid data pack handle 0 (error 4)
L 05/08/2009 - 23:07:19: [SM] Displaying call stack trace for plugin "autoupdate.smx":
L 05/08/2009 - 23:07:19: [SM]  [0]  Line 110, C:\SPComp\autoupdate.sp::OnSocketReceive()
L 05/08/2009 - 23:07:20: <FAILED> showhealth.smx: showhealth.googlecode.com/files/version.xml (couldn't find anything)


MikeJS 05-08-2009 16:05

Re: Plugin Autoupdater
 
Updated to 1.1 which fixes the datapack error (along with a few others) but I can't get it work for anything other than 127.0.0.1.

exvel 05-08-2009 16:31

Re: Plugin Autoupdater
 
Step by step it works better and better. :)
Now I can download files but...
Code:

sm_autoupdate_download
L 05/09/2009 - 00:27:10: <UPDATING> showhealth.smx to version 1.0.1 - Changes:
* 1.0.1
Minor code changes for better performance
Added config file
* 1.0.0
Initial Release

L 05/09/2009 - 00:27:10: Couldn't find gamedata.
L 05/09/2009 - 00:27:10: Downloaded addons\sourcemod\plugins\showhealth.smx
L 05/09/2009 - 00:27:10: Downloaded addons\sourcemod\scripting\showhealth.sp

After this I can't load/reload my plugin and I think know why. Here is a downloaded showhealth.sp file:
PHP Code:

<HTML><HEAD><meta http-equiv="content-type" content="text/html;charset=utf-8">
<
TITLE>302 Moved</TITLE></HEAD><BODY>
<
H1>302 Moved</H1>
The document has moved
<A HREF="http://www.google.ru/">here</A>.
</
BODY></HTML

And it seems that .smx has the same code inside.

Downtown1 05-08-2009 18:21

Re: Plugin Autoupdater
 
Would be 10x more useful if we could host our plugins to be auto-updated from the AlliedModders site.

Fast suggestions:

* Add support for updating extensions. Delay overwriting the extension until the server is restarted? Notify the user to restart server when a new extension is downloaded.
* Add some kind of checksum support, something simple like MD5. Don't want to download a file that's corrupt and have it overwrite our stuff, now do we?

Very sweet btw, I wanted to do this feature myself for my plugin to make distribution simpler, but though that such a feature should be applicable across all plugins. Unfortunately I did not realize that plugins can call code from other plugins via CreateNative.

What a nice breakthrough!

MikeJS 05-08-2009 18:42

Re: Plugin Autoupdater
 
Quote:

Originally Posted by Downtown1 (Post 823809)
* Add support for updating extensions. Delay overwriting the extension until the server is restarted? Notify the user to restart server when a new extension is downloaded.

Maybe.
Quote:

Originally Posted by Downtown1 (Post 823809)
* Add some kind of checksum support, something simple like MD5. Don't want to download a file that's corrupt and have it overwrite our stuff, now do we?

Why didn't I think of this :D

Downtown1 05-08-2009 22:40

Re: Plugin Autoupdater
 
I release updates that often add significant functionality updates (especially when its major bug fixes) to my plugins, so having a way to deploy it faster will be invaluable. Unfortunately I've also recently started to require an extension (that I also develop), so having a way to automatically update that would be prime.

BTW, MikeJS do you hang out on #sourcemod ?

Fredd 05-08-2009 23:05

Re: Plugin Autoupdater
 
Quote:

Originally Posted by Downtown1 (Post 823809)
* Add support for updating extensions. Delay overwriting the extension until the server is restarted? Notify the user to restart server when a new extension is downloaded.

That's not possible since this plugin provides a set functions to other plugins and afaik an extension can't use natives that are provided by a plugin... The only solution i see if you want extensions support is if this was written as an extension and then writing an interface for these functions so other extensions could you use it and at the same time plugins by just creating interface wrappers.

MikeJS 05-09-2009 06:35

Re: Plugin Autoupdater
 
Quote:

Originally Posted by Downtown1 (Post 823883)
BTW, MikeJS do you hang out on #sourcemod ?

Sometimes
Quote:

Originally Posted by Fredd (Post 823893)
That's not possible since this plugin provides a set functions to other plugins and afaik an extension can't use natives that are provided by a plugin... The only solution i see if you want extensions support is if this was written as an extension and then writing an interface for these functions so other extensions could you use it and at the same time plugins by just creating interface wrappers.

You could release the extension with a plugin that updates the extension

exvel 05-09-2009 06:43

Re: Plugin Autoupdater
 
MikeJS, did you find a problem that I wrote above? Or it is google code issue? I didn't find any other good file/code hostings so I hope you will change plugin to work with google code.
Also it is strnage that version.xml downloads without any problems but other files has this strange html code.

MikeJS 05-09-2009 06:49

Re: Plugin Autoupdater
 
Try using:
Code:

<binary>\files\showhealth.smx</binary>
<source>\files\showhealth.sp</source>
<gamedata>\files\empty.txt</gamedata>


exvel 05-09-2009 06:57

Re: Plugin Autoupdater
 
1 Attachment(s)
I've already tried adding empty gamedata file and the only differece is that now it downloads an another html code but not a real plugin's code.
I looked into the code and found that download processes for all files happen in one moment so maybe google refuses more than 1 connection at the moment?

Downtown1 05-09-2009 13:44

Re: Plugin Autoupdater
 
Ok upon thinking about this.. why do you need a plugin to add autoupdate support to itself via code? Why not do it via some kind of configuration file.

i.e. to add support to autoupdate a plugin called abc.smx we go to data/autoupdate/abc.txt and it is a key-value file with the URL to the XML file?
Code:

//Filename: abc.txt
{
  "Plugins Repository"
  {
    "http://localhost/plugins.xml"
  }
}

That way to add autoupdate support could be done to any plugin without having to edit the source code :).
------------------

You could try iterating the plugins with GetPluginIterator/MorePlugins/ReadPlugin then with GetPluginFilename see if there's any matches entries in data/autoupdate and if there is then you just associate them with it. GetPluginInfo or "sm plugins list" to get the version of the loaded plugin :).

blade81 05-10-2009 05:41

Re: Plugin Autoupdater
 
Is it possible to add ftp support?

MikeJS 05-10-2009 06:36

Re: Plugin Autoupdater
 
Quote:

Originally Posted by Downtown1 (Post 824253)
Ok upon thinking about this...

Nice idea.

Quote:

Originally Posted by blade81 (Post 824773)
Is it possible to add ftp support?

Probably not anytime soon :P

mattressfish 05-11-2009 09:59

Re: Plugin Autoupdater
 
Quote:

Originally Posted by Downtown1 (Post 824253)
Ok upon thinking about this.. why do you need a plugin to add autoupdate support to itself via code? Why not do it via some kind of configuration file.

i.e. to add support to autoupdate a plugin called abc.smx we go to data/autoupdate/abc.txt and it is a key-value file with the URL to the XML file?
Code:

//Filename: abc.txt
{
  "Plugins Repository"
  {
    "http://localhost/plugins.xml"
  }
}

That way to add autoupdate support could be done to any plugin without having to edit the source code :).
------------------

You could try iterating the plugins with GetPluginIterator/MorePlugins/ReadPlugin then with GetPluginFilename see if there's any matches entries in data/autoupdate and if there is then you just associate them with it. GetPluginInfo or "sm plugins list" to get the version of the loaded plugin :).

That's an even better idea!

I've been waiting for something like this guys. Keep up the good work!

Poheart 05-11-2009 11:11

Re: Plugin Autoupdater
 
it working on Left 4 Dead SourceMod Plugin?
And i don't know how to use it- -
Thanks a lot:)

exvel 05-11-2009 11:44

Re: Plugin Autoupdater
 
Tryed svn 2 http url:
http://code.google.com/p/showhealth/...wse/#svn/trunk
showhealth.smx: http://showhealth.googlecode.com/svn...showhealth.smx
showhealth.sp: http://showhealth.googlecode.com/svn.../showhealth.sp
:(
Same result. Text in .sp and .smx files:
Quote:

<HTML><HEAD><meta http-equiv="content-type" content="text/html;charset=utf-8">
<TITLE>302 Moved</TITLE></HEAD><BODY>
<H1>302 Moved</H1>
The document has moved
<A HREF="http://www.google.ru/">here</A>.
</BODY></HTML>

MikeJS 05-11-2009 12:05

Re: Plugin Autoupdater
 
Have you tried using code.google.com in the .sp and
Code:

<source>\p\showhealth\source\browse\trunk\scripting\showhealth.sp</source>
// etc

in the xml?

exvel 05-11-2009 12:14

Re: Plugin Autoupdater
 
http://code.google.com/p/showhealth/.../showhealth.sp is incorrect page, it shows info about file.
This one is a direct link: http://showhealth.googlecode.com/svn.../showhealth.sp and I tested plugin with it.
Also version.xml downloads well so I think links are correct. Mike, please figure it out. I am sure that something wrong inside plugin's downloading code. Maybe it is better to make a line for downloading-files so they won't download at the same time.

MikeJS 05-11-2009 13:43

Re: Plugin Autoupdater
 
Updated the plugin so it actually works with something other than XAMPP (use "/" rather than "\" in the xml file now). Also added a public cvar because I forgot to add it before.

exvel 05-11-2009 14:00

Re: Plugin Autoupdater
 
Jesus Christ! It works now.
Good job. :up:

exvel 05-12-2009 06:21

Re: Plugin Autoupdater
 
Waiting for custom files support. :)

p.s. or at least translations

MikeJS 05-12-2009 15:19

Re: Plugin Autoupdater
 
Updated to 1.3: can download multiple files of the same type (comma separated), can download "other" files and has cvars for controlling what it downloads.
Will be adding a config file and maybe translations shortly.

exvel 05-12-2009 15:31

Re: Plugin Autoupdater
 
I am glad to see that this awsome plugin is becoming better and better. I hope in the future there will be an admin menu so root admins would be able to update plugins or specific plugin just as easy as they can slay/slay players, etc. :)
Also, useful topic about MD5 hashing: http://forums.alliedmods.net/showthread.php?t=90326

MikeJS 05-12-2009 15:34

Re: Plugin Autoupdater
 
Quote:

Originally Posted by exvel (Post 826385)
I am glad to see that this awsome plugin is becoming better and better. I hope in the future there will be an admin menu so root admins would be able to update plugins or specific plugin just as easy as they can slay/slay players, etc. :)
Also, useful topic about MD5 hashing: http://forums.alliedmods.net/showthread.php?t=90326

Admin menu: not really needed, admins can just add sm_autoupdate_download to server.cfg

MD5: I forgot about that :mrgreen:

exvel 05-12-2009 15:39

Re: Plugin Autoupdater
 
Quote:

Originally Posted by MikeJS (Post 826387)
Admin menu: not really needed, admins can just add sm_autoupdate_download to server.cfg

MD5: I forgot about that :mrgreen:

Maybe you are right. But in this case "sm_autoupdate_download" should also reload plugins after updating. And it also may be better if this command would support an argument that will specify which plugin to update if administrator doesn't want to update all plugins at one time. If no args specified autoupdater will update all plugins.

p.s. found a nice little prog for getting md5 checksum: http://diamondcs.com.au/freeutilities/md5.php

MoggieX 05-12-2009 19:13

Re: Plugin Autoupdater
 
Just to clarify, I could with some sp coding, store in a MySQL db, which plugins should be deployed (true/false flags and have the files store in one place) to which game servers, along with cfg and what every else I need in the way of data files too, have them sent on command.

Its not clear on their removal and also what happens if the file is already stored locally?

Matt

MoggieX 05-12-2009 19:14

Re: Plugin Autoupdater
 
if you see http://forums.alliedmods.net/showthread.php?t=73119 you'll uderstand where I am going with the question.

Matt

MikeJS 05-13-2009 06:56

Re: Plugin Autoupdater
 
Quote:

Originally Posted by exvel (Post 826388)
Maybe you are right. But in this case "sm_autoupdate_download" should also reload plugins after updating. And it also may be better if this command would support an argument that will specify which plugin to update if administrator doesn't want to update all plugins at one time. If no args specified autoupdater will update all plugins.

It doesn't reload the plugins after it downloads them as some plugins break when you reload them. I'll add updating/checking single plugins though.

Quote:

Originally Posted by MoggieX (Post 826496)
if you see http://forums.alliedmods.net/showthread.php?t=73119 you'll uderstand where I am going with the question.

If you mean update different plugins for different servers, it's not really needed since the plugin only updates plugins already on the server.

Poheart 05-13-2009 07:14

Re: Plugin Autoupdater
 
Do i need to download autoupdate.smx in order to make it works fine?


All times are GMT -4. The time now is 12:29.

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