1
0
mirror of https://github.com/ShadowKatStudios/OC-Minitel.git synced 2024-11-23 10:38:05 +11:00

added mtcfg to the repo, added a utils and docs section to the oppm repo

This commit is contained in:
Izaya 2018-08-04 05:17:50 +10:00
parent 43c6f5279d
commit f2de219206
2 changed files with 160 additions and 0 deletions

View File

@ -10,6 +10,34 @@
authors = "Izaya, Skye",
repo = "tree/master/"
},
["minitel-util"] = {
files = {
["master/util/OpenOS/usr/bin/ping.lua"] = "/bin",
["master/util/OpenOS/usr/bin/mtcfg.lua"] = "/bin",
},
dependencies = {
["minitel"] = ""
},
name = "Minitel Util",
description = "Assorted Minitel utilities",
authors = "Izaya",
repo = "tree/master/"
},
["minitel-docs"] = {
files = {
["master/protocol-3.md"] = "/doc/minitel",
["master/protocol-4.md"] = "/doc/minitel",
["master/protocol-5.md"] = "/doc/minitel",
["master/protocol-ext-multicast.md"] = "/doc/minitel",
["master/FRequest/FRequest-protocol.md"] = "/doc/minitel",
["master/MMail/MMail-protocol.md"] = "/doc/minitel",
["master/syslog/syslog-protocol.md"] = "/doc/minitel",
},
name = "Minitel",
description = "Simple and powerful networking stack",
authors = "Izaya, Skye",
repo = "tree/master/"
},
["frequestd"] = {
files = {
["master/FRequest/OpenOS/etc/rc.d/fserv.lua"] = "//etc/rc.d"

View File

@ -0,0 +1,132 @@
local event = require "event"
local serial = require "serialization"
local computer = require "computer"
local hostname = os.getenv("HOSTNAME")
local cfgfile = "/etc/minitel.cfg"
local cfg = {}
cfg.debug = false
cfg.port = 4096
cfg.retry = 10
cfg.retrycount = 64
cfg.route = true
cfg.rctime = 15
cfg.pctime = 30
cfg.sroutes = {}
local function clear()
io.write("\27[2J\27[H")
end
local fobj = io.open(cfgfile, "rb")
if fobj then
cfg = serial.unserialize(fobj:read("*a"))
end
if not hostname then
local fobj = io.open("/etc/hostname","rb")
if fobj then
hostname = fobj:read()
fobj:close()
end
end
clear()
if not hostname then
print("Hostname not configured.")
hostname = computer.address():sub(1,8)
io.write("New hostname? ["..hostname.."] ")
local nhostname = io.read()
if nhostname:len() > 0 then
hostname = nhostname
end
local fobj = io.open("/etc/hostname","wb")
if fobj then
fobj:write(hostname)
fobj:close()
end
os.execute("hostname --update")
print("Hostname set to "..hostname..". Press any key to continue.")
event.pull("key_down")
end
local keytab = {}
for k,v in pairs(cfg) do
if type(v) ~= "table" then
keytab[#keytab+1] = k
end
end
table.sort(keytab)
local selected = 1
local run, config = true, true
local function drawmenu()
clear()
print("Value\tType\t\tSetting")
for k,v in pairs(keytab) do
if k == selected then
io.write("\27[30;47m")
end
print(tostring(cfg[v]).."\t"..type(cfg[v]).."\t\t"..v.."\27[0m")
end
print("Use the arrow keys to navigate, space to edit a setting, q to quit, and enter to confirm.")
end
local function editsetting(k)
if type(cfg[k]) ~= "boolean" then
clear()
print("Current setting for "..k..": "..tostring(cfg[k]))
else
cfg[k] = not cfg[k]
return
end
io.write("New setting for "..k.."? ["..tostring(cfg[k]).."] ")
local ns = io.read()
if ns:len() > 0 then
if type(cfg[k]) == "number" then
ns = tonumber(ns) or cfg[k]
end
cfg[k] = ns
end
end
while run do
drawmenu()
local _,_, ch, co = event.pull("key_down")
if ch == 113 and co == 16 then
run = false
config = false
elseif ch == 13 and co == 28 then
run = false
elseif ch == 0 and co == 208 then
selected = selected + 1
if selected > #keytab then
selected = #keytab
end
elseif ch == 0 and co == 200 then
selected = selected - 1
if selected < 1 then
selected = 1
end
elseif ch == 32 and co == 57 then
editsetting(keytab[selected])
end
end
clear()
if not config then
print("Aborted.")
return
end
print("Writing settings...")
local fobj = io.open(cfgfile, "wb")
if fobj then
fobj:write(serial.serialize(cfg))
fobj:close()
print("Settings successfully written!")
end