local url = "http://ac-get.darkdna.net/install.lua"

assert(http, "HTTP API is required for ac-get. See http://computercraft.info/wiki/HTTP_(API) for how to enable.")

print("Downloading ac-get setup...")
local dh = http.get(url)
assert(dh, "Unable to download ac-get setup file.")
assert(dh.getResponseCode() == 200, "Unable to download ac-get setup file. HTTP " .. dh.getResponseCode())
local setup = dh.readAll()
dh.close()
dh = nil
url = nil
print("ac-get setup downloaded, executing..")
loadstring(setup)()
print("Adding Odd's ac-get-repo...")
shell.run("/bin/ac-get add-repo https://bitbucket.org/Oddstr13/ac-get-repo/raw/default")

print("Writing startup file...")
f = fs.open("/startup", "w")
f.write([[--DO NOT REMOVE -- ac-get
local s_dir = '/cfg/startup.d'
local files = fs.list(s_dir)
table.sort(files)
for _, start in ipairs(files) do
  dofile(s_dir .. '/' .. start)
end
--DO NOT REMOVE]])
f.close()
print("Install done... please reboot.")