if fs.exists(".blocksetup") then
  shell.run("startup")
  return
end

if fs.exists("startup") then
  write("already configured; \nreformat? (y/n) > ")
  local answer=read()
  if answer:lower()~="y" then
    print("canceled.")
    return
  end
  fs.delete("startup")
end

local dir="computer/"
if turtle then dir="turtle/" end

local function copyContents(dir,dest)
  if fs.exists(dest) then
    if not fs.isDir(dest) then
      fs.delete(dest)
      fs.makeDir(dest)
    end
  else
    fs.makeDir(dest)
  end
  local l=fs.list(dir)
  for i=1,#l do
    if fs.exists(dest..l[i]) then
      fs.delete(dest..l[i])
    end
    print("copying "..dir..l[i].." to "..dest..l[i])
    fs.copy(dir..l[i], dest..l[i])
  end
end

copyContents("disk/common/programs/","programs/")
copyContents("disk/common/apis/","apis/")
copyContents("disk/"..dir.."apis/","apis/")    
copyContents("disk/"..dir.."programs/","programs/")
fs.copy("disk/common/startup","startup")