1
1
#! /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
3
4
4
5
# Define paths
5
6
OLD_INSTALL_PATH=" /opt/Redis Insight" # Path with space
6
7
NEW_INSTALL_PATH=" /opt/redisinsight" # New path without space
7
8
DESKTOP_FILE=" /usr/share/applications/redisinsight.desktop"
8
9
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
12
11
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"
15
29
exit 0
16
30
fi
17
31
18
32
# Check if old directory exists and rename it
19
33
if [ -d " $OLD_INSTALL_PATH " ]; then
20
34
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
+ }
22
44
fi
23
45
24
- # Update desktop file to use new path
46
+ # Update desktop file to use new path if it exists
25
47
if [ -f " $DESKTOP_FILE " ]; then
26
48
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
28
50
fi
29
51
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
32
54
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
35
59
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
39
65
40
66
echo " RedisInsight post-installation setup completed successfully"
0 commit comments