1
0
mirror of https://github.com/kepler155c/opus synced 2024-07-02 18:13:20 +00:00
opus/sys/extensions/4.user.lua

50 lines
1.0 KiB
Lua
Raw Normal View History

2018-01-14 21:44:43 +00:00
local Util = require('util')
local fs = _G.fs
local shell = _ENV.shell
if not fs.exists('usr/apps') then
2018-01-24 22:39:38 +00:00
fs.makeDir('usr/apps')
2018-01-14 21:44:43 +00:00
end
if not fs.exists('usr/autorun') then
2018-01-24 22:39:38 +00:00
fs.makeDir('usr/autorun')
2018-01-14 21:44:43 +00:00
end
2018-12-27 08:05:12 +00:00
local lua_path = package.path
2018-12-17 03:17:19 +00:00
2018-12-30 11:15:16 +00:00
-- TODO: Temporary
local upgrade = Util.readTable('usr/config/shell')
if upgrade and not upgrade.upgraded then
fs.delete('usr/config/shell')
end
2018-01-14 21:44:43 +00:00
if not fs.exists('usr/config/shell') then
2018-01-24 22:39:38 +00:00
Util.writeTable('usr/config/shell', {
aliases = shell.aliases(),
2018-12-27 08:05:12 +00:00
path = 'usr/apps',
2018-12-17 03:17:19 +00:00
lua_path = lua_path,
2018-12-30 11:15:16 +00:00
upgraded = true,
2018-01-24 22:39:38 +00:00
})
2018-01-14 21:44:43 +00:00
end
local config = Util.readTable('usr/config/shell')
if config.aliases then
2018-01-24 22:39:38 +00:00
for k in pairs(shell.aliases()) do
shell.clearAlias(k)
end
for k,v in pairs(config.aliases) do
shell.setAlias(k, v)
end
2018-01-14 21:44:43 +00:00
end
2018-12-27 08:05:12 +00:00
local path = config.path and Util.split(config.path, '(.-):') or { }
table.insert(path, 'sys/apps')
for _, v in pairs(Util.split(shell.path(), '(.-):')) do
table.insert(path, v)
end
shell.setPath(table.concat(path, ':'))
_G.LUA_PATH = config.lua_path
2018-01-14 21:44:43 +00:00
2018-01-20 12:18:13 +00:00
fs.loadTab('usr/config/fstab')