jammsen / docker-palworld-dedicated-server

Docker container to easily provision and manage Palworld Dedicated Server
https://hub.docker.com/r/jammsen/palworld-dedicated-server
MIT License
897 stars 151 forks source link

[Feature Request] The ability to allow advanced custom scripts #273

Open Jadiction opened 6 days ago

Jadiction commented 6 days ago

Have you read the Important information text above

Describe the feature

This would allow any advanced user to modify files or have custom scripts running/ran before the server starts, allowing unlimited potential. For example, if I wanted to replace a file, or use linux sed to replace a few words in a file, this would be possible.

I would just mount /mnt/myscripts with a custom.sh file to /opt/custom/.

Then adding something like this at the top of servermanager.sh should suffice:

echo "> Checking for optional scripts"
cp -f /opt/custom/custom.sh /opt/scripts/custom.sh > /dev/null 2>&1 ||:

if [ -f /opt/scripts/custom.sh ]; then
  echo "> Found optional script, executing---"
  chmod -f +x /opt/scripts/custom.sh ||:
  /opt/scripts/custom.sh || echo "> Error thrown in optional script"
else
  echo "> No optional script found, continuing"
fi

Additional information

Final checks

jammsen commented 5 days ago

Hello @Jadiction Thanks for the FR!

When i understand you correctly you want the ability to load custom-scripts inside the servermanager and then start what the servermanager is doing.

Back in the day of creating and reworking the entire codebase (around March 2024) of this project i was also looking into how to do custom-script, like in a event-style. Exampe Pre-Server-Start, Pre-Premission-Setup and others. But i didnt find a solid solution that couldnt be hijacked and miss-used for Trojans, RCEs, Malware and stuff, thats why i dropped the idea. The problem is with this mechanic someone else can make a "bad-version of a good-image" and make it look official and im on the hook for this, thats why i stepped back from it. Back in the days and also today i see this as very major it-security flaw to provide.

Thats why the logs and settings are so much open and wide to config, because when i give basically everything out to docker-compose/env then whats there to custom-load?

If you want a certain mechanic to be added and not a wildcard-custom-code in general i would rather try to talk about a way provide "that specific mechanic". Maybe others benefit from that too.

If you have any other points to make feel free to do it, happy to hear you out.

(In the end i dont really block it either though, the code is open-source you can just clone/fork my repo, add what you like and build your own image, if thats what you like)