Create with-contenv alias

This commit is contained in:
Eric Nemchik
2023-01-21 08:51:25 -06:00
parent 46c53fb190
commit 316a123538
+28 -8
View File
@@ -1,9 +1,11 @@
#!/usr/bin/with-contenv bash #!/command/with-contenv bash
# shellcheck shell=bash # shellcheck shell=bash
# Version 3 # Version 4
# 2022-09-25 # 2023-01-21
MOD_SCRIPT_VER="3" MOD_SCRIPT_VER="4"
# Use /command/with-contenv shebang because /usr/bin/with-contenv is created in this script
# Define custom folder paths # Define custom folder paths
SCRIPTS_DIR="/custom-cont-init.d" SCRIPTS_DIR="/custom-cont-init.d"
@@ -72,20 +74,37 @@ process_custom_services() {
create_lsiown_alias() { create_lsiown_alias() {
cat <<-EOF >/usr/bin/lsiown cat <<-EOF >/usr/bin/lsiown
#!/bin/bash #!/bin/bash
chown "\$@" || printf '**** Permissions could not be set. This is probably because your volume mounts are remote or read-only. ****\n**** The app may not work properly and we will not provide support for it. ****\n' chown "\$@" || printf '**** Permissions could not be set. This is probably because your volume mounts are remote or read-only. ****\n**** The app may not work properly and we will not provide support for it. ****\n'
EOF EOF
chmod +x /usr/bin/lsiown chmod +x /usr/bin/lsiown
} }
# Create our with-contenv alias with umask support
create_with_contenv_alias() {
if [[ -f /command/with-contenv ]]; then
echo "[mod-init] /command/with-contenv not found, skipping alias creation"
return
fi
rm -rf /usr/bin/with-contenv
cat <<-EOF >/usr/bin/with-contenv
#!/bin/bash
if [[ -f /run/s6/container_environment/UMASK ]] &&
{ [[ "$(pwdx \$\$)" =~ "/run/s6/legacy-services/" ]] ||
[[ "$(pwdx \$\$)" =~ "/run/s6/services/" ]] ||
[[ "$(pwdx \$\$)" =~ "/servicedirs/svc-" ]]; }; then
umask "$(cat /run/s6/container_environment/UMASK)"
fi
exec /command/with-contenv "\$@"
EOF
chmod +x /usr/bin/with-contenv
}
# Check for curl # Check for curl
curl_check() { curl_check() {
if [[ ! -f /usr/bin/curl ]] || [[ ! -f /usr/bin/jq ]]; then if [[ ! -f /usr/bin/curl ]] || [[ ! -f /usr/bin/jq ]]; then
echo "[mod-init] Curl/JQ was not found on this system for Docker mods installing" echo "[mod-init] Curl/JQ was not found on this system for Docker mods installing"
if [[ -f /usr/bin/apt ]]; then if [[ -f /usr/bin/apt ]]; then
## Ubuntu # Ubuntu
export DEBIAN_FRONTEND="noninteractive" export DEBIAN_FRONTEND="noninteractive"
apt-get update apt-get update
apt-get install --no-install-recommends -y \ apt-get install --no-install-recommends -y \
@@ -238,3 +257,4 @@ fi
set_legacy_executable_bits set_legacy_executable_bits
create_lsiown_alias create_lsiown_alias
create_with_contenv_alias