-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathupgrade-cursor
More file actions
executable file
·65 lines (53 loc) · 1.84 KB
/
upgrade-cursor
File metadata and controls
executable file
·65 lines (53 loc) · 1.84 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
#!/bin/bash
# Script to upgrade Cursor when triggered by apt
# Get the actual user's home directory, taking sudo into account
if [ -n "$SUDO_USER" ]; then
USER_HOME=$(eval echo ~$SUDO_USER)
else
USER_HOME=$HOME
fi
CURSOR_DIR="$USER_HOME/Applications/cursor"
UPDATE_SCRIPT="$CURSOR_DIR/update-cursor.sh"
VERSION_FILE="$CURSOR_DIR/cursor-version"
UPGRADE_MARKER="/var/lib/apt/lists/cursor-editor.update"
LOGFILE="$CURSOR_DIR/update-cursor.log"
# Function to log messages
log() {
echo "$(date '+%Y-%m-%d %H:%M:%S') - $1" | tee -a "$LOGFILE"
}
# Check if running as root
if [ "$(id -u)" -ne 0 ]; then
echo "This script must be run as root (via apt or sudo)."
exit 1
fi
# Check if there's an update marker
if [ ! -f "$UPGRADE_MARKER" ]; then
log "No Cursor updates available to install."
exit 0
fi
# Get the new version
NEW_VERSION=$(grep -oP 'Version: \K.+' "$UPGRADE_MARKER" 2>/dev/null || echo "unknown")
CURRENT_VERSION=$(cat "$VERSION_FILE" 2>/dev/null || echo "unknown")
log "Upgrading Cursor from $CURRENT_VERSION to $NEW_VERSION"
echo "Upgrading Cursor Editor from $CURRENT_VERSION to $NEW_VERSION..."
# Run the actual update script
if [ -x "$UPDATE_SCRIPT" ]; then
# Run the update script and capture output
if UPDATE_OUTPUT=$("$UPDATE_SCRIPT" 2>&1); then
log "Cursor update successful"
# Update the version file
echo "$NEW_VERSION" > "$VERSION_FILE"
# Remove the upgrade marker
rm -f "$UPGRADE_MARKER"
echo "Cursor Editor $NEW_VERSION has been installed successfully."
else
log "Cursor update failed: $UPDATE_OUTPUT"
echo "Failed to upgrade Cursor Editor: $UPDATE_OUTPUT"
exit 1
fi
else
log "Update script not found or not executable"
echo "Error: Cursor update script not found or not executable."
exit 1
fi
exit 0