1
1
#! /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
3
3
set -e
4
4
5
5
# Define paths
6
6
OLD_INSTALL_PATH=" /opt/Redis Insight" # Path with space
7
7
NEW_INSTALL_PATH=" /opt/redisinsight" # New path without space
8
8
DESKTOP_FILE=" /usr/share/applications/redisinsight.desktop"
9
9
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
11
11
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 "
13
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
14
+ # Always update the symlink
15
+ sudo ln -sf " $NEW_INSTALL_PATH /redisinsight" " /usr/bin/redisinsight" || true
17
16
18
- # Only try to set permissions if files exist
17
+ # Set permissions only if files exist
19
18
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
21
20
fi
22
21
23
22
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
26
25
fi
27
26
28
- echo " Auto -update post-installation completed"
27
+ echo " RedisInsight auto -update post-install completed"
29
28
exit 0
30
29
fi
31
30
32
31
# Check if old directory exists and rename it
33
32
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
44
39
fi
45
40
46
41
# Update desktop file to use new path if it exists
47
42
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
50
45
fi
51
46
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
54
49
55
- # Set basic executable permissions if file exists
50
+ # Set executable permissions
56
51
if [ -f " $NEW_INSTALL_PATH /redisinsight" ]; then
57
- chmod +x " $NEW_INSTALL_PATH /redisinsight" || true
52
+ sudo chmod +x " $NEW_INSTALL_PATH /redisinsight" || true
58
53
fi
59
54
60
- # Set correct ownership and permissions for chrome-sandbox if it exists
55
+ # Set correct ownership and permissions for chrome-sandbox
61
56
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
64
59
fi
65
60
66
61
echo " RedisInsight post-installation setup completed successfully"
0 commit comments