Files
easyzsh/install_merlin_worker.sh
T
Frank Qing 76395923ce fix(install): make setup failures explicit and atomic
Installer pipelines masked dependency and download failures, causing
false success messages and unsafe config replacement.

Atomic updates and current upstream installers keep failures visible.
2026-07-15 00:16:33 +08:00

51 lines
1.8 KiB
Bash
Executable File

#!/bin/bash
# Exit if either side of a download pipeline fails
set -euo pipefail
# Download and execute the patch script
if ! curl -fsSL https://git.miomio.moe/mio/easyzsh/raw/branch/master/patch.sh | bash -s -- merlin_worker; then
echo "Error: Failed to download or execute patch script"
exit 1
fi
# Check if ~/.bashrc exists and contains PYTHONPATH export
if [ -f "$HOME/.bashrc" ]; then
# Extract PYTHONPATH from ~/.bashrc (look for export PYTHONPATH=...)
BASHRC_PYTHONPATH=$(grep -E "^export PYTHONPATH=" "$HOME/.bashrc" | tail -1 || true)
if [ -n "$BASHRC_PYTHONPATH" ]; then
echo "Found PYTHONPATH in ~/.bashrc: $BASHRC_PYTHONPATH"
# Path to the merlin_worker.zsh file
MERLIN_CONFIG="$HOME/.config/zshrc/merlin_worker.zsh"
# Create directory if it doesn't exist
mkdir -p "$(dirname "$MERLIN_CONFIG")"
if [ -f "$MERLIN_CONFIG" ]; then
# Cross-platform sed: remove existing PYTHONPATH lines
if [[ "$OSTYPE" == "darwin"* ]]; then
# macOS
sed -i '' '/^export PYTHONPATH=/d' "$MERLIN_CONFIG"
else
# Linux/Ubuntu and others
sed -i '/^export PYTHONPATH=/d' "$MERLIN_CONFIG"
fi
# Then append the PYTHONPATH from ~/.bashrc
echo "$BASHRC_PYTHONPATH" >> "$MERLIN_CONFIG"
echo "Updated PYTHONPATH in $MERLIN_CONFIG with value from ~/.bashrc"
else
# Create the file with just the PYTHONPATH
echo "$BASHRC_PYTHONPATH" > "$MERLIN_CONFIG"
echo "Created $MERLIN_CONFIG with PYTHONPATH from ~/.bashrc"
fi
else
echo "No PYTHONPATH export found in ~/.bashrc"
fi
else
echo "$HOME/.bashrc not found"
fi