1
0
mirror of https://github.com/kepler155c/opus synced 2024-10-02 08:50:41 +00:00
opus/sys/extensions/4.user.lua
kepler155c@gmail.com e3a8e4e790 env cleanup
2018-12-27 03:05:12 -05:00

56 lines
1.2 KiB
Lua

_G.requireInjector(_ENV)
local Util = require('util')
local fs = _G.fs
local shell = _ENV.shell
if not fs.exists('usr/apps') then
fs.makeDir('usr/apps')
end
if not fs.exists('usr/autorun') then
fs.makeDir('usr/autorun')
end
local lua_path = package.path
if not fs.exists('usr/config/shell') then
Util.writeTable('usr/config/shell', {
aliases = shell.aliases(),
path = 'usr/apps',
lua_path = lua_path,
})
end
if not fs.exists('usr/config/packages') then
local packages = {
[ 'develop-1.8' ] = 'https://pastebin.com/raw/WhEiNGZE',
[ 'master-1.8' ] = 'https://pastebin.com/raw/pexZpAxt',
}
if packages[_G.OPUS_BRANCH] then
Util.download(packages[_G.OPUS_BRANCH], 'usr/config/packages')
end
end
local config = Util.readTable('usr/config/shell')
if config.aliases then
for k in pairs(shell.aliases()) do
shell.clearAlias(k)
end
for k,v in pairs(config.aliases) do
shell.setAlias(k, v)
end
end
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
fs.loadTab('usr/config/fstab')