Advertisement
Guest User

Untitled

a guest
Dec 9th, 2019
233
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 17.40 KB | None | 0 0
  1. local fs
  2.  
  3. for f in component.list("filesystem") do
  4. if (f ~= computer.tmpAddress()) then
  5. fs = component.proxy(f)
  6. end
  7. end
  8.  
  9. local lfile = fs.open("reactor.log", "a")
  10.  
  11. --This really isn't ideal.
  12. function print(...)
  13. fs.write(lfile, "["..computer.uptime().."] "..table.concat({...}, "\t").."\n")
  14. end
  15.  
  16. if (component.proxy(component.list("tape_drive")()) and component.proxy(component.list("tape_drive")()).write) then
  17. local prox = component.proxy(component.list("tape_drive")())
  18. function print(...)
  19. prox.write("["..computer.uptime().."] "..table.concat({...}, "\t").."\n")
  20. end
  21. end
  22.  
  23. print("litekernel init started.")
  24.  
  25. (function()
  26.  
  27. -- lkern is the light kernel used by Zorya NEO to simplify development.
  28.  
  29.  
  30. local kpkg = {}
  31. kpkg.libs = {}
  32. local krlib = kpkg.libs
  33. kpkg.search = {}
  34. local krfind = kpkg.search
  35. function krequire(pkg)
  36. if (krlib[pkg]) then return krlib[pkg] end
  37. for i=1, #krfind do
  38. local r = krfind[i](pkg)
  39. if (r) then krlib[pkg] = r() return krlib[pkg] end
  40. end
  41. end
  42. local krequire = krequire
  43.  
  44.  
  45.  
  46. krlib["fs"] = (function()
  47.  
  48. local vfs = {}
  49.  
  50. local fs = {}
  51.  
  52. function fs.mount(path, proxy)
  53. vfs[#vfs+1] = {path, proxy}
  54. end
  55.  
  56. function fs.resolve(path)
  57. for i=#vfs, 1, -1 do
  58. if (path:sub(1, #vfs[i][1]) == vfs[i][1]) or (path:sub(1, #vfs[i][1]).."/" == vfs[i][1]) then
  59. return path:sub(#vfs[i][1]), vfs[i][2]
  60. end
  61. end
  62. return nil, "not found"
  63. end
  64.  
  65. fs.mount("/", {
  66. list = function()
  67. local lst = {}
  68. for i=1, #vfs do
  69. if (vfs[i][1]:match("^/.+/$")) then
  70. lst[#lst+1] = vfs[i][1]:sub(2)
  71. end
  72. end
  73. return lst
  74. end,
  75. exists = function(path)
  76. local lst = {}
  77. for i=1, #vfs do
  78. if (vfs[i][1]:match("^/.+/$")) then
  79. lst[vfs[i][1]:sub(1, #vfs[i][1]-1)] = true
  80. end
  81. end
  82. return (lst[path]~=nil)
  83. end,
  84. isDirectory = function(path)
  85. local lst = {}
  86. for i=1, #vfs do
  87. if (vfs[i][1]:match("^/.+/$")) then
  88. lst[vfs[i][1]:sub(1, #vfs[i][1]-1)] = true
  89. end
  90. end
  91. return (lst[path]~=nil)
  92. end,
  93. isReadOnly = function()
  94. return true
  95. end
  96. })
  97.  
  98. -- Mount all filesystems.
  99.  
  100. for c in component.list("filesystem") do
  101. fs.mount("/"..c:sub(1, 8).."/", component.proxy(c))
  102. end
  103.  
  104. return fs
  105.  
  106. end)()
  107.  
  108. krlib["thd"] = (function()
  109.  
  110. local thd = {}
  111.  
  112. local threads = {}
  113.  
  114. local idx = 1
  115.  
  116. local computer = computer
  117. local unpack = unpack or table.unpack
  118. local coroutine = coroutine
  119. local c_create = coroutine.create
  120. local c_yield = coroutine.yield
  121. local c_resume = coroutine.resume
  122. local c_status = coroutine.status
  123.  
  124. function thd.add(name, func)
  125. threads[#threads+1] = {name, c_create(func), {}, 0, ".+"}
  126. end
  127.  
  128. local sigs = {}
  129.  
  130. function thd.autosleep()
  131. local msleep = math.huge
  132. for i=1, #threads do
  133. if (threads[i][4] and threads[i][4] < msleep) then
  134. msleep = threads[i][4]
  135. end
  136. end
  137. local rsleep = msleep-computer.uptime()
  138. if (rsleep < 0 or #sigs > 0) then
  139. rsleep = 0
  140. end
  141. local sig = {ps(rsleep)}
  142. if (#sigs > 0) then
  143. if (#sig > 0) then
  144. sigs[#sigs+1] = sig
  145. end
  146. sig = sigs[1]
  147. table.remove(sigs, 1)
  148. end
  149. return sig
  150. end
  151.  
  152. local last_sig = {}
  153.  
  154. function thd.run()
  155. last_sig = thd.autosleep()
  156. for i=1, #threads do
  157. if (threads[i][4] <= computer.uptime() or #last_sig > 0) then
  158. if (c_status(threads[i][2]) ~= "running") then
  159. local s, dl = (c_resume(threads[i][2], unpack(last_sig)))
  160. if not s then
  161. if print then print("[lkos] [error] "..threads[i][1].." "..dl) end
  162. end
  163. dl = computer.uptime() + (dl or math.huge)
  164. threads[i][4] = dl
  165. sigs[#sigs+1] = {ps(0)}
  166. end
  167. end
  168. end
  169. local t = {}
  170. for i=1, #threads do
  171. if (c_status(threads[i][2]) ~= "dead" or threads[i][6]) then
  172. t[#t+1] = threads[i]
  173. end
  174. end
  175. threads = t
  176. return #threads > 0
  177. end
  178.  
  179. function thd.kill(i)
  180. threads[i][6] = true
  181. end
  182.  
  183. function thd.sched_end()
  184. return #threads == idx
  185. end
  186.  
  187. function thd.get_threads()
  188. return threads
  189. end
  190. local pxy = component.proxy(component.list("sandbox")())
  191. local function dbg(...)
  192. pxy.log(table.concat({"[debug]", ...}, "\t"))
  193. return ...
  194. end
  195.  
  196. function computer.pullSignal(t)
  197. return c_yield(t)
  198. end
  199.  
  200. return thd
  201.  
  202. end)()
  203.  
  204. krlib["blt"] = (function()
  205.  
  206. -- BLT, made for Lua 5.3
  207.  
  208. local blt = {}
  209.  
  210. local types
  211.  
  212. local function serialize(val)
  213. local t = type(val)
  214. if (t == "number") then
  215. t = math.type(val)
  216. end
  217. local b, str = types["s"..t](val)
  218. b = (b << 3) | types[t]
  219. return string.char(b) .. str
  220. end
  221.  
  222. local function deserialize(str, t)
  223. local tb = str:byte(1)
  224. local type_ = tb & 7
  225. local b = tb >> 3
  226. local v, l = types[type_](b, str:sub(2))
  227. return v, l+1
  228. end
  229.  
  230. local function fromdouble(f)
  231. return 0, string.pack("<d", f)
  232. end
  233.  
  234. local function todouble(b, str)
  235. return string.unpack("<d", str:sub(1, 8)), 8
  236. end
  237.  
  238. local function _fromlongint(i)
  239. --print("longint")
  240. return 8, string.pack("<l", i)
  241. end
  242.  
  243. local function fromint(i)
  244. --Time to rabidly optimize this.
  245. local len = 0
  246. local cmp2 = 0
  247. if (i > 0xFFFFFFFFFFFFFF) then return _fromlongint(i) end
  248. for j=0, 7 do
  249. len = len + 1
  250. cmp2 = cmp2 | (0xFF << j)
  251. --print("fromint", i+((cmp2//2)), cmp2)
  252. --if (i+((cmp2//2)) <= cmp2) then
  253. if (math.abs(i) <= cmp2//2) then
  254. break
  255. end
  256. end
  257. if (i < 0) then
  258. i = i + (cmp2//2)
  259. end
  260. --i = i + (cmp2//2)
  261. local tmp = ""
  262. for j=0, len-1 do
  263. tmp = tmp .. string.char((i & (0xFF << (j*8))) >> (j*8))
  264. end
  265. --local tmp = string.pack("<i["..len.."]", i)
  266. return len, tmp
  267. end
  268.  
  269. local function _tolongint(str)
  270. --print("longint2")
  271. return string.unpack("<l", str:sub(1, 8)), 8
  272. end
  273.  
  274. local function toint(b, str)
  275. if (b == 8) then return _tolongint(str) end
  276. --return string.unpack("<i["..b.."]", str:sub(1, b)), b
  277. local tmp = 0
  278. for i=0, b-1 do
  279. tmp = tmp | (str:byte(i+1) << (i*8))
  280. end
  281. local sign = (tmp & (0x80 << ((b-1)*8)))
  282. sign = sign << (63 - (b*8))
  283. local int = tmp & ((0x80 << ((b-1)*8)) ~ 0xFFFFFFFFFFFFFF)
  284. return int | sign, b
  285. end
  286.  
  287. local function frombool(b)
  288. return b and 1 or 0, ""
  289. end
  290.  
  291. local function tobool(b, str)
  292. return b ~= 0, 0
  293. end
  294.  
  295. local function fromstr(s)
  296. local len, val = fromint(#s)
  297. return len, val .. s
  298. end
  299.  
  300. local function tostr(b, str)
  301. local strl, l = toint(b, str)
  302. local rtn = str:sub(1+l, l+strl)
  303. return rtn, strl+l
  304. end
  305.  
  306. local function fromarray(a)
  307. local b, tmp = fromint(#a)
  308. for i=1, #a do
  309. tmp = tmp .. serialize(a[i])
  310. end
  311. --print("alen_s", #tmp)
  312. return b, tmp
  313. end
  314.  
  315. local function toarray(b, str, arr)
  316. local arrl, l = toint(b, str)
  317. --print("clen", l)
  318. --print("arr len", arrl)
  319. local arr = {}
  320. local i = 0
  321. for i=1, arrl do
  322. --print("adec", i)
  323. local v, z = deserialize(str:sub(1+l))
  324. --print("arr", i, v)
  325. l = l+z
  326. --print("clen", l, z)
  327. arr[i] = v
  328. end
  329. --print("alen", l)
  330. return arr, l
  331. end
  332.  
  333. local function fromtbl(t)
  334. local tmp = ""
  335. --See if the numerical keys are a list, and, if so, write a list
  336. local nindex = 0
  337. local nmax = 0
  338. for k, v in pairs(t) do
  339. if (type(k) == "number") then
  340. if (math.type(k) == "integer") then
  341. nindex = nindex + 1
  342. if (nmax < k) then
  343. nmax = k
  344. end
  345. end
  346. else
  347. local ks = serialize(k)
  348. local vs = serialize(v)
  349. tmp = tmp .. ks .. vs
  350. end
  351. end
  352. if (nmax > 0) then
  353. if (nindex == nmax) then
  354. local ib, dat = fromarray(t)
  355. tmp = tmp .. string.char(0) .. string.char(types.table_array | (ib << 3)) .. dat
  356. else
  357. for k, v in pairs(t) do
  358. if (type(k) == "number" and math.type(k) == "integer") then
  359. local ks = serialize(k)
  360. local vs = serialize(v)
  361. tmp = tmp .. ks .. vs
  362. end
  363. end
  364. end
  365. end
  366. return 0, tmp .. string.char(0,0) --nil,nil terminated
  367. end
  368.  
  369. local function totbl(b, str)
  370. local t = {}
  371. local k = ""
  372. local v = ""
  373. local pos = 1
  374. --print("topen")
  375. while true do
  376. --print("k", str:byte(pos), str:byte(pos) & 7)
  377. local k, l = deserialize(str:sub(pos))
  378. pos = pos + l
  379. --print("v", str:byte(pos), str:byte(pos) & 7)
  380. if (str:byte(pos) & 7 == 6) then
  381. --print("ailen", str:byte(pos) & (7 ~ 0xFF))
  382. local r, l = deserialize(str:sub(pos))
  383. pos = pos + l
  384. for i=1, #r do
  385. t[i] = r[i]
  386. end
  387. else
  388. local v, l = deserialize(str:sub(pos))
  389. pos = pos + l
  390. if (not v and not k) then
  391. --print("tclose")
  392. break
  393. end
  394. --print("decode", k, v)
  395. t[k] = v
  396. end
  397. end
  398. return t, pos-1 --how
  399. end
  400.  
  401. -- Type LUT
  402. types = {
  403. ["nil"] = 0,
  404. float = 1,
  405. number = 1,
  406. integer = 2,
  407. string = 3,
  408. boolean = 4,
  409. table = 5,
  410. table_array = 6, --Meta-value
  411. [0] = function(b, str) return nil, 0 end,
  412. [1] = todouble,
  413. [2] = toint,
  414. [3] = tostr,
  415. [4] = tobool,
  416. [5] = totbl,
  417. [6] = toarray,
  418. snil = function()return 0, ""end,
  419. sfloat = fromdouble,
  420. sinteger = fromint,
  421. sstring = fromstr,
  422. sboolean = frombool,
  423. stable = fromtbl,
  424. stable_array = fromarray
  425. }
  426.  
  427. function blt.serialize(...)
  428. local args = {...}
  429. local tmp = string.char(#args)
  430. for i=1, #args do
  431. local str = serialize(args[i])
  432. tmp = tmp .. str
  433. end
  434. return tmp
  435. end
  436.  
  437. local unpack = unpack or table.unpack
  438.  
  439. function blt.deserialize(str)
  440. local args = {}
  441. local pos = 2
  442. local amt = str:byte(1)
  443. local l
  444. for i=1, amt do
  445. local v, l = deserialize(str:sub(pos))
  446. args[i] = v
  447. pos = pos + l
  448. end
  449. return unpack(args)
  450. end
  451.  
  452. return blt
  453.  
  454. end)()
  455.  
  456. krlib["microtel"] = (function()
  457.  
  458.  
  459. _G.net={}
  460.  
  461. do
  462. local modems,packetQueue,packetCache,routeCache,C,Y = {},{},{},{},COMPUTER,UNPACK
  463. net.port,net.hostname,net.route,net.hook,U=4096,computer.address():sub(1,8),true,{},UPTIME
  464.  
  465. for a in component.list("modem") do
  466. modems[a] = component.proxy(a)
  467. modems[a].open(net.port)
  468. end
  469.  
  470. local function genPacketID()
  471. local packetID = ""
  472. for i = 1, 16 do
  473. packetID = packetID .. string.char(math.random(32,126))
  474. end
  475. return packetID
  476. end
  477.  
  478. local function rawSendPacket(packetID,packetType,to,from,vport,data)
  479. if routeCache[to] then
  480. modems[routeCache[to][1]].send(routeCache[to][2],net.port,packetID,packetType,to,from,vport,data)
  481. else
  482. for k,v in pairs(modems) do
  483. v.broadcast(net.port,packetID,packetType,to,from,vport,data)
  484. end
  485. end
  486. end
  487.  
  488. local function sendPacket(packetID,packetType,to,vport,data)
  489. packetCache[packetID] = computer.uptime()
  490. rawSendPacket(packetID,packetType,to,net.hostname,vport,data)
  491. end
  492.  
  493. function net.send(to,vport,data,packetType,packetID)
  494. packetType,packetID = packetType or 1, packetID or genPacketID()
  495. packetQueue[packetID] = {packetType,to,vport,data,0}
  496. sendPacket(packetID,packetType,to,vport,data)
  497. end
  498.  
  499. local function checkCache(packetID)
  500. for k,v in pairs(packetCache) do
  501. if k == packetID then
  502. return false
  503. end
  504. end
  505. return true
  506. end
  507.  
  508. local realComputerPullSignal = computer.pullSignal
  509. function computer.pullSignal(t)
  510. local eventTab = {realComputerPullSignal(t)}
  511. for k,v in pairs(net.hook) do
  512. pcall(v,table.unpack(eventTab))
  513. end
  514. for k,v in pairs(packetCache) do
  515. if computer.uptime() > v+30 then
  516. packetCache[k] = nil
  517. end
  518. end
  519. for k,v in pairs(routeCache) do
  520. if computer.uptime() > v[3]+30 then
  521. routeCache[k] = nil
  522. end
  523. end
  524. if eventTab[1] == "modem_message" and (eventTab[4] == net.port or eventTab[4] == 0) and checkCache(eventTab[6]) then
  525. routeCache[eventTab[9]] = {eventTab[2],eventTab[3],computer.uptime()}
  526. if eventTab[8] == net.hostname then
  527. if eventTab[7] ~= 2 then
  528. computer.pushSignal("net_msg",eventTab[9],eventTab[10],eventTab[11])
  529. if eventTab[7] == 1 then
  530. sendPacket(genPacketID(),2,eventTab[9],eventTab[10],eventTab[6])
  531. end
  532. else
  533. packetQueue[eventTab[11]] = nil
  534. end
  535. elseif net.route and checkCache(eventTab[6]) then
  536. rawSendPacket(eventTab[6],eventTab[7],eventTab[8],eventTab[9],eventTab[10],eventTab[11])
  537. end
  538. packetCache[eventTab[6]] = computer.uptime()
  539. end
  540. for k,v in pairs(packetQueue) do
  541. if computer.uptime() > v[5] then
  542. sendPacket(k,table.unpack(v))
  543. v[5]=computer.uptime()+30
  544. end
  545. end
  546. return table.unpack(eventTab)
  547. end
  548.  
  549. end
  550.  
  551.  
  552. net.mtu = 4096
  553. function net.lsend(to,vport,ldata)
  554. local tdata = {}
  555. for i = 1, ldata:len(), net.mtu do
  556. tdata[#tdata+1] = ldata:sub(1,net.mtu)
  557. ldata = ldata:sub(net.mtu+1)
  558. end
  559. for k,v in ipairs(tdata) do
  560. net.send(to,vport,v)
  561. end
  562. end
  563.  
  564. function net.socket(address, port, sclose)
  565. local conn, rb = {}, ""
  566. conn.state, conn.buffer, conn.port, conn.address = "o", "", tonumber(port), address
  567. function conn.r(self,l)
  568. rb=self.buffer:sub(1,l)
  569. self.buffer=self.buffer:sub(l+1)
  570. return rb
  571. end
  572. function conn.w(self,data)
  573. net.lsend(self.address,self.port,data)
  574. end
  575. function conn.c(s)
  576. net.send(conn.address,conn.port,sclose)
  577. end
  578. function h(etype, from, port, data)
  579. if from == conn.address and port == conn.port then
  580. if data == sclose then
  581. net.hook[sclose] = nil
  582. conn.state = "c"
  583. return
  584. end
  585. conn.buffer = conn.buffer..data
  586. end
  587. end
  588. net.hook[sclose] = h
  589. return conn
  590. end
  591.  
  592. function net.listen(vport)
  593. local from,port,data
  594. repeat
  595. _, from, port, data = computer.pullSignal(0)
  596. until port == vport and data == "openstream"
  597. local nport,sclose = math.random(2^15,2^16),tostring(math.random(-2^16,2^16))
  598. net.send(from,port,tostring(nport))
  599. net.send(from,nport,sclose)
  600. return net.socket(from,nport,sclose)
  601. end
  602.  
  603. net.timeout = 60
  604. function net.open(address,vport)
  605. local st,from,port,data=computer.uptime()
  606. net.send(address,vport,"openstream")
  607. repeat
  608. _, from, port, data = computer.pullSignal(0.5)
  609. if computer.uptime() > st+net.timeout then return false end
  610. until from == address and port == vport and tonumber(data)
  611. vport=tonumber(data)
  612. repeat
  613. _, from, port, data = computer.pullSignal(0.5)
  614. until from == address and port == vport
  615. return net.socket(address,vport,data)
  616. end
  617. return net
  618.  
  619. end)()
  620.  
  621. krlib["zlan"] = (function()
  622.  
  623. local zlan = {}
  624. local mt = krequire("microtel")
  625.  
  626. local function zlan_frame(app, command)
  627. return string.char(2,0,#app)..app..command
  628. end
  629.  
  630. local function zlan_recv(sock)
  631. local packets = {}
  632. local rpmx = 0
  633. while true do
  634. --Recieve first bit of packet
  635. if (sock:r(2) ~= "\2\0") then
  636. return nil, "invalid host zlan version"
  637. end
  638. local pid = sock:r(1):byte()
  639. local pmx = sock:r(1):byte()
  640. if (pmx > rpmx) then
  641. rpmx = pmx
  642. end
  643. local size = sock:r(1):byte() | (sock:r(1):byte() << 8)
  644. packets[pid] = sock:r(size)
  645. if (#packets == rpmx) then
  646. return table.concat(packets, "")
  647. end
  648. end
  649. end
  650.  
  651. function zlan.information(hn, pkg)
  652. local sock = mt.open(hn, 9900)
  653. sock:write(zlan_frame(pkg, "i"))
  654. local dat = zlan_recv(sock)
  655. local size = (dat:byte(1) | (dat:byte(2) << 8) | (dat:byte(3) << 16))
  656. local namelen = dat:byte(4)
  657. local name = dat:sub(5, 5+namelen)
  658. local vlen = dat:byte(6+namelen)
  659. local ver = dat:sub(7+namelen, 7+namelen+vlen)
  660. local fmt = dat:byte(8+namelen+vlen)
  661. sock:c()
  662. return {
  663. size = size,
  664. name = name,
  665. version = ver,
  666. format = fmt
  667. }
  668. end
  669.  
  670. function zlan.exists(hn, pkg)
  671. local sock = mt.open(hn, 9900)
  672. sock:write(zlan_frame(pkg, "i"))
  673. local dat = zlan_recv(sock)
  674. sock:c()
  675. return (dat:byte(1) ~= 0)
  676. end
  677.  
  678. function zlan.download(hn, pkg)
  679. local sock = mt.open(hn, 9900)
  680. sock:write(zlan_frame(pkg, "d"))
  681. local dat = zlan_recv(sock)
  682. sock:c()
  683. return dat
  684. end
  685.  
  686. return zlan
  687.  
  688. end)()
  689.  
  690.  
  691. local ps = computer.pullSignal
  692. local thd = krequire("thd")
  693. local last_sig = {}
  694. krlib["system"] = (function()
  695. local sys = {}
  696. function sys.start()
  697. while thd.run() do end
  698. end
  699. local prun_i = 0
  700. function sys.protected_run(code, name)
  701. name = name or "lkprc$"..prun_i
  702. --Spin up a new thread
  703. local env = {}
  704. for k, v in pairs(_G) do
  705. env[k] = v
  706. end
  707. env._ENV = env
  708. env._G = env
  709. env.krequire = nil
  710. thd.add(name, assert(load(code, "="..name, "t", env)))
  711. end
  712. function sys.add_lib(lib, tbl)
  713. krlib[lib] = tbl
  714. end
  715. function sys.add_search(search)
  716. krfind[#krfind+1] = search
  717. end
  718. return sys
  719. end)()
  720. krlib["sys"] = krlib["system"]
  721. end)()
  722.  
  723. print("litekernel init complete.")
  724.  
  725. _OSVERSION="Reactor AMS 1.0"
  726. _OSVER=1.0
  727.  
  728. print(_OSVERSION)
  729.  
  730. local builtin_progs = {}
  731.  
  732. print("[init] Loading builtins...")
  733.  
  734.  
  735.  
  736.  
  737. builtin_prog["ams"] = function(...)
  738.  
  739. local microtel = krequire("microtel")
  740. local cfg = krequire("cfg")
  741.  
  742. local reactor = component.proxy(component.list("br_reactor")())
  743. local turbine = component.proxy(component.list("br_turbine")())
  744.  
  745. local get_energy = turbine.getEnergyStored
  746. local get_flow_rate = tubrine.getFluidFlowRate
  747. local get_rpm = tubrine.getRotorSpeed
  748.  
  749. local get_heat = reactor.getFuelTemperature
  750. local set_active = reactor.setActive
  751. local get_fuel = reactor.getFuelAmount
  752. local get_fuel_max = reactor.getFuelAmountMAx
  753.  
  754. while true do
  755. computer.pullSignal()
  756. end
  757.  
  758. end
  759.  
  760.  
  761. builtin_prog["frequest_client"] = function(...)
  762.  
  763.  
  764.  
  765. end
  766.  
  767.  
  768. builtin_prog["sysctl"] = function(...)
  769.  
  770.  
  771.  
  772. end
  773.  
  774.  
  775. local thd = krequire("thd")
  776. local sys = krequire("sys")
  777.  
  778. sys.add_lib("cfg", {
  779. max_temp=1500,
  780. warn_temp=1300,
  781. broadcast_temp_warn=true,
  782. broadcast_errors=true
  783. })
  784.  
  785. sys.add_lib("sysupdate", function(hostname, pkg)
  786. local res, err = require("zlan").download(hostname, pkg)
  787. if not res then return err end
  788. local prom = component.proxy(component.list("ossm_prom")())
  789. print("[update] Erasing EEPROM...")
  790. prom.erase()
  791. print("[update] Writing EEPROM...")
  792. for i=0, math.ceil(#res/512)-1 do
  793. prom.blockWrite(i+1, res:sub((i*512)+1, (i+1)*512))
  794. end
  795. print("[update] Update complete.")
  796. print("[update] Rebooting...")
  797. end)
  798.  
  799. _RID = -1
  800.  
  801. for k, v in pairs(builtin_prog) do
  802. print("[init] Starting "..k)
  803. thd.add(k, v)
  804. end
  805.  
  806. print("[init] Builtin loading complete.")
  807.  
  808. print("[init] Starting system.")
  809.  
  810. sys.start()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement