forgot to commit openos
This commit is contained in:
38
data/openos/etc/motd
Normal file
38
data/openos/etc/motd
Normal file
@@ -0,0 +1,38 @@
|
||||
local component = require("component")
|
||||
local computer = require("computer")
|
||||
local unicode = require("unicode")
|
||||
local tty = require("tty")
|
||||
|
||||
local f = io.open("/usr/misc/greetings.txt")
|
||||
local lines = {_OSVERSION .. " (" .. math.floor(computer.totalMemory() / 1024) .. "k RAM)"}
|
||||
local greeting = ""
|
||||
if f then
|
||||
local greetings = {}
|
||||
pcall(function()
|
||||
for line in f:lines() do table.insert(greetings, line) end
|
||||
end)
|
||||
f:close()
|
||||
greeting = greetings[math.random(1, math.max(#greetings, 1))] or ""
|
||||
end
|
||||
local width = math.min(#greeting, (tty.getViewport() or math.huge) - 5)
|
||||
local maxLine = #lines[1]
|
||||
while #greeting > 0 do
|
||||
local si, ei = greeting:sub(1, width):find("%s%S*$")
|
||||
local line = #greeting <= width and greeting or greeting:sub(1, si or width)
|
||||
lines[#lines + 1] = line
|
||||
maxLine = math.max(maxLine, #line)
|
||||
greeting = greeting:sub(#line + 1)
|
||||
end
|
||||
|
||||
local borders = {{unicode.char(0x2552), unicode.char(0x2550), unicode.char(0x2555)},
|
||||
{unicode.char(0x2502), nil, unicode.char(0x2502)},
|
||||
{unicode.char(0x2514), unicode.char(0x2500), unicode.char(0x2518)}}
|
||||
io.write(borders[1][1], string.rep(borders[1][2], maxLine + 2), borders[1][3], "\n")
|
||||
for _,line in ipairs(lines) do
|
||||
io.write(borders[2][1], " ", line, (" "):rep(maxLine - #line + 1), borders[2][3], " \n")
|
||||
end
|
||||
io.write(borders[3][1] .. string.rep(borders[3][2], maxLine + 2) .. borders[3][3] .. "\n")
|
||||
|
||||
if require("filesystem").get("home").isReadOnly() then
|
||||
io.write("\27[33mNote: Your home directory is readonly. Run `install` and reboot.\27[m\n")
|
||||
end
|
||||
44
data/openos/etc/profile.lua
Normal file
44
data/openos/etc/profile.lua
Normal file
@@ -0,0 +1,44 @@
|
||||
local shell = require("shell")
|
||||
local tty = require("tty")
|
||||
local fs = require("filesystem")
|
||||
|
||||
if tty.isAvailable() then
|
||||
if io.stdout.tty then
|
||||
io.write("\27[40m\27[37m")
|
||||
tty.clear()
|
||||
end
|
||||
end
|
||||
dofile("/etc/motd")
|
||||
|
||||
shell.setAlias("dir", "ls")
|
||||
shell.setAlias("move", "mv")
|
||||
shell.setAlias("rename", "mv")
|
||||
shell.setAlias("copy", "cp")
|
||||
shell.setAlias("del", "rm")
|
||||
shell.setAlias("md", "mkdir")
|
||||
shell.setAlias("cls", "clear")
|
||||
shell.setAlias("rs", "redstone")
|
||||
shell.setAlias("view", "edit -r")
|
||||
shell.setAlias("help", "man")
|
||||
shell.setAlias("l", "ls -lhp")
|
||||
shell.setAlias("..", "cd ..")
|
||||
shell.setAlias("df", "df -h")
|
||||
shell.setAlias("grep", "grep --color")
|
||||
shell.setAlias("more", "less --noback")
|
||||
shell.setAlias("reset", "resolution `cat /dev/components/by-type/gpu/0/maxResolution`")
|
||||
|
||||
os.setenv("EDITOR", "/bin/edit")
|
||||
os.setenv("HISTSIZE", "10")
|
||||
os.setenv("HOME", "/home")
|
||||
os.setenv("IFS", " ")
|
||||
os.setenv("MANPATH", "/usr/man:.")
|
||||
os.setenv("PAGER", "less")
|
||||
os.setenv("PS1", "\27[40m\27[31m$HOSTNAME$HOSTNAME_SEPARATOR$PWD # \27[37m")
|
||||
os.setenv("LS_COLORS", "di=0;36:fi=0:ln=0;33:*.lua=0;32")
|
||||
|
||||
shell.setWorkingDirectory(os.getenv("HOME"))
|
||||
|
||||
local home_shrc = shell.resolve(".shrc")
|
||||
if fs.exists(home_shrc) then
|
||||
loadfile(shell.resolve("source", "lua"))(home_shrc)
|
||||
end
|
||||
3
data/openos/etc/rc.cfg
Normal file
3
data/openos/etc/rc.cfg
Normal file
@@ -0,0 +1,3 @@
|
||||
enabled = {}
|
||||
|
||||
example = "Hello World!"
|
||||
14
data/openos/etc/rc.d/example.lua
Normal file
14
data/openos/etc/rc.d/example.lua
Normal file
@@ -0,0 +1,14 @@
|
||||
local count = 0
|
||||
|
||||
function start(msg)
|
||||
print("This script displays a welcome message and counts the number " ..
|
||||
"of times it has been called. The welcome message can be set in the " ..
|
||||
"config file /etc/rc.cfg")
|
||||
print(args)
|
||||
if msg then
|
||||
print(msg)
|
||||
end
|
||||
print(count)
|
||||
print("runlevel: " .. require("computer").runlevel())
|
||||
count = count + 1
|
||||
end
|
||||
Reference in New Issue
Block a user