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:
Kenji Morishige
2026-02-24 09:57:29 -06:00
parent 074ab05908
commit 67926c37bd
5 changed files with 101 additions and 4 deletions

View File

@@ -1065,14 +1065,43 @@ cmd_deploy_to() {
# Back up existing remote .bashrc.local if not already captured above
if $no_backup; then
: # skip
elif ssh "$target" '[ -L ~/.bashrc.local ]' 2>/dev/null; then
# It's a symlink (NFS setup) — back up the target file
local real_path
real_path=$(ssh "$target" 'readlink -f ~/.bashrc.local' 2>/dev/null || true)
if [[ -n "$real_path" ]]; then
local bl_backup="$HOME/.dotfiles_backup/remote-${remote_short}-$(date +%Y%m%d_%H%M%S)"
mkdir -p "$bl_backup"
scp -q "$target:$real_path" "$bl_backup/.bashrc.local" 2>/dev/null || true
info "Backed up remote $real_path$bl_backup/.bashrc.local"
fi
elif ssh "$target" '[ -f ~/.bashrc.local ]' 2>/dev/null; then
local bl_backup="$HOME/.dotfiles_backup/remote-${remote_short}-$(date +%Y%m%d_%H%M%S)"
mkdir -p "$bl_backup"
scp -q "$target:~/.bashrc.local" "$bl_backup/.bashrc.local" 2>/dev/null || true
info "Backed up remote ~/.bashrc.local → $bl_backup/.bashrc.local"
fi
scp -q "$host_local" "$target:~/.bashrc.local"
success "Deployed: hosts/${remote_short}.bashrc.local → ~/.bashrc.local"
# Detect NFS home on the remote and deploy to /opt/kenjim/ if needed
local _remote_nfs=false
if ssh "$target" 'df -P "$HOME" 2>/dev/null | tail -1 | grep -qE ":|nfs"' 2>/dev/null; then
_remote_nfs=true
fi
if $_remote_nfs; then
info "NFS home detected on $target — deploying to /opt/kenjim/.bashrc.local"
# Ensure /opt/kenjim exists — skip sudo if it already does
if ! ssh "$target" '[ -d /opt/kenjim ]' 2>/dev/null; then
info "Creating /opt/kenjim on $target (requires sudo)..."
ssh -t "$target" 'sudo mkdir -p /opt/kenjim && sudo chown $(id -u):$(id -g) /opt/kenjim && chmod 700 /opt/kenjim'
fi
scp -q "$host_local" "$target:/opt/kenjim/.bashrc.local"
ssh "$target" 'chmod 600 /opt/kenjim/.bashrc.local && ln -sfn /opt/kenjim/.bashrc.local ~/.bashrc.local'
success "Deployed: hosts/${remote_short}.bashrc.local → /opt/kenjim/.bashrc.local (symlinked from ~)"
else
scp -q "$host_local" "$target:~/.bashrc.local"
success "Deployed: hosts/${remote_short}.bashrc.local → ~/.bashrc.local"
fi
(( deployed++ )) || true
fi
else