feat(shell): add ble.sh (Bash Line Editor) installation on first boot
- Add blesh.sh script to install ble.sh from GitHub during first boot - Clone with --recursive --depth 1 --shallow-submodules as per official docs - Install to ~/.local/share/blesh using make install - Auto-configure .bashrc to source ble.sh for interactive shells - Update Go binary installer to download blesh.sh from GitHub - Update shell-based installer download script - Add blesh.sh execution to first-boot service workflow ble.sh provides advanced command-line editing features including syntax highlighting, command completion, and improved history search.
- commit
- 4bb5c44d01f58b042a27491c6e0eb39596dc3857
- author
- bnema · · 2025-10-28 21:48 UTC
- parent
- 029b9af
- signature
- unsigned
5 files · +67 -1
M install/helpers/download.sh +1 -1
| @@ -62,7 +62,7 @@ download_archup_files() { | |||
| 62 | 62 | ||
| 63 | 63 | # Post-boot | |
| 64 | 64 | download_section "Downloading post-boot scripts..." "post-boot" \ | |
| 65 | - | all.sh snapper.sh ufw.sh ssh-keygen.sh archup-cli.sh archup-first-boot.service | |
| 65 | + | all.sh snapper.sh ufw.sh ssh-keygen.sh archup-cli.sh blesh.sh archup-first-boot.service | |
| 66 | 66 | ||
| 67 | 67 | # Package lists | |
| 68 | 68 | curl -sL "$GITHUB_RAW/install/base.packages" -o "$ARCHUP_INSTALL/base.packages" 2>/dev/null | |
| @@ -62,7 +62,7 @@ download_archup_files() { | |||||
| 62 | 62 | ||||
| 63 | # Post-boot | 63 | # Post-boot | ||
| 64 | download_section "Downloading post-boot scripts..." "post-boot" \ | 64 | download_section "Downloading post-boot scripts..." "post-boot" \ | ||
| 65 | - | all.sh snapper.sh ufw.sh ssh-keygen.sh archup-cli.sh archup-first-boot.service | 65 | + | all.sh snapper.sh ufw.sh ssh-keygen.sh archup-cli.sh blesh.sh archup-first-boot.service |
| 66 | 66 | ||||
| 67 | # Package lists | 67 | # Package lists | ||
| 68 | curl -sL "$GITHUB_RAW/install/base.packages" -o "$ARCHUP_INSTALL/base.packages" 2>/dev/null | 68 | curl -sL "$GITHUB_RAW/install/base.packages" -o "$ARCHUP_INSTALL/base.packages" 2>/dev/null | ||
M install/post-boot/all.sh +10 -0
| @@ -52,6 +52,16 @@ if [ -f /usr/local/share/archup/post-boot/archup-cli.sh ]; then | |||
| 52 | 52 | fi | |
| 53 | 53 | fi | |
| 54 | 54 | ||
| 55 | + | # Install ble.sh (Bash Line Editor) | |
| 56 | + | if [ -f /usr/local/share/archup/post-boot/blesh.sh ]; then | |
| 57 | + | echo "Installing ble.sh (Bash Line Editor)..." | tee -a "$LOG_FILE" | |
| 58 | + | if bash /usr/local/share/archup/post-boot/blesh.sh >> "$LOG_FILE" 2>&1; then | |
| 59 | + | echo "✓ ble.sh installed successfully" | tee -a "$LOG_FILE" | |
| 60 | + | else | |
| 61 | + | echo "✗ ble.sh installation failed (non-critical)" | tee -a "$LOG_FILE" | |
| 62 | + | fi | |
| 63 | + | fi | |
| 64 | + | ||
| 55 | 65 | echo "=== First Boot Setup Complete ===" >> "$LOG_FILE" | |
| 56 | 66 | ||
| 57 | 67 | # Disable this service after first run | |
| @@ -52,6 +52,16 @@ if [ -f /usr/local/share/archup/post-boot/archup-cli.sh ]; then | |||||
| 52 | fi | 52 | fi | ||
| 53 | fi | 53 | fi | ||
| 54 | 54 | ||||
| 55 | + | # Install ble.sh (Bash Line Editor) | |||
| 56 | + | if [ -f /usr/local/share/archup/post-boot/blesh.sh ]; then | |||
| 57 | + | echo "Installing ble.sh (Bash Line Editor)..." | tee -a "$LOG_FILE" | |||
| 58 | + | if bash /usr/local/share/archup/post-boot/blesh.sh >> "$LOG_FILE" 2>&1; then | |||
| 59 | + | echo "✓ ble.sh installed successfully" | tee -a "$LOG_FILE" | |||
| 60 | + | else | |||
| 61 | + | echo "✗ ble.sh installation failed (non-critical)" | tee -a "$LOG_FILE" | |||
| 62 | + | fi | |||
| 63 | + | fi | |||
| 64 | + | ||||
| 55 | echo "=== First Boot Setup Complete ===" >> "$LOG_FILE" | 65 | echo "=== First Boot Setup Complete ===" >> "$LOG_FILE" | ||
| 56 | 66 | ||||
| 57 | # Disable this service after first run | 67 | # Disable this service after first run | ||
A install/post-boot/blesh.sh +53 -0
| @@ -0,0 +1,53 @@ | |||
| 1 | + | #!/bin/bash | |
| 2 | + | # Install and configure ble.sh (Bash Line Editor) | |
| 3 | + | # This provides advanced command-line editing features | |
| 4 | + | ||
| 5 | + | set -e | |
| 6 | + | ||
| 7 | + | # Get the username from the system | |
| 8 | + | USERNAME=$(ls /home | head -1) | |
| 9 | + | ||
| 10 | + | if [[ -z "${USERNAME}" ]]; then | |
| 11 | + | echo "ERROR: Could not find user for ble.sh installation" | |
| 12 | + | exit 1 | |
| 13 | + | fi | |
| 14 | + | ||
| 15 | + | USER_HOME="/home/$USERNAME" | |
| 16 | + | BLESH_INSTALL_DIR="$USER_HOME/.local" | |
| 17 | + | ||
| 18 | + | echo "Installing ble.sh for user: $USERNAME" | |
| 19 | + | ||
| 20 | + | # Clone ble.sh repository | |
| 21 | + | echo "Cloning ble.sh repository..." | |
| 22 | + | cd /tmp | |
| 23 | + | if [ -d "ble.sh" ]; then | |
| 24 | + | rm -rf ble.sh | |
| 25 | + | fi | |
| 26 | + | ||
| 27 | + | # Run as user to avoid permission issues | |
| 28 | + | sudo -u "$USERNAME" bash << EOF | |
| 29 | + | set -e | |
| 30 | + | cd /tmp | |
| 31 | + | git clone --recursive --depth 1 --shallow-submodules https://github.com/akinomyoga/ble.sh.git | |
| 32 | + | ||
| 33 | + | # Build and install ble.sh | |
| 34 | + | echo "Building and installing ble.sh..." | |
| 35 | + | make -C ble.sh install PREFIX="$BLESH_INSTALL_DIR" | |
| 36 | + | ||
| 37 | + | # Add ble.sh to .bashrc if not already present | |
| 38 | + | if ! grep -q "blesh/ble.sh" "$USER_HOME/.bashrc"; then | |
| 39 | + | echo "" >> "$USER_HOME/.bashrc" | |
| 40 | + | echo "# ble.sh - Bash Line Editor" >> "$USER_HOME/.bashrc" | |
| 41 | + | echo "[[ \$- == *i* ]] && source -- ~/.local/share/blesh/ble.sh" >> "$USER_HOME/.bashrc" | |
| 42 | + | echo "ble.sh added to .bashrc" | |
| 43 | + | else | |
| 44 | + | echo "ble.sh already configured in .bashrc" | |
| 45 | + | fi | |
| 46 | + | EOF | |
| 47 | + | ||
| 48 | + | # Cleanup | |
| 49 | + | rm -rf /tmp/ble.sh | |
| 50 | + | ||
| 51 | + | echo "✓ ble.sh installed successfully" | |
| 52 | + | echo " Location: $BLESH_INSTALL_DIR/share/blesh" | |
| 53 | + | echo " Note: ble.sh will be active on next shell session" | |
| @@ -0,0 +1,53 @@ | |||||
| 1 | + | #!/bin/bash | |||
| 2 | + | # Install and configure ble.sh (Bash Line Editor) | |||
| 3 | + | # This provides advanced command-line editing features | |||
| 4 | + | ||||
| 5 | + | set -e | |||
| 6 | + | ||||
| 7 | + | # Get the username from the system | |||
| 8 | + | USERNAME=$(ls /home | head -1) | |||
| 9 | + | ||||
| 10 | + | if [[ -z "${USERNAME}" ]]; then | |||
| 11 | + | echo "ERROR: Could not find user for ble.sh installation" | |||
| 12 | + | exit 1 | |||
| 13 | + | fi | |||
| 14 | + | ||||
| 15 | + | USER_HOME="/home/$USERNAME" | |||
| 16 | + | BLESH_INSTALL_DIR="$USER_HOME/.local" | |||
| 17 | + | ||||
| 18 | + | echo "Installing ble.sh for user: $USERNAME" | |||
| 19 | + | ||||
| 20 | + | # Clone ble.sh repository | |||
| 21 | + | echo "Cloning ble.sh repository..." | |||
| 22 | + | cd /tmp | |||
| 23 | + | if [ -d "ble.sh" ]; then | |||
| 24 | + | rm -rf ble.sh | |||
| 25 | + | fi | |||
| 26 | + | ||||
| 27 | + | # Run as user to avoid permission issues | |||
| 28 | + | sudo -u "$USERNAME" bash << EOF | |||
| 29 | + | set -e | |||
| 30 | + | cd /tmp | |||
| 31 | + | git clone --recursive --depth 1 --shallow-submodules https://github.com/akinomyoga/ble.sh.git | |||
| 32 | + | ||||
| 33 | + | # Build and install ble.sh | |||
| 34 | + | echo "Building and installing ble.sh..." | |||
| 35 | + | make -C ble.sh install PREFIX="$BLESH_INSTALL_DIR" | |||
| 36 | + | ||||
| 37 | + | # Add ble.sh to .bashrc if not already present | |||
| 38 | + | if ! grep -q "blesh/ble.sh" "$USER_HOME/.bashrc"; then | |||
| 39 | + | echo "" >> "$USER_HOME/.bashrc" | |||
| 40 | + | echo "# ble.sh - Bash Line Editor" >> "$USER_HOME/.bashrc" | |||
| 41 | + | echo "[[ \$- == *i* ]] && source -- ~/.local/share/blesh/ble.sh" >> "$USER_HOME/.bashrc" | |||
| 42 | + | echo "ble.sh added to .bashrc" | |||
| 43 | + | else | |||
| 44 | + | echo "ble.sh already configured in .bashrc" | |||
| 45 | + | fi | |||
| 46 | + | EOF | |||
| 47 | + | ||||
| 48 | + | # Cleanup | |||
| 49 | + | rm -rf /tmp/ble.sh | |||
| 50 | + | ||||
| 51 | + | echo "✓ ble.sh installed successfully" | |||
| 52 | + | echo " Location: $BLESH_INSTALL_DIR/share/blesh" | |||
| 53 | + | echo " Note: ble.sh will be active on next shell session" | |||
M install/post-install/post-boot-setup.sh +2 -0
| @@ -15,6 +15,7 @@ cp "$ARCHUP_INSTALL/post-boot/snapper.sh" /mnt/usr/local/share/archup/post-boot/ | |||
| 15 | 15 | cp "$ARCHUP_INSTALL/post-boot/ufw.sh" /mnt/usr/local/share/archup/post-boot/ | |
| 16 | 16 | cp "$ARCHUP_INSTALL/post-boot/ssh-keygen.sh" /mnt/usr/local/share/archup/post-boot/ | |
| 17 | 17 | cp "$ARCHUP_INSTALL/post-boot/archup-cli.sh" /mnt/usr/local/share/archup/post-boot/ | |
| 18 | + | cp "$ARCHUP_INSTALL/post-boot/blesh.sh" /mnt/usr/local/share/archup/post-boot/ | |
| 18 | 19 | ||
| 19 | 20 | # Make all scripts executable | |
| 20 | 21 | chmod +x /mnt/usr/local/share/archup/post-boot/*.sh | |
| @@ -30,5 +31,6 @@ echo "First-boot service will run on first reboot to:" >> "$ARCHUP_INSTALL_LOG_F | |||
| 30 | 31 | echo " - Configure snapper snapshots" >> "$ARCHUP_INSTALL_LOG_FILE" | |
| 31 | 32 | echo " - Generate SSH keys" >> "$ARCHUP_INSTALL_LOG_FILE" | |
| 32 | 33 | echo " - Build and install archup-cli from GitHub" >> "$ARCHUP_INSTALL_LOG_FILE" | |
| 34 | + | echo " - Install and configure ble.sh (Bash Line Editor)" >> "$ARCHUP_INSTALL_LOG_FILE" | |
| 33 | 35 | ||
| 34 | 36 | gum style --foreground 2 --padding "0 0 1 $PADDING_LEFT" "[OK] First-boot service configured" | |
| @@ -15,6 +15,7 @@ cp "$ARCHUP_INSTALL/post-boot/snapper.sh" /mnt/usr/local/share/archup/post-boot/ | |||||
| 15 | cp "$ARCHUP_INSTALL/post-boot/ufw.sh" /mnt/usr/local/share/archup/post-boot/ | 15 | cp "$ARCHUP_INSTALL/post-boot/ufw.sh" /mnt/usr/local/share/archup/post-boot/ | ||
| 16 | cp "$ARCHUP_INSTALL/post-boot/ssh-keygen.sh" /mnt/usr/local/share/archup/post-boot/ | 16 | cp "$ARCHUP_INSTALL/post-boot/ssh-keygen.sh" /mnt/usr/local/share/archup/post-boot/ | ||
| 17 | cp "$ARCHUP_INSTALL/post-boot/archup-cli.sh" /mnt/usr/local/share/archup/post-boot/ | 17 | cp "$ARCHUP_INSTALL/post-boot/archup-cli.sh" /mnt/usr/local/share/archup/post-boot/ | ||
| 18 | + | cp "$ARCHUP_INSTALL/post-boot/blesh.sh" /mnt/usr/local/share/archup/post-boot/ | |||
| 18 | 19 | ||||
| 19 | # Make all scripts executable | 20 | # Make all scripts executable | ||
| 20 | chmod +x /mnt/usr/local/share/archup/post-boot/*.sh | 21 | chmod +x /mnt/usr/local/share/archup/post-boot/*.sh | ||
| @@ -30,5 +31,6 @@ echo "First-boot service will run on first reboot to:" >> "$ARCHUP_INSTALL_LOG_F | |||||
| 30 | echo " - Configure snapper snapshots" >> "$ARCHUP_INSTALL_LOG_FILE" | 31 | echo " - Configure snapper snapshots" >> "$ARCHUP_INSTALL_LOG_FILE" | ||
| 31 | echo " - Generate SSH keys" >> "$ARCHUP_INSTALL_LOG_FILE" | 32 | echo " - Generate SSH keys" >> "$ARCHUP_INSTALL_LOG_FILE" | ||
| 32 | echo " - Build and install archup-cli from GitHub" >> "$ARCHUP_INSTALL_LOG_FILE" | 33 | echo " - Build and install archup-cli from GitHub" >> "$ARCHUP_INSTALL_LOG_FILE" | ||
| 34 | + | echo " - Install and configure ble.sh (Bash Line Editor)" >> "$ARCHUP_INSTALL_LOG_FILE" | |||
| 33 | 35 | ||||
| 34 | gum style --foreground 2 --padding "0 0 1 $PADDING_LEFT" "[OK] First-boot service configured" | 36 | gum style --foreground 2 --padding "0 0 1 $PADDING_LEFT" "[OK] First-boot service configured" | ||
M internal/config/config.go +1 -0
| @@ -193,6 +193,7 @@ var PostBootScripts = []string{ | |||
| 193 | 193 | "ufw.sh", | |
| 194 | 194 | "ssh-keygen.sh", | |
| 195 | 195 | "archup-cli.sh", | |
| 196 | + | "blesh.sh", | |
| 196 | 197 | } | |
| 197 | 198 | ||
| 198 | 199 | // Post-boot service template URL path | |
| @@ -193,6 +193,7 @@ var PostBootScripts = []string{ | |||||
| 193 | "ufw.sh", | 193 | "ufw.sh", | ||
| 194 | "ssh-keygen.sh", | 194 | "ssh-keygen.sh", | ||
| 195 | "archup-cli.sh", | 195 | "archup-cli.sh", | ||
| 196 | + | "blesh.sh", | |||
| 196 | } | 197 | } | ||
| 197 | 198 | ||||
| 198 | // Post-boot service template URL path | 199 | // Post-boot service template URL path | ||