Merge branch 'master' of github.com:XeonSquared/multice

This commit is contained in:
Izaya 2017-07-15 03:30:44 +10:00
commit f12080f7b9
9 changed files with 180 additions and 2 deletions

View File

@ -5,6 +5,7 @@ library/fs-min.lua
library/fs-std.lua
library/fs-util.lua
util/fs-automount.lua
util/fs-automount-ext.lua
drivers/tty.lua
drivers/kbd.lua
util/autogpu.lua
@ -15,10 +16,13 @@ library/base64.lua
library/chauth.lua
library/fs-ext.lua
library/readline.lua
library/buffer.lua
library/io.lua
net/nshd.lua
net/nshc.lua
net/nshd-auth.lua
net/nshc-auth.lua
net/pxesrv.lua
applications/shutil.lua
applications/skex2.lua
applications/luash.lua

View File

@ -0,0 +1,20 @@
base/header.lua
library/print.lua
library/net.lua
library/readline.lua
net/nshd.lua
library/crc32.lua
library/chauth.lua
net/nshd.lua
net/nshd-auth.lua
applications/luash-login.lua
applications/shutil.lua
library/fs-min.lua
library/fs-std.lua
library/fs-ext.lua
library/buffer.lua
library/io.lua
util/fs-automount-min.lua
util/fs-automount-ext.lua
util/autonsh.lua
base/footer.lua

View File

@ -0,0 +1,18 @@
function luash(si)
s("lua shell",function()
local np = ""
while np ~= pass do
write("Password: ")
np=readln("*")
end
if _OSVERSION and _BD then
write(_OSVERSION.." on "..nID.." (built at ".._BD..")\t")
end
print(tostring(computer.freeMemory()/1024).."K free.",_G.motd)
print(_VERSION)
while true do
write("> ")
print(pcall(load(readln())))
end
end,si)
end

View File

@ -1,6 +1,6 @@
fT = {}
function fres(p)
local F = (p:match("(%a-):") or p:match("/?(%a-)/"))
local P = (p:match("%a-:(.+)") or p:match("/?%a-/(.+)"))
local F = (p:match("(.-):") or p:match("/?(.-)/"))
local P = (p:match(".-:(.+)") or p:match("/?.-/(.+)"))
if fT[F] ~= nil then return fT[F],P else return false end
end

59
modules/net/pxesrv.lua Normal file
View File

@ -0,0 +1,59 @@
function pxesrv(i,P,LF) -- port, image, log file
_G.pxcl = {}
local P,i,LF = P or 9671,i or "boot:/pxeimage.lua",LF or "boot:/pxetab.csv"
for k,v in ipairs(tM) do v.open(P) end
print("[netboot] loading data")
f=io.open(i)
if f then d=f:read("*a") f:close()
else error("image not found")
end
print("[netboot] server starting, port "..TS(P)..", image file "..i)
print("[netboot] loading existing data")
local f=io.open(LF)
C.yield()
if f then
local c = f:read("*a")
f:close()
for m,C,h,p in c:gmatch("(.-),(.-),(.-),(.-)\n") do
print(m.." = {"..C..", "..h..", "..p.."}")
pxcl[m]={C,h,p}
end
end
s("pxesrv",function() print(pcall(function()
while true do
if ev[1] == "modem_message" and ev[4] == P then
print("[netboot] request from "..ev[3]:sub(1,8)..":"..TS(ev[6]):sub(1,8))
if type(pxcl[ev[3]]) ~= "table" then
pxcl[ev[3]]={ev[6],ev[6]:sub(1,8),"pass"}
else
pxcl[ev[3]]={ev[6],pxcl[ev[3]][2] or ev[6]:sub(1,8),pxcl[ev[3]][3] or "pass"}
end
fd=d:gsub("HOSTNAME",pxcl[ev[3]][2])
fd=fd:gsub("PASSWORD",pxcl[ev[3]][3])
local la,fr = ev[2],ev[3]
print(fd:len())
for i = 1, fd:len(), 2048 do
component.invoke(la,"send",fr,P,fd:sub(i,i+2047))
C.yield()
end
component.invoke(la,"send",fr,P,".")
end
C.yield()
end
end)) end)
s("pxesrv logger",function() print(pcall(function()
while true do
for i = 1, 100 do
C.yield()
end
f=fopen(LF,"w")
if f then
for k,v in pairs(pxcl) do
fwrite(f,k..","..v[1]..","..v[2]..","..v[3].."\n")
end
fclose(f)
C.yield()
end
end
end)) end)
end

View File

@ -0,0 +1,7 @@
do
local f=io.open("/boot/autoexec.lua")
if f then
pcall(load(f:read("*a")))
f:close()
end
end

3
modules/util/autonsh.lua Normal file
View File

@ -0,0 +1,3 @@
_G.pass = "PASSWORD"
nshd("nsh")
nshds("nshs",pass)

View File

@ -0,0 +1,9 @@
do
local C=0
for c in component.list("filesystem") do
if c ~= fT.boot.address and c ~= fT.tmp.address then
fT["fs"..string.format("%02d",C)] = component.proxy(c)
C=C+1
end
end
end

58
util/pixice.lua Normal file
View File

@ -0,0 +1,58 @@
--base/loadlin.lua
if pcall(require,"computer") then
print("OpenOS detected.")
print(os.getenv("_"))
local computer = require "computer"
local process = require "process"
os.execute("cp "..os.getenv("_").." /tmp/init.lua")
computer.setBootAddress(computer.tmpAddress())
computer.shutdown(true)
end
-- actual code starts here
s=""
computer.getBootAddress = computer.tmpAddress
do
local addr=nil
local OCPS,OCSD,OCI=computer.pullSignal,computer.shutdown,component.invoke
function computer.pullSignal(...)
local tA={...}
local eV={OCPS(...)}
if eV[1] == "modem_message" and eV[3] == addr and eV[4] == 9671 then
if eV[6] == "reboot" then
OCSD(true)
end
return
end
return table.unpack(eV)
end
function computer.shutdown()
OCSD(true)
end
function component.invoke(...)
tA={...}
if tA[2] == "stop" then return end
return OCI(...)
end
local m=component.proxy(component.list("modem")())
m.open(9671)
if addr then
m.send(addr,9671,computer.address())
while true do
local ev={computer.pullSignal()}
if ev[1] == "modem_message" and ev[3] == addr and ev[4] == 9671 then
if ev[6] == "." then break end
s=s..ev[6]
end
end
else
m.broadcast(9671,computer.address())
while true do
local ev={computer.pullSignal()}
if ev[1] == "modem_message" and ev[4] == 9671 then
if ev[6] == "." then break end
s=s..ev[6]
end
end
end
end
load(s)()