mirror of
https://github.com/tuxbox-neutrino/docker-buildenv.git
synced 2025-08-26 13:12:42 +02:00
Compare commits
10 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
dd6c8e26fe | ||
|
8c49c7b40e | ||
|
6e45f86dbf | ||
|
7ab5a410d3 | ||
|
f823e7e8ee | ||
|
f4acd5ed70 | ||
|
c7aa3570ca | ||
|
45702ac6d8 | ||
|
48409fb5af | ||
|
038479cf71 |
33
.env.sample
33
.env.sample
@@ -1,33 +0,0 @@
|
||||
BUILDENV_GIT_URL=https://github.com/tuxbox-neutrino/buildenv.git
|
||||
BUILDENV_VERSION=3.2.4
|
||||
BUILDENV_PREFIX=buildenv
|
||||
TB_BUILD_TIME=
|
||||
DISPLAY=:0
|
||||
ENABLE_UI_TOOLS=false
|
||||
GIT_EMAIL=${USER}@localhost
|
||||
GIT_USER=${USER}
|
||||
HISTFILE=/home/${USER}/tuxbox/.data/.bash_history
|
||||
HISTFILE_NAME=.bash_history
|
||||
HOST_PREFIX=tuxbox
|
||||
LANGUAGE=de_DE.UTF-8
|
||||
LC_ALL=de_DE.UTF-8
|
||||
LOCALE_LANG=de_DE.UTF-8
|
||||
LOCAL_HOSTNAME=localhost
|
||||
NVIDIA_VISIBLE_DEVICES=all
|
||||
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
|
||||
QT_QUICK_BACKEND=software
|
||||
QT_XCB_GL_INTEGRATION=xcb_egl
|
||||
START_PATH=/home/${USER}/tuxbox/buildenv
|
||||
TERM=xterm-256color
|
||||
TZ=Europe/Berlin
|
||||
USER=${USER}
|
||||
USER_DIR=/home/${USER}
|
||||
USER_GROUP=${USER}
|
||||
USER_GROUP_ID=1000
|
||||
USER_ID=1000
|
||||
USER_PASSWORD=${USER}
|
||||
USER_VOLUME_WORKDIR=/home/${USER}/tuxbox
|
||||
USER_VOLUME_DATADIR=/home/${USER}/tuxbox/.data
|
||||
TB_VERSION=
|
||||
XDG_CONFIG_HOME=/home
|
||||
XDG_RUNTIME_DIR=/tmp/runtime-root
|
25
.github/scripts/translate.py
vendored
25
.github/scripts/translate.py
vendored
@@ -1,25 +0,0 @@
|
||||
from googletrans import Translator
|
||||
|
||||
def translate_readme(input_text, target_lang):
|
||||
translator = Translator()
|
||||
translated = translator.translate(input_text, dest=target_lang)
|
||||
translated_text = translated.text
|
||||
|
||||
# add hint for automatically translation
|
||||
translated_text = f"Note: This is an automatically translated file. Original content from [here](https://github.com/tuxbox-neutrino/docker-buildenv/blob/master/README-de.md):\n\n{translated_text}"
|
||||
|
||||
# Use this workaround, because translater breaks some links and anchors
|
||||
translated_text = translated_text.replace("[Build Image](#Build Image)", "[Build Image](#build-image)")
|
||||
translated_text = translated_text.replace("devtool -reference.html", "devtool-reference.html")
|
||||
translated_text = translated_text.replace("dev-manual -common-tasks.html", "dev-manual-common-tasks.html")
|
||||
translated_text = translated_text.replace("Clone #1-Init-Script", "#1-clone-init-script")
|
||||
|
||||
return translated_text
|
||||
|
||||
if __name__ == "__main__":
|
||||
input_text = open("README-de.md", "r").read()
|
||||
target_lang = "en" # target language is english
|
||||
translated_text = translate_readme(input_text, target_lang)
|
||||
|
||||
with open("README-en.md", "w") as outfile:
|
||||
outfile.write(translated_text)
|
63
.github/workflows/readme.yml
vendored
63
.github/workflows/readme.yml
vendored
@@ -1,11 +1,17 @@
|
||||
name: Translate README
|
||||
name: Translate README and tag repository
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
paths:
|
||||
- 'README-de.md'
|
||||
- 'README_de.md'
|
||||
- 'create-env.sh'
|
||||
- 'docker-compose-wrapper'
|
||||
- 'docker-compose.yml'
|
||||
- 'Dockerfile'
|
||||
paths-ignore:
|
||||
- '.github/**'
|
||||
|
||||
permissions:
|
||||
contents: write
|
||||
@@ -16,27 +22,66 @@ jobs:
|
||||
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v2
|
||||
uses: actions/checkout@v3
|
||||
|
||||
- name: Setup Python
|
||||
uses: actions/setup-python@v2
|
||||
uses: actions/setup-python@v3
|
||||
with:
|
||||
python-version: 3.x
|
||||
|
||||
- name: Install dependencies
|
||||
- name: Install translate dependencies
|
||||
run: |
|
||||
python -m pip install --upgrade pip
|
||||
pip install --upgrade googletrans==3.1.0a0
|
||||
curl -o translate-md.py https://raw.githubusercontent.com/dbt1/translate-md/refs/heads/master/translate-md.py
|
||||
chmod 755 translate-md.py
|
||||
curl -o translate-md-config.json https://raw.githubusercontent.com/dbt1/translate-md/refs/heads/master/translate-md-config.json.sample
|
||||
|
||||
- name: Verify translate-md.py download
|
||||
run: |
|
||||
if [ ! -f translate-md.py ]; then
|
||||
echo "translate-md.py was not downloaded!"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
- name: Translate README
|
||||
run: |
|
||||
python .github/scripts/translate.py
|
||||
cp README_de.md template.md
|
||||
python translate-md.py --template-md template.md --output-dir . --prefix README_ --main-doc README.md -c translate-md-config.json -s de
|
||||
rm template.md
|
||||
|
||||
- name: Prepare Git user data
|
||||
run: |
|
||||
git config --global user.email "dbt@novatux.de"
|
||||
git config --global user.name "Thilo Graf"
|
||||
|
||||
- name: Commit and push translated README
|
||||
run: |
|
||||
git config --global user.email "actions@github.com"
|
||||
git config --global user.name "GitHub Actions"
|
||||
git add README-en.md
|
||||
git add README*.md
|
||||
git commit -m "readme: Automatically translated README"
|
||||
git push
|
||||
|
||||
- name: Install tagit dependencies
|
||||
run: |
|
||||
pip install GitPython
|
||||
curl -o tagit.py https://raw.githubusercontent.com/dbt1/tagit/master/tagit.py
|
||||
curl -o tagit-config.json https://raw.githubusercontent.com/dbt1/tagit/master/tagit-config.json
|
||||
chmod +x tagit.py
|
||||
|
||||
- name: Verify tagit.py download
|
||||
run: |
|
||||
if [ ! -f tagit.py ]; then
|
||||
echo "tagit.py was not downloaded!"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
- name: Tagging
|
||||
run: |
|
||||
python tagit.py -f Makefile
|
||||
|
||||
- name: Commit and push version and tag changes
|
||||
run: |
|
||||
git add Makefile
|
||||
git commit -m "tagging: Automatically updated tags [skip ci]" || echo "No changes to commit"
|
||||
git push
|
||||
git push --tags
|
4
.gitignore
vendored
4
.gitignore
vendored
@@ -3,5 +3,7 @@
|
||||
|
||||
.gitconfig
|
||||
.directory
|
||||
init.sh
|
||||
|
||||
*-swp
|
||||
env_backups
|
||||
venv
|
276
Dockerfile
276
Dockerfile
@@ -1,196 +1,174 @@
|
||||
## Use the official Debian 11 image based up debian:bullseye-slim as a base
|
||||
FROM dbt1/debian-tuxbox-base:latest
|
||||
# Dockerfile for Debian-based Tuxbox build environment
|
||||
FROM dbt1/debian-tuxbox-base:v1.6
|
||||
|
||||
### Args
|
||||
ARG PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
|
||||
## Build arguments from docker-compose ##
|
||||
|
||||
# Internal information
|
||||
ARG DOCKER_BUILDENV_VERSION=${DOCKER_BUILDENV_VERSION}
|
||||
ARG DOCKER_BUILDENV_GIT_URL=$DOCKER_BUILDENV_GIT_URL
|
||||
|
||||
# URL to buildenv sources and where to install
|
||||
ARG BUILDENV_GIT_URL=${BUILDENV_GIT_URL}
|
||||
ARG BUILDENV_VERSION=${BUILDENV_VERSION}
|
||||
ARG BUILDENV_PREFIX=${BUILDENV_PREFIX}
|
||||
ARG TB_BUILD_TIME=${TB_BUILD_TIME}
|
||||
|
||||
# User and group
|
||||
ARG USER_NAME=${USER_NAME}
|
||||
ARG USER_ID=${USER_ID}
|
||||
ARG USER_GROUP=${USER_GROUP}
|
||||
ARG USER_GROUP_ID=${USER_GROUP_ID}
|
||||
ARG USER_PASSWORD=${USER_PASSWORD}
|
||||
ARG USER_DIR=${USER_DIR}
|
||||
|
||||
# More build args
|
||||
ARG DISPLAY=${DISPLAY}
|
||||
ARG ENABLE_UI_TOOLS=false
|
||||
ARG ENABLE_UI_TOOLS=${ENABLE_UI_TOOLS}
|
||||
ARG GIT_EMAIL=${GIT_EMAIL}
|
||||
ARG GIT_USER=${GIT_USER}
|
||||
ARG USER_GROUP_ID=${USER_GROUP_ID}
|
||||
ARG HISTFILE_NAME=${HISTFILE_NAME}
|
||||
ARG HISTFILE=${HISTFILE}
|
||||
ARG HOST_PREFIX=${HOST_PREFIX}
|
||||
ARG LOCALE_LANG=${LOCALE_LANG}
|
||||
ARG BUILDENV_INSTALL_PREFIX=${BUILDENV_INSTALL_PREFIX}
|
||||
ARG LOCAL_HOSTNAME=${LOCAL_HOSTNAME}
|
||||
ARG LOCALE_LANG=${LOCALE_LANG}
|
||||
ARG TZ=${TZ}
|
||||
ARG TERM=${TERM}
|
||||
ARG NVIDIA_VISIBLE_DEVICES=${NVIDIA_VISIBLE_DEVICES}
|
||||
ARG QT_QUICK_BACKEND=${QT_QUICK_BACKEND}
|
||||
ARG QT_XCB_GL_INTEGRATION=${QT_XCB_GL_INTEGRATION}
|
||||
ARG USER_VOLUME_WORKDIR=${USER_VOLUME_WORKDIR}
|
||||
ARG USER_VOLUME_DATADIR=${USER_VOLUME_DATADIR}
|
||||
ARG START_PATH=${START_PATH}
|
||||
ARG TERM=${TERM}
|
||||
ARG TZ=${TZ}
|
||||
ARG USER=${USER}
|
||||
ARG USER_DIR=${USER_DIR}
|
||||
ARG USER_GROUP=${USER_GROUP}
|
||||
ARG USER_ID=${USER_ID}
|
||||
ARG USER_PASSWORD=${USER_PASSWORD}
|
||||
ARG USER_VOLUME_WORKDIR=${USER_DIR}/${HOST_PREFIX}
|
||||
ARG TB_VERSION=${TB_VERSION}
|
||||
ARG WWW_DOCDIR=${WWW_DOCDIR}
|
||||
ARG EXPLORER_ENABLE=${EXPLORER_ENABLE}
|
||||
ARG EXPLORER_GIT_URL=${EXPLORER_GIT_URL}
|
||||
ARG XDG_CONFIG_HOME=${XDG_CONFIG_HOME}
|
||||
ARG XDG_RUNTIME_DIR=${XDG_RUNTIME_DIR}
|
||||
|
||||
## Add the user with default password
|
||||
# Convert ARG to ENV for runtime usage
|
||||
ENV DOCKER_BUILDENV_VERSION=${DOCKER_BUILDENV_VERSION}
|
||||
ENV DISPLAY=${DISPLAY}
|
||||
ENV DOCKER_BUILDENV_GIT_URL=$DOCKER_BUILDENV_GIT_URL
|
||||
ENV BUILDENV_GIT_URL=$BUILDENV_GIT_URL
|
||||
ENV ENABLE_UI_TOOLS=${ENABLE_UI_TOOLS}
|
||||
ENV GIT_EMAIL=${GIT_EMAIL}
|
||||
ENV GIT_USER=${GIT_USER}
|
||||
ENV HISTFILE_NAME=${HISTFILE_NAME}
|
||||
ENV HISTFILE=${HISTFILE}
|
||||
ENV BUILDENV_INSTALL_PREFIX=${BUILDENV_INSTALL_PREFIX}
|
||||
ENV LOCAL_HOSTNAME=${LOCAL_HOSTNAME}
|
||||
ENV LOCALE_LANG=${LOCALE_LANG}
|
||||
ENV TZ=${TZ}
|
||||
ENV TERM=${TERM}
|
||||
ENV NVIDIA_VISIBLE_DEVICES=${NVIDIA_VISIBLE_DEVICES}
|
||||
ENV QT_QUICK_BACKEND=${QT_QUICK_BACKEND}
|
||||
ENV QT_XCB_GL_INTEGRATION=${QT_XCB_GL_INTEGRATION}
|
||||
ENV USER=${USER_NAME}
|
||||
ENV USER_ID=${USER_ID}
|
||||
ENV USER_GROUP=${USER_GROUP}
|
||||
ENV USER_GROUP_ID=${USER_GROUP_ID}
|
||||
ENV USER_PASSWORD=${USER_PASSWORD}
|
||||
ENV USER_DIR=${USER_DIR}
|
||||
ENV USER_VOLUME_WORKDIR=${USER_VOLUME_WORKDIR}
|
||||
ENV USER_VOLUME_DATADIR=${USER_VOLUME_DATADIR}
|
||||
ENV START_PATH=${START_PATH}
|
||||
ENV WWW_DOCDIR=${WWW_DOCDIR}
|
||||
ENV EXPLORER_ENABLE=${EXPLORER_ENABLE}
|
||||
ENV EXPLORER_GIT_URL=${EXPLORER_GIT_URL}
|
||||
ENV XDG_CONFIG_HOME=${XDG_CONFIG_HOME}
|
||||
ENV XDG_RUNTIME_DIR=${XDG_RUNTIME_DIR}
|
||||
|
||||
# Create user and group
|
||||
RUN groupadd -g "${USER_GROUP_ID}" "${USER_GROUP}" && \
|
||||
useradd -m -u "${USER_ID}" -g "${USER_GROUP_ID}" -s /bin/bash "${USER}" && \
|
||||
echo "${USER}:${USER_PASSWORD}" | chpasswd
|
||||
|
||||
## Set the desired Locale
|
||||
RUN locale-gen ${LOCALE_LANG} && \
|
||||
dpkg-reconfigure --frontend=noninteractive locales && \
|
||||
update-locale LANG=${LOCALE_LANG}
|
||||
# Set Locale
|
||||
RUN sed -i "/${LOCALE_LANG}/s/^# //g" /etc/locale.gen && \
|
||||
locale-gen ${LOCALE_LANG} && \
|
||||
update-locale LANG="${LOCALE_LANG}"
|
||||
|
||||
### Some labels
|
||||
LABEL maintainer="Thilo Graf <dbt@novatux.de>" \
|
||||
maintainer.org="tuxbox-neutrino" \
|
||||
maintainer.org.uri="https://tuxbox-neutrino.org" \
|
||||
com.tuxbox-neutrino.project.repo.type="git" \
|
||||
com.tuxbox-neutrino.project.repo.uri="https://github.com/dbt1/docker-tuxbox-build" \
|
||||
com.tuxbox-neutrino.project.repo.issues="https://github.com/dbt1/docker-tuxbox-build/issues" \
|
||||
com.tuxbox-neutrino.app.docker-tuxbox-build.version="${TB_VERSION}" \
|
||||
# Open container labels
|
||||
org.opencontainers.image.created="${TB_BUILD_TIME}" \
|
||||
org.opencontainers.image.description="Debian based" \
|
||||
org.opencontainers.image.vendor="tuxbox-neutrino" \
|
||||
org.opencontainers.image.source="https://github.com/dbt1/docker-tuxbox-build" \
|
||||
# Artifact hub annotations
|
||||
io.artifacthub.package.readme-url="https://github.com/dbt1/docker-tuxbox-build/blob/master/README.md" \
|
||||
io.artifacthub.package.logo-url="https://avatars.githubusercontent.com/u/22789022?s=200&v=4"
|
||||
|
||||
### ui package experimental atm
|
||||
RUN if [ "$ENABLE_UI_TOOLS" = "true" ]; then \
|
||||
apt-get update && apt-get install -y --no-install-recommends \
|
||||
breeze-icon-theme \
|
||||
meld \
|
||||
dbus \
|
||||
kdevelop; \
|
||||
# Install UI tools (if enabled)
|
||||
RUN if [ "${ENABLE_UI_TOOLS}" = "true" ]; then \
|
||||
apt-get update && apt-get install -y --no-install-recommends \
|
||||
breeze-icon-theme \
|
||||
meld \
|
||||
dbus \
|
||||
kdevelop; \
|
||||
fi
|
||||
|
||||
## avoid dbus warn messages
|
||||
ENV NO_AT_BRIDGE=1
|
||||
## Create some basic directories and permissions for X-Server
|
||||
RUN mkdir -p $XDG_RUNTIME_DIR && chown -R root:root $XDG_RUNTIME_DIR && chmod 0700 $XDG_RUNTIME_DIR
|
||||
RUN mkdir -p "${XDG_RUNTIME_DIR}" && chown -R root:root "${XDG_RUNTIME_DIR}" && chmod 0700 "${XDG_RUNTIME_DIR}"
|
||||
|
||||
## Copy welcome message
|
||||
ENV BANNER_FILE=/etc/welcome.txt
|
||||
COPY terminal-splash.txt /etc/terminal-splash.txt
|
||||
COPY files/terminal-splash.txt /etc/terminal-splash.txt
|
||||
RUN cat /etc/terminal-splash.txt > ${BANNER_FILE} && \
|
||||
echo "--------------------------------------------------------------" >> ${BANNER_FILE} && \
|
||||
echo "Tuxbox-Builder Version: ${TB_VERSION}" >> ${BANNER_FILE} && \
|
||||
echo "Tuxbox docker-buildenv: v${DOCKER_BUILDENV_VERSION}" >> ${BANNER_FILE} && \
|
||||
echo "--------------------------------------------------------------" >> ${BANNER_FILE}
|
||||
|
||||
### ssh stuff
|
||||
# ssh service setup
|
||||
ENV SSHD_RUN_SERVICE_DIR="/etc/service/sshd"
|
||||
ENV SSHD_RUN="${SSHD_RUN_SERVICE_DIR}/run"
|
||||
RUN mkdir /var/run/sshd && \
|
||||
RUN mkdir -p /var/run/sshd && \
|
||||
ssh-keygen -A && \
|
||||
mkdir -p ${SSHD_RUN_SERVICE_DIR} && \
|
||||
echo '#!/bin/sh' > ${SSHD_RUN} && \
|
||||
echo 'exec /usr/sbin/sshd -D' >> ${SSHD_RUN} && \
|
||||
chmod 755 ${SSHD_RUN}
|
||||
mkdir -p "${SSHD_RUN_SERVICE_DIR}" && \
|
||||
echo '#!/bin/sh' > "${SSHD_RUN}" && \
|
||||
echo 'exec /usr/sbin/sshd -D' >> "${SSHD_RUN}" && \
|
||||
chmod 755 "${SSHD_RUN}"
|
||||
|
||||
### Set timzone
|
||||
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
|
||||
# Set timezone
|
||||
RUN ln -snf /usr/share/zoneinfo/"${TZ}" /etc/localtime && echo "${TZ}" > /etc/timezone
|
||||
|
||||
## Lighttpd setup and create the runit service for lighttpd
|
||||
ENV LIGHTTPD_RUN="/etc/service/lighttpd/run"
|
||||
# Lighttpd setup
|
||||
RUN apt update && apt install -y php-cgi php-cli php-common php-fpm php-mbstring && \
|
||||
lighty-enable-mod fastcgi && \
|
||||
lighty-enable-mod fastcgi-php && \
|
||||
mkdir -p /run/lighttpd && \
|
||||
chown -R www-data:www-data /run/lighttpd && \
|
||||
chmod -R 755 /run/lighttpd
|
||||
ENV LIGHTTPD_SERVICE_RUN="/etc/service/lighttpd/run"
|
||||
ENV LIGHTTPD_CONFIG_PATH="/config/lighttpd"
|
||||
ENV LIGHTTPD_STD_CONFIG_FILE="${LIGHTTPD_CONFIG_PATH}/lighttpd.conf"
|
||||
ENV LIGHTTPD_ERROR_DOC="404.html"
|
||||
RUN mkdir -p /etc/service/lighttpd && \
|
||||
echo '#!/bin/sh' > ${LIGHTTPD_RUN} && \
|
||||
echo "if [ ! -d ${LIGHTTPD_CONFIG_PATH} ]; then" >> ${LIGHTTPD_RUN} && \
|
||||
echo " mkdir -p ${LIGHTTPD_CONFIG_PATH}" >> ${LIGHTTPD_RUN} && \
|
||||
echo "fi" >> ${LIGHTTPD_RUN} && \
|
||||
echo "" >> ${LIGHTTPD_RUN} && \
|
||||
echo "if [ ! -f ${LIGHTTPD_STD_CONFIG_FILE} ]; then" >> ${LIGHTTPD_RUN} && \
|
||||
echo " cp /etc/lighttpd/lighttpd.conf ${LIGHTTPD_STD_CONFIG_FILE}" >> ${LIGHTTPD_RUN} && \
|
||||
echo " echo 'dir-listing.activate = \"enable\"' >> ${LIGHTTPD_STD_CONFIG_FILE}" >> ${LIGHTTPD_RUN} && \
|
||||
echo " sed -i 's|/var/www/html|${USER_VOLUME_WORKDIR}/${BUILDENV_PREFIX}/dist|' ${LIGHTTPD_STD_CONFIG_FILE}" >> ${LIGHTTPD_RUN} && \
|
||||
echo "fi" >> ${LIGHTTPD_RUN} && \
|
||||
echo "" >> ${LIGHTTPD_RUN} && \
|
||||
echo "exec lighttpd -D -f ${LIGHTTPD_STD_CONFIG_FILE}" >> ${LIGHTTPD_RUN} && \
|
||||
chmod 755 ${LIGHTTPD_RUN}
|
||||
echo '#!/bin/sh' > "${LIGHTTPD_SERVICE_RUN}" && \
|
||||
echo "if [ ! -d ${LIGHTTPD_CONFIG_PATH} ]; then" >> "${LIGHTTPD_SERVICE_RUN}" && \
|
||||
echo " mkdir -p ${LIGHTTPD_CONFIG_PATH}" >> "${LIGHTTPD_SERVICE_RUN}" && \
|
||||
echo "fi" >> "${LIGHTTPD_SERVICE_RUN}" && \
|
||||
echo "" >> "${LIGHTTPD_SERVICE_RUN}" && \
|
||||
echo "if [ ! -f ${LIGHTTPD_STD_CONFIG_FILE} ]; then" >> "${LIGHTTPD_SERVICE_RUN}" && \
|
||||
echo " cp /etc/lighttpd/lighttpd.conf ${LIGHTTPD_STD_CONFIG_FILE}" >> "${LIGHTTPD_SERVICE_RUN}" && \
|
||||
echo " echo 'dir-listing.activate = \"enable\"' >> ${LIGHTTPD_STD_CONFIG_FILE}" >> "${LIGHTTPD_SERVICE_RUN}" && \
|
||||
echo " echo 'server.follow-symlink = \"enable\"' >> ${LIGHTTPD_STD_CONFIG_FILE}" >> "${LIGHTTPD_SERVICE_RUN}" && \
|
||||
echo " echo 'server.error-handler-404 = \"/${LIGHTTPD_ERROR_DOC}\"' >> ${LIGHTTPD_STD_CONFIG_FILE}" >> "${LIGHTTPD_SERVICE_RUN}" && \
|
||||
echo " sed -i 's|/var/www/html|${WWW_DOCDIR}|g' ${LIGHTTPD_STD_CONFIG_FILE}" >> "${LIGHTTPD_SERVICE_RUN}" && \
|
||||
echo "fi" >> "${LIGHTTPD_SERVICE_RUN}" && \
|
||||
echo "" >> "${LIGHTTPD_SERVICE_RUN}" && \
|
||||
echo "exec lighttpd -D -f ${LIGHTTPD_STD_CONFIG_FILE}" >> "${LIGHTTPD_SERVICE_RUN}" && \
|
||||
usermod -aG www-data "${USER}" && \
|
||||
chmod 755 "${LIGHTTPD_SERVICE_RUN}"
|
||||
|
||||
### Start generate content of start script ###
|
||||
# Copy helper scripts
|
||||
COPY files/show-env.sh /usr/local/bin/show-env.sh
|
||||
|
||||
# Set the location of the init script and copy the init script from your project into the image
|
||||
ENV CONTAINER_INIT_SCRIPT="/usr/local/bin/init.sh"
|
||||
RUN echo "#!/bin/bash" > ${CONTAINER_INIT_SCRIPT} && \
|
||||
echo "echo 'Initialize tuxbox-builder container...'" >> ${CONTAINER_INIT_SCRIPT} && \
|
||||
echo "chown -R ${USER}:${USER_GROUP} ${USER_DIR} ${USER_VOLUME_DATADIR}" >> ${CONTAINER_INIT_SCRIPT} && \
|
||||
echo "usermod -aG sudo $USER" >> ${CONTAINER_INIT_SCRIPT}
|
||||
COPY files/init.sh ${CONTAINER_INIT_SCRIPT}
|
||||
RUN chmod +x ${CONTAINER_INIT_SCRIPT}
|
||||
COPY files/.bashrc ${USER_DIR}/.bashrc
|
||||
|
||||
## prepare git config
|
||||
RUN mkdir -p ${XDG_CONFIG_HOME}/git && \
|
||||
echo "echo -e '[user]\\n\\temail = ${GIT_EMAIL}\\n\\tname = ${GIT_USER}' > ${XDG_CONFIG_HOME}/git/config" >> ${CONTAINER_INIT_SCRIPT} && \
|
||||
echo "chown -R ${USER}:${USER_GROUP} ${XDG_CONFIG_HOME}/git" >> ${CONTAINER_INIT_SCRIPT} && \
|
||||
echo "echo " >> ${CONTAINER_INIT_SCRIPT}
|
||||
|
||||
## Prepare buildenv script
|
||||
RUN echo "if [ ! -d ${START_PATH}/.git ]; then" >> ${CONTAINER_INIT_SCRIPT} && \
|
||||
echo " echo Cloning buildenv Repository from ${BUILDENV_GIT_URL}" >> ${CONTAINER_INIT_SCRIPT} && \
|
||||
echo " git clone ${BUILDENV_GIT_URL} /tmp/${BUILDENV_PREFIX}" >> ${CONTAINER_INIT_SCRIPT} && \
|
||||
echo " rsync -a /tmp/${BUILDENV_PREFIX} ${USER_VOLUME_WORKDIR}/" >> ${CONTAINER_INIT_SCRIPT} && \
|
||||
echo " rm -rf ${USER_DIR}/${BUILDENV_PREFIX}/tmp" >> ${CONTAINER_INIT_SCRIPT} && \
|
||||
echo "else" >> ${CONTAINER_INIT_SCRIPT} && \
|
||||
echo " echo 'Repository [${START_PATH}] already exists. Not touched!'" >> ${CONTAINER_INIT_SCRIPT} && \
|
||||
echo "fi" >> ${CONTAINER_INIT_SCRIPT} && \
|
||||
echo "chown -R ${USER}:${USER_GROUP} ${USER_VOLUME_WORKDIR}" >> ${CONTAINER_INIT_SCRIPT}
|
||||
|
||||
## prepare profile
|
||||
ENV BASH_RC_FILE=${USER_DIR}/.bashrc
|
||||
COPY .bashrc ${BASH_RC_FILE}
|
||||
RUN echo "sed -i 's|@START_PATH@|'"${START_PATH}"'|' ${BASH_RC_FILE}" >> ${CONTAINER_INIT_SCRIPT} && \
|
||||
echo "sed -i 's|@VERSION@|'"${TB_VERSION}"'|' ${BASH_RC_FILE}" >> ${CONTAINER_INIT_SCRIPT} && \
|
||||
echo "sed -i 's|@HISTFILE@|'"${HISTFILE}"'|' ${BASH_RC_FILE}" >> ${CONTAINER_INIT_SCRIPT}
|
||||
|
||||
## prepare ssh config
|
||||
RUN echo "mkdir -p ${USER_DIR}/.ssh" >> ${CONTAINER_INIT_SCRIPT}
|
||||
|
||||
## show env info
|
||||
RUN echo "echo " >> ${CONTAINER_INIT_SCRIPT} && \
|
||||
echo "echo Environment:" >> ${CONTAINER_INIT_SCRIPT} && \
|
||||
echo "echo BUILDENV_VERSION='${BUILDENV_VERSION}'" >> ${CONTAINER_INIT_SCRIPT} && \
|
||||
echo "echo HOST_PREFIX='${HOST_PREFIX}'" >> ${CONTAINER_INIT_SCRIPT} && \
|
||||
echo "echo BUILDENV_PREFIX='${BUILDENV_PREFIX}'" >> ${CONTAINER_INIT_SCRIPT} && \
|
||||
echo "echo BUILDENV_GIT_URL='${BUILDENV_GIT_URL}'" >> ${CONTAINER_INIT_SCRIPT} && \
|
||||
echo "echo TZ='${TZ}'" >> ${CONTAINER_INIT_SCRIPT} && \
|
||||
echo "echo USER='${USER}'" >> ${CONTAINER_INIT_SCRIPT} && \
|
||||
echo "echo USER_GROUP='${USER_GROUP}'" >> ${CONTAINER_INIT_SCRIPT} && \
|
||||
echo "echo USER_ID='${USER_ID}'" >> ${CONTAINER_INIT_SCRIPT} && \
|
||||
echo "echo USER_GROUP_ID='${USER_GROUP_ID}'" >> ${CONTAINER_INIT_SCRIPT} && \
|
||||
echo "echo USER_DIR='${HOME}'" >> ${CONTAINER_INIT_SCRIPT} && \
|
||||
echo "echo USER_PASSWORD=******" >> ${CONTAINER_INIT_SCRIPT} && \
|
||||
echo "echo HISTFILE='${HISTFILE}'" >> ${CONTAINER_INIT_SCRIPT} && \
|
||||
echo "echo GIT_USER='${GIT_USER}'" >> ${CONTAINER_INIT_SCRIPT} && \
|
||||
echo "echo GIT_EMAIL='${GIT_EMAIL}'" >> ${CONTAINER_INIT_SCRIPT} && \
|
||||
echo "echo PATH='${PATH}'" >> ${CONTAINER_INIT_SCRIPT} && \
|
||||
echo "echo LOCALE_LANG='${LOCALE_LANG}'" >> ${CONTAINER_INIT_SCRIPT} && \
|
||||
echo "echo START_PATH='${START_PATH}'" >> ${CONTAINER_INIT_SCRIPT} && \
|
||||
echo "echo TB_VERSION='${TB_VERSION}'" >> ${CONTAINER_INIT_SCRIPT} && \
|
||||
echo "echo TB_BUILD_TIME='${TB_BUILD_TIME}'" >> ${CONTAINER_INIT_SCRIPT} && \
|
||||
echo "echo DISPLAY='${DISPLAY}'" >> ${CONTAINER_INIT_SCRIPT} && \
|
||||
echo "echo ENABLE_UI_TOOLS='${ENABLE_UI_TOOLS} NOTE: Experimental only!'" >> ${CONTAINER_INIT_SCRIPT} && \
|
||||
echo "echo LOCAL_HOSTNAME='${LOCAL_HOSTNAME}'" >> ${CONTAINER_INIT_SCRIPT} && \
|
||||
echo "echo HOSTNAME='$HOSTNAME'" >> ${CONTAINER_INIT_SCRIPT} && \
|
||||
echo "echo XDG_RUNTIME_DIR='${XDG_RUNTIME_DIR}'" >> ${CONTAINER_INIT_SCRIPT} && \
|
||||
echo "echo XDG_CONFIG_HOME='${XDG_CONFIG_HOME}'" >> ${CONTAINER_INIT_SCRIPT} && \
|
||||
echo "echo QT_QUICK_BACKEND='${QT_QUICK_BACKEND}'" >> ${CONTAINER_INIT_SCRIPT} && \
|
||||
echo "echo QT_XCB_GL_INTEGRATION='${QT_XCB_GL_INTEGRATION}'" >> ${CONTAINER_INIT_SCRIPT} && \
|
||||
echo "echo NVIDIA_VISIBLE_DEVICES='${NVIDIA_VISIBLE_DEVICES}'" >> ${CONTAINER_INIT_SCRIPT} && \
|
||||
echo "echo " >> ${CONTAINER_INIT_SCRIPT}
|
||||
|
||||
## start services
|
||||
RUN echo "echo 'Ready...'" >> ${CONTAINER_INIT_SCRIPT} && \
|
||||
echo "exec runsvdir -P /etc/service" >> ${CONTAINER_INIT_SCRIPT}
|
||||
### END generate content of start script ###
|
||||
|
||||
# clean up
|
||||
RUN apt-get autoremove -y && apt-get autoclean && apt-get clean && \
|
||||
# Cleanup
|
||||
RUN apt-get autoremove -y && apt-get autoclean -y && apt-get clean -y && \
|
||||
rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
|
||||
|
||||
## make start script executable
|
||||
# Make init script executable
|
||||
RUN chmod 755 "${CONTAINER_INIT_SCRIPT}"
|
||||
|
||||
# Start container with init script
|
||||
ENTRYPOINT ["bash", "-c", "${CONTAINER_INIT_SCRIPT}"]
|
||||
CMD ["D"]
|
||||
ENTRYPOINT ["bash", "-c", "exec ${CONTAINER_INIT_SCRIPT:-/usr/local/bin/init.sh}"]
|
||||
|
||||
# Add HEALTHCHECK
|
||||
HEALTHCHECK --interval=5s --timeout=5s --start-period=1s --retries=10 \
|
||||
CMD [ -f /tmp/container_ready ] || exit 1
|
||||
|
142
README-de.md
142
README-de.md
@@ -1,7 +1,19 @@
|
||||
<!-- LANGUAGE_LINKS_START -->
|
||||
<span style="color: grey;">🇩🇪 German</span> | [🇬🇧 English](README-en.md)
|
||||
<!-- LANGUAGE_LINKS_END -->
|
||||
|
||||
Dieses Repository enthält die notwendigen Dateien, um einen Docker-Container zu konfigurieren, zu erzeugen und zu starten, einschließlich `docker-compose.yaml`, `Dockerfile` und Skripte. Einige Umgebungsvariablen werden in eine `.env`-Datei hinterlegt, die mit dem Script `create-env.sh` erzeugt werden müssen, damit einige Einstellungen vom Host-System übernommen werden können. Benötigt wird auch ein Basis Dockerimage, dass automatisch von Docker-Hub angefordert wird.
|
||||
Die Verwendung dieses Repositorys soll helfen, Docker-Container zu erzeugen, die die notwendigen Voraussetzungen bereitstellen, um Flashimages und Pakete mit dem Yocto/OE Buildsystem bauen zu können.
|
||||
# Docker Buildumgebung
|
||||
|
||||
Dieses Repository enthält die notwendigen Dateien, um einen Docker-Container zu konfigurieren, zu erzeugen und zu starten, einschließlich `docker-compose.yaml`, `Dockerfile` und Skripte. Einige Umgebungsvariablen werden in eine `.env`-Datei hinterlegt, die mit dem Skript `create-env.sh` erzeugt werden muss, um einige Einstellungen vom Host-System zu übernehmen. Ein Basis-Dockerimage, wird dabei automatisch von Docker-Hub geladen.
|
||||
|
||||
Die Verwendung dieses Repositorys soll helfen, Docker-Container zu erzeugen, die die notwendigen Voraussetzungen bereitstellen, um Neutrino Flashimages und Pakete mit dem Yocto/OE-Buildsystem bauen zu können.
|
||||
|
||||
# Inhalt
|
||||
- [Inhalt](#inhalt)
|
||||
- [🚀 Schnellstart](#-schnellstart)
|
||||
- [Container bauen](#container-bauen)
|
||||
- [Auf Container einloggen](#auf-container-einloggen)
|
||||
- [Buildumgebung im Docker-Terminal initialisieren](#buildumgebung-im-docker-terminal-initialisieren)
|
||||
- [1. Voraussetzungen](#1-voraussetzungen)
|
||||
- [2. Vorbereiten](#2-vorbereiten)
|
||||
- [2.1. Repository klonen und in das geklonte Repo wechseln](#21-repository-klonen-und-in-das-geklonte-repo-wechseln)
|
||||
@@ -12,16 +24,62 @@ Die Verwendung dieses Repositorys soll helfen, Docker-Container zu erzeugen, die
|
||||
- [2.4.2 SSH](#242-ssh)
|
||||
- [3. Container bauen](#3-container-bauen)
|
||||
- [3.1 Beispiel 1](#31-beispiel-1)
|
||||
- [3.2 Beispiel 2](#32-beispiel-2)
|
||||
- [4. Container starten](#4-container-starten)
|
||||
- [5. Container stoppen](#5-container-stoppen)
|
||||
- [6. Verwenden des Containers](#6-verwenden-des-containers)
|
||||
- [6.1. Einloggen](#61-einloggen)
|
||||
- [6.2. Buildumgebung nutzen](#62-buildumgebung-nutzen)
|
||||
- [6.1. Einloggen](#61-einloggen)
|
||||
- [6.2. Buildumgebung nutzen](#62-buildumgebung-nutzen)
|
||||
- [7. Container aktualisieren](#7-container-aktualisieren)
|
||||
- [8. Unterstützung](#8-unterstützung)
|
||||
|
||||
## 1. Voraussetzungen
|
||||
|
||||
# 🚀 Schnellstart
|
||||
|
||||
Falls du den Container schnell zum Laufen bringen willst, kannst du die folgenden Schritte in einem Terminal ausführen. Dies setzt voraus, dass Docker und Docker Compose bereits installiert sind.
|
||||
|
||||
## Container bauen
|
||||
|
||||
```bash
|
||||
~/docker-buildenv $ git clone https://github.com/tuxbox-neutrino/docker-buildenv.git && cd docker-buildenv
|
||||
./docker-compose build
|
||||
docker-compose up -d
|
||||
```
|
||||
|
||||
## Auf Container einloggen
|
||||
|
||||
```bash
|
||||
~/docker-buildenv $ docker exec -it --user $USER tuxbox-build bash
|
||||
```
|
||||
|
||||
## Buildumgebung im Docker-Terminal initialisieren
|
||||
|
||||
```bash
|
||||
user@asjghd76dfwh:~/tuxbox/buildenv$ ./init && cd poky-3.2.4
|
||||
...
|
||||
Create configurations ...
|
||||
...
|
||||
Start build
|
||||
------------------------------------------------------------------------------------------------
|
||||
Now you are ready to build your own images and packages.
|
||||
Selectable machines are:
|
||||
|
||||
hd51 ax51 mutant51 bre2ze4k hd60 ax60 hd61 ax61 h7 zgemmah7 osmio4k osmio4kplus e4hdultra
|
||||
|
||||
Select your favorite machine (or identical) and the next steps are:
|
||||
|
||||
cd /home/tg/tuxbox/buildenv/poky-3.2.4 && . ./oe-init-build-env build/<machine>
|
||||
bitbake neutrino-image
|
||||
|
||||
For more information and next steps take a look at the README.md!
|
||||
user@asjghd76dfwh:~/tuxbox/buildenv/poky-3.2.4$
|
||||
```
|
||||
|
||||
Weitere Anpassungen sollte am Container selbst nicht notwendig sein. Nach diesen Schritten läuft der Container im Hintergrund und stellt die Yocto/OE-Buildumgebung bereit.
|
||||
Du kannst nun mit dem Buildprozess beginnen.
|
||||
|
||||
**Hinweis:** Weitere Informationen zum weiteren Vorgehen findest du [hier](https://github.com/tuxbox-neutrino/buildenv/blob/master/README.md)
|
||||
|
||||
# 1. Voraussetzungen
|
||||
|
||||
Getestet wurde unter Linux Debian 11.x, Ubuntu 20.04, 22.04. Es sollte aber auf jeder aktuellen Distribution funktionieren auf der Docker läuft.
|
||||
|
||||
@@ -36,36 +94,39 @@ Die Verwendung dieses Repositorys soll helfen, Docker-Container zu erzeugen, die
|
||||
- [Docker Desktop](https://www.docker.com/products/docker-desktop/)
|
||||
- Portainer, [Installation](https://docs.portainer.io/start/install-ce/server/docker/linux) (mit Docker-Desktop als Plugin verfügbar)
|
||||
|
||||
**Wichtig!** Nachdem Du Docker installiert hast und Docker als nicht Root Benutzer ausführen möchtest, was für unsere Zwecke durchaus angebracht ist, solltest Du dich mit diesem Befehl als Benutzer zur "docker" Gruppe hinzufügen:
|
||||
**Wichtig!** Nachdem Du Docker installiert hast und Docker als nicht Root Benutzer ausführen möchtest, musst Du dich, falls noch nicht geschehen, mit diesem Befehl als Benutzer zur `docker` Gruppe hinzufügen:
|
||||
|
||||
```bash
|
||||
sudo usermod -aG docker $USER
|
||||
```
|
||||
Danach zum Übernehmen der Einstellung entweder ausloggen und wieder einloggen oder einen Neustart durchführen!
|
||||
Danach zum Übernehmen dieser Änderung ausloggen und wieder einloggen oder einen Neustart durchführen!
|
||||
|
||||
## 2. Vorbereiten
|
||||
# 2. Vorbereiten
|
||||
|
||||
### 2.1. Repository klonen und in das geklonte Repo wechseln
|
||||
## 2.1. Repository klonen und in das geklonte Repo wechseln
|
||||
|
||||
```bash
|
||||
git clone https://github.com/tuxbox-neutrino/docker-buildenv.git && cd docker-buildenv
|
||||
```
|
||||
|
||||
### 2.2. Umgebungsvariablen konfigurieren
|
||||
## 2.2. Umgebungsvariablen konfigurieren
|
||||
|
||||
Führe dieses Script aus, um die notwendige `.env`-Datei zu erzeugen:
|
||||
Ist noch keine .env Datei vorhanden, muss zumindest einmal diese Datei erzeugt werden.
|
||||
|
||||
Dazu führe dieses Script aus. Du wirst dabei abgerfragt, welche Umgebungsvariablen gesetzt werden sollen. Anpassungen sind normalerweise nicht erforderlich, weil das Script einige Umgebungsvariablen vom Host-System holt und diese in eine `.env`-Datei einbaut:
|
||||
|
||||
```bash
|
||||
./create-env.sh
|
||||
```
|
||||
|
||||
Das Script holt einige Umgebungsvariablen vom Host-System und passt, bzw. baut, diese in eine `.env`-Datei ein, damit der Container passend zu deinem Host-System konfiguriert wird. Sollten damit deine Anforderungen noch nicht abgedeckt sein, kannst Du diese erzeugte `.env`-Datei anpassen. Das Script solltest Du dann aber nicht noch einnmal ausführen, da die `.env`-Datei sonst wieder überschrieben wird. Es ist daher ratsam, etweder diese angepasste `.env`-Datei umzubenennen und entsprechend ebenfalls in der `docker-compose.yml`-Datei umbenennen, oder bevorzugt beim ausführen von `docker-compose` als Parameter eine andere in dieser Form `--env-file <meine .env-Datei>` an `docker-compose` übegeben.
|
||||
|
||||
Führst du dieses Script weitere Male aus, kannst du entscheiden ob du es ausführen willst, oder die es dabei belässt.
|
||||
|
||||
### 2.3 Volumes
|
||||
## 2.3 Volumes
|
||||
|
||||
Der Container verwendet Docker Volumes, um persistente Daten zu speichern, welche Zugriff auf spezifische Dateien und Verzeichnisse dauerhaft im Container ermöglichen.
|
||||
In der Standardkonfiguration werden prinzipell diese Volumes passend zur Umgebung deines Host-Systems eingebunden und beim Starten des Containers eingehängt, so dass Du im Idealfall an der Volumes-Konfiguration nichts ändern musst.
|
||||
Solltest Du daran Änderungen vornehmen wollen, findest Du in der `docker-compose.yml` die Konfiguration der Volumes. **Beachte** aber dass diese Einstellungem normalerweise mit den Pfaden wie sie für die Yocto/OE Buildumgebung mit dem init-Script aus dem Buildenv-Repository vorkonfiguriert werden, abgestimmt sind. Sollten daran Anpassungen vorgenommen werden, solltest Du das berücksichtigen!
|
||||
In der Standardkonfiguration werden prinzipiell diese Volumes passend zur Umgebung deines Host-Systems eingebunden und beim Starten des Containers eingehängt, so dass Du im Idealfall an der Volumes-Konfiguration nichts ändern musst.
|
||||
Solltest Du daran Änderungen vornehmen wollen, findest Du in der `docker-compose.yml` die Konfiguration der Volumes.
|
||||
**Beachte** aber dass diese Einstellungem normalerweise mit den Pfaden wie sie für die Yocto/OE Buildumgebung mit dem init-Script aus dem Buildenv-Repository vorkonfiguriert werden, abgestimmt sind. Sollten daran Anpassungen vorgenommen werden, solltest Du das berücksichtigen!
|
||||
|
||||
Diese Pfade werden als Volumes im Container bereitgestellt. Du hast über dein Host darauf normalen Zugriff:
|
||||
|
||||
@@ -83,21 +144,22 @@ Die Verwendung dieses Repositorys soll helfen, Docker-Container zu erzeugen, die
|
||||
├── sstate-cache
|
||||
```
|
||||
|
||||
### 2.4 Ports konfigurieren
|
||||
## 2.4 Ports konfigurieren
|
||||
|
||||
Der Container stellt einige Zugänge über bestimmte Netzwerkports zur Verfügung. Dies erlaubt den Zugang über einen Webbrowser auf die Buildergebnisse und den Zugang via ssh auf den Container.
|
||||
|
||||
#### 2.4.1 Webzugriff
|
||||
### 2.4.1 Webzugriff
|
||||
|
||||
Standardmäßig ist der Container so konfiguriert, dass er auf Port 80 lauscht. Dein Host wird über Port 8080 auf den eingebauten Webserver (`lighttpd`) des Containers gemappt:
|
||||
|
||||
- Port: 8080 (Host) -> 80 (Container)
|
||||
|
||||
Dies ermöglicht den Zugriff via Webserver auf die erzeugten Images und Pakete (ipk's). Set-Top Boxen können damit direkt Updates beispielsweise aus deinem Heimnetz abrufen. Falls der Port 8080 des Hostsystems bei Dir bereits belegt ist, kannst Du diese Einstellungen entweder in der `docker-compose.yml` Datei anpassen oder beim Starten des Containers angeben. Dies könnte so aussehen, wenn man auf den Port 8081 mappt:
|
||||
Dies ermöglicht den Zugriff via Webserver auf die erzeugten Images und Pakete (ipk's). Set-Top Boxen können damit direkt Updates beispielsweise aus deinem Heimnetz abrufen.
|
||||
Falls der Port 8080 des Hostsystems bei Dir bereits belegt ist, kannst Du diese Einstellungen entweder in der `docker-compose.yml` Datei anpassen oder beim Starten des Containers angeben. Dies könnte so aussehen, wenn man auf den Port 8081 mappt:
|
||||
|
||||
- 808**1**:80
|
||||
|
||||
Einstellungen am Webserver können in der zuständigen lightttpd-Konfugarionsdatei vorgenommen werden, welche im entsprechenden Volume zur Verfügung steht:
|
||||
Einstellungen am Webserver können in der zuständigen lighttpd-Konfugarionsdatei vorgenommen werden, welche im entsprechenden Volume zur Verfügung steht:
|
||||
|
||||
```bash
|
||||
~/tuxbox
|
||||
@@ -118,10 +180,10 @@ Die Verwendung dieses Repositorys soll helfen, Docker-Container zu erzeugen, die
|
||||
dir-listing.activate = "enable"
|
||||
```
|
||||
|
||||
#### 2.4.2 SSH
|
||||
### 2.4.2 SSH
|
||||
|
||||
Üblicherweise greift man auf den Container direkt über `docker exec` zu.
|
||||
Da Git ohnehin Bestandteil im Container ist, wird auch ein ssh-Server zur Verfügung gestellt. Der ssh-Server ist standardmäßig so konfiguriert:
|
||||
Der Container stellt auch einen ssh-Server zur Verfügung. Der ssh-Server ist standardmäßig so konfiguriert:
|
||||
|
||||
- Port: 222 (Host) -> 22 (Container)
|
||||
- Passwort: = Benutzername (wie in .env festgelegt)
|
||||
@@ -140,9 +202,9 @@ Die Verwendung dieses Repositorys soll helfen, Docker-Container zu erzeugen, die
|
||||
ssh <benutzer>@<IP oder Hostname des Rechners auf dem der Container läuft> -p 222
|
||||
```
|
||||
|
||||
## 3. Container bauen
|
||||
# 3. Container bauen
|
||||
|
||||
### 3.1 Beispiel 1
|
||||
## 3.1 Beispiel 1
|
||||
|
||||
Docker-compose Wrapper ausführen:
|
||||
|
||||
@@ -150,31 +212,21 @@ Die Verwendung dieses Repositorys soll helfen, Docker-Container zu erzeugen, die
|
||||
./docker-compose build
|
||||
```
|
||||
|
||||
**Hinweis:** Das vorangestellte `./` ist hier zu beachten, da sich das Wrapperscript im Repo befindet. Das Wrapper-Script ruft `docker-compose` wie vorgesehen auf, allerdings nachdem automatisch eine `.env`-Datei, wie in [Schritt 2.2](#22-umgebungsvariablen-konfigurieren) beschrieben ist, erzeugt wurde! Dieses Wrapperscript nimmt alle Parameter an, die für `docker-compose` üblich sind. Es dient lediglich dazu, den Aufwand für die Befehlseingabe zur Erzeugung der Umgebungsvariablen, welche über die generierte `.env`-Datei bereitgestellt werden, zu verringern.
|
||||
**Hinweis:** Das vorangestellte `./` ist hier zu berücksichtigen, da es sich um ein Wrapperscript handelt. Das Wrapper-Script ruft `docker-compose` wie vorgesehen auf, allerdings nachdem automatisch eine `.env`-Datei, wie in [Schritt 2.2](#22-umgebungsvariablen-konfigurieren) beschrieben ist, erzeugt wurde! Dieses Wrapperscript nimmt alle Parameter an, die für `docker-compose` üblich sind. Es dient lediglich dazu, den Aufwand für die Befehlseingabe zur Erzeugung der Umgebungsvariablen, welche über die generierte `.env`-Datei bereitgestellt werden, zu verringern.
|
||||
|
||||
### 3.2 Beispiel 2
|
||||
|
||||
Docker-compose ausführen: mit anderer `.env-Datei`
|
||||
|
||||
**Hinweis:** im Repository ist eine `.env.sample` als Beispiel enthalten. Falls gewünscht, muss diese allerdings angepasst und explizit beim Erzeugen des Containers an `docker-compose` übergeben werden.
|
||||
|
||||
```bash
|
||||
docker-compose --env-file <Pfad zu anderer .env-Datei> build
|
||||
```
|
||||
|
||||
## 4. Container starten
|
||||
# 4. Container starten
|
||||
|
||||
```bash
|
||||
docker-compose up -d
|
||||
```
|
||||
|
||||
## 5. Container stoppen
|
||||
# 5. Container stoppen
|
||||
|
||||
```bash
|
||||
docker-compose down
|
||||
```
|
||||
|
||||
## 6. Verwenden des Containers
|
||||
# 6. Verwenden des Containers
|
||||
|
||||
## 6.1. Einloggen
|
||||
|
||||
@@ -204,17 +256,17 @@ Die Verwendung dieses Repositorys soll helfen, Docker-Container zu erzeugen, die
|
||||
~/tuxbox/buildenv$
|
||||
```
|
||||
|
||||
Zuerst solltest Du sicherstellen, dass das Init-Script aktuell ist. Führe deshalb eine Aktualisierung durch:
|
||||
Zuerst solltest Du sicherstellen, dass `buildenv` aktuell ist. Wenn das Dockerimage frisch gebaut wurde, sollte das schon erledigt sein, ansonsten führe deshalb eine Aktualisierung durch:
|
||||
|
||||
```bash
|
||||
~/tuxbox/buildenv$ git pull -r origin master
|
||||
```
|
||||
|
||||
Ab jetzt kannst Du mit dem Container arbeiten.
|
||||
Ab jetzt kannst Du die Buildumgebung mit dem Container nutzen.
|
||||
|
||||
## 6.2. Buildumgebung nutzen
|
||||
|
||||
Nach dem Einloggen in den Container befindest Du dich bereits im Verzeichnis, in welchem sich das Init-Script befindet. Jetzt kannst du wie [hier](https://github.com/tuxbox-neutrino/buildenv/blob/master/README.md) beschrieben fortfahren.
|
||||
Nach dem Einloggen in den Container befindest Du dich bereits im Verzeichnis `buildenv`, in welchem sich das Init-Script befindet. Jetzt kannst du wie [hier](https://github.com/tuxbox-neutrino/buildenv/blob/master/README.md) beschrieben fortfahren.
|
||||
|
||||
Die vom Buildsystem erzeugten Images und Pakete werden über persistente Volumes innerhalb deines Home-Verzeichnisses des Hosts verfügbar gemacht. Standardmäßig ist dafür dieser Ort vorgesehen:
|
||||
|
||||
@@ -238,7 +290,7 @@ Die Verwendung dieses Repositorys soll helfen, Docker-Container zu erzeugen, die
|
||||
- [http://IP<:PORT-NUMMER>](http://192.168.1.36:8080)
|
||||
|
||||
|
||||
## 7. Container aktualisieren
|
||||
# 7. Container aktualisieren
|
||||
|
||||
Entsprechend wie unter [Schritt 2.1](#21-repository-klonen-und-in-das-geklonte-repo-wechseln) angegeben, kann das Repository, dass die Rezeptur für den Container enthält, regelmäßig aktualisiert werden.
|
||||
Dafür wechselt man in das Repository und führt dieses Kommando aus:
|
||||
@@ -247,9 +299,9 @@ Die Verwendung dieses Repositorys soll helfen, Docker-Container zu erzeugen, die
|
||||
~/docker-buildenv$ git pull -r origin master
|
||||
```
|
||||
|
||||
Anschließend wie [hier](#3-container-bauen) beschrieben, den Container erstellen lassen.
|
||||
Anschließend wie [hier](#3-container-bauen) beschrieben, den Container neu erstellen lassen.
|
||||
|
||||
## 8. Unterstützung
|
||||
# 8. Unterstützung
|
||||
|
||||
Für weitere Fragen, Problemen oder Unterstützung öffne ein [Issue im GitHub](https://github.com/dbt1/docker-buildenv/issues) oder melde Dich im [Forum](https://forum.tuxbox-neutrino.org/forum/viewforum.php?f=77).
|
||||
|
||||
|
337
README-en.md
337
README-en.md
@@ -1,255 +1,192 @@
|
||||
Note: This is an automatically translated file. Original content from [here](https://github.com/dbt1/docker-tuxbox-build/blob/master/README-de.md):
|
||||
<!-- LANGUAGE_LINKS_START -->
|
||||
[🇩🇪 German](README-de.md) | <span style="color: grey;">🇬🇧 English</span>
|
||||
<!-- LANGUAGE_LINKS_END -->
|
||||
|
||||
This repository contains the necessary files to configure, build, and launch a Docker container, including `docker-compose.yaml`, `Dockerfile`, and scripts. Some environment variables are stored in a `.env` file, which must be created with the `create-env.sh` script so that some settings can be adopted by the host system. You also need a base Docker image that is automatically requested from Docker Hub.
|
||||
The use of this repository is intended to help create Docker containers that provide the necessary requirements to be able to build flash images and packages with the Yocto/OE build system.
|
||||
# Docker Build Environment
|
||||
|
||||
- [1. Requirements](#1-requirements)
|
||||
- [2. Prepare](#2-prepare)
|
||||
- [2.1. Clone repository and switch to the cloned repo](#21-repository-clone-and-switch-to-the-cloned-repo)
|
||||
- [2.2. Configure environment variables](#22-configure-environment-variables)
|
||||
This repository contains the necessary files to configure, build, and run a Docker container, including `docker-compose.yaml`, `Dockerfile`, and scripts. Some environment variables are stored in a `.env` file, which must be created using the `create-env.sh` script to adopt specific settings from the host system. A base Docker image is automatically downloaded from Docker Hub.
|
||||
|
||||
The purpose of this repository is to assist in creating Docker containers that provide the necessary prerequisites for building Neutrino flash images and packages using the Yocto/OE build system.
|
||||
|
||||
## Contents
|
||||
- [Contents](#contents)
|
||||
- [🚀 Quick Start](#-quick-start)
|
||||
- [Build Container](#build-container)
|
||||
- [Login to Container](#login-to-container)
|
||||
- [Initialize Build Environment in Docker Terminal](#initialize-build-environment-in-docker-terminal)
|
||||
- [1. Prerequisites](#1-prerequisites)
|
||||
- [2. Preparation](#2-preparation)
|
||||
- [2.1 Clone Repository and Change Directory](#21-clone-repository-and-change-directory)
|
||||
- [2.2 Configure Environment Variables](#22-configure-environment-variables)
|
||||
- [2.3 Volumes](#23-volumes)
|
||||
- [2.4 Configure Ports](#24-ports-configure)
|
||||
- [2.4.1 Web Access](#241-web access)
|
||||
- [2.4 Configure Ports](#24-configure-ports)
|
||||
- [2.4.1 Web Access](#241-web-access)
|
||||
- [2.4.2 SSH](#242-ssh)
|
||||
- [3. Build Container](#3-container-build)
|
||||
- [3. Build Container](#3-build-container)
|
||||
- [3.1 Example 1](#31-example-1)
|
||||
- [3.2 Example 2](#32-example-2)
|
||||
- [4. Start container](#4-start-container)
|
||||
- [5. Stop container](#5-stop-container)
|
||||
- [4. Start Container](#4-start-container)
|
||||
- [5. Stop Container](#5-stop-container)
|
||||
- [6. Using the Container](#6-using-the-container)
|
||||
- [6.1. Login](#61-login)
|
||||
- [6.2. Use build environment](#62-build-environment-use)
|
||||
- [6.1 Login](#61-login)
|
||||
- [6.2 Using the Build Environment](#62-using-the-build-environment)
|
||||
- [7. Update Container](#7-update-container)
|
||||
- [8th. Support](#8-support)
|
||||
- [8. Support](#8-support)
|
||||
|
||||
## 1. Requirements
|
||||
## 🚀 Quick Start
|
||||
|
||||
Tested under Linux Debian 11.x, Ubuntu 20.04, 22.04. But it should work on any current distribution that runs Docker.
|
||||
If you want to quickly get the container running, execute the following steps in a terminal. This assumes that Docker and Docker Compose are already installed.
|
||||
|
||||
Necessary:
|
||||
|
||||
### Build Container
|
||||
|
||||
```bash
|
||||
~/docker-buildenv $ git clone https://github.com/tuxbox-neutrino/docker-buildenv.git && cd docker-buildenv
|
||||
./docker-compose build
|
||||
docker-compose up -d
|
||||
```
|
||||
|
||||
### Login to Container
|
||||
|
||||
```bash
|
||||
~/docker-buildenv $ docker exec -it --user $USER tuxbox-build bash
|
||||
```
|
||||
|
||||
### Initialize Build Environment in Docker Terminal
|
||||
|
||||
```bash
|
||||
user@asjghd76dfwh:~/tuxbox/buildenv$ ./init && cd poky-3.2.4
|
||||
...
|
||||
Create configurations ...
|
||||
...
|
||||
Start build
|
||||
------------------------------------------------------------------------------------------------
|
||||
Now you are ready to build your own images and packages.
|
||||
Selectable machines are:
|
||||
|
||||
hd51 ax51 mutant51 bre2ze4k hd60 ax60 hd61 ax61 h7 zgemmah7 osmio4k osmio4kplus e4hdultra
|
||||
|
||||
Select your favorite machine (or identical) and the next steps are:
|
||||
|
||||
cd /home/tg/tuxbox/buildenv/poky-3.2.4 && . ./oe-init-build-env build/<machine>
|
||||
bitbake neutrino-image
|
||||
|
||||
For more information and next steps, take a look at the README.md!
|
||||
user@asjghd76dfwh:~/tuxbox/buildenv/poky-3.2.4$
|
||||
```
|
||||
|
||||
No further adjustments should be necessary. After these steps, the container runs in the background and provides the Yocto/OE build environment.
|
||||
You can now start the build process.
|
||||
|
||||
**Note:** Further information on next steps can be found [here](https://github.com/tuxbox-neutrino/buildenv/blob/master/README.md).
|
||||
|
||||
## 1. Prerequisites
|
||||
|
||||
Tested on Linux Debian 11.x, Ubuntu 20.04, 22.04. It should work on any current distribution where Docker is supported.
|
||||
|
||||
Required:
|
||||
- Docker, [Installation](https://docs.docker.com/engine/install/debian/#install-using-the-convenience-script)
|
||||
- Docker Compose >= v2.24.3, [Installation](https://docs.docker.com/compose/install/standalone/)
|
||||
- Git, installation via the package manager depending on the distribution
|
||||
|
||||
Optional:
|
||||
|
||||
- Git, installable via the package manager according to your distribution
|
||||
|
||||
Optional:
|
||||
- [Docker Desktop](https://www.docker.com/products/docker-desktop/)
|
||||
- Portainer, [Installation](https://docs.portainer.io/start/install-ce/server/docker/linux) (available with Docker desktop as a plugin)
|
||||
- Portainer, [Installation](https://docs.portainer.io/start/install-ce/server/docker/linux) (available as a plugin with Docker Desktop)
|
||||
|
||||
**Important!** After you have installed Docker and want to run Docker as a non-root user, which is appropriate for our purposes, you should add yourself as a user to the "docker" group using this command:
|
||||
**Important!** After installing Docker, if you want to run Docker as a non-root user, add yourself to the `docker` group:
|
||||
|
||||
```bash
|
||||
sudo usermod -aG docker $USER
|
||||
```
|
||||
Then to apply the setting, either log out and log in again or restart!
|
||||
```bash
|
||||
sudo usermod -aG docker $USER
|
||||
```
|
||||
|
||||
## 2. Prepare
|
||||
Then log out and back in or restart your system for the changes to take effect.
|
||||
|
||||
### 2.1. Clone repository and switch to the cloned repo
|
||||
## 2. Preparation
|
||||
|
||||
```bash
|
||||
git clone https://github.com/tuxbox-neutrino/docker-buildenv.git && cd docker-buildenv
|
||||
```
|
||||
### 2.1 Clone Repository and Change Directory
|
||||
|
||||
### 2.2. Configure environment variables
|
||||
```bash
|
||||
git clone https://github.com/tuxbox-neutrino/docker-buildenv.git && cd docker-buildenv
|
||||
```
|
||||
|
||||
Run this script to create the necessary `.env` file:
|
||||
### 2.2 Configure Environment Variables
|
||||
|
||||
```bash
|
||||
./create-env.sh
|
||||
```
|
||||
|
||||
The script gets some environment variables from the host system and puts them into an `.env` file so that the container is configured to suit your host system. If this does not cover your requirements, you can adapt this generated `.env` file. However, you should not run the script again, otherwise the `.env` file will be overwritten again. It is therefore advisable to either rename this customized `.env` file and rename it accordingly in the `docker-compose.yml` file, or preferably to use another one in this form as a parameter when running `docker-compose` - -env-file <my .env file>` passed to `docker-compose`.
|
||||
If no `.env` file exists, create one using the provided script. This script retrieves environment variables from the host system and integrates them into the `.env` file.
|
||||
|
||||
```bash
|
||||
./create-env.sh
|
||||
```
|
||||
|
||||
You can rerun this script if needed.
|
||||
|
||||
### 2.3 Volumes
|
||||
|
||||
The container uses Docker Volumes to store persistent data, which allows access to specific files and directories permanently in the container.
|
||||
In the standard configuration, these volumes are in principle integrated to suit the environment of your host system and mounted when the container is started, so that ideally you do not have to change anything in the volume configuration.
|
||||
If you want to make changes to this, you can find the configuration of the volumes in the `docker-compose.yml`. **Note** that these settings are normally aligned with the paths as preconfigured for the Yocto/OE build environment using the init script from the Buildenv repository. If adjustments are made to this, you should take this into account!
|
||||
|
||||
These paths are mounted as volumes in the container. You have normal access to it via your host:
|
||||
The container uses Docker volumes to store persistent data. Default configurations should suffice, but changes can be made in `docker-compose.yml` if necessary.
|
||||
|
||||
```bash
|
||||
/home
|
||||
└──<$USER>
|
||||
├── tuxbox
|
||||
│ ├── .config
|
||||
│ ├── .data
|
||||
│ ├── am
|
||||
│ └── buildenv
|
||||
├── Archives
|
||||
├── am
|
||||
├── sources
|
||||
├── sstate cache
|
||||
```
|
||||
### 2.4 Configure Ports
|
||||
|
||||
### 2.4 Configure ports
|
||||
#### 2.4.1 Web Access
|
||||
|
||||
The container provides some access via certain network ports. This allows access to the build results via a web browser and access to the container via ssh.
|
||||
The container maps port 80 (container) to port 8080 (host) for web access:
|
||||
|
||||
#### 2.4.1 Web access
|
||||
- Port: 8080 (Host) -> 80 (Container)
|
||||
|
||||
By default, the container is configured to listen on port 80. Your host is mapped to the container's built-in web server (`lighttpd`) via port 8080:
|
||||
|
||||
- Port: 8080 (host) -> 80 (container)
|
||||
|
||||
This enables access via web server to the generated images and packages (ipk's). Set-top boxes can therefore access updates directly from your home network, for example. If port 8080 on your host system is already in use, you can either adjust these settings in the `docker-compose.yml` file or specify them when starting the container. This could look like this if you map to port 8081:
|
||||
|
||||
- 808**1**:80
|
||||
|
||||
Settings on the web server can be made in the responsible lightttpd configuration file, which is available in the corresponding volume:
|
||||
|
||||
```bash
|
||||
~/tuxbox
|
||||
└──.config
|
||||
└── lighttpd
|
||||
└── lighttpd.conf
|
||||
```
|
||||
`dir-listing` is activated in `lighttpd.conf`, so that you can get by without additional content.
|
||||
|
||||
```bash
|
||||
~/tuxbox/config/lighttpd$ cat lighttpd.conf
|
||||
...
|
||||
#server.compat-module-load = "disable"
|
||||
server.modules += (
|
||||
"mod_dirlisting",
|
||||
"mod_staticfile",
|
||||
)
|
||||
dir-listing.activate = "enable"
|
||||
```
|
||||
|
||||
#### 2.4.2 SSH
|
||||
|
||||
Usually you access the container directly via `docker exec`.
|
||||
Since Git is already part of the container, an ssh server is also provided. By default, the ssh server is configured like this:
|
||||
The container runs an SSH server with the following default settings:
|
||||
|
||||
- Port: 222 (host) -> 22 (container)
|
||||
- Password: = Username (as set in .env)
|
||||
- Port: 222 (Host) -> 22 (Container)
|
||||
- Password: = Username (as set in `.env` file)
|
||||
|
||||
If port 222 is already occupied on your host system, you can adjust these settings in the `docker-compose.yml` file, just like with the web server, or specify them when starting the container.
|
||||
|
||||
Login from the host system itself:
|
||||
|
||||
```bash
|
||||
ssh $USER@localhost -p 222
|
||||
```
|
||||
|
||||
Log in from another computer:
|
||||
|
||||
```bash
|
||||
ssh <user>@<IP or hostname of the computer on which the container is running> -p 222
|
||||
```
|
||||
|
||||
## 3. Build containers
|
||||
## 3. Build Container
|
||||
|
||||
### 3.1 Example 1
|
||||
|
||||
Run docker-compose wrapper:
|
||||
|
||||
```bash
|
||||
./docker-compose build
|
||||
```
|
||||
Run the Docker Compose wrapper script:
|
||||
|
||||
**Note:** The preceding `./` must be noted here as the wrapper script is in the repo. The wrapper script calls `docker-compose` as intended, but after automatically creating an `.env` file as described in [Step 2.2](#22-configure-environment-variables)! This wrapper script takes all parameters common to `docker-compose`. It only serves to reduce the effort required to enter commands to create the environment variables, which are provided via the generated `.env` file.
|
||||
```bash
|
||||
./docker-compose build
|
||||
```
|
||||
|
||||
### 3.2 Example 2
|
||||
## 4. Start Container
|
||||
|
||||
Run docker-compose: with different `.env file`
|
||||
```bash
|
||||
docker-compose up -d
|
||||
```
|
||||
|
||||
**Note:** there is an `.env.sample` included in the repository as an example. However, if desired, this must be adjusted and explicitly passed to `docker-compose` when creating the container.
|
||||
## 5. Stop Container
|
||||
|
||||
```bash
|
||||
docker-compose --env-file <path to other .env file> build
|
||||
```
|
||||
```bash
|
||||
docker-compose down
|
||||
```
|
||||
|
||||
## 4. Start container
|
||||
## 6. Using the Container
|
||||
|
||||
```bash
|
||||
docker-compose up -d
|
||||
```
|
||||
### 6.1 Login
|
||||
|
||||
## 5. Stop containers
|
||||
To log in, use the container ID or name:
|
||||
|
||||
```bash
|
||||
docker-compose down
|
||||
```
|
||||
```bash
|
||||
docker exec -it --user $USER tuxbox-build bash
|
||||
```
|
||||
|
||||
## 6. Using the container
|
||||
### 6.2 Using the Build Environment
|
||||
|
||||
## 6.1. log in
|
||||
Once logged in, navigate to `buildenv` and update it if necessary:
|
||||
|
||||
You should know the name or container ID to log in. Run `docker ps` to see which containers are currently available:
|
||||
```bash
|
||||
git pull -r origin master
|
||||
```
|
||||
|
||||
```bash
|
||||
docker ps
|
||||
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
|
||||
9d6e0d280a9e tuxbox-build:latest "/usr/local/bin/star…" 41 minutes ago Up 41 minutes 0.0.0.0:8080->80/tcp tuxbox-build
|
||||
```
|
||||
Proceed as described in the [README.md](https://github.com/tuxbox-neutrino/buildenv/blob/master/README.md).
|
||||
|
||||
For example, log in to the container with the `Container ID` **9d6e0d280a9e** or the `Container Name` like this:
|
||||
## 7. Update Container
|
||||
|
||||
To update the repository and rebuild the container:
|
||||
|
||||
```bash
|
||||
docker exec -it --user $USER tuxbox-build bash
|
||||
```
|
||||
or:
|
||||
|
||||
```bash
|
||||
docker exec -it --user $USER <CONTAINER ID> bash
|
||||
```
|
||||
|
||||
You should see something like this prompt:
|
||||
|
||||
```bash
|
||||
~/tuxbox/buildenv$
|
||||
```
|
||||
|
||||
First you should make sure that the init script is up to date. Therefore, carry out an update:
|
||||
|
||||
```bash
|
||||
~/tuxbox/buildenv$ git pull -r origin master
|
||||
```
|
||||
|
||||
From now on you can work with the container.
|
||||
|
||||
## 6.2. Use build environment
|
||||
|
||||
After logging into the container, you are already in the directory in which the init script is located. Now you can continue as described [here](https://github.com/tuxbox-neutrino/buildenv/blob/master/README.md).
|
||||
|
||||
The images and packages produced by the build system are made available via persistent volumes within your host home directory. By default, this location is intended for this:
|
||||
|
||||
```bash
|
||||
/home
|
||||
└──<$USER>
|
||||
├── tuxbox
|
||||
: ├── buildenv
|
||||
: ├── dist
|
||||
:
|
||||
```
|
||||
**Note:** If you have set up your volumes differently, this may of course differ.
|
||||
|
||||
The container provides a web server and can be accessed locally and on the LAN via port 8080 by default:
|
||||
|
||||
- [http://localhost<:PORT NUMBER>](http://localhost:8080)
|
||||
- [http://127.0.0.1<:PORT NUMBER>](http://127.0.0.1:8080)
|
||||
|
||||
or on the LAN
|
||||
|
||||
- [http://IP<:PORT NUMBER>](http://192.168.1.36:8080)
|
||||
|
||||
|
||||
## 7. Update containers
|
||||
|
||||
As stated in [Step 2.1](#21-clone-repository-and-switch-to-the-cloned-repo), the repository that contains the recipe for the container can be updated regularly.
|
||||
To do this, go to the repository and run this command:
|
||||
|
||||
```bash
|
||||
~/docker-buildenv$ git pull -r origin master
|
||||
```
|
||||
|
||||
Then have the container created as described [here](#3-build-container).
|
||||
```bash
|
||||
git pull -r origin master
|
||||
```
|
||||
|
||||
## 8. Support
|
||||
|
||||
For further questions, problems or support, open an [Issue in GitHub](https://github.com/dbt1/docker-buildenv/issues) or report in the [Forum](https://forum.tuxbox-neutrino.org /forum/viewforum.php?f=77).
|
||||
For issues or support, open an [issue on GitHub](https://github.com/dbt1/docker-buildenv/issues) or visit the [forum](https://forum.tuxbox-neutrino.org/forum/viewforum.php?f=77).
|
||||
|
||||
|
12
README.md
12
README.md
@@ -1,7 +1,9 @@
|
||||
# Documentation
|
||||
|
||||
## Localized `README.md`'s
|
||||
This document is available in the following languages:
|
||||
|
||||
| Language |
|
||||
| -------------------------- |
|
||||
| [English](README-en.md) |
|
||||
| [German](README-de.md) |
|
||||
<!-- LANGUAGE_LINKS_START -->
|
||||
[🇩🇪 German](README-de.md) | [🇬🇧 English](README-en.md)
|
||||
<!-- LANGUAGE_LINKS_END -->
|
||||
|
||||
Please choose your preferred language by clicking on the links above.
|
||||
|
390
create-env.sh
390
create-env.sh
@@ -1,106 +1,330 @@
|
||||
#!/bin/bash
|
||||
#!/usr/bin/env bash
|
||||
#
|
||||
# create_env.sh - Automatically create the .env file for Docker Compose
|
||||
# Creates a .env file with user and system settings.
|
||||
# If a .env file already exists, the user is asked
|
||||
# if a backup should be created and the file overwritten.
|
||||
|
||||
# Path to.env-Datei
|
||||
set -e # Stop on error
|
||||
|
||||
# Prints an error message and exits
|
||||
function error_exit {
|
||||
echo "$1" >&2
|
||||
exit 1
|
||||
}
|
||||
|
||||
# ------------------------------------------------------------------------------
|
||||
# Global constants
|
||||
# ------------------------------------------------------------------------------
|
||||
ENV_FILE=".env"
|
||||
BACKUP_DIR="env_backups"
|
||||
EXIT_USER_CANCEL=70
|
||||
|
||||
BUILDENV_VERSION="3.2.4"
|
||||
TB_VERSION="latest"
|
||||
TB_BUILD_TIME=$(date '+%Y-%m-%d %H:%M:%S')
|
||||
USER=$(whoami)
|
||||
USER_ID=$(id -u)
|
||||
USER_GROUP_ID=$(id -g)
|
||||
USER_DIR="${HOME}"
|
||||
HOST_PREFIX=tuxbox
|
||||
BUILDENV_PREFIX="buildenv"
|
||||
LOCAL_HOSTNAME=$(hostname)
|
||||
ENABLE_UI_TOOLS="false"
|
||||
USER_VOLUME_BINDIR="${USER_DIR}/bin"
|
||||
USER_VOLUME_WORKDIR="${USER_DIR}/${HOST_PREFIX}"
|
||||
USER_VOLUME_WORKBINDIR="${USER_VOLUME_WORKDIR}/bin"
|
||||
# ------------------------------------------------------------------------------
|
||||
# Prompt functions
|
||||
# ------------------------------------------------------------------------------
|
||||
|
||||
# Prompt the user with a message and default value
|
||||
function prompt {
|
||||
local PROMPT_MESSAGE=$1
|
||||
local DEFAULT_VALUE=$2
|
||||
local PAD_WIDTH=${3:-20}
|
||||
|
||||
# Build the prompt with color logic
|
||||
local PROMPT_WITH_COLOR
|
||||
PROMPT_WITH_COLOR=$(prompt_color "$PROMPT_MESSAGE" "$DEFAULT_VALUE" "$PAD_WIDTH")
|
||||
|
||||
# Read user input and use default if empty
|
||||
read -p "$(echo -e "$PROMPT_WITH_COLOR")" INPUT
|
||||
INPUT="${INPUT:-$DEFAULT_VALUE}"
|
||||
|
||||
echo "$INPUT"
|
||||
}
|
||||
|
||||
# Return a color-coded prompt based on whether the current default deviates from the original default
|
||||
function prompt_color {
|
||||
local PROMPT_MESSAGE=$1
|
||||
local DEFAULT_VALUE=$2
|
||||
local PAD_WIDTH=${3:-20}
|
||||
|
||||
local GREEN="\033[0;32m"
|
||||
local YELLOW="\033[0;33m"
|
||||
local RESET="\033[0m"
|
||||
|
||||
# Retrieve the original value from a variable named ORIG_<PROMPT_MESSAGE>
|
||||
local ORIG_VAR="ORIG_${PROMPT_MESSAGE}"
|
||||
local ORIG_VALUE="${!ORIG_VAR}"
|
||||
|
||||
local COLOR="$GREEN"
|
||||
if [[ -n "$ORIG_VALUE" && "$DEFAULT_VALUE" != "$ORIG_VALUE" ]]; then
|
||||
COLOR="$YELLOW"
|
||||
fi
|
||||
|
||||
local ADJUSTED_WIDTH=$((PAD_WIDTH + 3))
|
||||
local PROMPT_WITH_COLOR
|
||||
PROMPT_WITH_COLOR=$(printf "%-*s %s%s%s: " \
|
||||
$ADJUSTED_WIDTH \
|
||||
"$PROMPT_MESSAGE" \
|
||||
"$COLOR" \
|
||||
"$DEFAULT_VALUE" \
|
||||
"$RESET")
|
||||
echo "$PROMPT_WITH_COLOR"
|
||||
}
|
||||
|
||||
# Prompt for mandatory input (e.g. passwords), input is hidden
|
||||
function prompt_mandatory {
|
||||
local PROMPT_MESSAGE=$1
|
||||
local PAD_WIDTH=${2:-20}
|
||||
local INPUT=""
|
||||
|
||||
while [ -z "$INPUT" ]; do
|
||||
local PROMPT_WITH_COLOR
|
||||
PROMPT_WITH_COLOR=$(printf "%-*s: " $PAD_WIDTH "$PROMPT_MESSAGE")
|
||||
read -s -p "$(echo -e "$PROMPT_WITH_COLOR")" INPUT
|
||||
echo # newline after hidden input
|
||||
if [ -z "$INPUT" ]; then
|
||||
echo "The field $PROMPT_MESSAGE may not be empty. Please enter again."
|
||||
fi
|
||||
done
|
||||
echo "$INPUT"
|
||||
}
|
||||
|
||||
# Prompt the user with specific options and return the response in lowercase
|
||||
function prompt_user() {
|
||||
local prompt_message="$1"
|
||||
local options="$2"
|
||||
local default_response="$3"
|
||||
|
||||
read -p "$prompt_message ($options): " RESPONSE
|
||||
RESPONSE=${RESPONSE,,} # Convert to lowercase
|
||||
echo "${RESPONSE:-$default_response}"
|
||||
}
|
||||
|
||||
# ------------------------------------------------------------------------------
|
||||
# Function to edit an existing .env file (create a backup and load its values)
|
||||
# ------------------------------------------------------------------------------
|
||||
function edit_env_file() {
|
||||
# Create backup
|
||||
mkdir -p "$BACKUP_DIR"
|
||||
local TIMESTAMP
|
||||
TIMESTAMP=$(date +"%Y%m%d-%H%M%S")
|
||||
local BACKUP_FILE="${BACKUP_DIR}/.env.backup-${TIMESTAMP}"
|
||||
cp "$ENV_FILE" "$BACKUP_FILE" || error_exit "Error creating backup copy."
|
||||
echo "Backup copy created under $BACKUP_FILE."
|
||||
|
||||
# Read existing .env and export variables
|
||||
echo "Reading existing .env to use its values as defaults..."
|
||||
while IFS='=' read -r key value || [[ -n "$key" ]]; do
|
||||
# Skip empty lines and comments
|
||||
[[ -z "$key" || "$key" =~ ^# ]] && continue
|
||||
# Remove surrounding quotes if any
|
||||
value=${value#\"}
|
||||
value=${value%\"}
|
||||
value=${value#\'}
|
||||
value=${value%\'}
|
||||
export "$key=$value"
|
||||
done < "$ENV_FILE"
|
||||
}
|
||||
|
||||
# ------------------------------------------------------------------------------
|
||||
# Function to handle user cancellation
|
||||
# ------------------------------------------------------------------------------
|
||||
function cancel_operation() {
|
||||
echo "Operation cancelled by user."
|
||||
exit "$EXIT_USER_CANCEL"
|
||||
}
|
||||
|
||||
# ------------------------------------------------------------------------------
|
||||
# Main Logic
|
||||
# ------------------------------------------------------------------------------
|
||||
if [ -f "$ENV_FILE" ]; then
|
||||
RESPONSE=$(prompt_user "Edit: ${ENV_FILE} type <e> | Hold: type <enter> or <u> | Cancel: type <c>" "Edit/Use/Cancel" "use")
|
||||
case "$RESPONSE" in
|
||||
edit|e)
|
||||
edit_env_file
|
||||
;;
|
||||
use|u)
|
||||
echo "Existing ${ENV_FILE} file will be used (unchanged)."
|
||||
exit 0
|
||||
;;
|
||||
cancel|c)
|
||||
cancel_operation
|
||||
;;
|
||||
*)
|
||||
echo "Unknown input - existing ${ENV_FILE} will be used (unchanged)."
|
||||
exit 0
|
||||
;;
|
||||
esac
|
||||
else
|
||||
echo "No ${ENV_FILE} file found."
|
||||
RESPONSE=$(prompt_user "Create new: ${ENV_FILE} type <e> | Cancel: type <c>" "Edit/Cancel" "edit")
|
||||
case "$RESPONSE" in
|
||||
edit|e)
|
||||
echo "Proceeding to create a new ${ENV_FILE} file..."
|
||||
;;
|
||||
cancel|c)
|
||||
cancel_operation
|
||||
;;
|
||||
*)
|
||||
echo "Unknown input - proceeding to create a new ${ENV_FILE} file."
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
|
||||
# ------------------------------------------------------------------------------
|
||||
# Internal use: Retrieve git info
|
||||
# ------------------------------------------------------------------------------
|
||||
DOCKER_BUILDENV_GIT_URL="$(git config --get remote.origin.url)"
|
||||
DOCKER_BUILDENV_VERSION="$(git -C "$(pwd)" describe --tags --long | sed -e 's/-g[0-9a-f]\{7,\}$//' -e 's/-\([0-9]\+\)$/.\1/')"
|
||||
|
||||
# ------------------------------------------------------------------------------
|
||||
# Original defaults used for prompts (for color comparison and fallback)
|
||||
# ------------------------------------------------------------------------------
|
||||
ORIG_USER_NAME="$(whoami)"
|
||||
ORIG_USER_ID="$(id -u)"
|
||||
ORIG_USER_GROUP="$(id -gn)"
|
||||
ORIG_USER_GROUP_ID="$(id -g)"
|
||||
ORIG_DEFAULT_PASSWORD="tuxpwd"
|
||||
|
||||
if command -v git &>/dev/null; then
|
||||
ORIG_GIT_EMAIL=$(git config --global user.email || true)
|
||||
ORIG_GIT_USER=$(git config --global user.name || true)
|
||||
fi
|
||||
ORIG_GIT_EMAIL=${ORIG_GIT_EMAIL:-"${USER}@${HOSTNAME}"}
|
||||
ORIG_GIT_USER=${ORIG_GIT_USER:-$(getent passwd "${USER}" | cut -d: -f5 | cut -d, -f1)}
|
||||
|
||||
ORIG_BUILDENV_GIT_URL="https://github.com/tuxbox-neutrino/buildenv.git"
|
||||
ORIG_BUILDENV_PREFIX="buildenv"
|
||||
|
||||
# Additional defaults
|
||||
ORIG_DISPLAY="${DISPLAY:-:0}"
|
||||
ORIG_ENABLE_UI_TOOLS="false"
|
||||
ORIG_BUILDENV_INSTALL_PREFIX="tuxbox"
|
||||
ORIG_LOCAL_HOSTNAME="${HOSTNAME}"
|
||||
ORIG_LOCALE_LANG="${LANG:-en_US.UTF-8}"
|
||||
ORIG_TZ="$(cat /etc/timezone 2>/dev/null || echo 'UTC')"
|
||||
ORIG_TERM="${TERM:-xterm}"
|
||||
ORIG_NVIDIA_VISIBLE_DEVICES="all"
|
||||
ORIG_QT_QUICK_BACKEND="software"
|
||||
ORIG_QT_XCB_GL_INTEGRATION="xcb_egl"
|
||||
|
||||
ORIG_USER_DIR="${HOME}"
|
||||
|
||||
ORIG_EXPLORER_ENABLE="false"
|
||||
ORIG_EXPLORER_GIT_URL="https://github.com/dbt1/tuxbox-explorer.git"
|
||||
|
||||
ORIG_XDG_CONFIG_HOME="${ORIG_USER_DIR}/.config"
|
||||
ORIG_XDG_RUNTIME_DIR="${XDG_RUNTIME_DIR}"
|
||||
|
||||
# ------------------------------------------------------------------------------
|
||||
# Prompt the user for various settings using defaults (either from existing .env or original)
|
||||
# ------------------------------------------------------------------------------
|
||||
echo -e "Global user data"
|
||||
USER_NAME=$(prompt "USER_NAME" "${USER_NAME:-$ORIG_USER_NAME}")
|
||||
USER_DIR=$(prompt "USER_DIR" "${USER_DIR:-$ORIG_USER_DIR}")
|
||||
USER_ID=$(prompt "USER_ID" "${USER_ID:-$ORIG_USER_ID}")
|
||||
USER_GROUP=$(prompt "USER_GROUP" "${USER_GROUP:-$ORIG_USER_GROUP}")
|
||||
USER_GROUP_ID=$(prompt "USER_GROUP_ID" "${USER_GROUP_ID:-$ORIG_USER_GROUP_ID}")
|
||||
echo -e ""
|
||||
echo -e "Set or use this default user password, NOTE: Please change it if you run the container at first time!"
|
||||
USER_PASSWORD=$(prompt "USER_PASSWORD" "${USER_PASSWORD:-$ORIG_DEFAULT_PASSWORD}")
|
||||
# Alternatively, you could use prompt_mandatory for hidden password input:
|
||||
# USER_PASSWORD=$(prompt_mandatory "USER_PASSWORD" 20)
|
||||
|
||||
echo -e ""
|
||||
echo -e "Add some default git user data."
|
||||
GIT_EMAIL=$(prompt "GIT_EMAIL" "${GIT_EMAIL:-$ORIG_GIT_EMAIL}")
|
||||
GIT_USER=$(prompt "GIT_USER" "${GIT_USER:-$ORIG_GIT_USER}")
|
||||
|
||||
echo -e ""
|
||||
echo -e "Clone URL for buildenv sources."
|
||||
BUILDENV_GIT_URL=$(prompt "BUILDENV_GIT_URL" "${BUILDENV_GIT_URL:-$ORIG_BUILDENV_GIT_URL}")
|
||||
|
||||
echo -e ""
|
||||
echo -e "htdoc content for file explorer, allows userfriendly navigation through deploed results"
|
||||
EXPLORER_ENABLE=$(prompt "EXPLORER_ENABLE" "${EXPLORER_ENABLE:-$ORIG_EXPLORER_ENABLE}")
|
||||
EXPLORER_GIT_URL=$(prompt "EXPLORER_GIT_URL" "${EXPLORER_GIT_URL:-$ORIG_EXPLORER_GIT_URL}")
|
||||
|
||||
echo -e ""
|
||||
echo -e "Prefix where to install all buildenv stuff within user dir (default: $ORIG_BUILDENV_INSTALL_PREFIX)"
|
||||
BUILDENV_INSTALL_PREFIX=$(prompt "BUILDENV_INSTALL_PREFIX" "${BUILDENV_INSTALL_PREFIX:-$ORIG_BUILDENV_INSTALL_PREFIX}")
|
||||
|
||||
echo -e ""
|
||||
echo -e "Prefix for buildenv sources (default: $ORIG_BUILDENV_PREFIX)"
|
||||
BUILDENV_PREFIX=$(prompt "BUILDENV_PREFIX" "${BUILDENV_PREFIX:-$ORIG_BUILDENV_PREFIX}")
|
||||
|
||||
echo -e ""
|
||||
echo -e "UI-related settings."
|
||||
DISPLAY=$(prompt "DISPLAY" "${DISPLAY:-$ORIG_DISPLAY}")
|
||||
ENABLE_UI_TOOLS=$(prompt "ENABLE_UI_TOOLS" "${ENABLE_UI_TOOLS:-$ORIG_ENABLE_UI_TOOLS}")
|
||||
NVIDIA_VISIBLE_DEVICES=$(prompt "NVIDIA_VISIBLE_DEVICES" "${NVIDIA_VISIBLE_DEVICES:-$ORIG_NVIDIA_VISIBLE_DEVICES}")
|
||||
QT_QUICK_BACKEND=$(prompt "QT_QUICK_BACKEND" "${QT_QUICK_BACKEND:-$ORIG_QT_QUICK_BACKEND}")
|
||||
QT_XCB_GL_INTEGRATION=$(prompt "QT_XCB_GL_INTEGRATION" "${QT_XCB_GL_INTEGRATION:-$ORIG_QT_XCB_GL_INTEGRATION}")
|
||||
|
||||
echo -e ""
|
||||
echo -e "System variables."
|
||||
LOCAL_HOSTNAME=$(prompt "LOCAL_HOSTNAME" "${LOCAL_HOSTNAME:-$ORIG_LOCAL_HOSTNAME}")
|
||||
LOCALE_LANG=$(prompt "LOCALE_LANG" "${LOCALE_LANG:-$ORIG_LOCALE_LANG}")
|
||||
TZ=$(prompt "TZ" "${TZ:-$ORIG_TZ}")
|
||||
TERM=$(prompt "TERM" "${TERM:-$ORIG_TERM}")
|
||||
XDG_CONFIG_HOME=$(prompt "XDG_CONFIG_HOME" "${XDG_CONFIG_HOME:-$ORIG_XDG_CONFIG_HOME}")
|
||||
XDG_RUNTIME_DIR=$(prompt "XDG_RUNTIME_DIR" "${XDG_RUNTIME_DIR:-$ORIG_XDG_RUNTIME_DIR}")
|
||||
|
||||
# Derived variables based on the above
|
||||
USER_VOLUME_WORKDIR="${USER_DIR}/${BUILDENV_INSTALL_PREFIX}"
|
||||
USER_VOLUME_DATADIR="${USER_VOLUME_WORKDIR}/.data"
|
||||
USER_VOLUME_BINDIR="${USER_DIR}/bin"
|
||||
START_PATH="${USER_VOLUME_WORKDIR}/${BUILDENV_PREFIX}"
|
||||
WWW_DOCDIR="${USER_VOLUME_WORKDIR}/htdoc"
|
||||
|
||||
# Setup history file location
|
||||
HISTFILE_NAME=".bash_history"
|
||||
HISTFILE="${USER_VOLUME_DATADIR}/${HISTFILE_NAME}"
|
||||
|
||||
# Set default values for GIT_EMAIL, GIT_USER
|
||||
GIT_EMAIL="${USER}@${HOSTNAME}"
|
||||
GIT_USER="$(grep "${USER}" /etc/passwd | cut -d: -f5 | sed 's/,//g')"
|
||||
# ------------------------------------------------------------------------------
|
||||
# Write the final .env file
|
||||
# ------------------------------------------------------------------------------
|
||||
cat <<EOF > "$ENV_FILE"
|
||||
# Auto-generated $ENV_FILE file for docker-buildenv
|
||||
# Do not change manually! Run $0 to generate $ENV_FILE!
|
||||
|
||||
# Check if git is installed
|
||||
if git --version &>/dev/null; then
|
||||
# Git is installed, try to get global values
|
||||
GLOBAL_EMAIL=$(git config --global user.email)
|
||||
if [ -z "$GLOBAL_EMAIL" ]; then
|
||||
GLOBAL_EMAIL=$GIT_EMAIL
|
||||
fi
|
||||
GLOBAL_USER=$(git config --global user.name)
|
||||
if [ -z "$GLOBAL_USER" ]; then
|
||||
GLOBAL_USER=$GIT_USER
|
||||
fi
|
||||
|
||||
# Check if inside a Git repository
|
||||
if git rev-parse --is-inside-work-tree >/dev/null 2>&1; then
|
||||
# Try to get local values if globals are not set
|
||||
[ -z "$GLOBAL_EMAIL" ] && GIT_EMAIL=$(git config --local user.email) || GIT_EMAIL=$GLOBAL_EMAIL
|
||||
[ -z "$GLOBAL_USER" ] && GIT_USER=$(git config --local user.name) || GIT_USER=$GLOBAL_USER
|
||||
DOCKER_BUILDENV_GIT_URL=${DOCKER_BUILDENV_GIT_URL}
|
||||
DOCKER_BUILDENV_VERSION=${DOCKER_BUILDENV_VERSION}
|
||||
|
||||
# Get version info
|
||||
last_tag=$(git describe --tags --abbrev=0 2>/dev/null)
|
||||
last_commit_id=$(git rev-parse --short HEAD)
|
||||
current_branch=$(git rev-parse --abbrev-ref HEAD)
|
||||
if [ -z "$last_tag" ]; then
|
||||
commit_count=$(git rev-list --count HEAD)
|
||||
TB_VERSION="git+${commit_count}-${last_commit_id}-${current_branch}"
|
||||
else
|
||||
commit_count=$(git rev-list --count ${last_tag}..HEAD)
|
||||
TB_VERSION="${last_tag}.${commit_count}-${current_branch}"
|
||||
fi
|
||||
else
|
||||
# Not inside a Git repo, use global values if available
|
||||
GIT_EMAIL=${GLOBAL_EMAIL:-$GIT_EMAIL}
|
||||
GIT_USER=${GLOBAL_USER:-$GIT_USER}
|
||||
fi
|
||||
else
|
||||
echo "Git is not installed, using default values."
|
||||
fi
|
||||
|
||||
# Create environment variables and write into .env
|
||||
cat <<EOF >$ENV_FILE
|
||||
BUILDENV_GIT_URL=https://github.com/tuxbox-neutrino/buildenv.git
|
||||
BUILDENV_VERSION=${BUILDENV_VERSION}
|
||||
BUILDENV_GIT_URL=${BUILDENV_GIT_URL}
|
||||
BUILDENV_PREFIX=${BUILDENV_PREFIX}
|
||||
TB_BUILD_TIME=${TB_BUILD_TIME}
|
||||
|
||||
USER_NAME=${USER_NAME}
|
||||
USER_ID=${USER_ID}
|
||||
USER_GROUP=${USER_GROUP}
|
||||
USER_GROUP_ID=${USER_GROUP_ID}
|
||||
USER_PASSWORD=${USER_PASSWORD}
|
||||
|
||||
DISPLAY=${DISPLAY}
|
||||
ENABLE_UI_TOOLS=${ENABLE_UI_TOOLS}
|
||||
GIT_EMAIL=${GIT_EMAIL}
|
||||
GIT_USER=${GIT_USER}
|
||||
HISTFILE=${HISTFILE}
|
||||
HISTFILE_NAME=${HISTFILE_NAME}
|
||||
HOST_PREFIX=${HOST_PREFIX}
|
||||
LANGUAGE=${LANG}
|
||||
LC_ALL=${LANG}
|
||||
LOCALE_LANG=${LANG}
|
||||
HISTFILE=${HISTFILE}
|
||||
BUILDENV_INSTALL_PREFIX=${BUILDENV_INSTALL_PREFIX}
|
||||
LOCAL_HOSTNAME=${LOCAL_HOSTNAME}
|
||||
NVIDIA_VISIBLE_DEVICES=all
|
||||
QT_QUICK_BACKEND=software
|
||||
QT_XCB_GL_INTEGRATION=xcb_egl
|
||||
START_PATH=${USER_VOLUME_WORKDIR}/${BUILDENV_PREFIX}
|
||||
LOCALE_LANG=${LOCALE_LANG}
|
||||
TZ=${TZ}
|
||||
TERM=${TERM}
|
||||
TZ=$(cat /etc/timezone)
|
||||
USER=${USER}
|
||||
NVIDIA_VISIBLE_DEVICES=${NVIDIA_VISIBLE_DEVICES}
|
||||
QT_QUICK_BACKEND=${QT_QUICK_BACKEND}
|
||||
QT_XCB_GL_INTEGRATION=${QT_XCB_GL_INTEGRATION}
|
||||
USER_DIR=${USER_DIR}
|
||||
USER_GROUP=${USER}
|
||||
USER_GROUP_ID=${USER_GROUP_ID}
|
||||
USER_ID=${USER_ID}
|
||||
USER_PASSWORD=${USER}
|
||||
USER_VOLUME_WORKDIR=${USER_VOLUME_WORKDIR}
|
||||
USER_VOLUME_DATADIR=${USER_VOLUME_DATADIR}
|
||||
USER_VOLUME_BINDIR=${USER_VOLUME_BINDIR}
|
||||
USER_VOLUME_WORKBINDIR=${USER_VOLUME_WORKBINDIR}
|
||||
TB_VERSION=${TB_VERSION}
|
||||
XDG_CONFIG_HOME=/home
|
||||
XDG_RUNTIME_DIR=/tmp/runtime-root
|
||||
START_PATH=${START_PATH}
|
||||
WWW_DOCDIR=${WWW_DOCDIR}
|
||||
EXPLORER_ENABLE=${EXPLORER_ENABLE}
|
||||
EXPLORER_GIT_URL=${EXPLORER_GIT_URL}
|
||||
XDG_CONFIG_HOME=${XDG_CONFIG_HOME}
|
||||
XDG_RUNTIME_DIR=${XDG_RUNTIME_DIR}
|
||||
EOF
|
||||
|
||||
# validate
|
||||
echo ".env-file successfully created with:"
|
||||
cat $ENV_FILE
|
||||
echo -e ""
|
||||
echo -e "$ENV_FILE file was successfully created (or overwritten)."
|
||||
|
@@ -1,16 +1,28 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Path to script that will be executed before starts docker-compose
|
||||
# Path to script that will be executed before starting docker-compose
|
||||
ENV_SCRIPT="./create-env.sh"
|
||||
|
||||
# Define exit codes as constants
|
||||
EXIT_USER_CANCEL=70
|
||||
|
||||
# Check script
|
||||
if [ -x "$ENV_SCRIPT" ]; then
|
||||
echo "executing $ENV_SCRIPT..."
|
||||
$ENV_SCRIPT
|
||||
echo "Executing $ENV_SCRIPT..."
|
||||
"$ENV_SCRIPT"
|
||||
EXIT_CODE=$?
|
||||
|
||||
if [ $EXIT_CODE -eq $EXIT_USER_CANCEL ]; then
|
||||
echo "create-env.sh was canceled by the user."
|
||||
exit $EXIT_USER_CANCEL
|
||||
elif [ $EXIT_CODE -ne 0 ]; then
|
||||
echo "create-env.sh failed with exit code $EXIT_CODE."
|
||||
exit $EXIT_CODE
|
||||
fi
|
||||
else
|
||||
echo "Error: $ENV_SCRIPT not found or not executable."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Execute docker-compose with all parameters an sub commannds
|
||||
# Execute docker-compose with all parameters and subcommands
|
||||
docker-compose "$@"
|
||||
|
@@ -1,86 +1,118 @@
|
||||
version: '3.8'
|
||||
|
||||
services:
|
||||
tuxbox-build:
|
||||
container_name: tuxbox-build
|
||||
image: tuxbox-build
|
||||
environment:
|
||||
- PATH=${USER_VOLUME_WORKBINDIR}:${USER_VOLUME_BINDIR}:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
|
||||
env_file:
|
||||
- .env
|
||||
build:
|
||||
context: .
|
||||
dockerfile: Dockerfile
|
||||
args:
|
||||
- BUILDENV_GIT_URL=${BUILDENV_GIT_URL}
|
||||
- BUILDENV_PREFIX=${BUILDENV_PREFIX}
|
||||
- BUILDENV_VERSION=${BUILDENV_VERSION}
|
||||
- DISPLAY=${DISPLAY}
|
||||
- ENABLE_UI_TOOLS=false
|
||||
- GIT_EMAIL=${GIT_EMAIL}
|
||||
- GIT_USER=${GIT_USER}
|
||||
- HISTFILE=${USER_VOLUME_DATADIR}/${HISTFILE_NAME}
|
||||
- HISTFILE_NAME=${HISTFILE_NAME}
|
||||
- HOST_PREFIX=${HOST_PREFIX}
|
||||
- LOCALE_LANG=${LOCALE_LANG}
|
||||
- LOCAL_HOSTNAME=${LOCAL_HOSTNAME}
|
||||
- NVIDIA_VISIBLE_DEVICES=${NVIDIA_VISIBLE_DEVICES}
|
||||
- QT_QUICK_BACKEND=${QT_QUICK_BACKEND}
|
||||
- QT_XCB_GL_INTEGRATION=${QT_XCB_GL_INTEGRATION}
|
||||
- START_PATH=${START_PATH}
|
||||
- TB_BUILD_TIME=${TB_BUILD_TIME}
|
||||
- TB_VERSION=${TB_VERSION}
|
||||
- TERM=${TERM}
|
||||
- TZ=${TZ}
|
||||
- USER=${USER}
|
||||
- USER_DIR=${USER_DIR}
|
||||
- USER_GROUP=${USER_GROUP}
|
||||
- USER_GROUP_ID=${USER_GROUP_ID}
|
||||
- USER_ID=${USER_ID}
|
||||
- USER_PASSWORD=${USER_PASSWORD}
|
||||
- USER_VOLUME_WORKDIR=${USER_DIR}/${HOST_PREFIX}
|
||||
- USER_VOLUME_DATADIR=${USER_VOLUME_DATADIR}
|
||||
- XDG_CONFIG_HOME=${XDG_CONFIG_HOME}
|
||||
- XDG_RUNTIME_DIR=${XDG_RUNTIME_DIR}
|
||||
DOCKER_BUILDENV_VERSION: ${DOCKER_BUILDENV_VERSION}
|
||||
DOCKER_BUILDENV_GIT_URL: $DOCKER_BUILDENV_GIT_URL
|
||||
|
||||
PATH: "${USER_VOLUME_WORKDIR}/bin:${USER_VOLUME_BINDIR}:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
|
||||
BUILDENV_GIT_URL: ${BUILDENV_GIT_URL}
|
||||
BUILDENV_PREFIX: ${BUILDENV_PREFIX}
|
||||
|
||||
# Host user and group
|
||||
USER_NAME: ${USER_NAME}
|
||||
USER_ID: ${USER_ID}
|
||||
USER_GROUP: ${USER_GROUP}
|
||||
USER_GROUP_ID: ${USER_GROUP_ID}
|
||||
USER_PASSWORD: ${USER_PASSWORD}
|
||||
USER_DIR: ${USER_DIR}
|
||||
|
||||
# More Build-Args
|
||||
DISPLAY: ${DISPLAY}
|
||||
ENABLE_UI_TOOLS: ${ENABLE_UI_TOOLS}
|
||||
GIT_EMAIL: ${GIT_EMAIL}
|
||||
GIT_USER: ${GIT_USER}
|
||||
HISTFILE_NAME: ${HISTFILE_NAME}
|
||||
HISTFILE: ${HISTFILE}
|
||||
BUILDENV_INSTALL_PREFIX: ${BUILDENV_INSTALL_PREFIX}
|
||||
LOCAL_HOSTNAME: ${LOCAL_HOSTNAME}
|
||||
LOCALE_LANG: ${LOCALE_LANG}
|
||||
TZ: ${TZ}
|
||||
TERM: ${TERM}
|
||||
NVIDIA_VISIBLE_DEVICES: ${NVIDIA_VISIBLE_DEVICES}
|
||||
QT_QUICK_BACKEND: ${QT_QUICK_BACKEND}
|
||||
QT_XCB_GL_INTEGRATION: ${QT_XCB_GL_INTEGRATION}
|
||||
USER_VOLUME_WORKDIR: ${USER_VOLUME_WORKDIR}
|
||||
USER_VOLUME_DATADIR: ${USER_VOLUME_DATADIR}
|
||||
START_PATH: ${START_PATH}
|
||||
WWW_DOCDIR: ${WWW_DOCDIR}
|
||||
EXPLORER_ENABLE: ${EXPLORER_ENABLE}
|
||||
EXPLORER_GIT_URL: ${EXPLORER_GIT_URL}
|
||||
XDG_CONFIG_HOME: ${XDG_CONFIG_HOME}
|
||||
XDG_RUNTIME_DIR: ${XDG_RUNTIME_DIR}
|
||||
|
||||
image: tuxbox-build
|
||||
|
||||
environment:
|
||||
DOCKER_BUILDENV_VERSION: ${DOCKER_BUILDENV_VERSION}
|
||||
DOCKER_BUILDENV_GIT_URL: $DOCKER_BUILDENV_GIT_URL
|
||||
BUILDENV_GIT_URL: ${BUILDENV_GIT_URL}
|
||||
BUILDENV_PREFIX: ${BUILDENV_PREFIX}
|
||||
PATH: "${USER_VOLUME_WORKDIR}/bin:${USER_VOLUME_BINDIR}:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
|
||||
DISPLAY: ${DISPLAY}
|
||||
ENABLE_UI_TOOLS: ${ENABLE_UI_TOOLS}
|
||||
GIT_EMAIL: ${GIT_EMAIL}
|
||||
GIT_USER: ${GIT_USER}
|
||||
HISTFILE_NAME: ${HISTFILE_NAME}
|
||||
HISTFILE: ${HISTFILE}
|
||||
BUILDENV_INSTALL_PREFIX: ${BUILDENV_INSTALL_PREFIX}
|
||||
LOCAL_HOSTNAME: ${LOCAL_HOSTNAME}
|
||||
LOCALE_LANG: ${LOCALE_LANG}
|
||||
TZ: ${TZ}
|
||||
TERM: ${TERM}
|
||||
NVIDIA_VISIBLE_DEVICES: ${NVIDIA_VISIBLE_DEVICES}
|
||||
QT_QUICK_BACKEND: ${QT_QUICK_BACKEND}
|
||||
QT_XCB_GL_INTEGRATION: ${QT_XCB_GL_INTEGRATION}
|
||||
USER: ${USER_NAME}
|
||||
USER_ID: ${USER_ID}
|
||||
USER_GROUP: ${USER_GROUP}
|
||||
USER_GROUP_ID: ${USER_GROUP_ID}
|
||||
USER_PASSWORD: ${USER_PASSWORD}
|
||||
USER_DIR: ${USER_DIR}
|
||||
USER_VOLUME_WORKDIR: ${USER_VOLUME_WORKDIR}
|
||||
USER_VOLUME_DATADIR: ${USER_VOLUME_DATADIR}
|
||||
START_PATH: ${START_PATH}
|
||||
WWW_DOCDIR: ${WWW_DOCDIR}
|
||||
EXPLORER_ENABLE: ${EXPLORER_ENABLE}
|
||||
EXPLORER_GIT_URL: ${EXPLORER_GIT_URL}
|
||||
XDG_CONFIG_HOME: ${XDG_CONFIG_HOME}
|
||||
XDG_RUNTIME_DIR: ${XDG_RUNTIME_DIR}
|
||||
|
||||
devices:
|
||||
- /dev/dri:/dev/dri
|
||||
ports:
|
||||
# the host: container ports for web access, used for httpd inside container to get built packages and images via browser, wget, curl, set top boxes etc.
|
||||
- "8080:80"
|
||||
# the host: container ports for ssh access of users in its /home
|
||||
- "222:22"
|
||||
tty: true
|
||||
working_dir: /
|
||||
volumes:
|
||||
- ${USER_VOLUME_WORKDIR}:${USER_VOLUME_WORKDIR}
|
||||
- ${USER_VOLUME_BINDIR}:${USER_DIR}/bin
|
||||
- ${USER_VOLUME_DATADIR}:/data
|
||||
- ${USER_VOLUME_WORKDIR}/.config:/config
|
||||
- ${USER_VOLUME_WORKDIR}/.config/git/config:${XDG_CONFIG_HOME}/git
|
||||
- ${USER_DIR}/sstate-cache:${USER_DIR}/sstate-cache
|
||||
- ${USER_DIR}/Archive:${USER_DIR}/Archive
|
||||
- ${USER_DIR}/.ccache:${USER_DIR}/.ccache
|
||||
- ${USER_DIR}/sources:${USER_DIR}/sources
|
||||
- ${USER_VOLUME_BINDIR}:${USER_DIR}/bin
|
||||
- ${USER_VOLUME_WORKBINDIR}:${USER_VOLUME_WORKDIR}/bin
|
||||
- ${USER_DIR}/.ssh:${USER_DIR}/.ssh
|
||||
- ${USER_VOLUME_DATADIR}:/data
|
||||
- ${USER_VOLUME_WORKDIR}/.config:/config
|
||||
- ${USER_VOLUME_WORKDIR}/.config/git/config:${XDG_CONFIG_HOME}/git
|
||||
|
||||
|
||||
# Optional for UI tools
|
||||
- /tmp/.X11-unix:/tmp/.X11-unix
|
||||
- /usr/lib/x86_64-linux-gnu/mesa:/usr/lib/x86_64-linux-gnu/mesa
|
||||
networks:
|
||||
- tuxbox-network
|
||||
#hostname: ${LOCAL_HOSTNAME}
|
||||
|
||||
devices:
|
||||
- /dev/dri:/dev/dri # For GPU acceleration if needed
|
||||
|
||||
ports:
|
||||
- "8080:80" # Webserver
|
||||
- "222:22" # SSH
|
||||
|
||||
tty: true
|
||||
working_dir: /
|
||||
|
||||
cap_add:
|
||||
- SYS_ADMIN
|
||||
|
||||
restart: unless-stopped
|
||||
|
||||
networks:
|
||||
tuxbox-network:
|
||||
default:
|
||||
driver: bridge
|
||||
|
||||
volumes:
|
||||
tuxbox-volumes:
|
||||
driver: local
|
||||
|
||||
|
||||
|
||||
|
@@ -58,11 +58,12 @@ if [ -n "$force_color_prompt" ]; then
|
||||
fi
|
||||
|
||||
if [ "$color_prompt" = yes ]; then
|
||||
PS1='\[\033[01;33m\]\u\[\033[01;33m\]@\[\033[01;33m\]\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ '
|
||||
PS1='\[\033[01;33m\]\u\[\033[01;33m\]@@LOCAL_HOSTNAME@\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ '
|
||||
else
|
||||
PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w\$ '
|
||||
PS1='${debian_chroot:+($debian_chroot)}\u@@LOCAL_HOSTNAME@:\w\$ '
|
||||
fi
|
||||
|
||||
|
||||
unset color_prompt force_color_prompt
|
||||
|
||||
# If this is an xterm set the title to user@host:dir
|
||||
@@ -116,8 +117,56 @@ fi
|
||||
|
||||
cd @START_PATH@
|
||||
|
||||
while IFS= read -r line; do echo -e "$line"; done < /etc/terminal-splash.txt
|
||||
echo -e "--------------------------------------------------------------"
|
||||
echo -e "Tuxbox-Builder Version: @VERSION@"
|
||||
echo -e "--------------------------------------------------------------"
|
||||
echo -e "--------------------------------------------------------------------"
|
||||
while IFS= read -r line; do
|
||||
echo -e "$line"
|
||||
done < /etc/terminal-splash.txt
|
||||
echo -e "--------------------------------------------------------------------"
|
||||
echo -e "docker-buildenv: v@DOCKER_BUILDENV_VERSION@\t| @DOCKER_BUILDENV_GIT_URL@"
|
||||
echo -e "buildenv: $(git -C @START_PATH@ describe --tags --long | sed -e 's/-g[0-9a-f]\{7,\}$//' -e 's/-\([0-9]\+\)$/.\1/')\t| @BUILDENV_GIT_URL@"
|
||||
if [ -f /etc/os-release ]; then
|
||||
PRETTY_NAME=$(grep '^PRETTY_NAME=' /etc/os-release | cut -d= -f2 | tr -d '"')
|
||||
echo -e "OS-Version: $PRETTY_NAME"
|
||||
fi
|
||||
echo -e "Kernel-Version: $(uname -r)"
|
||||
echo -e "Container-Hostname: $(hostname)"
|
||||
echo -e "Container-IP: $(hostname -I | awk '{print $1}')"
|
||||
echo -e "--------------------------------------------------------------------"
|
||||
echo -e ""
|
||||
|
||||
convert_locale() {
|
||||
local input_locale="$1"
|
||||
echo "${input_locale%.*}:${input_locale%%_*}"
|
||||
}
|
||||
export LANG=@LANG@
|
||||
export LANGUAGE=$(convert_locale $LANG)
|
||||
export LC_ALL=$LANG
|
||||
|
||||
# Set the directory to check
|
||||
DIR_TO_CHECK=@START_PATH@
|
||||
|
||||
# Detect system locale
|
||||
LOCALE=$(locale | grep LANG= | cut -d= -f2 | cut -d_ -f1)
|
||||
|
||||
# Set link based on locale
|
||||
if [[ "$LOCALE" == "de" ]]; then
|
||||
LINK="https://github.com/tuxbox-neutrino/buildenv/blob/master/README-de.md#14-init-skript-ausf%C3%BChren"
|
||||
else
|
||||
LINK="https://github.com/tuxbox-neutrino/buildenv/blob/master/README-us.md#14-init-script"
|
||||
fi
|
||||
|
||||
# Check for subdirectories starting with 'meta-'
|
||||
if ! find "$DIR_TO_CHECK" -type d -name "meta-*" | grep -q .; then
|
||||
# Print bold and user-friendly message if no subdirectory matches
|
||||
echo -e "--------------------------------------------------------------"
|
||||
echo -e "\033[1m\033[33mNOTE: Your build environment seems to be uninitialized!\033[0m"
|
||||
echo -e "--------------------------------------------------------------"
|
||||
echo -e "\033[1mPlease run the init script to set up your environment.\033[0m"
|
||||
echo -e ""
|
||||
echo -e "./init && cd poky-@BUILDENV_VERSION@"
|
||||
echo -e ""
|
||||
echo -e "--------------------------------------------------------------"
|
||||
echo -e "Refer to the instructions here:"
|
||||
echo -e "\033[4m$LINK\033[0m"
|
||||
echo -e ""
|
||||
fi
|
120
files/init.sh
Executable file
120
files/init.sh
Executable file
@@ -0,0 +1,120 @@
|
||||
#!/bin/bash
|
||||
# Initialize tuxbox-builder container...
|
||||
echo 'Initialize tuxbox-builder container...'
|
||||
|
||||
# Define a dedicated user group
|
||||
GROUP_NAME="${USER_GROUP:-$USER}"
|
||||
|
||||
# Ensure the group exists, create it if necessary
|
||||
if ! getent group "$GROUP_NAME" > /dev/null; then
|
||||
echo "Group $GROUP_NAME does not exist. Creating..."
|
||||
groupadd "$GROUP_NAME"
|
||||
fi
|
||||
|
||||
# Ensure the user exists, create it if necessary
|
||||
if ! id "$USER" &>/dev/null; then
|
||||
echo "User $USER does not exist. Creating..."
|
||||
useradd -m -s /bin/bash -g "$GROUP_NAME" -G www-data "$USER"
|
||||
else
|
||||
usermod -aG "$GROUP_NAME" "$USER"
|
||||
usermod -aG www-data "$USER"
|
||||
fi
|
||||
|
||||
# Prepare global Git configuration
|
||||
mkdir -p "${XDG_CONFIG_HOME:-$USER_DIR/.config}/git"
|
||||
echo 'Setting up global Git configuration...'
|
||||
echo -e "[user]\n\temail = ${GIT_EMAIL}\n\tname = ${GIT_USER}" > "${XDG_CONFIG_HOME}/git/config"
|
||||
chown -R "$USER":"$GROUP_NAME" "${XDG_CONFIG_HOME}/git"
|
||||
|
||||
# Prepare SSH configuration
|
||||
mkdir -p "${USER_DIR}/.ssh"
|
||||
|
||||
# Optimize chown: Only change ownership if incorrect
|
||||
for dir in "$USER_VOLUME_WORKDIR" "$WWW_DOCDIR"; do
|
||||
if [ -d "$dir" ]; then
|
||||
current_owner=$(stat -c "%U:%G" "$dir")
|
||||
if [ "$current_owner" != "$USER:$GROUP_NAME" ]; then
|
||||
echo "Updating ownership for $dir..."
|
||||
chown -R "$USER":"$GROUP_NAME" "$dir"
|
||||
fi
|
||||
fi
|
||||
done
|
||||
|
||||
# Optimize chmod: Only change permissions if incorrect
|
||||
for dir in "$USER_VOLUME_WORKDIR" "$WWW_DOCDIR"; do
|
||||
if [ -d "$dir" ]; then
|
||||
if find "$dir" -not -perm -g+rw | grep . > /dev/null 2>&1; then
|
||||
echo "Updating permissions for $dir..."
|
||||
chmod -R g+rw "$dir"
|
||||
fi
|
||||
fi
|
||||
done
|
||||
|
||||
echo "User $USER is set up with group $GROUP_NAME and www-data for shared access."
|
||||
|
||||
# Prepare build environment
|
||||
if [ ! -d "${USER_VOLUME_WORKDIR}/${BUILDENV_PREFIX}/.git" ]; then
|
||||
if cd "${USER_VOLUME_WORKDIR}"; then
|
||||
echo "Cloning build environment repository..."
|
||||
git clone "${BUILDENV_GIT_URL}" "${BUILDENV_PREFIX}"
|
||||
else
|
||||
echo "Error: Could not change directory to ${USER_VOLUME_WORKDIR}" >&2
|
||||
exit 1
|
||||
fi
|
||||
else
|
||||
echo "Repository [${USER_VOLUME_WORKDIR}/${BUILDENV_PREFIX}] already exists. Not modified!"
|
||||
fi
|
||||
chown -R "$USER":"$GROUP_NAME" "$USER_VOLUME_WORKDIR"
|
||||
|
||||
# Detect the build environment version
|
||||
BUILDENV_DISTRO_VERSION=$(grep 'DEFAULT_IMAGE_VERSION=' "${START_PATH}/init.sh" | cut -d'=' -f2 | tr -d '"')
|
||||
echo "Detected DISTRO_VERSION = $BUILDENV_DISTRO_VERSION within ${START_PATH}"
|
||||
|
||||
# Prepare web server content if enabled
|
||||
if [ "${EXPLORER_ENABLE}" != "false" ]; then
|
||||
|
||||
if [ ! -d "${WWW_DOCDIR}/.git" ]; then
|
||||
echo 'Cloning File Explorer web content repository...'
|
||||
git clone "${EXPLORER_GIT_URL}" "${WWW_DOCDIR}"
|
||||
fi
|
||||
|
||||
# Download default configuration file if it does not exist
|
||||
if [ ! -f "${WWW_DOCDIR}/config/config.php" ]; then
|
||||
echo "[${WWW_DOCDIR}/config/config.php] does not exist. Downloading..."
|
||||
curl -o "${WWW_DOCDIR}/config/config.php" "https://raw.githubusercontent.com/dbt1/support/master/docker-buildenv/config-sample.php"
|
||||
else
|
||||
echo "Repository [${WWW_DOCDIR}] already exists and configured. Not modified!"
|
||||
fi
|
||||
|
||||
# Find the build directory based on detected distro version
|
||||
BUILD_DIR=$(find "${START_PATH}" -type d -path "*-${BUILDENV_DISTRO_VERSION}/build" ! -path "*-${BUILDENV_DISTRO_VERSION}/build/*" 2>/dev/null)
|
||||
if [ -n "$BUILD_DIR" ]; then
|
||||
sed -i "s|#@FILES_DIRECTORY@|\\\$FILES_DIRECTORY = '$BUILD_DIR'|g" "${WWW_DOCDIR}/config/config.php"
|
||||
fi
|
||||
|
||||
chown -R "$USER":"$GROUP_NAME" "$WWW_DOCDIR"
|
||||
|
||||
else
|
||||
echo "EXPLORER_ENABLE is disabled. Skipping web server setup."
|
||||
fi
|
||||
|
||||
# Prepare user profile with environment variables
|
||||
echo 'Configuring user profile...'
|
||||
BASH_RC_FILE="${USER_DIR}/.bashrc"
|
||||
sed -i "s|@START_PATH@|${START_PATH}|g" "$BASH_RC_FILE"
|
||||
sed -i "s|@BUILDENV_GIT_URL@|${BUILDENV_GIT_URL}|g" "$BASH_RC_FILE"
|
||||
sed -i "s|@DOCKER_BUILDENV_VERSION@|${DOCKER_BUILDENV_VERSION}|g" "$BASH_RC_FILE"
|
||||
sed -i "s|@HISTFILE@|${HISTFILE}|g" "$BASH_RC_FILE"
|
||||
sed -i "s|@LANG@|${LOCALE_LANG}|g" "$BASH_RC_FILE"
|
||||
sed -i "s|@BUILDENV_VERSION@|${BUILDENV_DISTRO_VERSION}|g" "$BASH_RC_FILE"
|
||||
sed -i "s|@DOCKER_BUILDENV_GIT_URL@|${DOCKER_BUILDENV_GIT_URL}|g" "$BASH_RC_FILE"
|
||||
sed -i "s|@LOCAL_HOSTNAME@|${LOCAL_HOSTNAME}|g" "$BASH_RC_FILE"
|
||||
chown "$USER":"$GROUP_NAME" "$BASH_RC_FILE"
|
||||
|
||||
# Mark container as ready
|
||||
touch /tmp/container_ready
|
||||
echo "Container setup complete. Ready to start services..."
|
||||
echo "Enjoy...!"
|
||||
|
||||
# Start services using runsvdir
|
||||
exec runsvdir -P /etc/service
|
44
files/show-env.sh
Executable file
44
files/show-env.sh
Executable file
@@ -0,0 +1,44 @@
|
||||
#!/bin/bash
|
||||
|
||||
echo ""
|
||||
echo "=== Environment Info for Normal Users, 'sshd', and 'root' ==="
|
||||
echo ""
|
||||
|
||||
# Read all users from /etc/passwd
|
||||
while IFS=: read -r username _ uid gid _ home _; do
|
||||
# Include normal users (UID >= 1000), 'sshd', and 'root'
|
||||
if [ "$uid" -ge 1000 ] || [ "$username" == "sshd" ] || [ "$username" == "root" ]; then
|
||||
echo "User: $username"
|
||||
echo "USER_ID: $uid"
|
||||
echo "USER_GROUP: $(getent group $gid | cut -d: -f1)"
|
||||
echo "USER_GROUP_ID: $gid"
|
||||
|
||||
# Git configuration, if available
|
||||
if [ -f "$home/.gitconfig" ]; then
|
||||
git_user=$(git config --global --file "$home/.gitconfig" user.name 2>/dev/null)
|
||||
git_email=$(git config --global --file "$home/.gitconfig" user.email 2>/dev/null)
|
||||
echo "GIT_USER: ${git_user:-Not configured}"
|
||||
echo "GIT_EMAIL: ${git_email:-Not configured}"
|
||||
fi
|
||||
|
||||
# Timezone, Locale, PATH, DISPLAY, and TERM
|
||||
echo "TIMEZONE: $(cat /etc/timezone)"
|
||||
|
||||
if [ -d "$home" ]; then
|
||||
locale_lang=$(LANG=$LANG HOME=$home bash -c 'echo $LANG' 2>/dev/null)
|
||||
user_path=$(HOME=$home bash -c 'echo $PATH' 2>/dev/null)
|
||||
display_var=$(HOME=$home bash -c 'echo $DISPLAY' 2>/dev/null)
|
||||
term_var=$(HOME=$home bash -c 'echo $TERM' 2>/dev/null)
|
||||
echo "LOCALE_LANG: ${locale_lang:-Not set}"
|
||||
echo "PATH: ${user_path:-Not set}"
|
||||
echo "DISPLAY: ${display_var:-Not set}"
|
||||
echo "TERM: ${term_var:-Not set}"
|
||||
echo "USER_HOME:"
|
||||
# Limit tree output to 6 levels, max 3 directories per level
|
||||
tree -L 6 -d "$home" | awk '{count[$1]++; if (count[$1] <= 3) print}'
|
||||
fi
|
||||
echo "-------------"
|
||||
fi
|
||||
done < /etc/passwd
|
||||
|
||||
echo "=== End of Environment Info ==="
|
Reference in New Issue
Block a user