Files
yakpanel-core/YakPanel-server/frontend/dist/assets/RemoteInstallPage-C4gVyakl.js

3 lines
7.4 KiB
JavaScript
Raw Normal View History

2026-04-07 09:46:22 +05:30
import{r as a,j as e,aw as A}from"./index-CRR9sQ49.js";import{A as b}from"./AdminAlert-DW1IRWce.js";import{A as M}from"./AdminButton-Bd2cLTu3.js";function Y(){const[t,T]=a.useState(null),[d,I]=a.useState(""),[j,L]=a.useState(""),[m,F]=a.useState("22"),[f,O]=a.useState("root"),[n,y]=a.useState("key"),[N,q]=a.useState(""),[g,U]=a.useState(""),[v,S]=a.useState(""),[w,k]=a.useState(""),[h,E]=a.useState([]),[P,u]=a.useState(!1),[H,C]=a.useState(null),[R,_]=a.useState(""),o=a.useRef(null);a.useEffect(()=>{fetch("/api/v1/public-install/config").then(s=>s.ok?s.json():Promise.reject(new Error(`HTTP ${s.status}`))).then(s=>{T(s),k(s.default_install_url||"")}).catch(()=>I("Could not load installer configuration"))},[]),a.useEffect(()=>{o.current&&(o.current.scrollTop=o.current.scrollHeight)},[h]);const p=a.useCallback(s=>{E(c=>[...c.slice(-2e3),s])},[]);async function $(s){if(s.preventDefault(),_(""),E([]),C(null),!(t!=null&&t.enabled))return;const c=w.trim()||t.default_install_url,K=n==="key"?{type:"key",private_key:N,passphrase:g||null}:{type:"password",password:v},B={host:j.trim(),port:parseInt(m,10)||22,username:f.trim(),auth:K,install_url:c===t.default_install_url?null:c};u(!0);try{const l=await fetch("/api/v1/public-install/jobs",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(B)});if(!l.ok){const i=await l.json().catch(()=>({}));throw new Error(i.detail||`HTTP ${l.status}`)}const{job_id:W}=await l.json(),J=window.location.protocol==="https:"?"wss:":"ws:",x=new WebSocket(`${J}//${window.location.host}/api/v1/public-install/ws/${W}`);x.onmessage=i=>{try{const r=JSON.parse(i.data);r.type==="line"&&typeof r.text=="string"&&p(r.text),r.type==="done"&&C(typeof r.exit_code=="number"?r.exit_code:-1)}catch{p(String(i.data))}},x.onerror=()=>p("[websocket error]"),x.onclose=()=>u(!1)}catch(l){_(l instanceof Error?l.message:"Request failed"),u(!1)}finally{n==="password"&&S("")}}return!t&&!d?e.jsx("div",{className:"min-vh-100 d-flex align-items-center justify-content-center bg-body-secondary",children:e.jsx("p",{className:"text-secondary mb-0",children:"Loading…"})}):d?e.jsx("div",{className:"min-vh-100 d-flex align-items-center justify-content-center bg-body-secondary p-3",children:e.jsx(b,{children:d})}):t&&!t.enabled?e.jsx("div",{className:"min-vh-100 d-flex align-items-center justify-content-center bg-body-secondary p-3",children:e.jsx("div",{className:"card shadow-sm w-100",style:{maxWidth:520},children:e.jsxs("div",{className:"card-body p-4",children:[e.jsx("h1",{className:"h4 mb-3",children:"Remote SSH installer disabled"}),e.jsxs("p",{className:"small text-secondary mb-3",children:["Enable it on the API server with environment variable"," ",e.jsx("code",{children:"ENABLE_REMOTE_INSTALLER=true"})," and restart the backend. Prefer SSH keys; exposing this endpoint increases risk."]}),e.jsx("p",{className:"small text-secondary mb-3",children:"One-liner on the target server (as root):"}),e.jsxs("pre",{className:"bg-dark text-success small p-3 rounded mb-3 mb-0 overflow-auto",children:["curl -fsSL ",t.default_install_url," | bash"]}),e.jsx(A,{to:"/login",className:"btn btn-link btn-sm px-0 mt-3",children:"Panel login"})]})})}):e.jsx("div",{className:"min-vh-100 bg-body-secondary py-4 px-3",children:e.jsxs("div",{className:"container",style:{maxWidth:900},children:[e.jsxs(b,{variant:"warning",className:"mb-3",children:[e.jsx("strong",{children:"Security warning:"})," SSH credentials are sent to this panel API and used only for this session (not stored). Prefer ",e.jsx("strong",{children:"SSH private keys"}),". Root password SSH is often disabled on Ubuntu. Non-root users need ",e.jsx("strong",{children:"passwordless sudo"})," (",e.jsx("code",{children:"sudo -n"}),") to run the installer. Allow SSH from this server to the target on port ",m,"."]}),e.jsx("div",{className:"card shadow-sm",children:e.jsxs("div",{className:"card-body p-4",children:[e.jsx("h1",{className:"h4 mb-2",children:"Remote install (SSH)"}),e.jsxs("p",{className:"small text-secondary mb-4 mb-0",children:["Runs the published ",e.jsx("co
2026-04-07 05:05:28 +05:30
`)}),H!==null?e.jsxs("p",{className:"small border-secondary border-top pt-2 mt-2 mb-0",children:["Exit code: ",e.jsx("strong",{children:H})]}):null]})}):null,e.jsx("p",{className:"text-center small text-secondary mt-3 mb-0",children:e.jsx(A,{to:"/login",children:"Panel login"})})]})})}export{Y as RemoteInstallPage};