NFS-aware .bashrc.local and VS Code dirs for work servers
- Remove zet* from _is_work_host (local git server, not a work host) - setup_enterprise_ai_bash.sh: detect NFS home on work servers, relocate .bashrc.local to /opt/kenjim/ with symlink, handle re-runs safely - setup_enterprise_ai_bash.sh: symlink ~/.vscode-server and ~/.vscode-remote-containers to /opt/kenjim/ on NFS hosts - dotfiles_manager.sh: deploy-to detects NFS on remote, deploys .bashrc.local to /opt/kenjim/ with symlink, backs up symlink targets - hosts/etqc-kenjim-11.bashrc.local: add NFS note to header
This commit is contained in:
@@ -186,6 +186,69 @@ fi
|
||||
|
||||
echo "✅ .bashrc.local written for profile: $MACHINE_PROFILE"
|
||||
|
||||
# ---- NFS-aware placement for work servers ----
|
||||
# Work servers with NFS-mounted home dirs share ~/.bashrc.local across hosts.
|
||||
# To keep per-machine overrides, store the real file in /opt/kenjim/ and symlink.
|
||||
if [[ "$MACHINE_PROFILE" == "work" ]]; then
|
||||
_is_nfs_home=false
|
||||
case "$(hostname -s)" in
|
||||
etqc-*|etbg-*|engtech-dev-*)
|
||||
if df -P "$HOME" 2>/dev/null | tail -1 | grep -qE ':|nfs'; then
|
||||
_is_nfs_home=true
|
||||
elif mount | grep -q "on ${HOME%%/} .*type nfs"; then
|
||||
_is_nfs_home=true
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
|
||||
if $_is_nfs_home; then
|
||||
OPT_DIR="/opt/kenjim"
|
||||
OPT_LOCAL="$OPT_DIR/.bashrc.local"
|
||||
echo "🔗 NFS home detected — relocating .bashrc.local to $OPT_LOCAL"
|
||||
|
||||
if [ ! -d "$OPT_DIR" ]; then
|
||||
echo " Creating $OPT_DIR ..."
|
||||
sudo mkdir -p "$OPT_DIR"
|
||||
sudo chown "$(id -u):$(id -g)" "$OPT_DIR"
|
||||
chmod 700 "$OPT_DIR"
|
||||
fi
|
||||
|
||||
# If ~/.bashrc.local is already a symlink (previous run), the cat above
|
||||
# wrote through it into the target. Remove the symlink first so mv
|
||||
# doesn't see source and destination as the same file.
|
||||
if [ -L "$BASHRC_LOCAL" ]; then
|
||||
rm -f "$BASHRC_LOCAL"
|
||||
# Content already landed at the symlink target; just ensure perms
|
||||
chmod 600 "$OPT_LOCAL"
|
||||
else
|
||||
mv "$BASHRC_LOCAL" "$OPT_LOCAL"
|
||||
chmod 600 "$OPT_LOCAL"
|
||||
fi
|
||||
|
||||
ln -sfn "$OPT_LOCAL" "$BASHRC_LOCAL"
|
||||
echo " Linked: ~/.bashrc.local → $OPT_LOCAL"
|
||||
|
||||
# VS Code Remote stores large caches in ~/.vscode-server and
|
||||
# ~/.vscode-remote-containers — keep them on local disk, not NFS.
|
||||
for _vsdir in .vscode-server .vscode-remote-containers; do
|
||||
_opt_target="$OPT_DIR/$_vsdir"
|
||||
_home_link="$HOME_DIR/$_vsdir"
|
||||
mkdir -p "$_opt_target"
|
||||
if [ -d "$_home_link" ] && [ ! -L "$_home_link" ]; then
|
||||
# Existing real directory — move contents then replace with symlink
|
||||
echo " Moving ~/$_vsdir → $OPT_DIR/$_vsdir ..."
|
||||
rsync -a "$_home_link/" "$_opt_target/" 2>/dev/null || \
|
||||
cp -a "$_home_link/." "$_opt_target/" 2>/dev/null || true
|
||||
rm -rf "$_home_link"
|
||||
fi
|
||||
ln -sfn "$_opt_target" "$_home_link"
|
||||
echo " Linked: ~/$_vsdir → $_opt_target"
|
||||
done
|
||||
|
||||
echo "✅ Per-machine .bashrc.local and VS Code dirs stored outside NFS at $OPT_DIR"
|
||||
fi
|
||||
fi
|
||||
|
||||
# ------------------------------------------------------
|
||||
# 4️⃣ INITIALIZE DOTFILES REPO (with Gitea remote)
|
||||
# ------------------------------------------------------
|
||||
|
||||
Reference in New Issue
Block a user