Skip to content

Deno Generic

A generic egg to run deno code.

egg-deno-generic.json

updated

Install

Installer image
ghcr.io/ptero-eggs/installers:debian
Install script
107 lines

Image

  • Debian ghcr.io/ptero-eggs/yolks:debian

Startup

The Panel runs this command to start the server. It replaces each variable in the command with the value of that variable.

6 variables

Startup command

./deno run bot.js
  • Username to auth with git.

    USERNAMEUsers can edit

    nullable|string

  • Password to use with git. It's best practice to use a Personal Access Token. https://github.com/settings/tokens https://gitlab.com/-/profile/personal_access_tokens

    ACCESS_TOKENUsers can edit

    nullable|string

  • GitHub Repo to clone I.E. https://github.com/parkervcp/repo_name

    GIT_ADDRESSUsers can edit

    nullable|string

  • Skip all the install stuff if you are letting a user upload files. 0 = false (default) 1 = true

    USER_UPLOADUsers can edit

    required|boolean

  • What branch to pull from github. Default is blank to pull the repo default branch

    BRANCHUsers can edit

    nullable|string

  • The JavaScript file to run

    JS_FILEUsers can edit

    required|string|max:20

Wings

Stop command
^C (SIGINT)
Running when the console shows
change this part

Readme

Deno - JavaScript & TypeScript Generic

From their site

This egg is designed to run any generic Deno application, allowing users to pull their own Deno source code from a Github repository.

There is an option to allow a user to upload their own files to run a server.

The startup configs and commands may need changing to actually function properly.

Configuration

The server will be stuck as starting until the egg Start Configuration is modified. You have to edit the text to match something your bot will print for Pterodactyl panel to detect it as running. image

You can use arrays to have multiple different values when different bots are being used

{
  "done":[
    "change this text 1",
    "change this text 2"
  ]
}

Changes

  1. Fix docker image case

    · Daniel Barton · c6218f8

  2. Update repo names and remove some GH stuff for now

    · Daniel Barton · 8a5189b

  3. Append the forgotten commit

    · QuintenQVD0 · b047ae6

  4. change over for pelican-eggs layout

    · Michael (Parker) Parker · 9a21770

  5. Move generic eggs

    · Michael Parker · d93502b

  6. Move generic eggs

    · Michael Parker · 0b8b3d9

All changes on GitHub

Problem with this egg?

Open an issue on GitHub. Include your Panel and Wings versions.

Install script 107 lines bash in ghcr.io/ptero-eggs/installers:debian Show
#!/bin/bash
# Deno Bot Installation Script
#
# Server Files: /mnt/server

apt update
apt install -y git curl jq file unzip

mkdir -p /mnt/server
cd /mnt/server

if [ "${USER_UPLOAD}" == "true" ] || [ "${USER_UPLOAD}" == "1" ]; then
    echo -e "assuming user knows what they are doing have a good day."
    exit 0
fi

## add git ending if it's not on the address
if [[ ${GIT_ADDRESS} != *.git ]]; then
    GIT_ADDRESS=${GIT_ADDRESS}.git
fi

if [ -z "${USERNAME}" ] && [ -z "${ACCESS_TOKEN}" ]; then
    echo -e "using anon api call"
else
    GIT_ADDRESS="https://${USERNAME}:${ACCESS_TOKEN}@$(echo -e ${GIT_ADDRESS} | cut -d/ -f3-)"
fi

## pull git js bot repo
if [ "$(ls -A /mnt/server)" ]; then
    echo -e "/mnt/server directory is not empty."
    if [ -d .git ]; then
        echo -e ".git directory exists"
        if [ -f .git/config ]; then
            echo -e "loading info from git config"
            ORIGIN=$(git config --get remote.origin.url)
        else
            echo -e "files found with no git config"
            echo -e "closing out without touching things to not break anything"
            exit 10
        fi
    fi

    if [ "${ORIGIN}" == "${GIT_ADDRESS}" ]; then
        echo "pulling latest from github"
        git pull
    fi
else
    echo -e "/mnt/server is empty.\ncloning files into repo"
    if [ -z ${BRANCH} ]; then
        echo -e "cloning default branch"
        git clone ${GIT_ADDRESS} .
    else
        echo -e "cloning ${BRANCH}'"
        git clone --single-branch --branch ${BRANCH} ${GIT_ADDRESS} .
    fi

fi

## get deno
GITHUB_PACKAGE=denoland/deno
MATCH=linux

## get release info and download links
LATEST_JSON=$(curl --silent "https://api.github.com/repos/${GITHUB_PACKAGE}/releases/latest")
RELEASES=$(curl --silent "https://api.github.com/repos/${GITHUB_PACKAGE}/releases")

if [ -z "${VERSION}" ] || [ "${VERSION}" == "latest" ]; then
    DOWNLOAD_URL=$(echo ${LATEST_JSON} | jq .assets | jq -r .[].browser_download_url | grep -i ${MATCH})
else
    VERSION_CHECK=$(echo ${RELEASES} | jq -r --arg VERSION "${VERSION}" '.[] | select(.tag_name==$VERSION) | .tag_name')
    if [ "${VERSION}" == "${VERSION_CHECK}" ]; then
        DOWNLOAD_LINK=$(echo ${RELEASES} | jq -r --arg VERSION "${VERSION}" '.[] | select(.tag_name==$VERSION) | .assets[].browser_download_url' | grep -i ${MATCH})
    else
        echo -e "defaulting to latest release"
        DOWNLOAD_LINK=$(echo ${LATEST_JSON} | jq .assets | jq -r .[].browser_download_url)
    fi
fi

if [ ! -z "${DOWNLOAD_URL}" ]; then
    if curl --output /dev/null --silent --head --fail ${DOWNLOAD_URL}; then
        echo -e "link is valid. setting download link to ${DOWNLOAD_URL}"
        DOWNLOAD_LINK=${DOWNLOAD_URL}
    else
        echo -e "link is invalid closing out"
        exit 2
    fi
fi

curl -sSL $DOWNLOAD_LINK -o ${DOWNLOAD_LINK##*/}

FILETYPE=$(file -F ',' ${DOWNLOAD_LINK##*/} | cut -d',' -f2 | cut -d' ' -f2)
if [ "$FILETYPE" == "gzip" ]; then
    tar xzvf ${DOWNLOAD_LINK##*/}
elif [ "$FILETYPE" == "Zip" ]; then
    unzip -o ${DOWNLOAD_LINK##*/}
elif [ "$FILETYPE" == "XZ" ]; then
    tar xvf ${DOWNLOAD_LINK##*/}
else
    echo -e "unknown filetype. Exiting"
    exit 2
fi

## cleaning up downloaded file
rm -f ${DOWNLOAD_LINK##*/}

echo -e "install complete"
exit 0