View difference between Paste ID: BBBJSdLh and 8w6Ni2U1
SHOW: | | - or go back to the newest paste.
1
-- List of programs to check for updates
2
local programs = {
3-
    {name = "Bastion", pastebinCode = "Czt0xUgp"},
3+
    {name = "startup", pastebinCode = "jnj8PdyL"},
4-
    {name = "RBastion", pastebinCode = "YLMd18xC"},
4+
    {name = "Dial", pastebinCode = "b3MuJrtj"},
5-
    {name = "FBastion", pastebinCode = "8pF6ds3s"},
5+
    {name = "Update", pastebinCode = "BBBJSdLh"},
6-
    {name = "GPS", pastebinCode = "d8WLzv0U"},
6+
    {name = "Lockdown", pastebinCode = "svrWKbdP"},
7-
    {name = "Update", pastebinCode = "8w6Ni2U1"},
7+
    {name = "CloseGate", pastebinCode = "mx2mPrhU"}
8-
    {name = "Greeting", pastebinCode = "REfxrLkG"},
8+
9-
    {name = "ArtilleryControl", pastebinCode = "BGUJrLzV"},
9+
10-
    {name = "startup", pastebinCode = "u2ey5fkZ"},
10+
11-
    {name = "Teleport", pastebinCode = "CLpkvMg8"}
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-
-- Function to delete existing program files
15+
      -- Check if the file already exists
16-
local function deleteFiles()
16+
      if not fs.exists(program.name) then
17
        -- Open a new file with the current program name
18-
        if fs.exists(program.name) then
18+
19-
            fs.delete(program.name)
19+
20-
            print("Deleted " .. program.name)
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-
-- Function to download and update a single program
25+
      end
26-
local function updateProgram(program)
26+
27-
    print("Updating " .. program.name .. "...")
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-
        file.write(remoteVersion)
35+
        if localVersion and localVersion ~= remoteVersion then
36
            print("Updating " .. program.name .. "...")
37
            local file = fs.open(program.name, "w")
38-
        print(program.name .. " updated successfully.")
38+
            file.write(remoteVersion)
39
            file.close()
40-
        print("Failed to update " .. program.name .. ". Check the Pastebin code or your internet connection.")
40+
            print(program.name .. " updated successfully.")
41
        else
42
            print(program.name .. " is up to date.")
43
        end
44-
-- Main function to delete all files and download new versions
44+
45
        print("Failed to check for updates for " .. program.name)
46-
    deleteFiles() -- Delete all existing files first
46+
47
end
48-
        updateProgram(program)
48+
49
-- Main function to check for updates for all programs
50
local function main()
51
    for _, program in ipairs(programs) do
52-
-- Run main function
52+
        checkForUpdates(program)
53
    end
54-
54+
55
56
main()
57
58
os.sleep(1)
59
os.reboot()