#!/ld/lua --[[ -- Installation script for ld, a cloud application layer -- for "CC: Tweaked" computers [ https://tweaked.cc/ ] -- -- to install ld, use: -- wget run https://ld.camacraft.net --]] local base_url = 'https://ld.camacraft.net' print() if fs.exists('/ld') then -- present /// update print('Updating ld using ' .. base_url) else -- absent /// install print('Installing ld using ' .. base_url) end pcall(fs.makeDir, '/ld') print('You can set setting \'ld.debug.print_messages\' to see debug messages') -- TODO add debug utility local function install(file, dir) if not dir then dir = '/ld/' end local req = http.get(base_url .. '/ld/' .. file) local str = req.readAll() req.close() local fh = io.open(dir .. file, 'w') fh:write(str) fh:close() end install('init') install('lua') -- a lua file loader so we can use hashbangs and get syntax hilighing in our irl code/text editors install('ldlib') install('startup', '/') -- craftos settings settings.set('shell.allow_startup', true) settings.set('bios.strict_globals', true) settings.set('motd.enable', false) -- ld settings settings.define('ld.debug.print_messages', { desription = 'Wheather to show output of the ld.debug:msg function', default = false, type = 'boolean', }) settings.define('ld.base_url', { desription = 'The URL of the ld repo', default = base_url, type = 'string', }) settings.set('ld.base_url', base_url) settings.define('ld.job', { desription = 'The ldsh command to run when the computer starts', type = 'string', }) if settings.get('ld.job') then print('Not overwriting setting ld.job') else settings.set('ld.job', 'ldsh') end -- save the modified settings settings.save() print('Finished ld installation') os.reboot()