2018-01-14 16:44:43 -05:00
|
|
|
local Util = require('util')
|
|
|
|
|
|
|
|
local fs = _G.fs
|
|
|
|
local shell = _ENV.shell
|
|
|
|
|
|
|
|
if not fs.exists('usr/apps') then
|
2018-01-24 17:39:38 -05:00
|
|
|
fs.makeDir('usr/apps')
|
2018-01-14 16:44:43 -05:00
|
|
|
end
|
|
|
|
if not fs.exists('usr/autorun') then
|
2018-01-24 17:39:38 -05:00
|
|
|
fs.makeDir('usr/autorun')
|
2018-01-14 16:44:43 -05:00
|
|
|
end
|
2018-12-27 03:05:12 -05:00
|
|
|
|
2018-12-30 06:15:16 -05:00
|
|
|
-- TODO: Temporary
|
|
|
|
local upgrade = Util.readTable('usr/config/shell')
|
2019-02-07 03:15:40 -05:00
|
|
|
if upgrade and (not upgrade.upgraded or upgrade.upgraded ~= 1) then
|
2018-12-30 06:15:16 -05:00
|
|
|
fs.delete('usr/config/shell')
|
|
|
|
end
|
|
|
|
|
2018-01-14 16:44:43 -05:00
|
|
|
if not fs.exists('usr/config/shell') then
|
2018-01-24 17:39:38 -05:00
|
|
|
Util.writeTable('usr/config/shell', {
|
|
|
|
aliases = shell.aliases(),
|
2018-12-27 03:05:12 -05:00
|
|
|
path = 'usr/apps',
|
2019-02-07 03:10:05 -05:00
|
|
|
lua_path = package.path,
|
|
|
|
upgraded = 1,
|
2018-01-24 17:39:38 -05:00
|
|
|
})
|
2018-01-14 16:44:43 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
local config = Util.readTable('usr/config/shell')
|
|
|
|
if config.aliases then
|
2018-01-24 17:39:38 -05: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 16:44:43 -05:00
|
|
|
end
|
2018-12-27 03:05:12 -05: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, ':'))
|
2019-02-07 03:10:05 -05:00
|
|
|
|
|
|
|
_G.LUA_PATH = config.lua_path
|
2019-03-28 07:29:01 -04:00
|
|
|
_G.settings.set('mbs.shell.require_path', config.lua_path)
|
2018-01-14 16:44:43 -05:00
|
|
|
|
2018-01-20 07:18:13 -05:00
|
|
|
fs.loadTab('usr/config/fstab')
|