SHOW:
|
|
- or go back to the newest paste.
1 | -- List of programs to check for updates | |
2 | local programs = { | |
3 | - | {name = "startup", pastebinCode = "jnj8PdyL"}, |
3 | + | {name = "startup", pastebinCode = "Y37RTBbv"}, |
4 | - | {name = "Dial", pastebinCode = "b3MuJrtj"}, |
4 | + | {name = "Dial", pastebinCode = "29citfmF"}, |
5 | - | {name = "Update", pastebinCode = "BBBJSdLh"}, |
5 | + | {name = "Update", pastebinCode = "VfUFuVxh"}, |
6 | - | {name = "Lockdown", pastebinCode = "svrWKbdP"}, |
6 | + | |
7 | -- Add more programs as needed | |
8 | } | |
9 | ||
10 | -- Function to check for updates | |
11 | local function checkForUpdates(program) | |
12 | -- Loop through the list of programs | |
13 | for i, program in ipairs(programs) do | |
14 | -- Check if the file already exists | |
15 | if not fs.exists(program.name) then | |
16 | -- Open a new file with the current program name | |
17 | local file = fs.open(program.name, "w") | |
18 | ||
19 | -- Write a message to the file | |
20 | file.write("This is " .. program.name .. ". The pastebin code is " .. program.pastebinCode) | |
21 | ||
22 | -- Close the file | |
23 | file.close() | |
24 | end | |
25 | end | |
26 | print("Files have been created.") | |
27 | ||
28 | print("Checking for updates for " .. program.name .. "...") | |
29 | local response = http.get("https://pastebin.com/raw/" .. program.pastebinCode) | |
30 | if response then | |
31 | local remoteVersion = response.readAll() | |
32 | response.close() | |
33 | local localVersion = fs.exists(program.name) and fs.open(program.name, "r").readAll() or nil | |
34 | if localVersion and localVersion ~= remoteVersion then | |
35 | print("Updating " .. program.name .. "...") | |
36 | local file = fs.open(program.name, "w") | |
37 | file.write(remoteVersion) | |
38 | file.close() | |
39 | print(program.name .. " updated successfully.") | |
40 | else | |
41 | print(program.name .. " is up to date.") | |
42 | end | |
43 | else | |
44 | print("Failed to check for updates for " .. program.name) | |
45 | end | |
46 | end | |
47 | ||
48 | -- Main function to check for updates for all programs | |
49 | local function main() | |
50 | for _, program in ipairs(programs) do | |
51 | checkForUpdates(program) | |
52 | end | |
53 | end | |
54 | ||
55 | -- Run main function | |
56 | - | main() |
56 | + | main() |