Implement /install
This commit is contained in:
1
server/lua
Symbolic link
1
server/lua
Symbolic link
@@ -0,0 +1 @@
|
||||
../lua/out
|
||||
@@ -1,7 +1,8 @@
|
||||
import asyncio
|
||||
import json
|
||||
from fastapi import FastAPI, Request
|
||||
from fastapi.responses import HTMLResponse
|
||||
from fastapi.staticfiles import StaticFiles
|
||||
from fastapi.responses import HTMLResponse, PlainTextResponse
|
||||
|
||||
from .settings import settings
|
||||
from .user import user_auth
|
||||
@@ -16,6 +17,16 @@ app.mount("/map/", map_meta)
|
||||
app.mount("/tiles/", map_tiles)
|
||||
app.mount("/ipmi/", monitoring)
|
||||
|
||||
installer = j2env.get_template("install.lua").render(deploy_path=settings.deploy_path)
|
||||
|
||||
|
||||
@app.get("/install")
|
||||
async def get_installer():
|
||||
return PlainTextResponse(installer)
|
||||
|
||||
|
||||
app.mount("/lua/", StaticFiles(directory=settings.lua_out_path))
|
||||
|
||||
|
||||
@app.on_event("startup")
|
||||
async def on_startup():
|
||||
@@ -26,8 +37,6 @@ frontend = FastAPI()
|
||||
|
||||
manifest = dict()
|
||||
if not settings.dev_mode:
|
||||
from fastapi.staticfiles import StaticFiles
|
||||
|
||||
with open(f"{settings.frontend_path}/manifest.json", "r") as f:
|
||||
manifest = json.load(f)
|
||||
|
||||
|
||||
@@ -7,6 +7,9 @@ class Settings(BaseSettings):
|
||||
|
||||
frontend_path: str = "frontend"
|
||||
unmined_out_path: str = "unmined-out"
|
||||
lua_out_path: str = "lua"
|
||||
|
||||
deploy_path: str = "http://localhost:8000"
|
||||
|
||||
|
||||
settings = Settings()
|
||||
|
||||
6
server/templates/install.lua
Normal file
6
server/templates/install.lua
Normal file
@@ -0,0 +1,6 @@
|
||||
local path = "{{ deploy_path }}"
|
||||
files = { "main.lua", "json.lua", "framebuffer.lua", "ringbuffer.lua" }
|
||||
for _, file in ipairs(files) do
|
||||
fs.delete(file)
|
||||
shell.run(("wget %s/lua/%s"):format(path, file))
|
||||
end
|
||||
Reference in New Issue
Block a user