mirror of
https://github.com/TheBinaryNinja/tvapp2.git
synced 2026-06-04 10:35:40 -04:00
build(s6-overlay): add new build structure
This commit is contained in:
@@ -1 +1 @@
|
|||||||
echo -e " Core : Completed loading container"
|
echo -e " Completed loading container"
|
||||||
|
|||||||
@@ -1,35 +1,160 @@
|
|||||||
#!/usr/bin/with-contenv bash
|
#!/usr/bin/with-contenv bash
|
||||||
# shellcheck shell=bash
|
# shellcheck shell=bash
|
||||||
|
|
||||||
|
# #
|
||||||
|
# defaults
|
||||||
|
# #
|
||||||
|
|
||||||
PUID=${PUID:-911}
|
PUID=${PUID:-911}
|
||||||
PGID=${PGID:-911}
|
PGID=${PGID:-911}
|
||||||
|
DIR_BUILD=${DIR_BUILD:-/usr/src/app}
|
||||||
|
DIR_RUN=${DIR_RUN:-/usr/bin/app}
|
||||||
|
bHasError=false
|
||||||
|
|
||||||
|
# #
|
||||||
|
# define > colors
|
||||||
|
#
|
||||||
|
# Use the color table at:
|
||||||
|
# - https://gist.github.com/fnky/458719343aabd01cfb17a3a4f7296797
|
||||||
|
# #
|
||||||
|
|
||||||
|
declare -A c=(
|
||||||
|
[end]=$'\e[0m'
|
||||||
|
[white]=$'\e[97m'
|
||||||
|
[bold]=$'\e[1m'
|
||||||
|
[dim]=$'\e[2m'
|
||||||
|
[underline]=$'\e[4m'
|
||||||
|
[strike]=$'\e[9m'
|
||||||
|
[blink]=$'\e[5m'
|
||||||
|
[inverted]=$'\e[7m'
|
||||||
|
[hidden]=$'\e[8m'
|
||||||
|
[black]=$'\e[0;30m'
|
||||||
|
[redl]=$'\e[0;91m'
|
||||||
|
[redd]=$'\e[0;31m'
|
||||||
|
[magental]=$'\e[0;95m'
|
||||||
|
[magentad]=$'\e[0;35mm'
|
||||||
|
[bluel]=$'\e[0;94m'
|
||||||
|
[blued]=$'\e[0;34m'
|
||||||
|
[cyanl]=$'\e[0;96m'
|
||||||
|
[cyand]=$'\e[0;36m'
|
||||||
|
[greenl]=$'\e[0;92m'
|
||||||
|
[greend]=$'\e[0;32m'
|
||||||
|
[yellowl]=$'\e[0;93m'
|
||||||
|
[yellowd]=$'\e[0;33m'
|
||||||
|
[greyl]=$'\e[0;37m'
|
||||||
|
[greyd]=$'\e[0;90m'
|
||||||
|
[navy]=$'\e[38;5;62m'
|
||||||
|
[olive]=$'\e[38;5;144m'
|
||||||
|
[peach]=$'\e[38;5;210m'
|
||||||
|
)
|
||||||
|
|
||||||
|
# #
|
||||||
|
# unicode for emojis
|
||||||
|
# https://apps.timwhitlock.info/emoji/tables/unicode
|
||||||
|
# #
|
||||||
|
|
||||||
|
declare -A icon=(
|
||||||
|
["symbolic link"]=$'\xF0\x9F\x94\x97' # 🔗
|
||||||
|
["regular file"]=$'\xF0\x9F\x93\x84' # 📄
|
||||||
|
["directory"]=$'\xF0\x9F\x93\x81' # 📁
|
||||||
|
["regular empty file"]=$'\xe2\xad\x95' # ⭕
|
||||||
|
["log"]=$'\xF0\x9F\x93\x9C' # 📜
|
||||||
|
["1"]=$'\xF0\x9F\x93\x9C' # 📜
|
||||||
|
["2"]=$'\xF0\x9F\x93\x9C' # 📜
|
||||||
|
["3"]=$'\xF0\x9F\x93\x9C' # 📜
|
||||||
|
["4"]=$'\xF0\x9F\x93\x9C' # 📜
|
||||||
|
["5"]=$'\xF0\x9F\x93\x9C' # 📜
|
||||||
|
["pem"]=$'\xF0\x9F\x94\x92' # 🔑
|
||||||
|
["pub"]=$'\xF0\x9F\x94\x91' # 🔒
|
||||||
|
["pfx"]=$'\xF0\x9F\x94\x92' # 🔑
|
||||||
|
["p12"]=$'\xF0\x9F\x94\x92' # 🔑
|
||||||
|
["key"]=$'\xF0\x9F\x94\x91' # 🔒
|
||||||
|
["crt"]=$'\xF0\x9F\xAA\xAA ' # 🪪
|
||||||
|
["gz"]=$'\xF0\x9F\x93\xA6' # 📦
|
||||||
|
["zip"]=$'\xF0\x9F\x93\xA6' # 📦
|
||||||
|
["gzip"]=$'\xF0\x9F\x93\xA6' # 📦
|
||||||
|
["deb"]=$'\xF0\x9F\x93\xA6' # 📦
|
||||||
|
["sh"]=$'\xF0\x9F\x97\x94' # 🗔
|
||||||
|
)
|
||||||
|
|
||||||
|
# #
|
||||||
|
# get container ips
|
||||||
|
# #
|
||||||
|
|
||||||
IP_GATEWAY=$(/sbin/ip route|awk '/default/ { print $3 }')
|
IP_GATEWAY=$(/sbin/ip route|awk '/default/ { print $3 }')
|
||||||
IP_CONTAINER=$(ifconfig | grep -Eo 'inet (addr:)?([0-9]*\.){3}[0-9]*' | grep -Eo '([0-9]*\.){3}[0-9]*' | grep -v '127.0.0.1')
|
IP_CONTAINER=$(ifconfig | grep -Eo 'inet (addr:)?([0-9]*\.){3}[0-9]*' | grep -Eo '([0-9]*\.){3}[0-9]*' | grep -v '127.0.0.1')
|
||||||
|
|
||||||
|
# #
|
||||||
|
# usermod
|
||||||
|
# -o, --non-unique allow using duplicate (non-unique) UID
|
||||||
|
# -g, --gid GROUP force use GROUP as new primary group
|
||||||
|
# -G, --groups GROUPS new list of supplementary GROUPS
|
||||||
|
# -u, --uid UID new UID for the user account
|
||||||
|
# -U, --unlock unlock the user account
|
||||||
|
#
|
||||||
|
# groupmod
|
||||||
|
# -g, --gid GID change the group ID to GID
|
||||||
|
# -o, --non-unique allow to use a duplicate (non-unique) GID
|
||||||
|
# #
|
||||||
|
|
||||||
if [[ -z ${TVAPP_READ_ONLY_FS} ]] && [[ -z ${TVAPP_NON_ROOT_USER} ]]; then
|
if [[ -z ${TVAPP_READ_ONLY_FS} ]] && [[ -z ${TVAPP_NON_ROOT_USER} ]]; then
|
||||||
groupmod -o -g "$PGID" dockerx
|
groupmod -o -g "$PGID" dockerx
|
||||||
usermod -o -u "$PUID" dockerx
|
usermod -o -u "$PUID" dockerx
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if { [[ -z ${TVAPP_READ_ONLY_FS} ]] && [[ -z ${TVAPP_NON_ROOT_USER} ]]; } || [[ ! ${TVAPP_FIRST_PARTY} = "true" ]]; then
|
# #
|
||||||
cat /etc/s6-overlay/s6-rc.d/init-adduser/branding
|
# s6 > branding
|
||||||
else
|
# #
|
||||||
cat /run/branding
|
|
||||||
fi
|
printf '%-1s\n' " ${c[greyd]}──────────────────────────────────────────────────────────────────────────────────────────${c[end]}"
|
||||||
|
printf '%-1s\n' " ${c[greyd]} TVApp2 Docker Image${c[end]}"
|
||||||
|
printf '%-1s\n' " ${c[greyd]}──────────────────────────────────────────────────────────────────────────────────────────${c[end]}"
|
||||||
|
|
||||||
|
printf '%-2s\n' " ${c[greyd]}The TvApp2 image allows you to fetch M3U playlist and EPG data for numerous IPTV ${c[end]}"
|
||||||
|
printf '%-2s\n' " ${c[greyd]}services online. ${c[end]}"
|
||||||
|
echo -e
|
||||||
|
printf '%-2s\n' " ${c[greyd]}Once the files are fetched by the image, you can visit the self-hosted webpage, copy ${c[end]}"
|
||||||
|
printf '%-2s\n' " ${c[greyd]}the links to the M3U and EPG files; and add them to your favorite IPTV app such as ${c[end]}"
|
||||||
|
printf '%-2s\n' " ${c[greyd]}Jellyfin, Plex, or Emby. ${c[end]}"
|
||||||
|
echo -e
|
||||||
|
printf '%-2s\n' " ${c[greyd]}For more information about this project; visit the links below. This app is served on ${c[end]}"
|
||||||
|
printf '%-2s\n' " ${c[greyd]}multiple repositories as backup. Use any of the repo links below: ${c[end]}"
|
||||||
|
echo -e
|
||||||
|
printf '%-6s %-35s %-65s\n' "" " ${c[greenl]}TVApp2 Repo 1${c[end]}" "${c[end]}https://github.com/TheBinaryNinja/tvapp2 ${c[end]}"
|
||||||
|
printf '%-6s %-35s %-65s\n' "" " ${c[greenl]}TVApp2 Repo 2${c[end]}" "${c[end]}https://git.binaryninja.net/BinaryNinja/tvapp2 ${c[end]}"
|
||||||
|
printf '%-6s %-35s %-65s\n' "" " ${c[greenl]}Base Alpine Image${c[end]}" "${c[end]}https://github.com/Aetherinox/docker-base-alpine ${c[end]}"
|
||||||
|
echo -e
|
||||||
|
|
||||||
|
printf '%-2s\n' " ${c[greyd]}If you are making this container available on a public-facing domain, please consider ${c[end]}"
|
||||||
|
printf '%-2s\n' " ${c[greyd]}using Traefik and Authentik to protect this container from outside access. Your M3U ${c[end]}"
|
||||||
|
printf '%-2s\n' " ${c[greyd]}and EPG files will be available for the public to download and use. ${c[end]}"
|
||||||
|
|
||||||
|
# if { [[ -z ${TVAPP_READ_ONLY_FS} ]] && [[ -z ${TVAPP_NON_ROOT_USER} ]]; } || [[ ! ${TVAPP_FIRST_PARTY} = "true" ]]; then
|
||||||
|
# cat /etc/s6-overlay/s6-rc.d/init-adduser/branding
|
||||||
|
# else
|
||||||
|
# cat /run/branding
|
||||||
|
# fi
|
||||||
|
|
||||||
|
# #
|
||||||
|
# branding > non-root user
|
||||||
|
# #
|
||||||
|
|
||||||
if [[ -z ${TVAPP_NON_ROOT_USER} ]]; then
|
if [[ -z ${TVAPP_NON_ROOT_USER} ]]; then
|
||||||
echo ""
|
echo -e
|
||||||
echo " User:Group $(id -u dockerx):$(id -g dockerx)"
|
printf '%-6s %-35s %-65s\n' "" " ${c[greenl]}User:Group${c[end]}" "${c[end]}$(id -u dockerx):$(id -g dockerx)${c[end]}"
|
||||||
else
|
else
|
||||||
echo " User:Group $(stat /run -c %u):$(stat /run -c %g)"
|
printf '%-6s %-35s %-65s\n' "" " ${c[greenl]}User:Group${c[end]}" "${c[end]}$(stat /run -c %u):$(stat /run -c %g)${c[end]}"
|
||||||
fi
|
fi
|
||||||
echo " Port(s) $(echo $WEB_PORT)"
|
printf '%-6s %-35s %-65s\n' "" " ${c[greenl]}Port(s)${c[end]}" "${c[end]}$(echo $WEB_PORT)${c[end]}"
|
||||||
echo " Gateway $(echo $IP_GATEWAY)"
|
printf '%-6s %-35s %-65s\n' "" " ${c[greenl]}Gateway${c[end]}" "${c[end]}$(echo $IP_GATEWAY)${c[end]}"
|
||||||
echo " Web Server $(echo $IP_CONTAINER:$WEB_PORT)"
|
printf '%-6s %-35s %-65s\n' "" " ${c[greenl]}Web Server${c[end]}" "${c[end]}$(echo $IP_CONTAINER:$WEB_PORT)${c[end]}"
|
||||||
echo " App Folder $(echo $DIR_RUN)"
|
printf '%-6s %-35s %-65s\n' "" " ${c[greenl]}App Folder${c[end]}" "${c[end]}$(echo $DIR_RUN)${c[end]}"
|
||||||
echo ""
|
echo -e
|
||||||
echo '──────────────────────────────────────────────────────────────────────────────────────────'
|
printf '%-1s\n' " ${c[greyd]}──────────────────────────────────────────────────────────────────────────────────────────${c[end]}"
|
||||||
|
|
||||||
|
# #
|
||||||
|
# set permissions
|
||||||
|
# #
|
||||||
|
|
||||||
if [[ -z ${TVAPP_READ_ONLY_FS} ]] && [[ -z ${TVAPP_NON_ROOT_USER} ]]; then
|
if [[ -z ${TVAPP_READ_ONLY_FS} ]] && [[ -z ${TVAPP_NON_ROOT_USER} ]]; then
|
||||||
aetherxown dockerx:dockerx /app
|
aetherxown dockerx:dockerx /app
|
||||||
|
|||||||
@@ -1,22 +1,88 @@
|
|||||||
#!/usr/bin/with-contenv bash
|
#!/usr/bin/with-contenv bash
|
||||||
# shellcheck shell=bash
|
# shellcheck shell=bash
|
||||||
|
|
||||||
|
# #
|
||||||
|
# define > colors
|
||||||
|
#
|
||||||
|
# Use the color table at:
|
||||||
|
# - https://gist.github.com/fnky/458719343aabd01cfb17a3a4f7296797
|
||||||
|
# #
|
||||||
|
|
||||||
|
declare -A c=(
|
||||||
|
[end]=$'\e[0m'
|
||||||
|
[white]=$'\e[97m'
|
||||||
|
[bold]=$'\e[1m'
|
||||||
|
[dim]=$'\e[2m'
|
||||||
|
[underline]=$'\e[4m'
|
||||||
|
[strike]=$'\e[9m'
|
||||||
|
[blink]=$'\e[5m'
|
||||||
|
[inverted]=$'\e[7m'
|
||||||
|
[hidden]=$'\e[8m'
|
||||||
|
[black]=$'\e[0;30m'
|
||||||
|
[redl]=$'\e[0;91m'
|
||||||
|
[redd]=$'\e[0;31m'
|
||||||
|
[magental]=$'\e[0;95m'
|
||||||
|
[magentad]=$'\e[0;35mm'
|
||||||
|
[bluel]=$'\e[0;94m'
|
||||||
|
[blued]=$'\e[0;34m'
|
||||||
|
[cyanl]=$'\e[0;96m'
|
||||||
|
[cyand]=$'\e[0;36m'
|
||||||
|
[greenl]=$'\e[0;92m'
|
||||||
|
[greend]=$'\e[0;32m'
|
||||||
|
[yellowl]=$'\e[0;93m'
|
||||||
|
[yellowd]=$'\e[0;33m'
|
||||||
|
[greyl]=$'\e[0;37m'
|
||||||
|
[greyd]=$'\e[0;90m'
|
||||||
|
[navy]=$'\e[38;5;62m'
|
||||||
|
[olive]=$'\e[38;5;144m'
|
||||||
|
[peach]=$'\e[38;5;210m'
|
||||||
|
)
|
||||||
|
|
||||||
|
# #
|
||||||
|
# unicode for emojis
|
||||||
|
# https://apps.timwhitlock.info/emoji/tables/unicode
|
||||||
|
# #
|
||||||
|
|
||||||
|
declare -A icon=(
|
||||||
|
["symbolic link"]=$'\xF0\x9F\x94\x97' # 🔗
|
||||||
|
["regular file"]=$'\xF0\x9F\x93\x84' # 📄
|
||||||
|
["directory"]=$'\xF0\x9F\x93\x81' # 📁
|
||||||
|
["regular empty file"]=$'\xe2\xad\x95' # ⭕
|
||||||
|
["log"]=$'\xF0\x9F\x93\x9C' # 📜
|
||||||
|
["1"]=$'\xF0\x9F\x93\x9C' # 📜
|
||||||
|
["2"]=$'\xF0\x9F\x93\x9C' # 📜
|
||||||
|
["3"]=$'\xF0\x9F\x93\x9C' # 📜
|
||||||
|
["4"]=$'\xF0\x9F\x93\x9C' # 📜
|
||||||
|
["5"]=$'\xF0\x9F\x93\x9C' # 📜
|
||||||
|
["pem"]=$'\xF0\x9F\x94\x92' # 🔑
|
||||||
|
["pub"]=$'\xF0\x9F\x94\x91' # 🔒
|
||||||
|
["pfx"]=$'\xF0\x9F\x94\x92' # 🔑
|
||||||
|
["p12"]=$'\xF0\x9F\x94\x92' # 🔑
|
||||||
|
["key"]=$'\xF0\x9F\x94\x91' # 🔒
|
||||||
|
["crt"]=$'\xF0\x9F\xAA\xAA ' # 🪪
|
||||||
|
["gz"]=$'\xF0\x9F\x93\xA6' # 📦
|
||||||
|
["zip"]=$'\xF0\x9F\x93\xA6' # 📦
|
||||||
|
["gzip"]=$'\xF0\x9F\x93\xA6' # 📦
|
||||||
|
["deb"]=$'\xF0\x9F\x93\xA6' # 📦
|
||||||
|
["sh"]=$'\xF0\x9F\x97\x94' # 🗔
|
||||||
|
)
|
||||||
|
|
||||||
# Directories
|
# Directories
|
||||||
SCRIPTS_DIR="/custom-cont-init.d"
|
SCRIPTS_DIR="/custom-cont-init.d"
|
||||||
|
|
||||||
# Make sure custom init directory exists and has files in it
|
# Make sure custom init directory exists and has files in it
|
||||||
if [[ -e "${SCRIPTS_DIR}" ]] && [[ -n "$(/bin/ls -A ${SCRIPTS_DIR} 2>/dev/null)" ]]; then
|
if [[ -e "${SCRIPTS_DIR}" ]] && [[ -n "$(/bin/ls -A ${SCRIPTS_DIR} 2>/dev/null)" ]]; then
|
||||||
echo -e " Loader : Plugins found, loading them ..."
|
printf '%-29s %-65s\n' " ${c[bluel]}Loader${c[end]}" "${c[end]}Loading any found plugins${c[end]}"
|
||||||
for SCRIPT in "${SCRIPTS_DIR}"/*; do
|
for SCRIPT in "${SCRIPTS_DIR}"/*; do
|
||||||
NAME="$(basename "${SCRIPT}")"
|
NAME="$(basename "${SCRIPT}")"
|
||||||
if [[ -f "${SCRIPT}" ]]; then
|
if [[ -f "${SCRIPT}" ]]; then
|
||||||
echo -e " Loader : Executing ..."
|
printf '%-29s %-65s\n' " ${c[bluel]}Loader${c[end]}" "${c[end]}Executing${c[end]}"
|
||||||
/bin/bash "${SCRIPT}"
|
/bin/bash "${SCRIPT}"
|
||||||
echo -e " Loader : ${NAME}: Ran Successfully with code [$?]"
|
printf '%-29s %-65s\n' " ${c[bluel]}Loader${c[end]}" "${c[end]}Successfully ran with code ${c[bluel]}[$?]${c[end]}"
|
||||||
elif [[ ! -f "${SCRIPT}" ]]; then
|
elif [[ ! -f "${SCRIPT}" ]]; then
|
||||||
echo -e " Loader : ${NAME}: Not a valid file"
|
printf '%-29s %-65s\n' " ${c[bluel]}Loader${c[end]}" "${c[end]}${c[bluel]}${NAME}${c[end]} is not a valid file${c[end]}"
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
else
|
else
|
||||||
echo -e " Loader : No Plugins found, skipping..."
|
printf '%-29s %-65s\n' " ${c[bluel]}Loader${c[end]}" "${c[end]}No plugins found; skipping${c[end]}"
|
||||||
fi
|
fi
|
||||||
|
|||||||
Reference in New Issue
Block a user