53 lines
1.3 KiB
Bash
53 lines
1.3 KiB
Bash
#!/usr/bin/env bash
|
|
set -euo pipefail
|
|
|
|
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
source "$SCRIPT_DIR/../lib/common.sh"
|
|
|
|
log_info "Setting up user account"
|
|
|
|
ACCT=$(whoami)
|
|
|
|
# Create workspace directory
|
|
if [ ! -d "$HOME/.workspace" ]; then
|
|
log_info "Creating workspace directory"
|
|
mkdir -p "$HOME/.workspace"
|
|
log_success "Workspace directory created at $HOME/.workspace"
|
|
else
|
|
log_success "Workspace directory already exists"
|
|
fi
|
|
|
|
# Change default shell to bash
|
|
CURRENT_SHELL=$(basename "$SHELL")
|
|
if [ "$CURRENT_SHELL" != "bash" ]; then
|
|
log_info "Changing default shell to bash"
|
|
chsh -s /bin/bash "$ACCT"
|
|
log_success "Default shell changed to bash"
|
|
else
|
|
log_success "Default shell is already bash"
|
|
fi
|
|
|
|
# Generate SSH keypair for GitHub
|
|
SSH_KEY="$HOME/.ssh/id_ed25519"
|
|
if [ -f "$SSH_KEY" ]; then
|
|
log_success "SSH key already exists at $SSH_KEY"
|
|
else
|
|
log_info "Generating SSH keypair for GitHub"
|
|
read -p "Enter your email: " EMAIL
|
|
|
|
ensure_dir "$HOME/.ssh"
|
|
chmod 700 "$HOME/.ssh"
|
|
|
|
ssh-keygen -o -a 100 -t ed25519 -f "$SSH_KEY" -C "$EMAIL"
|
|
|
|
log_success "SSH key generated at $SSH_KEY"
|
|
log_info ""
|
|
log_info "Add this public key to GitHub:"
|
|
log_info "https://github.com/settings/ssh/new"
|
|
log_info ""
|
|
cat "$SSH_KEY.pub"
|
|
log_info ""
|
|
fi
|
|
|
|
log_success "User setup complete"
|