🔧 Update scripts and add CA cert update 🔧

Update all container scripts to 202605241245-git and add CA certificate
update step after package installation.
- rootfs/root/docker/setup/00-init.sh: updated to latest template
- rootfs/root/docker/setup/01-system.sh: updated to latest template
- rootfs/root/docker/setup/02-packages.sh: add update-ca-certificates/update-ca-trust step
- rootfs/root/docker/setup/03-files.sh: updated to latest template
- rootfs/root/docker/setup/04-users.sh: updated to latest template
- rootfs/root/docker/setup/05-custom.sh: updated to latest template
- rootfs/root/docker/setup/06-post.sh: updated to latest template
- rootfs/root/docker/setup/07-cleanup.sh: updated to latest template
- rootfs/usr/local/bin/entrypoint.sh: updated to 202605241245-git
- rootfs/usr/local/bin/pkmgr: updated to 202605241245-git
- rootfs/usr/local/etc/docker/functions/entrypoint.sh: updated to 202605241245-git

rootfs/root/docker/setup/00-init.sh
rootfs/root/docker/setup/01-system.sh
rootfs/root/docker/setup/02-packages.sh
rootfs/root/docker/setup/03-files.sh
rootfs/root/docker/setup/04-users.sh
rootfs/root/docker/setup/05-custom.sh
rootfs/root/docker/setup/06-post.sh
rootfs/root/docker/setup/07-cleanup.sh
rootfs/usr/local/bin/entrypoint.sh
rootfs/usr/local/bin/pkmgr
rootfs/usr/local/etc/docker/functions/entrypoint.sh
This commit is contained in:
2026-05-24 21:46:52 -04:00
parent 36e0fccdfe
commit c44d678c9c
11 changed files with 334 additions and 737 deletions
+4 -3
View File
@@ -1,12 +1,12 @@
#!/usr/bin/env bash
# shellcheck shell=bash
# - - - - - - - - - - - - - - - - - - - - - - - - -
##@Version : 202604221922-git
##@Version : 202605242100-git
# @@Author : CasjaysDev
# @@Contact : CasjaysDev <docker-admin@casjaysdev.pro>
# @@License : MIT
# @@Copyright : Copyright 2026 CasjaysDev
# @@Created : Wed Apr 22 07:22:55 PM EDT 2026
# @@Created : Sun May 24 09:00:28 PM EDT 2026
# @@File : 00-init.sh
# @@Description : script to run init
# @@Changelog : newScript
@@ -36,9 +36,10 @@ if [ -d "/usr/local/share/template-files/defaults" ]; then rm -Rf "/usr/local/sh
# - - - - - - - - - - - - - - - - - - - - - - - - -
# Set the exit code
#exitCode=$?
exitCode=$?
# - - - - - - - - - - - - - - - - - - - - - - - - -
exit $exitCode
# - - - - - - - - - - - - - - - - - - - - - - - - -
# ex: ts=2 sw=2 et filetype=sh
# - - - - - - - - - - - - - - - - - - - - - - - - -
+4 -3
View File
@@ -1,12 +1,12 @@
#!/usr/bin/env bash
# shellcheck shell=bash
# - - - - - - - - - - - - - - - - - - - - - - - - -
##@Version : 202604221922-git
##@Version : 202605242100-git
# @@Author : CasjaysDev
# @@Contact : CasjaysDev <docker-admin@casjaysdev.pro>
# @@License : MIT
# @@Copyright : Copyright 2026 CasjaysDev
# @@Created : Wed Apr 22 07:22:56 PM EDT 2026
# @@Created : Sun May 24 09:00:28 PM EDT 2026
# @@File : 01-system.sh
# @@Description : script to run system
# @@Changelog : newScript
@@ -34,9 +34,10 @@ exitCode=0
# - - - - - - - - - - - - - - - - - - - - - - - - -
# Set the exit code
#exitCode=$?
exitCode=$?
# - - - - - - - - - - - - - - - - - - - - - - - - -
exit $exitCode
# - - - - - - - - - - - - - - - - - - - - - - - - -
# ex: ts=2 sw=2 et filetype=sh
# - - - - - - - - - - - - - - - - - - - - - - - - -
+10 -138
View File
@@ -1,12 +1,12 @@
#!/usr/bin/env bash
# shellcheck shell=bash
# - - - - - - - - - - - - - - - - - - - - - - - - -
##@Version : 202604221922-git
##@Version : 202605242139-git
# @@Author : CasjaysDev
# @@Contact : CasjaysDev <docker-admin@casjaysdev.pro>
# @@License : MIT
# @@Copyright : Copyright 2026 CasjaysDev
# @@Created : Wed Apr 22 07:22:56 PM EDT 2026
# @@Created : Sun May 24 09:00:29 PM EDT 2026
# @@File : 02-packages.sh
# @@Description : script to run packages
# @@Changelog : newScript
@@ -31,148 +31,20 @@ exitCode=0
# - - - - - - - - - - - - - - - - - - - - - - - - -
# Main script
# Install the latest stable Rust toolchain via the official rustup-init
# bootstrapper. CARGO_HOME and RUSTUP_HOME are pinned to /usr/local/share
# so the toolchain lives in a system path that's easy to volume-mount
# and shareable across users (vs the default ~/.cargo, ~/.rustup).
#
# Wrapped in a subshell with `set -euo pipefail` so any single step
# (curl, sha256sum, rustup, rustup target add, ...) that fails aborts
# the whole installer and the parent script returns non-zero - the
# Dockerfile then fails the build rather than silently producing a
# broken image.
(
set -euo pipefail
export CARGO_HOME="/usr/local/share/cargo"
export RUSTUP_HOME="/usr/local/share/rustup"
mkdir -p "$CARGO_HOME" "$RUSTUP_HOME"
case "$(uname -m)" in
x86_64) RUST_ARCH="x86_64-unknown-linux-musl"; RUSTUP_ARCH="x86_64-unknown-linux-musl" ;;
aarch64) RUST_ARCH="aarch64-unknown-linux-musl"; RUSTUP_ARCH="aarch64-unknown-linux-musl" ;;
armv7l) RUST_ARCH="armv7-unknown-linux-musleabihf"; RUSTUP_ARCH="armv7-unknown-linux-musleabihf" ;;
i686|i386) RUST_ARCH="i686-unknown-linux-musl"; RUSTUP_ARCH="i686-unknown-linux-musl" ;;
ppc64le) RUST_ARCH="powerpc64le-unknown-linux-gnu"; RUSTUP_ARCH="powerpc64le-unknown-linux-gnu" ;;
s390x) RUST_ARCH="s390x-unknown-linux-gnu"; RUSTUP_ARCH="s390x-unknown-linux-gnu" ;;
riscv64) RUST_ARCH="riscv64gc-unknown-linux-gnu"; RUSTUP_ARCH="riscv64gc-unknown-linux-gnu" ;;
*)
echo "Unsupported architecture for rustup install: $(uname -m)" >&2
exit 1
;;
esac
# Pull rustup-init from the official static.rust-lang.org distribution
# point. The script form (sh.rustup.rs) is a thin wrapper that does
# exactly this; we go direct so we can SHA256-verify the binary.
RUSTUP_INIT_URL="https://static.rust-lang.org/rustup/dist/${RUSTUP_ARCH}/rustup-init"
RUSTUP_SHA_URL="${RUSTUP_INIT_URL}.sha256"
echo "Fetching rustup-init for ${RUSTUP_ARCH}"
curl -fsSL "$RUSTUP_INIT_URL" -o /tmp/rustup-init
RUSTUP_SHA256="$(curl -fsSL "$RUSTUP_SHA_URL" | awk '{print $1}')"
if [ -z "$RUSTUP_SHA256" ]; then
echo "Failed to fetch rustup-init SHA256 from $RUSTUP_SHA_URL" >&2
exit 1
fi
echo "${RUSTUP_SHA256} /tmp/rustup-init" | sha256sum -c -
chmod +x /tmp/rustup-init
echo "Installing stable Rust toolchain via rustup"
# --component accepts comma-separated values; passing space-separated
# makes clap take only the first as the value and treat the rest as
# stray positional args (which fails with "unexpected argument").
/tmp/rustup-init -y \
--no-modify-path \
--default-toolchain stable \
--profile minimal \
--default-host "$RUSTUP_ARCH" \
--component rustfmt,clippy,rust-src,rust-analyzer,llvm-tools-preview
rm -f /tmp/rustup-init
# Expose rustc/cargo/rustup/rustfmt/clippy on /usr/local/bin so they
# work without the profile.d export (e.g. one-shot `docker run ... cargo build`).
for bin in rustc cargo rustup rustfmt cargo-fmt cargo-clippy clippy-driver rust-analyzer rust-gdb rust-lldb; do
if [ -e "${CARGO_HOME}/bin/${bin}" ]; then
ln -sf "${CARGO_HOME}/bin/${bin}" "/usr/local/bin/${bin}"
fi
done
# rust-lld lives inside the toolchain's rustlib dir (shipped via the
# llvm-tools-preview component). Putting it on PATH lets the cargo
# config.toml `linker = "rust-lld"` overrides resolve - this enables
# plain `cargo build --target=...` to work for ARM/aarch64 musl and
# bare-metal embedded targets without an external C cross-toolchain.
RUST_LLD="$(rustc --print sysroot)/lib/rustlib/${RUSTUP_ARCH}/bin/rust-lld"
if [ -e "$RUST_LLD" ]; then
ln -sf "$RUST_LLD" /usr/local/bin/rust-lld
fi
# Pre-install Rust std for a broad cross-compile matrix. Each target
# adds ~50-150MB; the full set below expands the image by ~2-3GB but
# gives "Go-style" cross-compile turn-key support out of the box.
# Pair with cargo-zigbuild (installed in 05-custom.sh) for the C side
# of any *-sys / build.rs cross builds.
for target in \
x86_64-unknown-linux-gnu \
x86_64-unknown-linux-musl \
aarch64-unknown-linux-gnu \
aarch64-unknown-linux-musl \
i686-unknown-linux-gnu \
i686-unknown-linux-musl \
armv7-unknown-linux-gnueabihf \
armv7-unknown-linux-musleabihf \
arm-unknown-linux-gnueabihf \
riscv64gc-unknown-linux-gnu \
riscv64gc-unknown-linux-musl \
powerpc64le-unknown-linux-gnu \
s390x-unknown-linux-gnu \
x86_64-pc-windows-gnu \
i686-pc-windows-gnu \
aarch64-pc-windows-gnullvm \
x86_64-apple-darwin \
aarch64-apple-darwin \
x86_64-unknown-freebsd \
wasm32-unknown-unknown \
wasm32-wasip1 \
wasm32-wasip2 \
wasm32-unknown-emscripten \
thumbv6m-none-eabi \
thumbv7em-none-eabihf \
thumbv8m.main-none-eabihf \
riscv32imc-unknown-none-elf \
riscv32imac-unknown-none-elf \
aarch64-linux-android \
; do
echo "rustup target add $target"
rustup target add "$target" || true
done
# Sanity-check the install before subsequent setup steps depend on it.
/usr/local/bin/rustc --version
/usr/local/bin/cargo --version
rustup target list --installed
# Trim docs that the toolchain ships - we don't need them inside a
# build container (saves ~150MB across all installed toolchains).
rm -rf "${RUSTUP_HOME}/toolchains"/*/share/doc \
"${RUSTUP_HOME}/toolchains"/*/share/man || true
)
__rust_install_rc=$?
# Note: this is intentionally a separate statement, not `(...) || exit`.
# Bash silently disables `set -e` inside an explicit subshell when the
# subshell appears on the left of && or ||, so the form below is the
# only reliable way to propagate set -e failures from the subshell.
if [ "$__rust_install_rc" -ne 0 ]; then
exit "$__rust_install_rc"
if command -v update-ca-certificates >/dev/null 2>&1; then
update-ca-certificates
elif command -v update-ca-trust >/dev/null 2>&1; then
update-ca-trust extract
elif command -v trust >/dev/null 2>&1; then
trust extract-compat
fi
unset __rust_install_rc
# - - - - - - - - - - - - - - - - - - - - - - - - -
# Set the exit code
#exitCode=$?
exitCode=$?
# - - - - - - - - - - - - - - - - - - - - - - - - -
exit $exitCode
# - - - - - - - - - - - - - - - - - - - - - - - - -
# ex: ts=2 sw=2 et filetype=sh
# - - - - - - - - - - - - - - - - - - - - - - - - -
+21 -54
View File
@@ -1,12 +1,12 @@
#!/usr/bin/env bash
# shellcheck shell=bash
# - - - - - - - - - - - - - - - - - - - - - - - - -
##@Version : 202604221922-git
##@Version : 202605242100-git
# @@Author : CasjaysDev
# @@Contact : CasjaysDev <docker-admin@casjaysdev.pro>
# @@License : MIT
# @@Copyright : Copyright 2026 CasjaysDev
# @@Created : Wed Apr 22 07:22:57 PM EDT 2026
# @@Created : Sun May 24 09:00:30 PM EDT 2026
# @@File : 03-files.sh
# @@Description : script to run files
# @@Changelog : newScript
@@ -31,51 +31,55 @@ exitCode=0
if [ -d "/tmp/bin" ]; then
mkdir -p "/usr/local/bin"
for bin in "/tmp/bin"/*; do
name="$(basename -- "$bin")"
[ -e "$bin" ] || continue
name="${bin##*/}"
echo "Installing $name to /usr/local/bin/$name"
copy "$bin" "/usr/local/bin/$name"
cp -Rf "$bin" "/usr/local/bin/$name"
chmod -f +x "/usr/local/bin/$name"
done
fi
unset bin
if [ -d "/tmp/var" ]; then
for var in "/tmp/var"/*; do
name="$(basename -- "$var")"
[ -e "$var" ] || continue
name="${var##*/}"
echo "Installing $var to /var/$name"
if [ -d "$var" ]; then
mkdir -p "/var/$name"
copy "$var/." "/var/$name/"
cp -Rf "$var/." "/var/$name/"
else
copy "$var" "/var/$name"
cp -Rf "$var" "/var/$name"
fi
done
fi
unset var
if [ -d "/tmp/etc" ]; then
for config in "/tmp/etc"/*; do
name="$(basename -- "$config")"
[ -e "$config" ] || continue
name="${config##*/}"
echo "Installing $config to /etc/$name"
if [ -d "$config" ]; then
mkdir -p "/etc/$name"
copy "$config/." "/etc/$name/"
cp -Rf "$config/." "/etc/$name/"
mkdir -p "/usr/local/share/template-files/config/$name"
copy "$config/." "/usr/local/share/template-files/config/$name/"
cp -Rf "$config/." "/usr/local/share/template-files/config/$name/"
else
copy "$config" "/etc/$name"
copy "$config" "/usr/local/share/template-files/config/$name"
cp -Rf "$config" "/etc/$name"
cp -Rf "$config" "/usr/local/share/template-files/config/$name"
fi
done
fi
unset config
if [ -d "/tmp/data" ]; then
for data in "/tmp/data"/*; do
name="$(basename -- "$data")"
[ -e "$data" ] || continue
name="${data##*/}"
echo "Installing $data to /usr/local/share/template-files/data"
if [ -d "$data" ]; then
mkdir -p "/usr/local/share/template-files/data/$name"
copy "$data/." "/usr/local/share/template-files/data/$name/"
cp -Rf "$data/." "/usr/local/share/template-files/data/$name/"
else
copy "$data" "/usr/local/share/template-files/data/$name"
cp -Rf "$data" "/usr/local/share/template-files/data/$name"
fi
done
fi
@@ -83,49 +87,12 @@ unset data
# - - - - - - - - - - - - - - - - - - - - - - - - -
# Main script
# Create conventional Rust project dirs. Users can mount their code into
# any of these; WORKDIR defaults to /app.
for dir in /app /work /root/app /root/project; do
mkdir -p "$dir"
chmod 0755 "$dir"
done
# Canonical Rust state dirs (FHS-style: arch-independent shared data);
# declared as Docker VOLUMEs for cross-rebuild persistence. CARGO_HOME
# stores the registry index, downloaded crates, and user-installed
# cargo binaries; RUSTUP_HOME stores rustc/cargo toolchains and
# components. The conventional ~/.cargo and ~/.rustup paths are
# symlinked here so anything that hardcodes them keeps working.
# /data/cargo and /data/rustup are symlinked at runtime by the init
# script (since /data is itself a volume mount).
CARGO_HOME_DIR="/usr/local/share/cargo"
RUSTUP_HOME_DIR="/usr/local/share/rustup"
mkdir -p \
"${CARGO_HOME_DIR}/bin" \
"${CARGO_HOME_DIR}/registry" \
"${CARGO_HOME_DIR}/git" \
"${CARGO_HOME_DIR}/target" \
"${RUSTUP_HOME_DIR}"
chmod -R 0755 "${CARGO_HOME_DIR}" "${RUSTUP_HOME_DIR}"
for pair in \
"/root/.cargo:${CARGO_HOME_DIR}" \
"/root/.rustup:${RUSTUP_HOME_DIR}" \
; do
link="${pair%%:*}"
target="${pair#*:}"
if [ -e "$link" ] && [ ! -L "$link" ]; then
rm -rf "$link"
fi
ln -sfn "$target" "$link"
done
unset CARGO_HOME_DIR RUSTUP_HOME_DIR pair link target
# - - - - - - - - - - - - - - - - - - - - - - - - -
# Set the exit code
#exitCode=$?
exitCode=$?
# - - - - - - - - - - - - - - - - - - - - - - - - -
exit $exitCode
# - - - - - - - - - - - - - - - - - - - - - - - - -
# ex: ts=2 sw=2 et filetype=sh
# - - - - - - - - - - - - - - - - - - - - - - - - -
+4 -3
View File
@@ -1,12 +1,12 @@
#!/usr/bin/env bash
# shellcheck shell=bash
# - - - - - - - - - - - - - - - - - - - - - - - - -
##@Version : 202604221922-git
##@Version : 202605242100-git
# @@Author : CasjaysDev
# @@Contact : CasjaysDev <docker-admin@casjaysdev.pro>
# @@License : MIT
# @@Copyright : Copyright 2026 CasjaysDev
# @@Created : Wed Apr 22 07:22:57 PM EDT 2026
# @@Created : Sun May 24 09:00:31 PM EDT 2026
# @@File : 04-users.sh
# @@Description : script to run users
# @@Changelog : newScript
@@ -34,9 +34,10 @@ exitCode=0
# - - - - - - - - - - - - - - - - - - - - - - - - -
# Set the exit code
#exitCode=$?
exitCode=$?
# - - - - - - - - - - - - - - - - - - - - - - - - -
exit $exitCode
# - - - - - - - - - - - - - - - - - - - - - - - - -
# ex: ts=2 sw=2 et filetype=sh
# - - - - - - - - - - - - - - - - - - - - - - - - -
+8 -105
View File
@@ -1,12 +1,12 @@
#!/usr/bin/env bash
# shellcheck shell=bash
# - - - - - - - - - - - - - - - - - - - - - - - - -
##@Version : 202604221922-git
##@Version : 202605242100-git
# @@Author : CasjaysDev
# @@Contact : CasjaysDev <docker-admin@casjaysdev.pro>
# @@License : MIT
# @@Copyright : Copyright 2026 CasjaysDev
# @@Created : Wed Apr 22 07:22:57 PM EDT 2026
# @@Created : Sun May 24 09:00:31 PM EDT 2026
# @@File : 05-custom.sh
# @@Description : script to run custom
# @@Changelog : newScript
@@ -32,109 +32,12 @@ exitCode=0
# - - - - - - - - - - - - - - - - - - - - - - - - -
# Main script
# Install Rust developer tools into $CARGO_HOME/bin (which is on PATH
# via the symlinks created in 02-packages.sh).
#
# Strategy: bootstrap `cargo-binstall` first via its upstream installer
# script, then use it for everything else. binstall fetches prebuilt
# binaries when the upstream crate publishes them and falls back to a
# normal `cargo install` otherwise - dramatically faster than
# source-compiling 30+ tools sequentially.
export CARGO_HOME="${CARGO_HOME:-/usr/local/share/cargo}"
export RUSTUP_HOME="${RUSTUP_HOME:-/usr/local/share/rustup}"
export PATH="${CARGO_HOME}/bin:${PATH}"
mkdir -p "$CARGO_HOME" "$RUSTUP_HOME"
if command -v cargo >/dev/null 2>&1; then
echo "Installing Rust developer tools with $(rustc --version)"
# cargo-binstall: bootstrap via `cargo install`. Compiles from
# crates.io (~3-5 min cold) but avoids the upstream install script's
# curl-pipe-to-bash, which has been observed to fail with TLS SAN
# errors when fetching the prebuilt binary from github.com inside
# certain build environments. Slower but bulletproof.
cargo install cargo-binstall --locked \
|| echo " WARN: cargo-binstall bootstrap failed - falling through" >&2
# Use binstall for the remainder. --no-confirm skips prompts;
# --locked uses each crate's checked-in Cargo.lock for reproducibility;
# binstall transparently falls back to `cargo install` when no
# prebuilt binary is available.
for tool in \
cargo-edit \
cargo-watch \
cargo-update \
cargo-outdated \
cargo-expand \
cargo-info \
cargo-nextest \
cargo-llvm-cov \
cargo-tarpaulin \
cargo-mutants \
cargo-audit \
cargo-deny \
cargo-machete \
cargo-msrv \
cargo-semver-checks \
cargo-make \
cargo-deb \
cargo-generate \
cargo-release \
cargo-dist \
cargo-chef \
cargo-zigbuild \
cargo-flamegraph \
bacon \
mdbook \
mdbook-toc \
wasm-pack \
wasm-bindgen-cli \
wasm-tools \
sqlx-cli \
sea-orm-cli \
trunk \
samply \
just \
tokei \
hyperfine \
cargo-binutils \
cargo-cross \
flip-link \
probe-rs-tools \
cargo-ndk \
cbindgen \
cargo-bloat \
cargo-asm \
; do
echo "cargo binstall $tool"
# Best-effort: skip individual tool failures rather than aborting
# the whole build. binstall falls back to `cargo install` when no
# prebuilt is available; if both fail (stale deps, etc.), warn
# and move on.
cargo binstall --no-confirm --locked "$tool" \
|| echo " WARN: skipping $tool (install failed)" >&2
done
# Re-link any newly installed cargo-* binaries into /usr/local/bin so
# they're discoverable for non-login `docker exec` invocations.
for bin in "${CARGO_HOME}"/bin/*; do
[ -e "$bin" ] || continue
name="$(basename "$bin")"
[ -e "/usr/local/bin/${name}" ] || ln -sf "$bin" "/usr/local/bin/${name}"
done
unset bin name
# Drop the registry cache + git checkouts; they balloon the image and
# get rehydrated on first `cargo build` against a real volume.
rm -rf "${CARGO_HOME}/registry" "${CARGO_HOME}/git" 2>/dev/null || true
else
echo "cargo binary not found; skipping Rust dev tools" >&2
fi
# Always succeed: tool installation is best-effort, the build environment
# is functional even if some optional dev tools didn't make it. The
# rustup toolchain itself was already verified by 02-packages.sh.
exit 0
# - - - - - - - - - - - - - - - - - - - - - - - - -
# Set the exit code
exitCode=$?
# - - - - - - - - - - - - - - - - - - - - - - - - -
exit $exitCode
# - - - - - - - - - - - - - - - - - - - - - - - - -
# ex: ts=2 sw=2 et filetype=sh
# - - - - - - - - - - - - - - - - - - - - - - - - -
+4 -3
View File
@@ -1,12 +1,12 @@
#!/usr/bin/env bash
# shellcheck shell=bash
# - - - - - - - - - - - - - - - - - - - - - - - - -
##@Version : 202604221922-git
##@Version : 202605242100-git
# @@Author : CasjaysDev
# @@Contact : CasjaysDev <docker-admin@casjaysdev.pro>
# @@License : MIT
# @@Copyright : Copyright 2026 CasjaysDev
# @@Created : Wed Apr 22 07:22:58 PM EDT 2026
# @@Created : Sun May 24 09:00:32 PM EDT 2026
# @@File : 06-post.sh
# @@Description : script to run post
# @@Changelog : newScript
@@ -34,9 +34,10 @@ exitCode=0
# - - - - - - - - - - - - - - - - - - - - - - - - -
# Set the exit code
#exitCode=$?
exitCode=$?
# - - - - - - - - - - - - - - - - - - - - - - - - -
exit $exitCode
# - - - - - - - - - - - - - - - - - - - - - - - - -
# ex: ts=2 sw=2 et filetype=sh
# - - - - - - - - - - - - - - - - - - - - - - - - -
+5 -4
View File
@@ -1,12 +1,12 @@
#!/usr/bin/env bash
# shellcheck shell=bash
# - - - - - - - - - - - - - - - - - - - - - - - - -
##@Version : 202604221922-git
##@Version : 202605242100-git
# @@Author : CasjaysDev
# @@Contact : CasjaysDev <docker-admin@casjaysdev.pro>
# @@License : MIT
# @@Copyright : Copyright 2026 CasjaysDev
# @@Created : Wed Apr 22 07:22:58 PM EDT 2026
# @@Created : Sun May 24 09:00:33 PM EDT 2026
# @@File : 07-cleanup.sh
# @@Description : script to run cleanup
# @@Changelog : newScript
@@ -24,7 +24,7 @@ set -o pipefail
[ "$DEBUGGER" = "on" ] && echo "Enabling debugging" && set -x$DEBUGGER_OPTIONS
# - - - - - - - - - - - - - - - - - - - - - - - - -
# Load functions
__find_and_remove() { [ -z "$1" ] || find "${2:-/etc}" -iname "$1" -exec rm -Rf {} \; 2>/dev/null; }
__find_and_remove() { [ -z "$1" ] || find "${2:-/etc}" -iname "$1" -exec rm -Rf {} + 2>/dev/null; }
# - - - - - - - - - - - - - - - - - - - - - - - - -
# Set env variables
exitCode=0
@@ -38,9 +38,10 @@ if [ -d "$HOME/.cache" ]; then rm -Rf "$HOME/.cache"; fi
# - - - - - - - - - - - - - - - - - - - - - - - - -
# Set the exit code
#exitCode=$?
exitCode=$?
# - - - - - - - - - - - - - - - - - - - - - - - - -
exit $exitCode
# - - - - - - - - - - - - - - - - - - - - - - - - -
# ex: ts=2 sw=2 et filetype=sh
# - - - - - - - - - - - - - - - - - - - - - - - - -
+37 -51
View File
@@ -1,15 +1,15 @@
#!/usr/bin/env bash
# shellcheck shell=bash
# - - - - - - - - - - - - - - - - - - - - - - - - -
##@Version : 202602061352-git
##@Version : 202605241245-git
# @@Author : Jason Hempstead
# @@Contact : jason@casjaysdev.pro
# @@License : WTFPL
# @@ReadME : entrypoint.sh --help
# @@Copyright : Copyright: (c) 2026 Jason Hempstead, Casjays Developments
# @@Created : Wednesday, Apr 22, 2026 19:22 EDT
# @@Created : Sunday, May 24, 2026 21:00 EDT
# @@File : entrypoint.sh
# @@Description : Entrypoint file for go
# @@Description : Entrypoint file for alpine
# @@Changelog : New script
# @@TODO : Better documentation
# @@Other :
@@ -21,17 +21,25 @@
# shellcheck disable=SC1001,SC1003,SC2001,SC2003,SC2016,SC2031,SC2090,SC2115,SC2120,SC2155,SC2199,SC2229,SC2317,SC2329
# - - - - - - - - - - - - - - - - - - - - - - - - -
# run trap command on exit
trap 'retVal=$?;[ "$SERVICE_IS_RUNNING" != "yes" ] && [ -f "$SERVICE_PID_FILE" ] && rm -Rf "$SERVICE_PID_FILE";exit $retVal' INT TERM PWR
trap 'retVal=$?;[ "$SERVICE_IS_RUNNING" != "yes" ] && [ -f "$SERVICE_PID_FILE" ] && rm -Rf "$SERVICE_PID_FILE";exit $retVal' INT TERM
trap 'retVal=$?;[ "$SERVICE_IS_RUNNING" != "yes" ] && [ -f "$SERVICE_PID_FILE" ] && rm -Rf "$SERVICE_PID_FILE";exit $retVal' SIGPWR 2>/dev/null || true
# - - - - - - - - - - - - - - - - - - - - - - - - -
# setup debugging - https://www.gnu.org/software/bash/manual/html_node/The-Set-Builtin.html
[ -f "/config/.debug" ] && [ -z "$DEBUGGER_OPTIONS" ] && export DEBUGGER_OPTIONS="$(<"/config/.debug")" || DEBUGGER_OPTIONS="${DEBUGGER_OPTIONS:-}"
{ [ "$DEBUGGER" = "on" ] || [ -f "/config/.debug" ]; } && echo "Enabling debugging" && set -o pipefail -x$DEBUGGER_OPTIONS && export DEBUGGER="on" || set -o pipefail
if [ "$DEBUGGER" = "on" ] || [ -f "/config/.debug" ]; then
echo "Enabling debugging"
set -o pipefail
[ -n "$DEBUGGER_OPTIONS" ] && set -"$DEBUGGER_OPTIONS"
export DEBUGGER="on"
else
set -o pipefail
fi
# - - - - - - - - - - - - - - - - - - - - - - - - -
PATH="/usr/local/etc/docker/bin:/usr/local/bin:/usr/bin:/usr/sbin:/bin:/sbin"
# - - - - - - - - - - - - - - - - - - - - - - - - -
# Set bash options
SCRIPT_FILE="$0"
CONTAINER_NAME="go"
CONTAINER_NAME="alpine"
SCRIPT_NAME="${SCRIPT_FILE##*/}"
CONTAINER_NAME="${ENV_CONTAINER_NAME:-$CONTAINER_NAME}"
# - - - - - - - - - - - - - - - - - - - - - - - - -
@@ -54,7 +62,7 @@ case "$1" in
-h | --help)
shift 1
echo 'Docker container for '$CONTAINER_NAME''
echo "Usage: $CONTAINER_NAME [help tail cron exec start init shell certbot ssl procs ports healthcheck backup command]"
echo "Usage: $CONTAINER_NAME [help tail cron exec start init shell procs ports healthcheck backup command]"
echo ""
exit 0
;;
@@ -87,8 +95,8 @@ SERVICE_UID="${SERVICE_UID:-0}"
SERVICE_GID="${SERVICE_GID:-0}"
# - - - - - - - - - - - - - - - - - - - - - - - - -
# User and group in which the service switches to - IE: nginx,apache,mysql,postgres
#SERVICE_USER="${SERVICE_USER:-go}" # execute command as another user
#SERVICE_GROUP="${SERVICE_GROUP:-go}" # Set the service group
#SERVICE_USER="${SERVICE_USER:-alpine}" # execute command as another user
#SERVICE_GROUP="${SERVICE_GROUP:-alpine}" # Set the service group
# - - - - - - - - - - - - - - - - - - - - - - - - -
# Secondary ports
# specifiy other ports
@@ -143,7 +151,7 @@ export DOMAINNAME="$(hostname -d)"
# - - - - - - - - - - - - - - - - - - - - - - - - -
# Default directories
export SSL_DIR="${SSL_DIR:-/config/ssl}"
export SSL_CA="${SSL_CERT:-/config/ssl/ca.crt}"
export SSL_CA="${SSL_CA:-/config/ssl/ca.crt}"
export SSL_KEY="${SSL_KEY:-/config/ssl/localhost.pem}"
export SSL_CERT="${SSL_CERT:-/config/ssl/localhost.crt}"
export LOCAL_BIN_DIR="${LOCAL_BIN_DIR:-/usr/local/bin}"
@@ -164,7 +172,7 @@ export NGINX_CONFIG_FILE="${NGINX_CONFIG_FILE:-$(__find_nginx_conf)}"
export MYSQL_CONFIG_FILE="${MYSQL_CONFIG_FILE:-$(__find_mysql_conf)}"
export PGSQL_CONFIG_FILE="${PGSQL_CONFIG_FILE:-$(__find_pgsql_conf)}"
export MONGODB_CONFIG_FILE="${MONGODB_CONFIG_FILE:-$(__find_mongodb_conf)}"
export ENTRYPOINT_PID_FILE="${ENTRYPOINT_PID_FILE:-$ENTRYPOINT_PID_FILE}"
export ENTRYPOINT_PID_FILE="${ENTRYPOINT_PID_FILE:-/run/.entrypoint.pid}"
export ENTRYPOINT_INIT_FILE="${ENTRYPOINT_INIT_FILE:-/config/.entrypoint.done}"
export ENTRYPOINT_DATA_INIT_FILE="${ENTRYPOINT_DATA_INIT_FILE:-/data/.docker_has_run}"
export ENTRYPOINT_CONFIG_INIT_FILE="${ENTRYPOINT_CONFIG_INIT_FILE:-/config/.docker_has_run}"
@@ -214,8 +222,6 @@ SERVER_PORTS="${SERVER_PORTS//,/ }" #
SERVER_PORTS="${SERVER_PORTS//\/*/}" #
# - - - - - - - - - - - - - - - - - - - - - - - - -
# clean WEB_SERVER_PORTS variables
WEB_SERVER_PORTS="${WEB_SERVER_PORT//\/*/}" #
WEB_SERVER_PORTS="${WEB_SERVER_PORTS//\/*/}" #
WEB_SERVER_PORTS="${WEB_SERVER_PORT//,/ } ${ENV_WEB_SERVER_PORTS//,/ }" #
# - - - - - - - - - - - - - - - - - - - - - - - - -
# rewrite and merge variables
@@ -288,7 +294,7 @@ fi
if [ "$ENTRYPOINT_FIRST_RUN" != "no" ]; then
if [ "$CONFIG_DIR_INITIALIZED" = "no" ] || [ "$DATA_DIR_INITIALIZED" = "no" ]; then
if [ "$ENTRYPOINT_MESSAGE" = "yes" ]; then
echo "Executing entrypoint script for go"
echo "Executing entrypoint script for alpine"
fi
fi
# - - - - - - - - - - - - - - - - - - - - - - - - -
@@ -357,7 +363,7 @@ if [ "$ENTRYPOINT_FIRST_RUN" != "no" ]; then
fi
# - - - - - - - - - - - - - - - - - - - - - - - - -
if [ -f "/etc/hostname" ]; then
if [ -n "$(type -P hostname 2>/dev/null)" ]; then
if command -v hostname &>/dev/null; then
hostname -F "/etc/hostname" 2>/dev/null || true
else
HOSTNAME="$(<"/etc/hostname")" 2>/dev/null || true
@@ -372,7 +378,7 @@ if [ "$ENTRYPOINT_FIRST_RUN" != "no" ]; then
# - - - - - - - - - - - - - - - - - - - - - - - - -
# import resolv.conf file into container
if [ "$CUSTOM_DNS" != "yes" ] && [ -f "/usr/local/etc/resolv.conf" ] && [ "$UPDATE_FILE_RESOLV" = "yes" ]; then
cat "/usr/local/etc/resolv.conf" >"/etc/resolv.conf" 2>/dev/null || true
cp -f "/usr/local/etc/resolv.conf" "/etc/resolv.conf" 2>/dev/null || true
fi
# - - - - - - - - - - - - - - - - - - - - - - - - -
if [ -n "$HOME" ] && [ -d "/usr/local/etc/skel" ]; then
@@ -383,12 +389,13 @@ if [ "$ENTRYPOINT_FIRST_RUN" != "no" ]; then
# - - - - - - - - - - - - - - - - - - - - - - - - -
fi
# - - - - - - - - - - - - - - - - - - - - - - - - -
# Delete any .gitkeep files
# Delete any .gitkeep files (bash * does not match dotfiles by default,
# so the explicit /.gitkeep path is required at each depth)
if [ -d "/data" ]; then
rm -Rf "/data/.gitkeep" "/data"/*/*.gitkeep 2>/dev/null || true
rm -Rf "/data/.gitkeep" "/data"/*/.gitkeep 2>/dev/null || true
fi
if [ -d "/config" ]; then
rm -Rf "/config/.gitkeep" "/config"/*/*.gitkeep 2>/dev/null || true
rm -Rf "/config/.gitkeep" "/config"/*/.gitkeep 2>/dev/null || true
fi
if [ -f "/usr/local/bin/.gitkeep" ]; then
rm -Rf "/usr/local/bin/.gitkeep" 2>/dev/null || true
@@ -442,7 +449,7 @@ fi
# if no pid assume container restart - clean stale files on restart
if [ -f "$ENTRYPOINT_PID_FILE" ]; then
# Check if the PID in the file is still running
entrypoint_pid=$(cat "$ENTRYPOINT_PID_FILE" 2>/dev/null || echo "")
entrypoint_pid=$(<"$ENTRYPOINT_PID_FILE") 2>/dev/null
if [ -n "$entrypoint_pid" ] && kill -0 "$entrypoint_pid" 2>/dev/null; then
# Process is still running, don't restart services
START_SERVICES="no"
@@ -482,7 +489,7 @@ __set_user_group_id $SERVICE_USER ${SERVICE_UID:-} ${SERVICE_GID:-}
__run_message
# - - - - - - - - - - - - - - - - - - - - - - - - -
# Just start services
START_SERVICES="${START_SERVICES:-SYSTEM_INIT}"
START_SERVICES="${START_SERVICES:-yes}"
# - - - - - - - - - - - - - - - - - - - - - - - - -
# Determine if we should start services based on command
# Only skip service start for the 'init' command
@@ -540,10 +547,10 @@ logs)
tail -Fq /data/logs/*/*
;;
clean)
log_files="$(find "/data/logs" -type f)"
mapfile -t log_files < <(find "/data/logs" -type f 2>/dev/null)
for log in "${log_files[@]}"; do
__log_info "Clearing log file: $log"
printf '' >$log
printf '' >"$log"
done
;;
*)
@@ -578,16 +585,16 @@ healthcheck)
healthPorts="${WEB_SERVER_PORTS:-}"
healthEndPoints="${HEALTH_ENDPOINTS:-}"
SERVICES_LIST="${arguments:-$SERVICES_LIST}"
services="$(echo "${SERVICES_LIST//,/ }")"
services="${SERVICES_LIST//,/ }"
healthMessage="Everything seems to be running"
[ "$healthEnabled" = "yes" ] || exit 0
if [ -d "/run/healthcheck" ] && [ "$(ls -A "/run/healthcheck" | wc -l)" -ne 0 ]; then
if [ -d "/run/healthcheck" ] && ! __is_dir_empty "/run/healthcheck"; then
for service in /run/healthcheck/*; do
name="${service##*/}"
services+="$name "
done
fi
services="$(echo "$services" | tr ' ' '\n' | sort -u | grep -v '^$')"
services="$(printf '%s\n' $services | sort -u | grep -v '^$')"
for proc in $services; do
if [ -n "$proc" ]; then
if ! __pgrep "$proc"; then
@@ -596,8 +603,8 @@ healthcheck)
fi
fi
done
for port in $ports; do
if [ -n "$(type -P netstat)" ] && [ -n "$port" ]; then
for port in $healthPorts; do
if command -v netstat &>/dev/null && [ -n "$port" ]; then
if ! netstat -taupln | grep -q ":$port "; then
echo "$port isn't open" >&2
healthStatus=$((healthStatus + 1))
@@ -621,38 +628,17 @@ healthcheck)
# show open ports
ports)
shift 1
ports="$(__netstat -taupln | awk -F ' ' '{print $4}' | awk -F ':' '{print $2}' | sort --unique --version-sort | grep -v '^$' | grep '^' || echo '')"
ports="$(__netstat -taupln 2>/dev/null | awk '{ split($4, a, ":"); if (a[2] != "") print a[2] }' | sort -uV)"
[ -n "$ports" ] && printf '%s\n%s\n' "The following are servers:" "$ports" | tr '\n' ' '
exit $?
;;
# show running processes
procs)
shift 1
ps="$(__ps axco command | grep -vE 'COMMAND|grep|ps' | sort -u || grep '^' || echo '')"
ps="$(__ps axco command 2>/dev/null | grep -vE '^(COMMAND|grep|ps)$' | sort -u)"
[ -n "$ps" ] && printf '%s\n%s\n' "Found the following processes" "$ps" | tr '\n' ' '
exit $?
;;
# setup ssl
ssl)
shift 1
__create_ssl_cert
exit $?
;;
# manage ssl certificate
certbot)
shift 1
CERT_BOT_ENABLED="yes"
if [ "$1" = "create" ]; then
shift 1
__certbot "create"
elif [ "$1" = "renew" ]; then
shift 1
__certbot "renew certonly --force-renew"
else
__exec_command "certbot" "$@"
fi
exit $?
;;
# Launch shell
*/bin/sh | */bin/bash | bash | sh | shell)
shift 1
+2 -1
View File
@@ -103,7 +103,7 @@ install)
[ -n "$1" ] || exit 0
[ "$USER_UID" -eq 0 ] || [ "$USER" = "root" ] || pkmgr_install_cmd="sudo $pkmgr_install_cmd"
if [ -f "$1" ]; then
install_list="$(cat "$1")"
install_list="$(tr '\n' ' ' < "$1")"
else
install_list="$*"
fi
@@ -140,3 +140,4 @@ clean)
esac
# - - - - - - - - - - - - - - - - - - - - - - - - -
# end
File diff suppressed because it is too large Load Diff