added root user setup
This commit is contained in:
Executable
+59
@@ -0,0 +1,59 @@
|
||||
#!/bin/bash
|
||||
# run_once_55-configure-root.sh
|
||||
# Root user configuration.
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
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 || true
|
||||
else
|
||||
echo ">>> [configure-root] root shell already fish"
|
||||
fi
|
||||
else
|
||||
echo ">>> [configure-root] fish not installed; skipping fish+chsh"
|
||||
fi
|
||||
|
||||
echo ">>> [configure-root] done"
|
||||
Reference in New Issue
Block a user