Jump to content




File rollout server


  • You cannot reply to this topic
4 replies to this topic

#1 albrat

  • Members
  • 162 posts
  • LocationA Chair

Posted 11 July 2013 - 12:29 PM

I have been working on a file updating system to roll out on my computers...

I have not got a HTTP server connection so programs have to be hand typed on a computer then transfered using a disk drive (which had to be placed and removed every time as the computers are stand alone).

This system is intended to be automatic.

here is a pastebin link to the fileserver code

http://pastebin.com/Z0Ls2rbX

edit : To use the fileserver -- you MUST create two folders ( - mkdir server / mkdir client - )
edit : Just to avoid confusion these two folders must be made on your file server


This is the pastebin for the client code

http://pastebin.com/rGuCZh8N

edit : my fileserver is id 1.. change your fileserver id in the file to match your fileservers id in your client code.

the client code runs the update, then after the final command "bt.eol" - end of list - it then runs a set of shell commands to delete itself, rename the update of itself to its own name, calls the startup file and exits with the error "File updates finished" you can even update the program that is running the updates!!

I built a file structure to be \\server\\ files and \\client\\ files

This currently only supports a client and server profile but expanding to more clients would be pretty easy.


My plands to use this on a multiplayer server mean that any computer can be installed as a client. (I have to write a server update script still. But it is basically the same but with "update_server" instead of "update_client" then it will pull the server update files from the server folder.)

I hope some people can find a use for this. (it helps to distribute new code easily)

(some of my files are 100's of lines of code, which would have meant a long rednet send message, hence I split by line) - not sure on the limits of a rednet message.

#2 rhyleymaster

  • Members
  • 186 posts
  • LocationCanada

Posted 11 July 2013 - 12:45 PM

Not bad! (- the fact it floods rednet.)

#3 Lyqyd

    Lua Liquidator

  • Moderators
  • 8,465 posts

Posted 11 July 2013 - 01:09 PM

Send the whole file at once, don't send individual lines.

#4 TheOddByte

    Lazy Coder

  • Members
  • 1,607 posts
  • LocationSweden

Posted 12 July 2013 - 05:34 AM

As Lyqyd said don't send on line at a time...
I don't know how you are doing it but..
Here's how I would do it
repeat
filename = read()
until fs.exists(filename)

file = fs.open(filename,"r")
code = file.readAll()
file.close()

rID = 1337
rednet.send(rID,code)
This was just an example of how to send the full code directly

#5 albrat

  • Members
  • 162 posts
  • LocationA Chair

Posted 12 July 2013 - 06:05 AM

Fileserv - Updated code to send the whole file at once.
Spoiler

Updated code for the fileupdate program.

Spoiler

In the fileserv file, I changed the io.open to fs.open and file.read() to textutils.serialize(file.readAll()) ..
then commented out the while loop and check for data == nil / loop break command, as I removed the loop to receive sections of data.

In the fileupdate program I changed the local subbedData = string.sub(msg, #"bt.file:" + 1) to "local subbedData = textutils.unserialize(string.sub(msg, #"bt.file:" + 1))" voila works to copy and write the new files. 1 send instead of each line sending. ( much faster ).





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users