Alteiria / pterodactylAutoStart

Pterodactyl bash script to auto start servers (at boot for example)
2 stars 1 forks source link
bash pterodactyl pterodactyl-panel-api

:warning:Pterodactly just introduced the feature "return to the latest powerstate of a server" so this script is basically useless now.:warning:

Please use the new feature in pterodactyl: https://github.com/pterodactyl/panel/issues/136#issuecomment-557996853

Pterodactyl Auto Start

Build Status

Description

This bash script auto start (at boot for example) the servers in Pterodactyl that have alwaysStart in their description.

Requirements

Installation

  1. Generate an account API token: https://your.pterodactyl.panel/account/api
  2. Download the git repository to the /opt/pterodactylAutoStart directory using:
    sudo git clone https://github.com/Alteiria/pterodactylAutoStart.git /opt/pterodactylAutoStart
  3. Install JQ from the release page:
    sudo wget https://github.com/stedolan/jq/releases/download/jq-1.6/jq-linux64 -O /usr/bin/jq
    sudo chmod +x /usr/bin/jq
  4. Move the service file from the installation directory to the systemd service files:
    sudo mv /opt/pterodactylAutoStart/pterodactylAutoStart.service /etc/systemd/system/pterodactylAutoStart.service
  5. Edit the service file and modify the two environment variables baseURL and apiToken:
sudo nano /etc/systemd/system/pterodactylAutoStart.service

Note: Make sure to follow the Requirements section for the two environment variables!

  1. Enable the service file to make the script starting at boot:
    sudo systemctl enable pterodactylAutoStart
  2. On your Pterodactyl panel, edit the description of every server that you wish to auto start by simply adding alwaysStart in their description. Watchout for the capitalized in the second s!

    Screenshot of one of my server that auto start:

How to test if the script works as intended.

  1. Manually shutdown a server that you configured to auto start.
  2. Run the systemd start command to start the script:
    sudo systemctl start pterodactylAutoStart
  3. Check if your server start after that, it will take up to 80 seconds because there is an hard coded delay in the service file (more details available here).
  4. If your server didn't start after that period of 80 seconds check the logs using journalctl:
    sudo journalctl -u pterodactylAutoStart

    If you see some text or errors please open a new issue.