Join us in Outworldz at www.outworldz.com:9000 or follow us:

Search dozens of selected web sites for OpenSim and LSL script

New! Script Meta-Search will search thousands of scripts here and at other sites for LSL or Opensim scripts.
Loading

Want to add a script or a project? Upload it and a half million people will see it and your name here this year.

Home   Show All
Category: Contributor: Creator
Update Open Updater  

Open Updater

Grid-wide Updater for products. This is the Client

Category: Update
By : Ferd Frederix
Created: 2013-09-06 Edited: 2014-02-23
Worlds: Second Life

the Zip file

Download all files for Open Updater
Contents are in zip format, with .LSL (text) source code and LSLEdit (text + Solution) formats.
Get file # 1. Product Updater Client.lsl
Get file # 2. Product Updater Server .lsl

This script by Ferd Frederix may be used in any manner, modified, and republished.  Unless specified otherwise, my scripts are always free and open source.  Objects made with these scripts may be sold with no restrictions.  All I ask is that you point others to this location should they ask you about it and to not sell this script, unless it is for $0 L. Please help improve my work by reporting bugs and improvements.

1
2 // Script by Ferd Frederix
3 // fred@mitsi.com
4 // License: CC-BY-NC
5 // This means you must leave the headers in this script intact, and it is not to be sold by itself, not even for a Linden
6 // You are allowed to use and sell Products that use this script.
7 //
8 // Open Update Client
9 // Updater that goes into any product.
10 // Rev 1.0 5/24/2013 Initial release
11 // Rev 1.1 2/21/2014 changed UUID to a valid one as people do not know how to read instructions.
12
13 // Put this script into any prim and give the prim to someone.
14 // When that product is rezzed, it will check for updates from a Server prim
15 // You must make the name of the Prim "Name-VN", where N is a version number such as 1, 1.0, 2 and so on.
16 // The Name must not have a | in it.
17 // The product MUST have a name followed by -V and a version number
18 //
19 // Examples: Horsie-V1.0 ( Same as V1)
20 // Horsie-V1 ( Same as V1.0)
21 // Horsie-V1.1 ( if inside the updater, this will be sent if the version of Horsie is less than 1.1 )
22 // Horsie-V4.1.1 ( This is an illegal number as it has 2 decimals, and will not update as you expect)
23 // Horsie|From Me-V4.1 ( This is an illegal name as it has a "|" in it)
24
25 //////////////////////////////////////////////////////////
26 // IMPORTANT CONFIGURATION //
27 //////////////////////////////////////////////////////////
28
29 // You MUST put in a UUID from this web site here and put the same UUID in the updater script
30 // Get a UUID from Latif Khalifa at:
31 //
32 // http://gridurl.appspot.com/random
33 //
34 // You only need to do this once for the server that has the same key. That server has to have a copy of the object in it.
35 // You can run more than one server, just make sure that the product goes into the correct server and that the key inside this script in that product matches the key inside the server
36
37 string UUID = "92e723e8-3653-451c-816d-23f920cd02c8"; // You MUST change this
38
39 integer CHATTY = TRUE; // When TRUE, tells the prim owner it is checking for updates. If FALSE, this script is silent.
40
41 //////////////////////////////////////////////////////////
42 // CODE BEGINS, Move on, nothing here to change //
43 //////////////////////////////////////////////////////////
44
45
46 // Just for Debugging
47 integer debug = FALSE; // Show what is happenning in chat if TRUE
48
49 DEBUG(string msg)
50 {
51 if(debug)
52 llOwnerSay(llGetScriptName() + " : " + msg);
53 }
54
55
56 // globals
57 key http_request_id; // this key of for the update request
58 key URL_request_id; // this key is for the HTTP-In
59 string serverURL; // This will become out HTTP-I URL
60
61
62 key Request(string cmd)
63 {
64 DEBUG("Sending:"+serverURL+"?"+cmd);
65 return llHTTPRequest( serverURL+"?"+cmd, [HTTP_METHOD, "GET"], "");
66 }
67
68
69
70 CheckForUpdate()
71 {
72 // Check for an update from the server prim
73 string AvatarName = llKey2Name(llGetOwner());
74 string AvatarNameESC = llEscapeURL(AvatarName);
75 string ProductName = llEscapeURL(llGetObjectName());
76
77 //Product Name|UUID|Avatar Name is the message
78
79 string query = "?q=" + ProductName + "|"+ (string) llGetOwner() +"|" + AvatarName;
80
81 DEBUG("URL:" + serverURL);
82 http_request_id = llHTTPRequest(serverURL + query,[HTTP_METHOD,"POST"],"");
83 }
84
85
86 default
87 {
88
89 on_rez(integer param)
90 {
92 }
93
95 {
96 if(CHATTY)
97 llOwnerSay( "Checking for updates");
98 string keyURL = "http://gridurl.appspot.com/get/"+ llEscapeURL(UUID);
99 DEBUG(keyURL);
100 URL_request_id = llHTTPRequest(keyURL, [HTTP_METHOD, "GET"], ""); // find the server
101 }
102
103
104 http_response(key request_id, integer status, list metadata, string body)
105 {
106 if(URL_request_id == request_id)
107 {
108 URL_request_id = NULL_KEY; // the same event sometimes shows up more then once
109 if(status == 200)
110 {
111 DEBUG("Server URL is :" + body);
112 serverURL = body;
113 CheckForUpdate(); // let's see if there is an update by connecting to the URL we just got
114 }
115 }
116 else if(http_request_id == request_id)
117 {
118 if(status == 200)
119 {
120 DEBUG("Success response:" + body); // report what was returned from update request
121 }
122 else
123 {
124 DEBUG("Fail response:" + body); // report what was returned from update request
125 }
126 }
127 }
128 }

Open Updater

Grid-wide Updater for products. This is the Server

Category: Update
By : Ferd Frederix
Created: 2013-09-06 Edited: 2014-02-23
Worlds: Second Life


This script by Ferd Frederix may be used in any manner, modified, and republished.  Unless specified otherwise, my scripts are always free and open source.  Objects made with these scripts may be sold with no restrictions.  All I ask is that you point others to this location should they ask you about it and to not sell this script, unless it is for $0 L. Please help improve my work by reporting bugs and improvements.

1
2 // Script by Ferd Frederix
3 // fred@mitsi.com
4 // License: CC-BY-NC
5 // This means you must leave the headers in this script intact, and it is not to be sold by itself, not even for a Linden
6 // You are allowed to use and sell Products that use this script.
7
8 //
9 // Open Update server
10 // Rev 1.0 5/24/2013
11 // Rev 1.1 1/21/2014 missing llUrlUnesacape - Thxxx Linn!
12
13 // Put Products in a box inside the prim that has this script. Put the Product Updater scipt in products that get rezzed, and not the box that holds them.
14 // You must make the name of the box that you put in this server "Name-VN", where N is a version number such as 1, 1.0, 2 and so on.
15 // The Name must not have a | in it.
16 // The box MUST have a name followed by -V and a version number
17 //
18 // Examples: Horsie-V1.0 ( Same as V1 )
19 // Horsie-V1 ( Same as V1.0, V1.000 etc. )
20 // Horsie-V1.1 ( his will be sent if the product is named Horsie-V0.99999 or lower )
21 // Horsie-V4.1.1 ( This is an illegal number as it has 2 decimals, and will not update as you expect)
22 // Horsie|From Me-V4.1 ( This is an illegal name as it has a "|" in it)
23
24
25
26 //////////////////////////////////////////////////////////
27 // IMPORTANT CONFIGURATION //
28 //////////////////////////////////////////////////////////
29
30 // You MUST put in a UUID from this web site here and put the same UUID in the updater script in your products
31 // Get one from Latif Khalifa at
32 // http://gridurl.appspot.com/random
33 //
34 string UUID = "92e723e8-3653-451c-816d-23f920cd02c8"; // You MUST change this here and in the products upadter script that you put in your products.
35
36 // Debugging and setup things that can be changed
37 integer debug = FALSE; // Show what is happening in chat
38 integer ENABLED = TRUE; // If TRUE, issue updates to clients, if FALSE, do everything but actually give inventory
39 float HoverText = 1.0; // Set to 0.0 to turn hovertext status updates off
40
41
42 //////////////////////////////////////////////////////////
43 // CODE BEGINS, Move on, nothing here to change //
44 //////////////////////////////////////////////////////////
45
46
47 // global vars
48 integer nServed; // how many updates sent, starts at zero
49
50 // HTTP-IN and other web traffic stuff
51 key URLReq = NULL_KEY;
52 string url; // sop we can release HTTP-In keys
53 key urlRequestId; // the key of the request for a HTTP-In URL
54 key http_RequestID; // the key of th4e Post to outselves
55 integer CHECKTIMER = 600; // run a self-test every 5 minutes. if this fails, request a new URL
56
57
58 RequestHTTPInURL()
59 {
60 llSetTimerEvent(0); // Do not run diags unless we have a valid URL
61 llReleaseURL(url); // there is a limit to the number of URLS, so we always release them.
62 url = "";
63 urlRequestId = llRequestURL(); // get a HTTP-In URL
64 }
65
66
67 DEBUG(string msg)
68 {
69 if(debug)
70 llOwnerSay(llGetScriptName() + " : " + msg);
71 }
72
73 key Request(string URL)
74 {
75 llSetText("Registering",<0,0,1>,HoverText); // blue
76 string url = "http://gridurl.appspot.com/reg?service=" + UUID + "&url=" + llEscapeURL(URL) + "/";
77 return llHTTPRequest( url, [HTTP_METHOD, "GET"], "");
78 }
79
80
81 default
82 {
83 // When rezzed, lets start everything from scratch
84 on_rez(integer param)
85 {
87 }
88
89 // when reset, we get a HTTP-IN URL. Without this, we can do nothing
91 {
92 llSetText("Initializing",<0,0,1>,HoverText); // blue
93 RequestHTTPInURL();
94 }
95
96 // This event will occur whenever a URL is granted or the web server it created gets a POST or GET
97 http_request(key id, string method, string body)
98 {
99 if(method == URL_REQUEST_GRANTED)
100 {
101 DEBUG(body);
102 url = body; // save body response, which is our actual URL, so we can release it.
103 llSetText("Update Server is Starting",<0,0,1>,HoverText);
104 URLReq = Request(body); // send it to the server so the gadgets in the field know where to go to get updates.
105
106 llSetTimerEvent(2); // check server just to be certain
107 }
108 else if(method == URL_REQUEST_DENIED)
109 {
110 llSetText("ERROR: URL request was denied, retrying in 1 minute",<1,0,0>,HoverText);
111 llSleep(60);
112 RequestHTTPInURL();
113 }
114 else if(id == URLReq)
115 {
116 if(body == "OK")
117 {
118 llSetText("Test passed ",<0,0,1>,HoverText);
119 llSleep(1);
120 }
121 else
122 {
123 llSetText("Unable to register, please check your UUID",<1,0,0>,HoverText);
124 }
125 }
126 else if(method == "GET")
127 {
128 DEBUG("GET ACK");
129 llHTTPResponse(id, 200, "ACK");
130 }
131 else if(method == "POST")
132 {
133 DEBUG("POST received");
134 string resp = llGetHTTPHeader(id, "x-query-string");
135 // Product Name|Ver|UUID|Avatar Name is the message
136
137 resp = llUnescapeURL(resp);
138 DEBUG("Query String = " + resp);
139
140
141 list info = llParseString2List(resp,["|"],[]);
142 DEBUG(llDumpList2String(info,"|"));
143
144 // get rid of the q= at the beginning of the name
145 string name= llList2String(info,0);
146 list names = llParseString2List(name,["="],[]);
147
148 string shortName = llList2String(names,1);
149 DEBUG("shortName:" + shortName);
150 names = llParseString2List(shortName,["-V"],["-V"]);
151
152 float VerWanted = (float) llList2String(names,1);
153 DEBUG("Version of product:" + (string) VerWanted);
154
155 string productName = llList2String(names,0);
156 DEBUG("productName:" + productName);
157
158 key Theirkey = (key) llList2String(info,1);
159 DEBUG("Owner key:" + (string) Theirkey);
160
161 string Avatar = llList2String(info,2);
162
163 // should look like this for a version 1 Object
164 // Object-1|1.0|10000000-0000-0000-0000-000000000000|SecondLife OwnerName
165
167 while(count--)
168 {
169 string fullname = llGetInventoryName(INVENTORY_OBJECT,count); // obj 1 = 0
170 list parts = llParseString2List(fullname,["-V"],["-V"]);
171
172 string invName = llList2String(parts,0);
173 float invVersion = (float) llList2String(parts,1);
174 DEBUG("Inv Name :" + (string) invName);
175 DEBUG("Inv Version:" + (string) invVersion);
176
177 if(productName == invName && invVersion > VerWanted )
178 {
179 DEBUG("Giving:" + invName);
180 nServed++; // counter for products dispensed
181 if(ENABLED) llGiveInventory(Theirkey,fullname);
182 llSetText(Avatar + " got " + fullname + "\nTotal Items Updated:" + (string) nServed, <1,1,1>,1.0 );
183 }
184 }
185 llHTTPResponse(id, 200, "ACK");
186 }
187 else
188 {
189 llSetText("Unknown command received",<1,0,0>,HoverText);
190 llHTTPResponse(id, 501, "Not Implemented "+method);
191 }
192 }
193
194 // This even will run when a web page is fetched
195 http_response(key request_id, integer status, list metadata, string body)
196 {
197
198 // This would be the response from Grispot that out URL was accepted.
199 if(URLReq == request_id)
200 {
201 URLReq = NULL_KEY;
202 if(status == 200)
203 {
204 llSetText("Server is OK",<0,1,0>,HoverText);
205 }
206 else
207 {
208 llSetText("The internet is broken - retrying",<1,0,0>,HoverText);
209 llSleep(60); // be nice
210 RequestHTTPInURL(); // try again
211 }
212 }
213
214 // this occurs when we test ourselves. We should have gotten an ACK to keep us happy.
215 // if no ACK, we need a new URL
216 else if(request_id == http_RequestID)
217 {
218 if(body != "ACK")
219 {
220 llSetText("The internet is broken - retrying",<1,0,0>,HoverText);
221 llSleep(60); // be nice to ourserver, the server has probably run out of URLS.
222 RequestHTTPInURL();
223 }
224 else
225 {
226 llSetText("Server is ready",<0,1,0>,HoverText);
227 }
228 }
229 }
230
231
232 // run a self test every so often by GETing from ourselves
233 // This also resets the timer to CHECKTIMER, as the very first one of these happens at startup in a few seconds.
234 timer()
235 {
236 llSetText("Update Server is checking itself",<0,0,1>,HoverText);
237 http_RequestID = llHTTPRequest(url,[HTTP_METHOD,"GET"],"");
238 llSetTimerEvent(CHECKTIMER); // check server just to be certain
239 }
240
241
242
243 }

Back to the Best Free Tools in Second Life and OpenSim.