Added functionality to expand startup of container with custom scripts #1773
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
{Please select 'base: development' as target branch above! (you can delete this line)}
Description
Added functionality to the start.sh script so custom scripts can be mounted and started from the "/custom-cont-init.d" directory inside the docker container. All scripts in the directory are
chmod +x
´ed and then executed in sorted order, but in background and "only" with a 10 seconds sleep timer between each script execution. So if scripts are dependant on each other, one would need a mechanic to handle that.As an example i created 3 test scripts:
These are executed in order with a 10 second delay in between but if the first script would take longer to execute, the second script would start nontheless. So each script does neither interfere with other scripts from that folder, nor do they interfere with the way the pihole processes are started, as everything is run in background/parallel. Also output from those scripts should be captured correctly and forwarded so they can be viewed from the docker logs, though i am not sure if processes that are started in background from one of those scripts are handled in the same way. Thats something i cant really tell for sure.
Motivation and Context
This PR solves #1752
With this PR the pihole docker image can be used as a base image for other containers so other containers can have their own startup scripts without interfering with the way pihole starts.
Also this PR adds a mechanic for users to simply mount bash scripts into the container, that are executed at runtime for whatever reason, might solve #1701 (comment)
How Has This Been Tested?
I have created the above mentioned scripts with this code:
10-successful-script.sh:
20-failing-script.sh:
30-endless-script.sh:
The first script just runs once and exits without an error, the second one exits with an error code of 1 and the third script keeps running endlessly and continuesly outputs to the stdout which is visible in the docker logs.
All these scripts can be placed in the current working directory and the docker container can be started with a command similar to this:
docker run -d --name pihole-test -v "$(pwd):/custom-cont-init.d" pihole/pihole:latest
Afterwards viewing the docker logs should show the output of the different scripts that have been mounted.
Types of changes
Checklist: