Egg Repository

Pterodactyl Community Egg Repository

5e Tools

A suite of tools for 5th Edition Dungeons & Dragons players and Dungeon Masters.

Read Me

5e Tools

A suite of tools for 5th Edition Dungeons & Dragons players and Dungeon Masters.

This is a self-hosted mirror of https://5e.tools. It will clone a github repository mirror on install and update on container reboot.

Yolks
NameTag
ghcr.io/ptero-eggs/yolks:debianghcr.io/ptero-eggs/yolks:debian
Variables
NameDescriptionEnvironment VariableDefault ValueUser ViewableUser Editable
5e Tools RepositoryGit Repository to use for cloning 5e ToolsREPOSITORYhttps://github.com/5etools-mirror-1/5etools-mirror-1.github.ioNoNo
Install Script
#!/bin/bash
# 5e Tools install script
#
# Server Files: /mnt/server
declare -r DIR="/mnt/server"
declare -r CADDY_INSTALL_URL="https://caddyserver.com/api/download?os=linux&arch=amd64&idempotency=41554620449867"
declare -r LOCAL_REPO="${DIR}/5e-tools"

die() {
  local message="$1"
  printf "\n%s\n" "${message}"
  exit 2
}
cd_error() {
  die "ERROR: installation encountered an error while trying to change directory"
}

main() {
  local git_origin
  apt update
  apt install -y wget
  cd "${DIR}" || cd_error
  printf "\nInstalling Caddy...\n"
  wget "${CADDY_INSTALL_URL}" -O ./caddy
  chmod +x ./caddy
  printf "\nGenerating Caddy configuration...\n"
  # this is a default config
  # key variables, such as the port, will get overwritten with the pterodactyl
  # configuration parser
  cat <<EOF >"${DIR}/caddy.json"
{
  "apps": {
    "http": {
      "servers": {
        "srv0": {
          "listen": [
            ":8080"
          ],
          "routes": [
            {
              "handle": [
                {
                  "handler": "vars",
                  "root": "/home/container/5e-tools"
                },
                {
                  "encodings": {
                    "gzip": {},
                    "zstd": {}
                  },
                  "handler": "encode",
                  "prefer": [
                    "zstd",
                    "gzip"
                  ]
                },
                {
                  "handler": "file_server"
                }
              ]
            }
          ]
        }
      }
    }
  }
}
EOF
  git config --global pull.ff only
  if [[ ! -d "${LOCAL_REPO}" ]]; then
    printf "\nCloning latest version (this may take a while)...\n"
    # $REPOSITORY is passed via environment variable from pterodactyl
    git clone "${REPOSITORY}" "${LOCAL_REPO}"
  else
    cd "${LOCAL_REPO}" || cd_error
    git_origin="$(git config --get remote.origin.url)"
    cd "${DIR}" || cd_error
    printf "\n\ngit origin is %s\n\n" "${git_origin}"
    # if the user hasn't change the repository variable
    if [[ "${git_origin}" == "${REPOSITORY}" ]]; then
      cd "${LOCAL_REPO}" || cd_error
      printf "\nRepository already installed - updating...\n"
      git fetch --all
      git reset --hard origin/master
      git pull
      cd "${DIR}" || cd_error
    else
      printf "\nRepository variable changed since last update\n...\n"
      rm -rf "${LOCAL_REPO}"
      git clone "${REPOSITORY}" "${LOCAL_REPO}"
    fi
  fi
  printf "\nInstallation Complete\n"
}
main "@"