V8.00.000.2025.06.17
Some checks failed
🛡️ Shell Script Linting / 🛡️ Shell Script Linting (push) Failing after 32s
Some checks failed
🛡️ Shell Script Linting / 🛡️ Shell Script Linting (push) Failing after 32s
Signed-off-by: Marc S. Weidner <msw@coresecret.dev>
This commit is contained in:
@@ -894,12 +894,10 @@ pwline="$(getent passwd "${user}" || true)"
|
||||
[[ -n "${pwline}" ]] || { echo "User not found: ${user}" >&2; exit 1; }
|
||||
IFS=: read -r _ _ uid gid _ home _ <<<"${pwline}"
|
||||
|
||||
### Prepare a small script that runs as the target user (correct HOME/ownership)
|
||||
usr_script="$(mktemp /tmp/omz_user_install.XXXXXX)"
|
||||
chown "${uid}:${gid}" "${usr_script}"
|
||||
chmod 0700 "${usr_script}"
|
||||
|
||||
cat >|"${usr_script}" <<'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
|
||||
/bin/bash -s <<'USR'
|
||||
#!/bin/bash
|
||||
set -Ceuo pipefail
|
||||
export LC_ALL=C
|
||||
@@ -943,13 +941,56 @@ mkdir -p "${ZSH_CUSTOM}/plugins"
|
||||
:
|
||||
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
|
||||
/bin/bash "${usr_script}"
|
||||
### ----------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
else
|
||||
su - "${user}" -s /bin/bash -c "/bin/bash '${usr_script}'"
|
||||
su - "${user}" -s /bin/bash <<'USR'
|
||||
#!/bin/bash
|
||||
set -Ceuo pipefail
|
||||
export LC_ALL=C
|
||||
umask 077
|
||||
|
||||
### 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
|
||||
|
||||
### 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"
|
||||
[[ -d "${ZSH_CUSTOM}/plugins/zsh-autosuggestions/.git" ]] || \
|
||||
git clone --depth 1 https://github.com/zsh-users/zsh-autosuggestions "${ZSH_CUSTOM}/plugins/zsh-autosuggestions"
|
||||
[[ -d "${ZSH_CUSTOM}/plugins/zsh-syntax-highlighting/.git" ]] || \
|
||||
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
|
||||
|
||||
### ----------------------------------------------------------------------------------------------------------------------------
|
||||
fi
|
||||
|
||||
rm -f -- "${usr_script}" || :
|
||||
:
|
||||
EOF
|
||||
|
||||
Reference in New Issue
Block a user