mirror of
https://github.com/lrnselfreliance/wrolpi.git
synced 2026-10-26 19:01:39 -04:00
Samba is installed and can be configured in the Controller.
This commit is contained in:
parent
0ceac364ec
commit
ce0cdd3a2e
15 changed files with 837 additions and 5 deletions
|
|
@ -10,6 +10,10 @@ from controller.api.schemas import (
|
|||
HotspotActionResponse,
|
||||
HotspotStatusResponse,
|
||||
RestartServicesResponse,
|
||||
SambaShareAddRequest,
|
||||
SambaShareRemoveResponse,
|
||||
SambaShareResponse,
|
||||
SambaStatusResponse,
|
||||
ServiceRestartResult,
|
||||
SystemActionResponse,
|
||||
ThrottleActionResponse,
|
||||
|
|
@ -35,6 +39,11 @@ from controller.lib.admin import (
|
|||
shutdown_system,
|
||||
)
|
||||
from controller.lib.config import is_docker_mode
|
||||
from controller.lib.samba import (
|
||||
add_share,
|
||||
get_samba_status_dict,
|
||||
remove_share,
|
||||
)
|
||||
|
||||
router = APIRouter(tags=["admin"])
|
||||
|
||||
|
|
@ -91,6 +100,32 @@ async def bluetooth_disable() -> BluetoothActionResponse:
|
|||
return BluetoothActionResponse(**result)
|
||||
|
||||
|
||||
# --- Samba ---
|
||||
|
||||
@router.get("/api/samba/status", response_model=SambaStatusResponse)
|
||||
async def samba_status() -> SambaStatusResponse:
|
||||
"""Get Samba sharing status."""
|
||||
return SambaStatusResponse(**get_samba_status_dict())
|
||||
|
||||
|
||||
@router.post("/api/samba/shares", response_model=SambaShareResponse)
|
||||
async def samba_add_share(request: SambaShareAddRequest) -> SambaShareResponse:
|
||||
"""Add a Samba share."""
|
||||
result = add_share(request.name, request.path, request.read_only, request.comment or "")
|
||||
if not result.get("success"):
|
||||
raise HTTPException(status_code=400, detail=result.get("error", "Failed"))
|
||||
return SambaShareResponse(**result)
|
||||
|
||||
|
||||
@router.delete("/api/samba/shares/{share_name}", response_model=SambaShareRemoveResponse)
|
||||
async def samba_remove_share(share_name: str) -> SambaShareRemoveResponse:
|
||||
"""Remove a Samba share."""
|
||||
result = remove_share(share_name)
|
||||
if not result.get("success"):
|
||||
raise HTTPException(status_code=404, detail=result.get("error", "Failed"))
|
||||
return SambaShareRemoveResponse(**result)
|
||||
|
||||
|
||||
# --- Throttle ---
|
||||
|
||||
@router.get("/api/throttle/status", response_model=ThrottleStatusResponse)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue