Tomodachi94

ccpkg installer

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