V8.00.000.2025.06.17
All checks were successful
🛡️ Shell Script Linting / 🛡️ Shell Script Linting (push) Successful in 1m6s
All checks were successful
🛡️ Shell Script Linting / 🛡️ Shell Script Linting (push) Successful in 1m6s
Signed-off-by: Marc S. Weidner <msw@coresecret.dev>
This commit is contained in:
@@ -572,6 +572,7 @@ software:
|
|||||||
# e2fsprogs
|
# e2fsprogs
|
||||||
# fdisk
|
# fdisk
|
||||||
# findutils
|
# findutils
|
||||||
|
# git
|
||||||
# grep
|
# grep
|
||||||
# gzip
|
# gzip
|
||||||
# hostname
|
# hostname
|
||||||
@@ -707,7 +708,6 @@ software:
|
|||||||
- debconf
|
- debconf
|
||||||
- debconf-utils
|
- debconf-utils
|
||||||
- dialog
|
- dialog
|
||||||
- git
|
|
||||||
- knot-dnssecutils
|
- knot-dnssecutils
|
||||||
- knot-dnsutils
|
- knot-dnsutils
|
||||||
- locate
|
- locate
|
||||||
|
|||||||
@@ -883,31 +883,70 @@ zsh_omz_installer() {
|
|||||||
### Declare Arrays, HashMaps, and Variables.
|
### Declare Arrays, HashMaps, and Variables.
|
||||||
declare var_user="${1}"
|
declare var_user="${1}"
|
||||||
|
|
||||||
|
### Install Oh My Zsh and two plugins for a given user (non-interactive, idempotent).
|
||||||
|
### Args to payload: $1 = username (e.g., "root" or "alice")
|
||||||
chroot_stdin "${TARGET}" "__payload__" -- "${var_user}" <<'EOF'
|
chroot_stdin "${TARGET}" "__payload__" -- "${var_user}" <<'EOF'
|
||||||
export LC_ALL=C
|
export LC_ALL=C
|
||||||
user="$1"
|
user="$1"
|
||||||
### Login shell for proper HOME, PATH, etc.
|
|
||||||
### We also set installer env to prevent zsh spawn or chsh.
|
### Resolve account data
|
||||||
su - "${user}" -s /bin/bash -c '
|
pwline="$(getent passwd "${user}" || true)"
|
||||||
set -euo pipefail
|
[[ -n "${pwline}" ]] || { echo "User not found: ${user}" >&2; exit 1; }
|
||||||
export RUNZSH=no CHSH=no KEEP_ZSHRC=yes
|
IFS=: read -r _ _ uid gid _ home _ <<<"${pwline}"
|
||||||
export ZSH="${HOME}/.oh-my-zsh"
|
|
||||||
### Pre-create ~/.oh-my-zsh to control perms.
|
### Prepare a small script that runs as the target user (correct HOME/ownership)
|
||||||
mkdir -p "${ZSH}" && chmod 0700 "${ZSH}"
|
usr_script="$(mktemp /tmp/omz_user_install.XXXXXX)"
|
||||||
umask 0077
|
cat >|"${usr_script}" <<'USR'
|
||||||
### Use wget or curl as available.
|
set -Ceuo pipefail
|
||||||
if command -v wget >/dev/null; then
|
export LC_ALL=C
|
||||||
sh -c "$(wget -qO- https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
|
umask 077
|
||||||
else
|
|
||||||
sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
|
### We are running as the target user here
|
||||||
|
ZSH_DIR="${HOME}/.oh-my-zsh"
|
||||||
|
|
||||||
|
### If ZSH_DIR exists but is EMPTY (e.g., previous aborted run), remove it, so the installer can proceed.
|
||||||
|
if [[ -d "${ZSH_DIR}" ]] && [[ -z "$(ls -A "${ZSH_DIR}")" ]]; then
|
||||||
|
rm -rf "${ZSH_DIR}"
|
||||||
fi
|
fi
|
||||||
### Plugins (clone shallow).
|
|
||||||
ZSH_CUSTOM="${ZSH}/custom"
|
### If already installed (git repo present), skip the installer.
|
||||||
|
if [ -d "${ZSH_DIR}/.git" ]; then
|
||||||
|
:
|
||||||
|
else
|
||||||
|
### Download installer to a temp file and run it with non-interactive env.
|
||||||
|
inst="$(mktemp)"
|
||||||
|
if command -v wget >/dev/null 2>&1; then
|
||||||
|
wget -qO "${inst}" https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh
|
||||||
|
else
|
||||||
|
curl -fsSL -o "${inst}" https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh
|
||||||
|
fi
|
||||||
|
### Ensure that ZSH is not set for the installer, and keep it fully non-interactive.
|
||||||
|
RUNZSH=no CHSH=no KEEP_ZSHRC=yes env -u ZSH sh "${inst}"
|
||||||
|
rm -f "${inst}"
|
||||||
|
fi
|
||||||
|
|
||||||
|
### Install plugins (shallow clone; idempotent)
|
||||||
|
ZSH_CUSTOM="${ZSH_DIR}/custom"
|
||||||
mkdir -p "${ZSH_CUSTOM}/plugins"
|
mkdir -p "${ZSH_CUSTOM}/plugins"
|
||||||
git clone --depth 1 https://github.com/zsh-users/zsh-autosuggestions "${ZSH_CUSTOM}/plugins/zsh-autosuggestions" || true
|
[[ -d "${ZSH_CUSTOM}/plugins/zsh-autosuggestions/.git" ]] || \
|
||||||
git clone --depth 1 https://github.com/zsh-users/zsh-syntax-highlighting.git "${ZSH_CUSTOM}/plugins/zsh-syntax-highlighting" || true
|
git clone --depth 1 https://github.com/zsh-users/zsh-autosuggestions "${ZSH_CUSTOM}/plugins/zsh-autosuggestions"
|
||||||
'
|
[ [ -d "${ZSH_CUSTOM}/plugins/zsh-syntax-highlighting/.git" ]] || \
|
||||||
umask 0022
|
git clone --depth 1 https://github.com/zsh-users/zsh-syntax-highlighting "${ZSH_CUSTOM}/plugins/zsh-syntax-highlighting"
|
||||||
|
|
||||||
|
### '~/.zshrc' will be updated later in the main CISS.debian.installer environment.
|
||||||
|
|
||||||
|
### Do NOT start zsh here and do NOT chsh (RUNZSH/CHSH handled above).
|
||||||
|
:
|
||||||
|
USR
|
||||||
|
|
||||||
|
### Execute as user (login shell to get proper env), then clean up the temp script.
|
||||||
|
if [[ "${uid}" -eq 0 ]]; then
|
||||||
|
### root user: no su needed
|
||||||
|
bash "${usr_script}"
|
||||||
|
else
|
||||||
|
su - "${user}" -s /bin/bash -c "bash '${usr_script}'"
|
||||||
|
fi
|
||||||
|
rm -f -- "${usr_script}" || :
|
||||||
:
|
:
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user