Skip to content

Commit 5bee056

Browse files
committed
chore: harden bootstrap flow and add CI validation
1 parent 8ae1c70 commit 5bee056

3 files changed

Lines changed: 43 additions & 8 deletions

File tree

.github/workflows/validate.yml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
name: Validate
2+
3+
on:
4+
push:
5+
pull_request:
6+
7+
jobs:
8+
validate:
9+
runs-on: ubuntu-latest
10+
steps:
11+
- name: Checkout
12+
uses: actions/checkout@v4
13+
14+
- name: Validate shell scripts
15+
run: |
16+
bash -n bootstrap.sh
17+
while IFS= read -r -d '' f; do
18+
bash -n "$f"
19+
done < <(find scripts -type f -name '*.sh' -print0)
20+
21+
- name: Validate compose config
22+
run: |
23+
cp .env.example .env
24+
docker compose --profile autoupdate config >/dev/null
25+
rm .env

bootstrap.sh

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# Mac Media Stack - One-Shot Installer
33
# Usage: curl -fsSL https://raw.githubusercontent.com/liamvibecodes/mac-media-stack/main/bootstrap.sh | bash
44

5-
set -e
5+
set -euo pipefail
66

77
RED='\033[0;31m'
88
GREEN='\033[0;32m'
@@ -47,7 +47,12 @@ echo ""
4747
INSTALL_DIR="$HOME/mac-media-stack"
4848
if [[ -d "$INSTALL_DIR" ]]; then
4949
echo -e "${YELLOW}Note:${NC} $INSTALL_DIR already exists. Pulling latest..."
50-
cd "$INSTALL_DIR" && git pull --ff-only 2>/dev/null || true
50+
if ! git -C "$INSTALL_DIR" pull --ff-only; then
51+
echo -e "${RED}Failed to update existing repo at $INSTALL_DIR.${NC}"
52+
echo "Resolve local git issues, then re-run bootstrap."
53+
echo "Suggested check: cd $INSTALL_DIR && git status"
54+
exit 1
55+
fi
5156
else
5257
echo -e "${CYAN}Cloning repo...${NC}"
5358
git clone https://github.com/liamvibecodes/mac-media-stack.git "$INSTALL_DIR"
@@ -69,7 +74,8 @@ if grep -q "your_wireguard_private_key_here" .env 2>/dev/null; then
6974
echo "You need your ProtonVPN WireGuard credentials."
7075
echo "If someone gave you a private key and address, enter them now."
7176
echo ""
72-
read -p " WireGuard Private Key: " vpn_key
77+
read -s -p " WireGuard Private Key: " vpn_key
78+
echo ""
7379
read -p " WireGuard Address (e.g. 10.2.0.2/32): " vpn_addr
7480

7581
if [[ -n "$vpn_key" && -n "$vpn_addr" ]]; then

scripts/install-auto-heal.sh

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,18 @@
11
#!/bin/bash
22
# Installs the auto-heal launchd job (runs hourly).
33

4-
set -e
4+
set -euo pipefail
55

66
GREEN='\033[0;32m'
77
NC='\033[0m'
88

99
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
10+
LAUNCH_DIR="$HOME/Library/LaunchAgents"
11+
LOG_DIR="$HOME/Media/logs/launchd"
1012
PLIST_NAME="com.media-stack.auto-heal"
11-
PLIST_PATH="$HOME/Library/LaunchAgents/$PLIST_NAME.plist"
13+
PLIST_PATH="$LAUNCH_DIR/$PLIST_NAME.plist"
14+
15+
mkdir -p "$LAUNCH_DIR" "$LOG_DIR"
1216

1317
cat > "$PLIST_PATH" <<EOF
1418
<?xml version="1.0" encoding="UTF-8"?>
@@ -27,9 +31,9 @@ cat > "$PLIST_PATH" <<EOF
2731
<key>RunAtLoad</key>
2832
<true/>
2933
<key>StandardOutPath</key>
30-
<string>/dev/null</string>
34+
<string>$LOG_DIR/auto-heal.out.log</string>
3135
<key>StandardErrorPath</key>
32-
<string>/dev/null</string>
36+
<string>$LOG_DIR/auto-heal.err.log</string>
3337
</dict>
3438
</plist>
3539
EOF
@@ -38,6 +42,6 @@ launchctl unload "$PLIST_PATH" 2>/dev/null || true
3842
launchctl load "$PLIST_PATH"
3943

4044
echo -e "${GREEN}Auto-heal installed.${NC} Runs every hour + on login."
41-
echo "Logs: ~/Media/logs/auto-heal.log"
45+
echo "Logs: ~/Media/logs/auto-heal.log and ~/Media/logs/launchd/"
4246
echo ""
4347
echo "To uninstall: launchctl unload $PLIST_PATH && rm $PLIST_PATH"

0 commit comments

Comments
 (0)