Compare commits
No commits in common. "0ac49235685a74cd7f186ee56c2744d5b5a39d79" and "8920c074c424c1e152c9bb4cc4dbcdbc99b97055" have entirely different histories.
0ac4923568
...
8920c074c4
@ -3,17 +3,6 @@ local fs = require "fs"
|
|||||||
local shell = require "shell"
|
local shell = require "shell"
|
||||||
local shutil = {}
|
local shutil = {}
|
||||||
|
|
||||||
local function wrapUnits(n)
|
|
||||||
local scale = {"K","M","G","T","P"}
|
|
||||||
local count = 0
|
|
||||||
while n >= 1024 do
|
|
||||||
count = count + 1
|
|
||||||
if not scale[count] then return "inf" end
|
|
||||||
n = n / 1024
|
|
||||||
end
|
|
||||||
return tostring(math.floor(n))..(scale[count] or "")
|
|
||||||
end
|
|
||||||
|
|
||||||
function shutil.import(lib)
|
function shutil.import(lib)
|
||||||
local cE = os.getenv("INCLUDE") or shell.include
|
local cE = os.getenv("INCLUDE") or shell.include
|
||||||
local nE = {}
|
local nE = {}
|
||||||
@ -62,6 +51,16 @@ function shutil.df()
|
|||||||
ml = v:len()
|
ml = v:len()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
local scale = {"K","M","G","T","P"}
|
||||||
|
local function wrapUnits(n)
|
||||||
|
local count = 0
|
||||||
|
while n > 1024 do
|
||||||
|
count = count + 1
|
||||||
|
if not scale[count] then return "inf" end
|
||||||
|
n = n / 1024
|
||||||
|
end
|
||||||
|
return tostring(math.floor(n))..(scale[count] or "")
|
||||||
|
end
|
||||||
local fstr = "%-"..tostring(ml).."s %5s %5s"
|
local fstr = "%-"..tostring(ml).."s %5s %5s"
|
||||||
print("fs"..(" "):rep(ml-2).." size used")
|
print("fs"..(" "):rep(ml-2).." size used")
|
||||||
for k,v in pairs(mt) do
|
for k,v in pairs(mt) do
|
||||||
@ -95,11 +94,6 @@ function shutil.mount(addr,path)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function shutil.free()
|
|
||||||
print("Total Used Free")
|
|
||||||
print(string.format("%5s %5s %5s",wrapUnits(computer.totalMemory()),wrapUnits(computer.totalMemory()-computer.freeMemory()),wrapUnits(computer.freeMemory())))
|
|
||||||
end
|
|
||||||
|
|
||||||
shutil.cd = os.chdir
|
shutil.cd = os.chdir
|
||||||
shutil.mkdir = fs.makeDirectory
|
shutil.mkdir = fs.makeDirectory
|
||||||
shutil.cp = fs.copy
|
shutil.cp = fs.copy
|
||||||
|
@ -8,38 +8,6 @@
|
|||||||
--#include "module/devfs/syslog.lua"
|
--#include "module/devfs/syslog.lua"
|
||||||
--#include "module/loadfile.lua"
|
--#include "module/loadfile.lua"
|
||||||
--#include "module/vt-task.lua"
|
--#include "module/vt-task.lua"
|
||||||
|
os.spawnfile("/boot/exec/init.lua")
|
||||||
os.spawn(function()
|
|
||||||
os.setenv("PWD","/boot")
|
|
||||||
io.input("/dev/null")
|
|
||||||
io.output("/dev/syslog")
|
|
||||||
local f = io.open("/boot/cfg/hostname","rb")
|
|
||||||
local hostname = computer.address():sub(1,8)
|
|
||||||
if f then
|
|
||||||
hostname = f:read("*l")
|
|
||||||
f:close()
|
|
||||||
end
|
|
||||||
os.setenv("HOSTNAME",hostname)
|
|
||||||
syslog(string.format("Hostname set to %s",hostname))
|
|
||||||
local pids = {}
|
|
||||||
local function loadlist()
|
|
||||||
local f = io.open("/boot/cfg/init.txt","rb")
|
|
||||||
if not f then return false end
|
|
||||||
for line in f:read("*a"):gmatch("[^\r\n]+") do
|
|
||||||
pids[line] = -1
|
|
||||||
end
|
|
||||||
f:close()
|
|
||||||
end
|
|
||||||
loadlist()
|
|
||||||
while true do
|
|
||||||
for k,v in pairs(pids) do
|
|
||||||
if not os.taskInfo(v) then
|
|
||||||
syslog("Starting service "..k)
|
|
||||||
pids[k] = os.spawnfile("/boot/service/"..k)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
coroutine.yield()
|
|
||||||
end
|
|
||||||
end, "init")
|
|
||||||
|
|
||||||
os.sched()
|
os.sched()
|
||||||
|
Loading…
Reference in New Issue
Block a user