07.08.2024, 12:31
Hi threre gang,
I'd like to offer my Dreamcast for helping out with some automated test cases.
For that I'd like DreamShell to download an iso file from a plain http server and run it at startup instead of showing the main menu.
So I'm trying to edit the DS/lua/startup.lua file:
As you can see I didn't got very far.
Any help would be greatly appreciated.
I'd like to offer my Dreamcast for helping out with some automated test cases.
For that I'd like DreamShell to download an iso file from a plain http server and run it at startup instead of showing the main menu.
So I'm trying to edit the DS/lua/startup.lua file:
Код:
-----------------------------------------
-- --
-- @name: Startup script --
-- @author: SWAT --
-- @url: http://www.dc-swat.ru --
-- --
-----------------------------------------
--
-- Internal DreamShell lua functions:
--
-- OpenModule Open module file and return ID
-- CloseModule Close module by ID
-- GetModuleByName Get module ID by module NAME
--
-- AddApp Add app by XML file, return app NAME
-- OpenApp Open app by NAME (second argument for args)
-- CloseApp Close app by NAME (second argument for change unload flag)
--
-- ShowConsole
-- HideConsole
-- SetDebugIO Set the debug output (scif, dclsocket, fb, ds, sd). By default is ds.
-- Sleep Sleep in current thread (in ms)
-- MapleAttached Check for attached maple device
--
-- Bit library: bit.or, bit.and, bit.not, bit.xor
-- File system library: lfs.chdir, lfs.currentdir, lfs.dir, lfs.mkdir, lfs.rmdir
--
------------------------------------------
local DreamShell = {
initialized = false,
modules = {
--"tolua",
--"tolua_2plus",
--"luaDS", -- Depends: tolua
--"luaKOS", -- Depends: tolua
--"luaSDL", -- Depends: tolua
--"luaGUI", -- Depends: tolua
--"luaMXML", -- Depends: tolua
--"luaSTD", -- Depends: tolua
--"sqlite3",
--"luaSQL", -- Depends: sqlite3
"luaSocket",
--"luaTask",
--"bzip2",
"minilzo",
--"zip", -- Depends: bzip2
"http",
--"httpd",
--"telnetd",
--"mongoose",
--"ppp",
--"mpg123",
--"oggvorbis",
--"adx",
--"s3m",
--"wav",
--"xvid",
--"SDL_mixer", -- Depends: oggvorbis
--"ffmpeg", -- Depends: oggvorbis, mpg123, bzip2
--"opengl",
"isofs", -- Depends: minilzo
"isoldr" -- Depends: isofs
--"SDL_net",
--"opkg", -- Depends: minilzo
--"aicaos",
--"gumbo",
--"ini",
--"bflash",
--"openssl",
--"bitcoin",
--"quirc",
--"ftpd"
},
Initialize = function(self)
os.execute("env USER Default");
local path = os.getenv("PATH");
print(os.getenv("HOST") .. " " .. os.getenv("VERSION") .. "\n");
print(os.getenv("ARCH") .. ": " .. os.getenv("BOARD_ID") .. "\n");
print("Date: " .. os.date() .. "\n");
print("Base path: " .. path .. "\n");
print("User: " .. os.getenv("USER") .. "\n");
local emu = os.getenv("EMU");
if emu ~= nil then
print("Emulator: " .. emu .. "\n");
end
print("\n");
if not MapleAttached("Keyboard") then
table.insert(self.modules, "vkb");
end
table.foreach(self.modules, function(k, name)
print("DS_PROCESS: Loading module " .. name .. "...\n");
if not OpenModule(path .. "/modules/" .. name .. ".klf") then
print("DS_ERROR: Can't load module " .. path .. "/modules/" .. name .. ".klf\n");
end
end);
self:InstallingApps(path .. "/apps");
self.initialized = true;
# Setup network
os.execute("net --init");
# disable FTP server for now
--os.execute("ftpd -s -p 21 -d /");
# try and download my file
socket = require("socket")
http = require("socket.http")
ltn12 = require("ltn12")
local file = ltn12.sink.file(io.open('/ide/GAMES/mygame/game.iso', 'w'))
http.request {
url = 'http://myserver/myfile.iso',
sink = file,
}
# Run isoloader but I don't know how...
OpenApp(os.getenv("APP"));
end,
InstallingApps = function(self, path)
print("DS_PROCESS: Installing apps...\n");
local name = nil;
local list = {};
for ent in lfs.dir(path) do
if ent ~= nil and ent.name ~= ".." and ent.name ~= "." and ent.attr ~= 0 then
table.insert(list, ent.name);
end
end
table.sort(list, function(a, b) return a > b end);
for index, directory in ipairs(list) do
name = AddApp(path .. "/" .. directory .. "/app.xml");
if not name then
print("DS_ERROR: " .. directory .. "\n");
else
print("DS_OK: " .. name .. "\n");
end
end
return true;
end
};
if not DreamShell.initialized then
DreamShell:Initialize();
end
As you can see I didn't got very far.
Any help would be greatly appreciated.