The LG Control Server is a powerful and intuitive Node.js-based application for managing Liquid Galaxy (LG) systems via SSH. It offers a robust REST API to handle various LG operations, from visualizations to system management.
-
Clone the repository:
git clone https://github.com/LiquidGalaxyLAB/lg-server.git cd lg-server
-
Install dependencies:
npm install
-
Set up HTTPS with
mkcert
:
Installmkcert
(follow this guide) and generate your SSL certificates:mkcert -install mkcert localhost <ip_address>
- Create a
certs
folder in the project root and place the generated.key
and.pem
files there. - Learn more. Rename them to cert.pem and key.pem as shown in the article.
- Create a
-
Install
RootCA.pem
on your device:Find the
RootCA.pem
location:mkcert CAROOT
Send the
RootCA.pem
file to your Android or iOS device, rename it with a.crt
extension, and install it.
app.js
: Entry point of the application.server.js
: Configures middleware, routes, and starts the server.routers/
: Defines API routes.controllers/
: Contains logic to handle API requests.services/
: Implements SSH interactions and reusable logic.
-
Start the server:
npm run dev
-
Verify the server is running by hitting the health check endpoint:
curl http://localhost:8000/ping
Expected Response:
{ "message": "pong@@" }
-
In the
services/
directory, add a new function:export const newCommandService = async (ip, port, username, password, command) => { const client = new Client(); try { await connectSSH(client, { ip, port: parseInt(port, 10), username, password }); const result = await executeCommand(client, command); console.log("Command result:", result); return result; } catch (error) { console.error("Error during SSH operations:", error); return { success: false, message: error.message }; } finally { client.end(); } };
-
In
controllers/
, add the logic to handle the new command:newCommand = async (req, res) => { const { ip, port, username, password, command } = req.body; const response = await newCommandService(ip, port, username, password, command); return res.status(200).json(response); };
-
Add a route in
routers/index.js
:router.route("/new-command").post(lgConnectionController.newCommand);
-
Use
curl
or Postman to test:curl -X POST http://localhost:8000/api/new-command \ -H "Content-Type: application/json" \ -d '{ "ip": "192.168.x.x", "port": "22", "username": "your-username", "password": "your-password", "command": "your-command" }'
Endpoint | Method | Description |
---|---|---|
/ping |
GET | Health check endpoint. |
/api/execute-orbit |
POST | Executes an orbit command. |
/api/clean-visualization |
POST | Cleans LG visualizations. |
/api/clean-logos |
POST | Removes LG logos. |
/api/relaunch-lg |
POST | Relaunches the LG system. |
/api/reboot-lg |
POST | Reboots the LG system. |
/api/stop-orbit |
POST | Stops orbit visualization. |
/api/clean-balloon |
POST | Cleans balloon visualizations. |
/api/new-command |
POST | Executes a custom command. |
This project is licensed under the MIT License.
The backend is developed by Lovely Sehotra.
Designed by Mentor Yash.