daily pastebin goal
50%
SHARE
TWEET

refresh

legg0028 Sep 21st, 2013 (edited) 435 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. local start = nil
  2. local label = nil
  3. local api_user_name = nil
  4.  
  5. -- Get username
  6. if fs.exists("disk/username") then
  7.   local h = fs.open("disk/username", "r")
  8.   api_user_name = h.readAll()
  9.   h.close()
  10. else
  11.   error("No username information available")
  12. end
  13.  
  14. term.clear()
  15. term.setCursorPos(1,1)
  16.  
  17. if os.computerLabel() == nil then
  18.   print("What label do you want to give this device?")
  19.   label = io.read()
  20.   os.setComputerLabel(label)
  21. else
  22.  label = os.computerLabel()
  23. end
  24.  
  25. -- Copy over programs
  26. local folderName = api_user_name
  27. if fs.exists("/" ..folderName) then
  28.   fs.delete("/" ..folderName)
  29. end
  30. fs.copy("disk/" ..folderName, folderName)
  31.  
  32. -- Removing existing startup program
  33. if fs.exists("startup") then
  34.     fs.delete("/startup")
  35. end
  36.  
  37. -- Set startup program
  38. if os.computerLabel() == "compressor" then
  39.   start = api_user_name.."/compressor"
  40. elseif os.computerLabel() == "cComp" then
  41.   start = ""
  42.   shell.run("disk/"..api_user_name.."/update")
  43. else
  44.   print("What program do you want to set as startup?")
  45.   start = io.read()
  46. end
  47. if start ~= "" then
  48.   h = fs.open("startup", "w")
  49.   h.write("shell.run\(\""..start.."\"\)")
  50.   h.close()
  51. end
  52.  
  53. print("Device '"..label.."' has been updated")
  54. if start ~= "" then
  55.     print("Startup program set to "..start)
  56. else
  57.     print("No startup program set")
  58. end
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top