Advertisement
denvys5

Legion

Nov 1st, 2013
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.21 KB | None | 0 0
  1. if shell.getRunningProgram() == "disk/startup" then
  2.   print("Installing...")  
  3.  
  4.   if fs.isDir("disk/install") then
  5.     local files = fs.list("disk/install")
  6.     for _,file in ipairs( files ) do
  7.       print("disk/install/"..file.." -> "..file)
  8.       fs.delete(file)
  9.       fs.copy("disk/install/"..file,file)
  10.     end
  11.   else
  12.     print "No files to install. Put install files to directory 'disk/install'"
  13.   end
  14.  
  15.   if not os.getComputerLabel("label") then
  16.     labelFile = fs.open("disk/label", "r")
  17.     if labelFile then
  18.       label = labelFile.readAll()
  19.       labelFile.close()
  20.       if label == "id" then
  21.         os.setComputerLabel(os.getComputerId())
  22.       else  
  23.         os.setComputerLabel(label)
  24.         label = string.gsub(label, '[0-9]+', function (x) return x+1 end)
  25.         labelFile = fs.open("disk/label", "w")
  26.         labelFile.write(label)
  27.         labelFile.close()
  28.       end
  29.       print("Set label to " .. os.getComputerLabel())
  30.     else
  31.       print "No label file. Put label to file 'disk/label'\nIt should contain number, that will be incremented each time"
  32.     end
  33.   end
  34.   print("Done!")
  35. else
  36.   print "Place a disk drive with floppy near computer and copy this program to disk/startup"
  37. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement