2023-01-26 19:07:54 +01:00
|
|
|
local uman={}
|
|
|
|
|
|
|
|
uman.userinfo = function(user)
|
|
|
|
local info = {}
|
|
|
|
local uid = ulib.uid(user)
|
|
|
|
if uid then
|
2023-06-20 17:11:58 +02:00
|
|
|
-- create the following directory structure if does not exists
|
|
|
|
local dir = require('vfs').ospath("home:///.antos", user)
|
|
|
|
if not ulib.exists(dir) then
|
|
|
|
ulib.mkdir(dir)
|
|
|
|
ulib.chown(dir, uid.id, uid.gid)
|
|
|
|
end
|
|
|
|
local setting_dir = dir.."/settings"
|
|
|
|
if not ulib.exists(setting_dir) then
|
|
|
|
ulib.mkdir(setting_dir)
|
|
|
|
ulib.chown(setting_dir, uid.id, uid.gid)
|
|
|
|
end
|
|
|
|
local desktop_dir = dir.."/desktop"
|
|
|
|
if not ulib.exists(desktop_dir) then
|
|
|
|
ulib.mkdir(desktop_dir)
|
|
|
|
ulib.chown(desktop_dir, uid.id, uid.gid)
|
|
|
|
end
|
2023-01-26 19:07:54 +01:00
|
|
|
-- read the setting
|
|
|
|
-- use the decodeFile function of JSON instead
|
2023-06-20 17:11:58 +02:00
|
|
|
local file = require('vfs').ospath("home:///").."/.antos/settings/settings.json"
|
2023-01-26 19:07:54 +01:00
|
|
|
local st = JSON.decodeFile(file)
|
|
|
|
if(st) then
|
|
|
|
info = st
|
|
|
|
end
|
|
|
|
info.user = {
|
|
|
|
username = user,
|
|
|
|
id = uid.id,
|
|
|
|
name = user,
|
|
|
|
groups = uid.groups
|
|
|
|
}
|
|
|
|
--print(JSON.encode(info))
|
|
|
|
return info
|
|
|
|
else
|
|
|
|
return {}
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
return uman
|