Skip to content

Commit 6d91057

Browse files
author
KIvanow
committed
RI-6690 brute forcing with sudo
1 parent f399c9e commit 6d91057

File tree

1 file changed

+25
-30
lines changed

1 file changed

+25
-30
lines changed

scripts/deb-after-install.sh

Lines changed: 25 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,66 +1,61 @@
11
#!/bin/bash
2-
# Use set -e, but not set -x to avoid excessive logs that might slow down the script
2+
# Exit on error but continue past command failures with || true
33
set -e
44

55
# Define paths
66
OLD_INSTALL_PATH="/opt/Redis Insight" # Path with space
77
NEW_INSTALL_PATH="/opt/redisinsight" # New path without space
88
DESKTOP_FILE="/usr/share/applications/redisinsight.desktop"
99

10-
# Check for update scenario - for auto-updates, NEW_INSTALL_PATH typically already exists
10+
# Simple auto-update detection - if we have the new path but not the old path
1111
if [ -d "$NEW_INSTALL_PATH" ] && [ ! -d "$OLD_INSTALL_PATH" ]; then
12-
echo "Auto-update detected - existing installation at $NEW_INSTALL_PATH"
12+
echo "Auto-update scenario detected"
1313

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
14+
# Always update the symlink
15+
sudo ln -sf "$NEW_INSTALL_PATH/redisinsight" "/usr/bin/redisinsight" || true
1716

18-
# Only try to set permissions if files exist
17+
# Set permissions only if files exist
1918
if [ -f "$NEW_INSTALL_PATH/redisinsight" ]; then
20-
timeout 5s chmod +x "$NEW_INSTALL_PATH/redisinsight" || true
19+
sudo chmod +x "$NEW_INSTALL_PATH/redisinsight" || true
2120
fi
2221

2322
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
23+
sudo chown root:root "$NEW_INSTALL_PATH/chrome-sandbox" || true
24+
sudo chmod 4755 "$NEW_INSTALL_PATH/chrome-sandbox" || true
2625
fi
2726

28-
echo "Auto-update post-installation completed"
27+
echo "RedisInsight auto-update post-install completed"
2928
exit 0
3029
fi
3130

3231
# Check if old directory exists and rename it
3332
if [ -d "$OLD_INSTALL_PATH" ]; then
34-
echo "Renaming $OLD_INSTALL_PATH to $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-
}
33+
echo "Migrating from old installation path"
34+
if [ -d "$NEW_INSTALL_PATH" ]; then
35+
echo "WARNING: Both old and new paths exist. Removing new path first."
36+
sudo rm -rf "$NEW_INSTALL_PATH" || true
37+
fi
38+
sudo mv "$OLD_INSTALL_PATH" "$NEW_INSTALL_PATH" || true
4439
fi
4540

4641
# Update desktop file to use new path if it exists
4742
if [ -f "$DESKTOP_FILE" ]; then
48-
echo "Updating desktop file to use new path"
49-
timeout 10s sed -i "s|$OLD_INSTALL_PATH|$NEW_INSTALL_PATH|g" "$DESKTOP_FILE" || true
43+
echo "Updating desktop file"
44+
sudo sed -i "s|$OLD_INSTALL_PATH|$NEW_INSTALL_PATH|g" "$DESKTOP_FILE" || true
5045
fi
5146

52-
# Update binary link - don't use sudo if not necessary
53-
ln -sf "$NEW_INSTALL_PATH/redisinsight" "/usr/bin/redisinsight" || true
47+
# Always update the symlink
48+
sudo ln -sf "$NEW_INSTALL_PATH/redisinsight" "/usr/bin/redisinsight" || true
5449

55-
# Set basic executable permissions if file exists
50+
# Set executable permissions
5651
if [ -f "$NEW_INSTALL_PATH/redisinsight" ]; then
57-
chmod +x "$NEW_INSTALL_PATH/redisinsight" || true
52+
sudo chmod +x "$NEW_INSTALL_PATH/redisinsight" || true
5853
fi
5954

60-
# Set correct ownership and permissions for chrome-sandbox if it exists
55+
# Set correct ownership and permissions for chrome-sandbox
6156
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
57+
sudo chown root:root "$NEW_INSTALL_PATH/chrome-sandbox" || true
58+
sudo chmod 4755 "$NEW_INSTALL_PATH/chrome-sandbox" || true
6459
fi
6560

6661
echo "RedisInsight post-installation setup completed successfully"

0 commit comments

Comments
 (0)