-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathupdate.sh
More file actions
executable file
·72 lines (59 loc) · 1.62 KB
/
update.sh
File metadata and controls
executable file
·72 lines (59 loc) · 1.62 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
#!/bin/bash
set -e
echo "==================================="
echo " PortOS Update"
echo "==================================="
echo ""
# Resilient npm install — retries once after cleaning node_modules on failure
# Handles ENOTEMPTY and other transient npm bugs
safe_install() {
local dir="${1:-.}"
local label="${dir}"
[ "$dir" = "." ] && label="root"
echo "📦 Installing deps ($label)..."
if (cd "$dir" && npm install 2>&1); then
return 0
fi
echo "⚠️ npm install failed for $label — cleaning node_modules and retrying..."
rm -rf "$dir/node_modules"
if (cd "$dir" && npm install 2>&1); then
return 0
fi
echo "❌ npm install failed for $label after retry"
return 1
}
# Pull latest
echo "Pulling latest changes..."
git pull --rebase --autostash
echo ""
# Stop PM2 apps to release file locks before updating
echo "Stopping PortOS apps..."
npm run pm2:stop 2>/dev/null || true
echo ""
# Update dependencies with retry logic
echo "Updating dependencies..."
safe_install .
safe_install client
safe_install server
echo ""
# Verify critical dependencies exist
if [ ! -f "client/node_modules/vite/bin/vite.js" ]; then
echo "❌ Critical dependency missing: client/node_modules/vite"
echo " Try running: npm run install:all"
exit 1
fi
# Run setup (data dirs + browser deps)
echo "Ensuring data & browser setup..."
npm run setup
echo ""
# Ghostty sync (if installed)
node scripts/setup-ghostty.js
echo ""
# Restart PM2 apps
echo "Restarting PortOS..."
npm run pm2:restart
echo ""
echo "==================================="
echo " ✅ Update Complete!"
echo "==================================="
echo ""