linuxserver/docker-baseimage-alpine

[FEAT] Add support for Python custom scripts

paya-cz opened this issue · 6 comments

Is this a new feature request?

  • I have searched the existing issues

Wanted change

custom-cont-init.d scripts run via bash. If I want to use Python instead, I need to use an extra bash script that executes my Python script (like a trampoline). Add support for running Pythong scripts directly within custom-cont-init.d.

Reason for change

It would be nice to just drop a Python script into custom-cont-init.d with Python shebang and have it work out of the box. I find the extra step of adding a bash script to delegate execution to Python as unnecessary.

Proposed code change

No response

Thanks for opening your first issue here! Be sure to follow the bug or feature issue templates!

I don't think we will support this. The main reason off the top of my head is because not all of our images include python. All of our images do include bash.

The workflow for an image that does not include python would need to include a bash script to install python before attempting to run any python scripts.

Another team member may have additional thoughts on this.

I don't think we will support this. The main reason off the top of my head is because not all of our images include python. All of our images do include bash.

If that's the case then it certainly wouldn't make sense to bundle Python to all images just to add support for this.

On the other hand, the script could simply check for the presence of Python in that particular image and execute Python scripts if it is installed. Or perhaps avoid invoking bash directly:

/bin/bash "${SCRIPT}"

And instead depend on proper shebangs.

On the other hand, the script could simply check for the presence of Python in that particular image and execute Python scripts if it is installed.

I feel like this would lead to an inconsistent user experience. Some scripts run and some don't, depending on whether python is included. This can also change over time as different python packages and dependencies cycle through the image. An alternative would be to check if a python script exists in the custom folder and then install python if it doesn't already exist, but that adds some significant logic to the init in order to support custom scripts that are not really supported (we support your ability to run a script, but not the script itself).

Or perhaps avoid invoking bash directly:

/bin/bash "${SCRIPT}"

And instead depend on proper shebangs.

shebangs are not the only concern. Invoking /bin/bash "${SCRIPT}" avoids issues where ${SCRIPT} must be executable if it is invoked directly. If we invoke directly (relying on the shebang) and the script is not executable, it would not fire, and result in an error. We also would want to avoid making permission changes to these files because of the inherent security risks they pose. Permission changes on these files should be deliberate and done by the user running the container.

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

This issue is locked due to inactivity