Raised This Month: $7 Target: $400
 1% 

Updater


Post New Thread Reply   
 
Thread Tools Display Modes
Author
GoD-Tony
Veteran Member
Join Date: Jul 2005
Plugin ID:
2599
Plugin Version:
1.2.1
Plugin Category:
Technical/Development
Plugin Game:
Any
Plugin Dependencies:
    Servers with this Plugin:
    778 
    Plugin Description:
    Automatically updates SourceMod plugins and files
    Old 10-08-2011 , 13:03   Updater
    Reply With Quote #1

    Updater

    Allows developers to automatically update their plugins and files. Updates will be checked on server startup and then once every 24 hours. All updates will be logged to Updater.log in your SourceMod log directory.

    Installation:
    1. Your server must be running at least one of the following extensions:
    2. Extract updater.zip to your SourceMod directory.
    Cvars:
    • sm_updater <1|2|3> - Determines update functionality.
      • 1 = Only notify in the log file when an update is available.
      • 2 = Automatically download and install available updates. *Default
      • 3 = Include the source code with updates.
    Commands:
    • sm_updater_check - Forces Updater to check all plugins for updates. Can only be run once per hour.
    • sm_updater_status - View the status of Updater.
    Attached Files
    File Type: zip updater.zip (37.1 KB, 12938 views)
    __________________

    Last edited by GoD-Tony; 08-28-2020 at 06:39. Reason: BitBucket repo died
    GoD-Tony is offline
    GoD-Tony
    Veteran Member
    Join Date: Jul 2005
    Old 10-08-2011 , 13:04   Re: Updater
    Reply With Quote #2

    Information for Developers
    Code:
    /**  * Adds your plugin to the updater. The URL will be updated if  * your plugin was previously added.  *  * @param url      URL to your plugin's update file.  * @noreturn  */ native Updater_AddPlugin(const String:url[]); /**  * Removes your plugin from the updater. This does not need to  * be called during OnPluginEnd.  *  * @noreturn  */ native Updater_RemovePlugin(); /**  * Forces your plugin to be checked for updates. The behaviour  * of the update is dependant on the server's configuration.  *  * @return    True if an update was triggered. False otherwise.  * @error      Plugin not found in updater.  */ native bool:Updater_ForceUpdate(); /**  * Called when your plugin is about to be checked for updates.  *  * @return    Plugin_Handled to prevent checking, Plugin_Continue to allow it.  */ forward Action:Updater_OnPluginChecking(); /**  * Called when your plugin is about to begin downloading an available update.  *  * @return    Plugin_Handled to prevent downloading, Plugin_Continue to allow it.  */ forward Action:Updater_OnPluginDownloading(); /**  * Called when your plugin's update files have been fully downloaded  * and are about to write to their proper location. This should be used  * to free read-only resources that require write access for your update.  *  * @note OnPluginUpdated will be called later during the same frame.  *  * @noreturn  */ forward Updater_OnPluginUpdating(); /**  * Called when your plugin's update has been completed. It is safe  * to reload your plugin at this time.  *  * @noreturn  */ forward Updater_OnPluginUpdated(); /**  * @brief Reloads a plugin.  *  * @param plugin    Plugin Handle (INVALID_HANDLE uses the calling plugin).  * @noreturn  */ stock ReloadPlugin(Handle:plugin=INVALID_HANDLE);

    When testing an update with your plugin, I recommend that you test it against a debug version of Updater. It will log detailed download information to Updater_Debug.log in case you accidentally used malformed URLs or paths.
    Code:
    /* Line 25: updater.sp */ #define DEBUG   // This will enable verbose logging. Useful for developers testing their updates.

    Example Plugin
    Code:
    #include <sourcemod> #undef REQUIRE_PLUGIN #include <updater> #define UPDATE_URL    "http://website.com/myplugin/updatefile.txt" public OnPluginStart() {     if (LibraryExists("updater"))     {         Updater_AddPlugin(UPDATE_URL)     } } public OnLibraryAdded(const String:name[]) {     if (StrEqual(name, "updater"))     {         Updater_AddPlugin(UPDATE_URL)     } }
    Now let's take a look at what UPDATE_URL is pointing to ...

    Update File Format

    Simple Update - Majority of plugins will use this.
    Code:
    "Updater"
    {
    	"Information"
    	{
    		"Version"
    		{
    			"Latest"	"1.0.1"
    		}
    		
    		"Notes"	"More info @ www.sourcemod.net. Changes in 1.0.1:"
    		"Notes"	"Added new Batman model"
    		"Notes"	"Minor code changes"
    	}
    	
    	"Files"
    	{
    		"Plugin"	"Path_SM/plugins/myplugin.smx"
    		"Plugin"	"Path_SM/translations/myplugin.phrases.txt"
    		"Plugin"	"Path_SM/translations/ru/myplugin.phrases.txt"
    		"Plugin"	"Path_Mod/models/characters/batman.mdl"
    		"Plugin"	"Path_Mod/materials/models/characters/batman.vmt"
    		
    		"Source"	"Path_SM/scripting/myplugin.sp"
    	}
    }
    Patch Update - Useful on large plugins to avoid downloading all files when only a few have changed. Patch files will be used if the "Previous" version matches the server's currently running version.
    Code:
    "Updater"
    {
    	"Information"
    	{
    		"Version"
    		{
    			"Latest"	"1.0.1"
    			"Previous"	"1.0.0"
    		}
    		
    		"Notes"	"More info @ www.sourcemod.net. Changes in 1.0.1:"
    		"Notes"	"Added Russian phrases"
    		"Notes"	"Minor code changes"
    	}
    	
    	"Files"
    	{
    		"Patch"
    		{
    			"Plugin"	"Path_SM/plugins/myplugin.smx"
    			"Plugin"	"Path_SM/translations/ru/myplugin.phrases.txt"
    
    			"Source"	"Path_SM/scripting/myplugin.sp"
    		}
    		
    		"Plugin"	"Path_SM/plugins/myplugin.smx"
    		"Plugin"	"Path_SM/translations/myplugin.phrases.txt"
    		"Plugin"	"Path_SM/translations/ru/myplugin.phrases.txt"
    		"Plugin"	"Path_Mod/models/characters/batman.mdl"
    		"Plugin"	"Path_Mod/materials/models/characters/batman.vmt"
    		
    		"Source"	"Path_SM/scripting/myplugin.sp"
    	}
    }
    All web paths are relative to your plugin's update file (UPDATE_URL in this case). Using the above example, the URLs for this update would look like this:

    Code:
    UPDATE_URL = http://website.com/myplugin/updatefile.txt
    
    http://website.com/myplugin/plugins/myplugin.smx
    http://website.com/myplugin/translations/myplugin.phrases.txt
    http://website.com/myplugin/translations/ru/myplugin.phrases.txt
    http://website.com/myplugin/models/characters/batman.mdl
    http://website.com/myplugin/materials/models/characters/batman.vmt
    http://website.com/myplugin/scripting/myplugin.sp
    Final Notes
    • You should only reload your plugin manually if your plugin can handle late load situations. Otherwise letting it reload automatically during the next mapchange is safest.
    • If you have released a plugin that uses Updater, post a link to it in this thread. I'd like to take a look at it!
    • If you're looking for somewhere to host your update files for free: Updater Integration Using Bitbucket

    Last edited by GoD-Tony; 12-23-2012 at 06:20.
    GoD-Tony is offline
    KyleS
    SourceMod Plugin Approver
    Join Date: Jul 2009
    Location: Segmentation Fault.
    Old 10-08-2011 , 15:54   Re: Updater
    Reply With Quote #3

    Holy smokes nice job!
    KyleS is offline
    McFlurry
    Veteran Member
    Join Date: Mar 2010
    Location: RemoveEdict(0);
    Old 10-08-2011 , 16:26   Re: Updater
    Reply With Quote #4

    This is pretty awesome, have some bacon.
    __________________
    McFlurry is offline
    Send a message via Skype™ to McFlurry
    GoD-Tony
    Veteran Member
    Join Date: Jul 2005
    Old 10-12-2011 , 09:05   Re: Updater
    Reply With Quote #5

    Changelog
    Quote:
    Updater 1.2.2
    - Added support for downloading updates using the SteamWorks extension.
    Quote:
    Updater 1.2.1
    - Added support for SourceMod 1.7.
    - Minor fixes for http-redirects.
    Quote:
    Updater 1.2.0
    - Changed from KV to SMC for parsing updater manifests.
    --- This fixes plugin versions sometimes being converted to float values.
    - Removed 10 second startup delay.
    - Fixed plugins without an info enum logging garbage data.
    - Fixed SSL URLs being incorrectly prefixed.
    - Fixed error handling when failing to create files.
    - Fixed error log ordering potentially affecting downloads.
    - Improved Socket extension support.
    --- Added support for HTTP redirects.
    --- Improved HTTP error logging.
    --- SSL download attempts will now properly throw an error.
    - Improved debug error logs.
    Quote:
    Updater 1.1.5
    - Fixed multiple HTTP parsing issues with Sockets.
    Quote:
    Updater 1.1.4
    - Added support for nesting plugins in plugin directory.
    Quote:
    Updater 1.1.3
    - Added command to check Updater status: sm_updater_status
    - Disabled HTTP download caching on all extensions.
    - Improved error logging.
    - Updated documentation.
    Quote:
    Updater 1.1.1
    - Auto-fix urls for SteamTools if missing http prefix.
    Quote:
    Updater 1.1.0
    - Added support for downloading updates using the SteamTools extension.
    - Added a command to force all plugins to be checked for updates: sm_updater_check
    - Improved logging on unsuccessful updates.
    Quote:
    Updater 1.0.2
    - Added a log message when a plugin was successfully updated.
    - Added a log message when Updater restarts itself after being updated.
    Quote:
    Updater 1.0.1
    - Prevent parsing of corrupt KV files
    - Added more descriptive update logging
    - Updated some documentation
    - Minor code changes
    __________________

    Last edited by GoD-Tony; 05-19-2015 at 12:25.
    GoD-Tony is offline
    Powerlord
    AlliedModders Donor
    Join Date: Jun 2008
    Location: Seduce Me!
    Old 10-12-2011 , 09:37   Re: Updater
    Reply With Quote #6

    What's the advantage of using this over Plugin Autoupdater?
    __________________
    Not currently working on SourceMod plugin development.
    Powerlord is offline
    GoD-Tony
    Veteran Member
    Join Date: Jul 2005
    Old 10-12-2011 , 09:52   Re: Updater
    Reply With Quote #7

    Quote:
    Originally Posted by Powerlord View Post
    What's the advantage of using this over Plugin Autoupdater?
    I made this because that plugin had bugs piling up and it wasn't being maintained. I originally made this for SMAC early in the year, but decided to release it as a separate plugin so that anyone could use it in other projects, including my own.

    I incorporated this quick list of ideas to start:
    Quote:
    Originally Posted by GoD-Tony View Post
    • Bug fixes.
    • Path_SM support instead of having to hardcode the SourceMod folder (none of my servers used the original name).
    • KeyValue files instead of XML.
    • More features for developers, and less confusing for users.
    • The auto-updating plugin should update itself, so that other plugins can always rely on the latest features/fixes.
    In addition, XML wasn't very pawn friendly, and there was a bug that scattered files if the URL or local path was too long. This plugin also lets the user to choose which extension they want to use (some had crashing issues with Sockets).

    Last edited by GoD-Tony; 10-12-2011 at 10:11.
    GoD-Tony is offline
    Despirator
    Senior Member
    Join Date: Jun 2011
    Location: Kazakhstan ->Shymkent
    Old 10-12-2011 , 12:02   Re: Updater
    Reply With Quote #8

    thank you GoD-Tony. I really appreciate it
    Despirator is offline
    Steell
    SourceMod Donor
    Join Date: Mar 2009
    Old 10-12-2011 , 13:14   Re: Updater
    Reply With Quote #9

    If I may request a feature: can we have an option that makes a backup of a certain file, rather than just replacing it?
    __________________
    Steell is offline
    GoD-Tony
    Veteran Member
    Join Date: Jul 2005
    Old 10-12-2011 , 14:17   Re: Updater
    Reply With Quote #10

    Quote:
    Originally Posted by Steell View Post
    can we have an option that makes a backup of a certain file, rather than just replacing it?
    I thought about this before but couldn't decide on a proper way to implement it.

    How would you like the backups to work? Should all of the replaced files be grouped into the same folder, or should they keep their directory structure intact but move to /data/updater/backups?

    The main problem I see with backups is that they're rendered useless if a plugin is updated twice within a close time-frame. Basically your backups would only be as good as the second newest version.

    Last edited by GoD-Tony; 10-12-2011 at 14:36.
    GoD-Tony is offline
    Reply


    Thread Tools
    Display Modes

    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 04:25.


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