Skip to content

Commit f399c9e

Browse files
author
KIvanow
committed
RI-6690 trying fallback + timeout
1 parent b4f88c8 commit f399c9e

File tree

1 file changed

+42
-16
lines changed

1 file changed

+42
-16
lines changed

scripts/deb-after-install.sh

Lines changed: 42 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,66 @@
11
#!/bin/bash
2-
set -ex
2+
# Use set -e, but not set -x to avoid excessive logs that might slow down the script
3+
set -e
34

45
# Define paths
56
OLD_INSTALL_PATH="/opt/Redis Insight" # Path with space
67
NEW_INSTALL_PATH="/opt/redisinsight" # New path without space
78
DESKTOP_FILE="/usr/share/applications/redisinsight.desktop"
89

9-
# Auto-update scenario detection:
10-
# If NEW_INSTALL_PATH exists and OLD_INSTALL_PATH doesn't, assume we're running
11-
# after an auto-update and just exit successfully
10+
# Check for update scenario - for auto-updates, NEW_INSTALL_PATH typically already exists
1211
if [ -d "$NEW_INSTALL_PATH" ] && [ ! -d "$OLD_INSTALL_PATH" ]; then
13-
echo "Detected existing installation at $NEW_INSTALL_PATH"
14-
echo "This appears to be an auto-update scenario - no migration needed"
12+
echo "Auto-update detected - existing installation at $NEW_INSTALL_PATH"
13+
14+
# For auto-updates, just ensure binary links and permissions are correct
15+
# Use timeout to prevent hanging
16+
timeout 10s ln -sf "$NEW_INSTALL_PATH/redisinsight" "/usr/bin/redisinsight" || true
17+
18+
# Only try to set permissions if files exist
19+
if [ -f "$NEW_INSTALL_PATH/redisinsight" ]; then
20+
timeout 5s chmod +x "$NEW_INSTALL_PATH/redisinsight" || true
21+
fi
22+
23+
if [ -f "$NEW_INSTALL_PATH/chrome-sandbox" ]; then
24+
timeout 5s chown root:root "$NEW_INSTALL_PATH/chrome-sandbox" || true
25+
timeout 5s chmod 4755 "$NEW_INSTALL_PATH/chrome-sandbox" || true
26+
fi
27+
28+
echo "Auto-update post-installation completed"
1529
exit 0
1630
fi
1731

1832
# Check if old directory exists and rename it
1933
if [ -d "$OLD_INSTALL_PATH" ]; then
2034
echo "Renaming $OLD_INSTALL_PATH to $NEW_INSTALL_PATH"
21-
sudo mv "$OLD_INSTALL_PATH" "$NEW_INSTALL_PATH"
35+
# Add timeout and fallback for safety
36+
timeout 30s mv "$OLD_INSTALL_PATH" "$NEW_INSTALL_PATH" || {
37+
echo "Warning: Could not move directory. It might be in use or already moved."
38+
# If we couldn't move, but destination exists, continue anyway
39+
if [ ! -d "$NEW_INSTALL_PATH" ]; then
40+
echo "Error: Neither source nor destination directory exists. Installation may be incomplete."
41+
exit 1
42+
fi
43+
}
2244
fi
2345

24-
# Update desktop file to use new path
46+
# Update desktop file to use new path if it exists
2547
if [ -f "$DESKTOP_FILE" ]; then
2648
echo "Updating desktop file to use new path"
27-
sudo sed -i "s|$OLD_INSTALL_PATH|$NEW_INSTALL_PATH|g" "$DESKTOP_FILE"
49+
timeout 10s sed -i "s|$OLD_INSTALL_PATH|$NEW_INSTALL_PATH|g" "$DESKTOP_FILE" || true
2850
fi
2951

30-
# Update binary link
31-
sudo ln -sf "$NEW_INSTALL_PATH/redisinsight" "/usr/bin/redisinsight"
52+
# Update binary link - don't use sudo if not necessary
53+
ln -sf "$NEW_INSTALL_PATH/redisinsight" "/usr/bin/redisinsight" || true
3254

33-
# Set basic executable permissions
34-
sudo chmod +x "$NEW_INSTALL_PATH/redisinsight"
55+
# Set basic executable permissions if file exists
56+
if [ -f "$NEW_INSTALL_PATH/redisinsight" ]; then
57+
chmod +x "$NEW_INSTALL_PATH/redisinsight" || true
58+
fi
3559

36-
# Set correct ownership and permissions for chrome-sandbox
37-
sudo chown root:root "$NEW_INSTALL_PATH/chrome-sandbox"
38-
sudo chmod 4755 "$NEW_INSTALL_PATH/chrome-sandbox"
60+
# Set correct ownership and permissions for chrome-sandbox if it exists
61+
if [ -f "$NEW_INSTALL_PATH/chrome-sandbox" ]; then
62+
chown root:root "$NEW_INSTALL_PATH/chrome-sandbox" || true
63+
chmod 4755 "$NEW_INSTALL_PATH/chrome-sandbox" || true
64+
fi
3965

4066
echo "RedisInsight post-installation setup completed successfully"

0 commit comments

Comments
 (0)