Tomodachi94

ccpkg installer i guess

Jun 28th, 2022 (edited)
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.24 KB | None | 0 0
  1. -- ccpkg/ccstartd installer
  2. -- (c) 2022 tomodachi94
  3. -- mit license
  4. if not http then
  5. error("The http api is required to proceed with installation.")
  6. return false
  7. end
  8.  
  9. local function get(sUrl)
  10. --write("Connecting to " .. sUrl .. "... ")
  11. --[[local ok, err = http.checkURL(sUrl)
  12. if not ok then
  13. print("Failed.")
  14. if err then
  15. printError(err)
  16. end
  17. return nil
  18. end
  19. --]]
  20. local response = http.get(sUrl, nil, true)
  21. if not response then
  22. print("Failed.")
  23. return nil
  24. end
  25.  
  26. --print("Success.")
  27.  
  28. local sResponse = response.readAll()
  29. response.close()
  30. return sResponse
  31. end
  32.  
  33. local function write(content, path)
  34. f = fs.open(path, "w")
  35. f.write(content)
  36. f.flush()
  37. f.close()
  38. end
  39.  
  40. local function installStuff()
  41. fs.makeDir("/bin")
  42. fs.makeDir("/lib")
  43. write(get('https://tomodachi94.github.io/ccpkg-packages/packages/ccstartd.lua'), '/bin/ccstartd')
  44. write(get('https://tomodachi94.github.io/ccpkg-packages/packages/ccpkg.lua'), '/bin/ccpkg')
  45. write(get('https://tomodachi94.github.io/ccpkg-packages/lib/ccpkg.lua'), '/lib/ccpkg')
  46. write(get('https://tomodachi94.github.io/ccpkg-packages/lib/json.lua'), '/lib/json')
  47. shell.run("/bin/ccstartd")
  48. print('Rebooting...')
  49. sleep(1)
  50. os.reboot()
  51. end
  52.  
  53. installStuff()
Advertisement
Add Comment
Please, Sign In to add comment