Skip to content

Commit b65574d

Browse files
author
Kristiyan Ivanov
authored
Merge pull request #4554 from RedisInsight/RI-6690-testing-debian-updates
Ri-6690 - Redis Insight client v2.66 installed with the deb package fails to upgrade to a newer version (2.67) on Ububntu && RI-6691 - After client update 2.64 to 2.67 Redis Insight can't be started from the application icon
2 parents 459b72b + cc7e8d4 commit b65574d

File tree

1 file changed

+96
-20
lines changed

1 file changed

+96
-20
lines changed

scripts/deb-after-install.sh

Lines changed: 96 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,107 @@
11
#!/bin/bash
2-
set -ex
2+
set -e
33

4-
# Define paths
5-
OLD_INSTALL_PATH="/opt/Redis Insight" # Path with space
6-
NEW_INSTALL_PATH="/opt/redisinsight" # New path without space
4+
OLD_INSTALL_PATH="/opt/Redis Insight"
5+
NEW_INSTALL_PATH="/opt/redisinsight"
76
DESKTOP_FILE="/usr/share/applications/redisinsight.desktop"
87

9-
# Check if old directory exists and rename it
10-
if [ -d "$OLD_INSTALL_PATH" ]; then
11-
echo "Renaming $OLD_INSTALL_PATH to $NEW_INSTALL_PATH"
12-
sudo mv "$OLD_INSTALL_PATH" "$NEW_INSTALL_PATH"
13-
fi
148

15-
# Update desktop file to use new path
9+
echo "Checking for running RedisInsight instances..."
10+
RUNNING_PIDS=$(pgrep -f "$NEW_INSTALL_PATH/redisinsight" || pgrep -f "$OLD_INSTALL_PATH/redisinsight" || true)
11+
12+
OUR_PID=$$
13+
for PID in $RUNNING_PIDS; do
14+
if ! ps -o pid= --ppid $OUR_PID | grep -q $PID; then
15+
echo "Found running RedisInsight instance (PID: $PID), attempting to terminate..."
16+
kill $PID 2>/dev/null || true
17+
fi
18+
done
19+
20+
# Brief pause to let processes terminate
21+
sleep 1
22+
1623
if [ -f "$DESKTOP_FILE" ]; then
17-
echo "Updating desktop file to use new path"
18-
sudo sed -i "s|$OLD_INSTALL_PATH|$NEW_INSTALL_PATH|g" "$DESKTOP_FILE"
24+
echo "Updating desktop file for launcher compatibility..."
25+
26+
# First replace the old path with the new path throughout the file
27+
sed -i "s|$OLD_INSTALL_PATH|$NEW_INSTALL_PATH|g" "$DESKTOP_FILE" || true
28+
29+
# Then ensure the Exec line is properly formatted without quotes
30+
sed -i "s|^Exec=.*|Exec=$NEW_INSTALL_PATH/redisinsight %U|g" "$DESKTOP_FILE" || true
31+
32+
# Update desktop database to refresh the icon
33+
update-desktop-database 2>/dev/null || true
1934
fi
2035

21-
# Update binary link
22-
sudo ln -sf "$NEW_INSTALL_PATH/redisinsight" "/usr/bin/redisinsight"
36+
# Handle update case: redisinsight exists, Redis Insight exists too
37+
# This means that we are in an update scenario
38+
if [ -d "$NEW_INSTALL_PATH" ] && [ -d "$OLD_INSTALL_PATH" ]; then
39+
echo "Both old and new paths exist - handling update scenario"
40+
41+
cp -rf "$OLD_INSTALL_PATH"/* "$NEW_INSTALL_PATH"/ || true
42+
43+
rm -rf "$OLD_INSTALL_PATH" || true
44+
45+
# Ensure binary link and permissions
46+
ln -sf "$NEW_INSTALL_PATH/redisinsight" "/usr/bin/redisinsight" || true
47+
if [ -f "$NEW_INSTALL_PATH/redisinsight" ]; then
48+
chmod +x "$NEW_INSTALL_PATH/redisinsight" || true
49+
fi
50+
if [ -f "$NEW_INSTALL_PATH/chrome-sandbox" ]; then
51+
chown root:root "$NEW_INSTALL_PATH/chrome-sandbox" || true
52+
chmod 4755 "$NEW_INSTALL_PATH/chrome-sandbox" || true
53+
fi
54+
55+
echo "Update handled successfully"
56+
exit 0
57+
fi
58+
59+
# Handle simple auto-update case: only redisinsight exists
60+
if [ -d "$NEW_INSTALL_PATH" ] && [ ! -d "$OLD_INSTALL_PATH" ]; then
61+
echo "New path exists but old doesn't - likely clean install or auto-update"
62+
63+
# Ensure binary link and permissions
64+
ln -sf "$NEW_INSTALL_PATH/redisinsight" "/usr/bin/redisinsight" || true
65+
if [ -f "$NEW_INSTALL_PATH/redisinsight" ]; then
66+
chmod +x "$NEW_INSTALL_PATH/redisinsight" || true
67+
fi
68+
if [ -f "$NEW_INSTALL_PATH/chrome-sandbox" ]; then
69+
chown root:root "$NEW_INSTALL_PATH/chrome-sandbox" || true
70+
chmod 4755 "$NEW_INSTALL_PATH/chrome-sandbox" || true
71+
fi
72+
73+
echo "Installation/update completed successfully"
74+
exit 0
75+
fi
76+
77+
# Handle migration case: only Redis Insight exists.
78+
#This is to ensure that if somebody updates from a very old version to a newer one, we'll still migrate it as expected
79+
if [ ! -d "$NEW_INSTALL_PATH" ] && [ -d "$OLD_INSTALL_PATH" ]; then
80+
echo "Old path found but new doesn't exist - migrating to new path"
81+
82+
# Simply move the directory
83+
mv "$OLD_INSTALL_PATH" "$NEW_INSTALL_PATH" || true
84+
85+
# Ensure binary link and permissions
86+
ln -sf "$NEW_INSTALL_PATH/redisinsight" "/usr/bin/redisinsight" || true
87+
if [ -f "$NEW_INSTALL_PATH/redisinsight" ]; then
88+
chmod +x "$NEW_INSTALL_PATH/redisinsight" || true
89+
fi
90+
if [ -f "$NEW_INSTALL_PATH/chrome-sandbox" ]; then
91+
chown root:root "$NEW_INSTALL_PATH/chrome-sandbox" || true
92+
chmod 4755 "$NEW_INSTALL_PATH/chrome-sandbox" || true
93+
fi
94+
95+
echo "Migration completed successfully"
96+
exit 0
97+
fi
2398

24-
# Set basic executable permissions
25-
sudo chmod +x "$NEW_INSTALL_PATH/redisinsight"
99+
# Neither directory exists - unexpected state
100+
echo "Neither old nor new path exists. This is an unexpected state."
101+
echo "Creating new installation directory as a fallback"
102+
mkdir -p "$NEW_INSTALL_PATH" || true
26103

27-
# Set correct ownership and permissions for chrome-sandbox
28-
sudo chown root:root "$NEW_INSTALL_PATH/chrome-sandbox"
29-
sudo chmod 4755 "$NEW_INSTALL_PATH/chrome-sandbox"
104+
# Always set up the binary link
105+
ln -sf "$NEW_INSTALL_PATH/redisinsight" "/usr/bin/redisinsight" || true
30106

31-
echo "RedisInsight post-installation setup completed successfully"
107+
echo "Post-installation completed with warnings"

0 commit comments

Comments
 (0)