feat: deploy-to --run-setup flag to bootstrap directory structure on remote
This commit is contained in:
@@ -883,20 +883,24 @@ cmd_remote_bootstrap() {
|
||||
# COMMAND: deploy-to (push dotfiles to a server that can't reach Gitea)
|
||||
# -----------------------------------------------------------------------
|
||||
cmd_deploy_to() {
|
||||
[ $# -ge 1 ] || die "Usage: deploy-to <user@host> [--scripts-only] [--include-ssh] [--no-backup] [--dry-run]"
|
||||
[ $# -ge 1 ] || die "Usage: deploy-to <user@host> [--scripts-only] [--include-ssh] [--no-backup] [--run-setup] [--profile work|personal] [--dry-run]"
|
||||
|
||||
local target="$1"; shift
|
||||
local scripts_only=false
|
||||
local skip_ssh=true # default: skip .ssh/ — avoid pushing keys/config to servers
|
||||
local no_backup=false
|
||||
local run_setup=false
|
||||
local setup_profile="work" # default profile for servers
|
||||
local dry_run=false
|
||||
|
||||
while [[ $# -gt 0 ]]; do
|
||||
case "$1" in
|
||||
--scripts-only) scripts_only=true; shift ;;
|
||||
--include-ssh) skip_ssh=false; shift ;;
|
||||
--no-backup) no_backup=true; shift ;;
|
||||
--dry-run) dry_run=true; shift ;;
|
||||
--scripts-only) scripts_only=true; shift ;;
|
||||
--include-ssh) skip_ssh=false; shift ;;
|
||||
--no-backup) no_backup=true; shift ;;
|
||||
--run-setup) run_setup=true; shift ;;
|
||||
--profile) setup_profile="${2:-work}"; shift 2 ;;
|
||||
--dry-run) dry_run=true; shift ;;
|
||||
*) die "Unknown option: $1" ;;
|
||||
esac
|
||||
done
|
||||
@@ -1076,6 +1080,26 @@ cmd_deploy_to() {
|
||||
info "Create one to manage ~/.bashrc.local centrally: dotfiles/hosts/${remote_short}.bashrc.local"
|
||||
fi
|
||||
|
||||
# ---- 6. Optionally run setup on the remote ----
|
||||
if ! $dry_run; then
|
||||
local do_setup=$run_setup
|
||||
if ! $run_setup; then
|
||||
echo
|
||||
read -r -p "Run setup_enterprise_ai_bash.sh on $target now? Creates dirs, writes shell config. (y/n): " _ans
|
||||
[[ "$_ans" == [yY] ]] && do_setup=true
|
||||
fi
|
||||
|
||||
if $do_setup; then
|
||||
echo
|
||||
info "Running setup on $target (profile=$setup_profile)..."
|
||||
info "This will create the directory structure and write shell config."
|
||||
echo
|
||||
ssh -t "$target" \
|
||||
"MACHINE_PROFILE=${setup_profile} DOTFILES_REMOTE=${DOTFILES_REMOTE} bash ~/scripts/setup_enterprise_ai_bash.sh"
|
||||
success "Setup complete on $target."
|
||||
fi
|
||||
fi
|
||||
|
||||
echo
|
||||
if $dry_run; then
|
||||
info "Dry run complete. Re-run without --dry-run to transfer files."
|
||||
@@ -1083,6 +1107,7 @@ cmd_deploy_to() {
|
||||
bold "Deploy complete: $deployed file(s) deployed, $skipped skipped."
|
||||
info "Files were copied directly (no symlinks). Re-run deploy-to to push updates."
|
||||
$skip_ssh && info "~/.ssh/ was skipped. Use --include-ssh to also deploy ~/.ssh/config."
|
||||
! $run_setup && info "Tip: add --run-setup to also create directories and shell config on the remote."
|
||||
fi
|
||||
}
|
||||
|
||||
@@ -1114,14 +1139,17 @@ ${BOLD}COMMANDS — SSH & Keys${RESET}
|
||||
${BOLD}COMMANDS — Multi-machine${RESET}
|
||||
remote-bootstrap <user@host> [--profile work|personal]
|
||||
Upload scripts and run full setup on a remote machine
|
||||
deploy-to <user@host> [--scripts-only] [--include-ssh] [--no-backup] [--dry-run]
|
||||
deploy-to <user@host> [--scripts-only] [--include-ssh] [--no-backup] [--run-setup] [--profile work|personal] [--dry-run]
|
||||
SCP tracked dotfiles + scripts directly to a server.
|
||||
Use when the server can't reach the Gitea repo.
|
||||
Backs up existing remote files locally before overwriting.
|
||||
--scripts-only Only push ~/scripts/, skip dotfiles
|
||||
--include-ssh Also deploy ~/.ssh/config (skipped by default)
|
||||
--no-backup Skip the pre-deploy remote backup
|
||||
--dry-run Preview what would be transferred
|
||||
--scripts-only Only push ~/scripts/, skip dotfiles
|
||||
--include-ssh Also deploy ~/.ssh/config (skipped by default)
|
||||
--no-backup Skip the pre-deploy remote backup
|
||||
--run-setup Run setup_enterprise_ai_bash.sh on the remote
|
||||
after deploy (creates dirs, shell config)
|
||||
--profile work|personal Profile to pass to setup (default: work)
|
||||
--dry-run Preview what would be transferred
|
||||
|
||||
${BOLD}QUICK START — this machine (work)${RESET}
|
||||
./dotfiles_manager.sh init
|
||||
|
||||
Reference in New Issue
Block a user