local LOCAL_MANIFEST_PATH = '/trapos/manifest.json'; local function readLocalManifest() if not fs.exists(LOCAL_MANIFEST_PATH) then return nil end local f = fs.open(LOCAL_MANIFEST_PATH, 'r'); if not f then return nil end local data = f.readAll(); f.close(); if not data or data == '' then return nil end return textutils.unserializeJSON(data); end local function init() shell.setPath(shell.path() .. ':/programs'); end init(); if periphemu then periphemu.create('top', 'modem'); end local function shellFn() os.sleep(0.1); shell.run("shell"); end local function getServerFns(serverList) local servers = {}; for k, v in ipairs(serverList) do local serverName = v; servers[k] = function() if serverName then shell.run(serverName); end end end return servers; end local manifest = readLocalManifest(); local SERVERS = (manifest and manifest.autostart) or {}; local servers = getServerFns(SERVERS); if #SERVERS > 0 then print("\nStarting servers..."); for _, v in ipairs(SERVERS) do print("\t\t" .. v) end end parallel.waitForAny(shellFn, table.unpack(servers)); os.shutdown();