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
-
Ngrok Setup Instructions
- For executing the commands in the deployed front-end application
- A local server running on port 3000
a. Download and Install ngrok
-
Navigate to ngrok downloads
-
Macos
brew install ngrok
-
Ubuntu
sudo snap install ngrok
-
Download and extract the ngrok executable to your preferred location (windows)
b. Launch Tunnel
- Open a new terminal window
- Execute the following command:
ngrok http 3000
- Verify the tunnel is active when you see the forwarding URL in the terminal
c. Configure Frontend
-
Copy the HTTPS forwarding URL from the ngrok terminal (Example:
https://a1b2c3d4.ngrok.io
) -
Update your frontend application's configuration with this URL
-
Note The ngrok terminal must remain open to maintain the tunnel connection. The free tier will generate a new URL each time you restart ngrok.
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.