Implement /install

This commit is contained in:
2022-09-22 21:01:40 +02:00
parent 7fa635170a
commit 226aba437a
7 changed files with 91 additions and 15 deletions

1
server/lua Symbolic link
View File

@@ -0,0 +1 @@
../lua/out

View File

@@ -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)

View File

@@ -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()

View 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