Advertisement
Alexr360

Update Stargate

Mar 29th, 2024 (edited)
785
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. -- List of programs to check for updates
  2. local programs = {
  3.     {name = "startup", pastebinCode = "jnj8PdyL"},
  4.     {name = "Dial", pastebinCode = "29citfmF"},
  5.     {name = "Update", pastebinCode = "BBBJSdLh"},
  6.     {name = "Lockdown", pastebinCode = "svrWKbdP"},
  7.     {name = "CloseGate", pastebinCode = "mx2mPrhU"}
  8.     -- Add more programs as needed
  9. }
  10.  
  11. -- Function to check for updates
  12. local function checkForUpdates(program)
  13.     -- Loop through the list of programs
  14.     for i, program in ipairs(programs) do
  15.       -- Check if the file already exists
  16.       if not fs.exists(program.name) then
  17.         -- Open a new file with the current program name
  18.         local file = fs.open(program.name, "w")
  19.  
  20.         -- Write a message to the file
  21.         file.write("This is " .. program.name .. ". The pastebin code is " .. program.pastebinCode)
  22.  
  23.         -- Close the file
  24.         file.close()
  25.       end
  26.     end
  27.     print("Files have been created.")
  28.    
  29.     print("Checking for updates for " .. program.name .. "...")
  30.     local response = http.get("https://pastebin.com/raw/" .. program.pastebinCode)
  31.     if response then
  32.         local remoteVersion = response.readAll()
  33.         response.close()
  34.         local localVersion = fs.exists(program.name) and fs.open(program.name, "r").readAll() or nil
  35.         if localVersion and localVersion ~= remoteVersion then
  36.             print("Updating " .. program.name .. "...")
  37.             local file = fs.open(program.name, "w")
  38.             file.write(remoteVersion)
  39.             file.close()
  40.             print(program.name .. " updated successfully.")
  41.         else
  42.             print(program.name .. " is up to date.")
  43.         end
  44.     else
  45.         print("Failed to check for updates for " .. program.name)
  46.     end
  47. end
  48.  
  49. -- Main function to check for updates for all programs
  50. local function main()
  51.     for _, program in ipairs(programs) do
  52.         checkForUpdates(program)
  53.     end
  54. end
  55.  
  56. main()
  57.  
  58. os.sleep(1)
  59. os.reboot()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement