Skip to content

LindaJuffermans/ptero-taskmanager

Repository files navigation

Ptero Taskmanager

This project was created to easily perform common and multiple tasks across a number of servers that are maintained with the Pterodactyl Panel.

Background

I'm a moderator in a community where we host dozens of servers with the same Minecraft modpack. Each time the modpack had to be updated, it had to be updated on every server. Each update involved uploading a file, stopping the server, deleting old mods and configs, extracting the file and starting the server.

I don't like repetetive manual tasks and so I looked at the Pterodactyl APIs for a way to automate. At the same time I felt like learning the modern JS, HTML and CSS (my knowledge dated from the early 2000's) and thus I came up with this project.

Implementation

The Pterodactyl APIs use an API key that can be obtained through the admin panel. This application authenticates itself against the API endpoints by passing this key. Those APIs are also used by the panel itself where authentication is based on session cookies. This causes some behaviours on the API endpoints that had to be worked around.

For example, some APIs would require a CSRF token if the Origin header is passed in the request. If these calls are made from a browser, as a pure frontend application, the Origin header is always present; however getting a CSRF token was undocumented and is also not a feature I wanted to implement (also since I believe it is unnecessary for an Authorization header based call).

It was suggested to make these calls from a server which gives full control over the headers, allowing me to omit the Origin header. Since this also hides the API key from the user, I felt this was the best approach and thus I went from my initial pure React application to a Next.js application.

The frontend part connects to the backend websocket (/api/socket) which pushes information about server statuses and resources, to update the realtime information in the UI. Additionally, a single API (/api/runTasks) call is made with a list of servers and tasks to be executed. The execution happens completely in the backend and updates are pushed to the existing websocket.

Configuration

The project uses a YAML file with details about the API endpoint and the servers. The format is:

# Pterodactyl Panel Information:
panelDomain: "panelurl.net"
clientKey: "ptlc_FAKEKEYWILLNOTWORK"

# servers
categories:
- name: "Category Name 1"
  servers:
    - name: "Server Name 1"
      id: "dd15f315"
    - name: "Server Name 2"
      id: "42aa13a2"
    - name: "Server Name 3"
      id: "2eb9bf30"
- name: "Category Name 2"
  servers:
    - name: "Server Name 4"
      id: "94c1e340"
    - name: "Server Name 5"
      id: "c92c7882"
- name: "Category Name 3"
  servers:
    - name: "Server Name 6"
      id: "9a1c0741"
    - name: "Server Name 7"
      id: "e83c06f5"
    - name: "Server Name 8"
      id: "bd8f5d1e"

where id is the Pterodactyl Panel ID of the server (e.g. in https://panelurl.net/server/dd15f315).

UI

The UI is divided in 3 parts:

  • List of servers by category
  • Set of tasks
  • Execution status

Server list

This section shows all configured servers by category and in the order that you've configured them in the YAML file. The status, CPU and memory resources are updated approx. every second through websockets. The toggle behind a server can be enabled if you want the server to be included in the task run; if you click the Tasks header above, it will enable or disable all servers in the category at once.

Tasks

Here you define a set of tasks to be executed.

Buttons on the top bar:

- Run the tasks
- Open a JSON file containing a set of tasks *
- Save the tasks to a JSON file
- Clear the tasks
* Alternatively you can drag & drop a JSON file onto the Tasks container.

Buttons on each task:

- Move the task up
- Move the task down
- Delete the task

Bottom button:

- Add a new task.
This opens a popup where you can select a task to be added; the same task type can be added more than once (e.g. to delete different files).

Execution status

When the tasks are being executed, this will show the status of each task on each server.

Deploying

Deploy on Vercel

The easiest way to deploy your Next.js app is to use the Vercel Platform from the creators of Next.js.

Check out our Next.js deployment documentation for more details.

Deploy on NodeJS server

To deploy this application in a NodeJS capable environment, first build the application with:

npm run build
# or
yarn build
# or
pnmp build

Next start the server with:

npm run start
# or
yarn start
# or
pnmp start

Development

This project is offered as open source under the GNU General Public License v3.0 (see LICENSE.md). You're welcome to make changes as you desire as long as you follow the license agreement.

About

Taskmanager for the Pterodactyl control panel

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published