62 lines
2.0 KiB
Cheetah
Executable File
62 lines
2.0 KiB
Cheetah
Executable File
#!/bin/bash
|
|
# run_once_55-configure-root.sh
|
|
# Root user configuration.
|
|
|
|
set -euo pipefail
|
|
|
|
warn() { echo ">>> [configure-root] WARNING: $*" >&2; }
|
|
|
|
SRC="{{ .chezmoi.sourceDir }}"
|
|
ROOT_HOME="/root"
|
|
|
|
echo ">>> [configure-root] deploying shell configs to $ROOT_HOME"
|
|
|
|
# Bash (always useful)
|
|
if [ -f "$SRC/dot_bashrc" ]; then
|
|
echo ">>> [configure-root] install .bashrc"
|
|
sudo install -m644 "$SRC/dot_bashrc" "$ROOT_HOME/.bashrc"
|
|
fi
|
|
|
|
# Fish + conf.d + starship
|
|
if command -v fish >/dev/null 2>&1; then
|
|
sudo install -d -m755 "$ROOT_HOME/.config/fish"
|
|
|
|
if [ -f "$SRC/dot_config/fish/config.fish" ]; then
|
|
echo ">>> [configure-root] install fish/config.fish"
|
|
sudo install -m644 "$SRC/dot_config/fish/config.fish" \
|
|
"$ROOT_HOME/.config/fish/config.fish"
|
|
fi
|
|
|
|
if [ -d "$SRC/dot_config/fish/conf.d" ]; then
|
|
echo ">>> [configure-root] install fish/conf.d/"
|
|
sudo install -d -m755 "$ROOT_HOME/.config/fish/conf.d"
|
|
for f in "$SRC"/dot_config/fish/conf.d/*; do
|
|
[ -f "$f" ] || continue
|
|
target_name="$(basename "$f")"
|
|
target_name="${target_name#executable_}"
|
|
sudo install -m755 "$f" "$ROOT_HOME/.config/fish/conf.d/$target_name"
|
|
done
|
|
fi
|
|
|
|
# Starship
|
|
if [ -f "$SRC/dot_config/starship.toml.tmpl" ]; then
|
|
echo ">>> [configure-root] render starship.toml"
|
|
chezmoi execute-template < "$SRC/dot_config/starship.toml.tmpl" \
|
|
| sudo tee "$ROOT_HOME/.config/starship.toml" >/dev/null
|
|
sudo chmod 644 "$ROOT_HOME/.config/starship.toml"
|
|
fi
|
|
|
|
# Set root's shell to fish
|
|
current="$(getent passwd root | cut -d: -f7)"
|
|
if [ "$current" != "$(command -v fish)" ]; then
|
|
echo ">>> [configure-root] chsh root → fish"
|
|
sudo chsh -s "$(command -v fish)" root || warn "chsh failed for root (may need /etc/shells entry)"
|
|
else
|
|
echo ">>> [configure-root] root shell already fish"
|
|
fi
|
|
else
|
|
echo ">>> [configure-root] fish not installed; skipping fish+chsh"
|
|
fi
|
|
|
|
echo ">>> [configure-root] done"
|