69 lines
1.6 KiB
Bash
69 lines
1.6 KiB
Bash
#!/bin/bash
|
|
|
|
set -euo pipefail
|
|
|
|
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
REPO_ROOT="$(dirname "$SCRIPT_DIR")"
|
|
REBOOT_MARKER="$REPO_ROOT/.setup-reboot-required"
|
|
REPO_SECRET_FILE="$REPO_ROOT/Zsh/.zsh_secrets"
|
|
HOME_SECRET_FILE="$HOME/.zsh_secrets"
|
|
|
|
handle_reboot_marker() {
|
|
if [ -f "$REBOOT_MARKER" ]; then
|
|
rm -f "$REBOOT_MARKER"
|
|
echo "Package layering finished. Reboot, then rerun the same command."
|
|
exit 0
|
|
fi
|
|
}
|
|
|
|
sync_repo_managed_secret_file() {
|
|
mkdir -p "$(dirname "$REPO_SECRET_FILE")"
|
|
|
|
if [ -L "$HOME_SECRET_FILE" ]; then
|
|
return 0
|
|
fi
|
|
|
|
if [ -f "$HOME_SECRET_FILE" ]; then
|
|
if [ ! -f "$REPO_SECRET_FILE" ] || [ ! -s "$REPO_SECRET_FILE" ]; then
|
|
mv "$HOME_SECRET_FILE" "$REPO_SECRET_FILE"
|
|
return 0
|
|
fi
|
|
|
|
if cmp -s "$HOME_SECRET_FILE" "$REPO_SECRET_FILE"; then
|
|
rm -f "$HOME_SECRET_FILE"
|
|
return 0
|
|
fi
|
|
|
|
echo "Conflict: both $HOME_SECRET_FILE and $REPO_SECRET_FILE exist with different contents."
|
|
echo "Please merge them manually, then rerun the command."
|
|
exit 1
|
|
fi
|
|
|
|
touch "$REPO_SECRET_FILE"
|
|
}
|
|
|
|
main() {
|
|
rm -f "$REBOOT_MARKER"
|
|
|
|
bash "$SCRIPT_DIR/base.sh"
|
|
handle_reboot_marker
|
|
|
|
bash "$SCRIPT_DIR/node.sh"
|
|
bash "$SCRIPT_DIR/go.sh"
|
|
bash "$SCRIPT_DIR/rust.sh"
|
|
bash "$SCRIPT_DIR/python.sh"
|
|
handle_reboot_marker
|
|
|
|
bash "$SCRIPT_DIR/r.sh"
|
|
handle_reboot_marker
|
|
|
|
sync_repo_managed_secret_file
|
|
|
|
stow --dir="$REPO_ROOT" -D Zsh --target="$HOME" 2>/dev/null || true
|
|
stow --dir="$REPO_ROOT" Zsh --target="$HOME"
|
|
|
|
echo "Full setup completed."
|
|
}
|
|
|
|
main "$@"
|