Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Add your configuration settings here
- local config = {
- GitHubUsername = 'oeed',
- GitHubRepoName = 'OneOS',
- InstallPath = '/',
- }
- -- Function to handle HTTP requests with error handling
- local function download(url)
- local response = http.get(url)
- if not response then
- error('Failed to download: ' .. url)
- end
- return response.readAll()
- end
- -- Function to download JSON from GitHub API
- local function downloadJSON(path)
- local url = 'https://api.github.com/repos/' .. config.GitHubUsername .. '/' .. config.GitHubRepoName .. path
- return textutils.unserialiseJSON(download(url))
- end
- -- Function to download a file and handle retries
- local function downloadFile(url, destination)
- local tries, file
- repeat
- file = download(url)
- tries = tries + 1
- until tries > 5 or file
- if not file then
- error('Downloading failed, try again. ' .. url)
- end
- local handle = fs.open(destination, 'w')
- handle.write(file)
- handle.close()
- end
- -- Function to update OneOS
- local function updateOneOS()
- -- Add update logic here
- -- Use the functions defined above to download JSON, files, etc.
- end
- -- Main function
- local function main()
- print('OneOS Update Script')
- -- Check if HTTP is enabled
- if not http then
- printError('HTTP is required for updating.')
- return
- end
- -- Update OneOS
- updateOneOS()
- print('Installation complete! Rebooting in 1 second...')
- sleep(1)
- os.reboot()
- end
- -- Run the main function
- main()
Advertisement
Add Comment
Please, Sign In to add comment