-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
76 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
Empty file.
Empty file.
1 change: 1 addition & 0 deletions
1
base-fullbuild/root/etc/s6-overlay/s6-rc.d/init-config-end/type
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
oneshot |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
# This file doesn't do anything, it's just the end of the downstream image init process |
15 changes: 9 additions & 6 deletions
15
base-fullbuild/root/etc/s6-overlay/s6-rc.d/init-custom-packages/run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,17 @@ | ||
#!/usr/bin/with-contenv bash | ||
#!/command/with-contenv bash | ||
|
||
# Install DockerCLI if true | ||
if [ "${DOCKERCLI}" == "true" ]; then | ||
echo "[custom-init] Installing Docker CLI and Compose..." | ||
echo "[custom-init] Installing Docker CLI and Docker Compose..." | ||
apk add -U --quiet docker-cli docker-cli-compose | ||
else | ||
echo "[custom-init] Docker CLI variable not set, skipping..." | ||
fi | ||
|
||
# Install additional packages | ||
if [ -v EXTRA_PKGS ] | ||
then | ||
echo "[custom-init] Installing extra packages: $EXTRA_PKGS" | ||
apk add -U --quiet $EXTRA_PKGS | ||
if [ -v EXTRA_PKGS ]; then | ||
echo "[custom-init] Installing extra packages: $EXTRA_PKGS" | ||
apk add -U --quiet $EXTRA_PKGS | ||
else | ||
echo "[custom-init] No custom packages found, skipping..." | ||
fi |
2 changes: 1 addition & 1 deletion
2
base-fullbuild/root/etc/s6-overlay/s6-rc.d/init-custom-scripts/run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
#!/usr/bin/with-contenv bash | ||
#!/command/with-contenv bash | ||
|
||
# Directories | ||
SCRIPTS_DIR="/custom-cont-init.d" | ||
|
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
#!/command/with-contenv bash | ||
|
||
# Borrowed heavily from https://github.com/linuxserver/docker-mods/tree/mod-scripts | ||
|
||
echo "[init] Initialising Container..." | ||
|
||
# Define custom folder paths | ||
SCRIPTS_DIR="/custom-cont-init.d" | ||
SERVICES_DIR="/custom-services.d" | ||
|
||
# Set executable bit on cont-init and services built into the image | ||
set_legacy_executable_bits() { | ||
mkdir -p /etc/{cont-init.d,services.d} | ||
chmod +x \ | ||
/etc/cont-init.d/* \ | ||
/etc/services.d/*/* 2>/dev/null || true | ||
} | ||
|
||
# https://www.linuxserver.io/blog/2019-09-14-customizing-our-containers#custom-services | ||
process_custom_services() { | ||
# Remove all existing custom services before continuing to ensure | ||
# we aren't running anything the user may have removed | ||
if [[ -n "$(/bin/ls -A /etc/s6-overlay/s6-rc.d/custom-svc-* 2>/dev/null)" ]]; then | ||
echo "[custom-init] removing existing custom services..." | ||
rm -rf /etc/s6-overlay/s6-rc.d/custom-svc-* | ||
rm /etc/s6-overlay/s6-rc.d/user/contents.d/custom-svc-* | ||
fi | ||
|
||
# Make sure custom service directory exists and has files in it | ||
if [[ -e "${SERVICES_DIR}" ]] && [[ -n "$(/bin/ls -A ${SERVICES_DIR} 2>/dev/null)" ]]; then | ||
echo "[custom-init] Service files found in ${SERVICES_DIR}" | ||
for SERVICE in "${SERVICES_DIR}"/*; do | ||
NAME="$(basename "${SERVICE}")" | ||
if [[ -f "${SERVICE}" ]]; then | ||
echo "[custom-init] ${NAME}: service detected, copying..." | ||
mkdir -p /etc/s6-overlay/s6-rc.d/custom-svc-"${NAME}"/dependencies.d/ | ||
cp "${SERVICE}" /etc/s6-overlay/s6-rc.d/custom-svc-"${NAME}"/run | ||
chmod +x /etc/s6-overlay/s6-rc.d/custom-svc-"${NAME}"/run | ||
echo "longrun" >/etc/s6-overlay/s6-rc.d/custom-svc-"${NAME}"/type | ||
touch /etc/s6-overlay/s6-rc.d/custom-svc-"${NAME}"/dependencies.d/init-services | ||
touch /etc/s6-overlay/s6-rc.d/user/contents.d/custom-svc-"${NAME}" | ||
echo "[custom-init] ${NAME}: copied" | ||
elif [[ ! -f "${SERVICE}" ]]; then | ||
echo "[custom-init] ${NAME}: is not a file" | ||
fi | ||
done | ||
else | ||
echo "[custom-init] No custom services found, skipping..." | ||
fi | ||
} | ||
|
||
if [[ -d "${SCRIPTS_DIR}" ]] || [[ -d "${SERVICES_DIR}" ]]; then | ||
process_custom_services | ||
fi | ||
|
||
# Set executable bit on legacy cont-init and services built into the image and anything legacy unpacked by mods | ||
set_legacy_executable_bits |