Add/nodemon.js (#1281)

* Add nodemon egg

Co-authored-by: Alex <admin@softwarenoob.com>
This commit is contained in:
NickDevNL 2021-08-27 05:17:15 +02:00 committed by GitHub
parent b557ac8860
commit c7d02b9e1c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 146 additions and 2 deletions

View File

@ -34,7 +34,8 @@ If you are reading this it looks like you are looking to add an egg to your serv
* [discordgo](bots/discord/discordgo) Golang generic
* [fragbot](/bots/discord/fragbot) Golang
* [JMusicBot](/bots/discord/jmusicbot) Java
* [parkertron](/bots/discord/parkertron) Golang
* [nodemon.js](bots/discord/nodemon.js) Nodemon JS generic
* [parkertron](/bots/discord/parkertron) Golang
* [pixel-bot](/bots/discord/pixelbot) Python
* [Redbot](/bots/discord/redbot) Python
* [SinusBot](/bots/discord/sinusbot)
@ -244,4 +245,4 @@ If you are reading this it looks like you are looking to add an egg to your serv
### Grafana
* [Grafana](/software/grafana)
### haste-server
* [haste-server](/software/haste-server)
* [haste-server](/software/haste-server)

View File

@ -34,6 +34,10 @@ The bot that runs as the fragforce `@Fragbot` offering looking-for-group service
[jagrosh/MusicBot](https://github.com/jagrosh/MusicBot)
A Discord music bot that's easy to set up and run yourself!
#### nodemon
[nodemon](https://nodemon.io/)
A nodemon javascript egg for running and automatically restarting the node application when file changes in the directory are detected
#### parkertron
[parkervcp/parkertron](https://github.com/parkervcp/parkertron)
The bot that runs as the pterodactyl `@Support Bot`

View File

@ -0,0 +1,24 @@
# nodemon.js
Tired of manually restarting your bot? Nodemon will do it by itself.
Nodemon is a tool that helps develop node.js based applications by automatically restarting the node application when file changes in the directory are detected. Nodemon does not require any additional changes to your code or method of development.
This egg is designed to run any generic Javascript application, allowing users to pull their own javascript discord bot from a Github repository.
There is an option to allow a user to upload their own files to run a bot.
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](https://user-images.githubusercontent.com/10975908/126516861-c5cb4630-9f25-405c-8199-97bf5ec15a7f.png)
You can use arrays to have multiple different values when different bots are being used
```
{
"done":[
"change this text 1",
"change this text 2"
]
}

View File

@ -0,0 +1,115 @@
{
"_comment": "DO NOT EDIT: FILE GENERATED AUTOMATICALLY BY PTERODACTYL PANEL - PTERODACTYL.IO",
"meta": {
"version": "PTDL_v1",
"update_url": null
},
"exported_at": "2021-08-26T23:09:55-04:00",
"name": "nodemon",
"author": "nick@blackfortmc.com",
"description": "Nodemon javascript egg that automatically restarts the node application when file changes in the directory are detected\r\n\r\nThis will clone a git repo for a bot. it defaults to master if no branch is specified.\r\n\r\nInstalls the node_modules on install. If you set user_upload, then I assume you know what you are doing.",
"features": null,
"images": [
"ghcr.io\/parkervcp\/yolks:nodejs_16",
"ghcr.io\/parkervcp\/yolks:nodejs_15",
"ghcr.io\/parkervcp\/yolks:nodejs_14",
"ghcr.io\/parkervcp\/yolks:nodejs_12"
],
"file_denylist": [],
"startup": "npm install nodemon; if [[ -d .git ]] && [[ {{AUTO_UPDATE}} == \"1\" ]]; then git pull; fi; if [[ ! -z ${NODE_PACKAGES} ]]; then \/usr\/local\/bin\/npm install ${NODE_PACKAGES}; fi; if [[ ! -z ${UNNODE_PACKAGES} ]]; then \/usr\/local\/bin\/npm uninstall ${UNNODE_PACKAGES}; fi; if [ -f \/home\/container\/package.json ]; then \/usr\/local\/bin\/npm install --production; fi; \/home\/container\/node_modules\/nodemon\/bin\/nodemon.js \/home\/container\/{{BOT_JS_FILE}}",
"config": {
"files": "{}",
"startup": "{\r\n \"done\": \"change this text\"\r\n}",
"logs": "{}",
"stop": "^c"
},
"scripts": {
"installation": {
"script": "#!\/bin\/bash\r\n# NodeJS Bot Installation Script\r\n#\r\n# Server Files: \/mnt\/server\r\napt update\r\napt install -y git curl jq file unzip make gcc g++ python python-dev libtool\r\n\r\nmkdir -p \/mnt\/server\r\ncd \/mnt\/server\r\n\r\nif [ \"${USER_UPLOAD}\" == \"true\" ] || [ \"${USER_UPLOAD}\" == \"1\" ]; then\r\n echo -e \"assuming user knows what they are doing have a good day.\"\r\n exit 0\r\nfi\r\n\r\n## add git ending if it's not on the address\r\nif [[ ${GIT_ADDRESS} != *.git ]]; then\r\n GIT_ADDRESS=${GIT_ADDRESS}.git\r\nfi\r\n\r\nif [ -z \"${USERNAME}\" ] && [ -z \"${ACCESS_TOKEN}\" ]; then\r\n echo -e \"using anon api call\"\r\nelse\r\n GIT_ADDRESS=\"https:\/\/${USERNAME}:${ACCESS_TOKEN}@$(echo -e ${GIT_ADDRESS} | cut -d\/ -f3-)\"\r\nfi\r\n\r\n## pull git js bot repo\r\nif [ \"$(ls -A \/mnt\/server)\" ]; then\r\n echo -e \"\/mnt\/server directory is not empty.\"\r\n if [ -d .git ]; then\r\n echo -e \".git directory exists\"\r\n if [ -f .git\/config ]; then\r\n echo -e \"loading info from git config\"\r\n ORIGIN=$(git config --get remote.origin.url)\r\n else\r\n echo -e \"files found with no git config\"\r\n echo -e \"closing out without touching things to not break anything\"\r\n exit 10\r\n fi\r\n fi\r\n\r\n if [ \"${ORIGIN}\" == \"${GIT_ADDRESS}\" ]; then\r\n echo \"pulling latest from github\"\r\n git pull\r\n fi\r\nelse\r\n echo -e \"\/mnt\/server is empty.\\ncloning files into repo\"\r\n if [ -z ${BRANCH} ]; then\r\n echo -e \"cloning default branch\"\r\n git clone ${GIT_ADDRESS} .\r\n else\r\n echo -e \"cloning ${BRANCH}'\"\r\n git clone --single-branch --branch ${BRANCH} ${GIT_ADDRESS} .\r\n fi\r\n\r\nfi\r\n\r\necho \"Installing nodejs packages\"\r\nif [[ ! -z ${NODE_PACKAGES} ]]; then\r\n \/usr\/local\/bin\/npm install ${NODE_PACKAGES}\r\nfi\r\n\r\nif [ -f \/mnt\/server\/package.json ]; then\r\n \/usr\/local\/bin\/npm install --production\r\nfi\r\n\r\necho -e \"install complete\"\r\nexit 0",
"container": "node:14-buster-slim",
"entrypoint": "bash"
}
},
"variables": [{
"name": "Git Repo Address",
"description": "GitHub Repo to clone\r\n\r\nI.E. https:\/\/github.com\/nickdevnl\/repo_name",
"env_variable": "GIT_ADDRESS",
"default_value": "",
"user_viewable": true,
"user_editable": true,
"rules": "nullable|string"
},
{
"name": "Install Branch",
"description": "The branch of the bot to install.",
"env_variable": "BRANCH",
"default_value": "",
"user_viewable": true,
"user_editable": true,
"rules": "nullable|string"
},
{
"name": "User Uploaded Files",
"description": "Skip all the install stuff if you are letting a user upload files.\r\n\r\n0 = false (default)\r\n1 = true",
"env_variable": "USER_UPLOAD",
"default_value": "0",
"user_viewable": true,
"user_editable": true,
"rules": "required|bool"
},
{
"name": "Auto Update",
"description": "Pull the latest files on startup when using a GitHub repo. You must have .git folder, reinstall if you are missing it.",
"env_variable": "AUTO_UPDATE",
"default_value": "0",
"user_viewable": true,
"user_editable": true,
"rules": "required|boolean"
},
{
"name": "Bot js file",
"description": "The file that starts the bot.",
"env_variable": "BOT_JS_FILE",
"default_value": "index.js",
"user_viewable": true,
"user_editable": true,
"rules": "required|string"
},
{
"name": "Additional Node packages",
"description": "Install additional node packages.\r\n\r\nUse spaces to separate.",
"env_variable": "NODE_PACKAGES",
"default_value": "",
"user_viewable": true,
"user_editable": true,
"rules": "nullable|string"
},
{
"name": "Uninstall Node packages",
"description": "Uninstall node packages.\r\n\r\nUse spaces to separate.",
"env_variable": "UNNODE_PACKAGES",
"default_value": "",
"user_viewable": true,
"user_editable": true,
"rules": "nullable|string"
},
{
"name": "Git Username",
"description": "Username to auth with git.",
"env_variable": "USERNAME",
"default_value": "",
"user_viewable": true,
"user_editable": true,
"rules": "nullable|string"
},
{
"name": "Git Access Token",
"description": "Password to use with git.\r\n\r\nIt's best practice to use a Personal Access Token.\r\nhttps:\/\/github.com\/settings\/tokens\r\nhttps:\/\/gitlab.com\/-\/profile\/personal_access_tokens",
"env_variable": "ACCESS_TOKEN",
"default_value": "",
"user_viewable": true,
"user_editable": true,
"rules": "nullable|string"
}
]
}