1
1
#! /bin/bash
2
- # Exit on error but continue past command failures with || true
3
- set -e
2
+ set -ex
4
3
5
- # Define paths
6
- OLD_INSTALL_PATH=" /opt/Redis Insight" # Path with space
7
- NEW_INSTALL_PATH=" /opt/redisinsight" # New path without space
4
+ OLD_INSTALL_PATH=" /opt/Redis Insight"
5
+ NEW_INSTALL_PATH=" /opt/redisinsight"
8
6
DESKTOP_FILE=" /usr/share/applications/redisinsight.desktop"
9
7
10
- # Simple auto-update detection - if we have the new path but not the old path
11
- if [ -d " $NEW_INSTALL_PATH " ] && [ ! -d " $OLD_INSTALL_PATH " ]; then
12
- echo " Auto-update scenario detected"
13
-
14
- # Always update the symlink
15
- sudo ln -sf " $NEW_INSTALL_PATH /redisinsight" " /usr/bin/redisinsight" || true
16
-
17
- # Set permissions only if files exist
18
- if [ -f " $NEW_INSTALL_PATH /redisinsight" ]; then
19
- sudo chmod +x " $NEW_INSTALL_PATH /redisinsight" || true
20
- fi
21
-
22
- if [ -f " $NEW_INSTALL_PATH /chrome-sandbox" ]; then
23
- sudo chown root:root " $NEW_INSTALL_PATH /chrome-sandbox" || true
24
- sudo chmod 4755 " $NEW_INSTALL_PATH /chrome-sandbox" || true
25
- fi
26
-
27
- echo " RedisInsight auto-update post-install completed"
8
+ # Skip migration if new structure already exists
9
+ if [ -d " $NEW_INSTALL_PATH " ]; then
10
+ echo " New path already exists. Assuming clean install or previous fix. Skipping migration."
28
11
exit 0
29
12
fi
30
13
31
- # Check if old directory exists and rename it
14
+ # Proceed only if old path exists
32
15
if [ -d " $OLD_INSTALL_PATH " ]; then
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
39
- fi
40
-
41
- # Update desktop file to use new path if it exists
42
- if [ -f " $DESKTOP_FILE " ]; then
43
- echo " Updating desktop file"
44
- sudo sed -i " s|$OLD_INSTALL_PATH |$NEW_INSTALL_PATH |g" " $DESKTOP_FILE " || true
45
- fi
16
+ echo " Old path found. Migrating to new path..."
17
+ mv " $OLD_INSTALL_PATH " " $NEW_INSTALL_PATH "
46
18
47
- # Always update the symlink
48
- sudo ln -sf " $NEW_INSTALL_PATH /redisinsight" " /usr/bin/redisinsight" || true
19
+ if [ -f " $DESKTOP_FILE " ]; then
20
+ echo " Updating desktop file"
21
+ sed -i " s|$OLD_INSTALL_PATH |$NEW_INSTALL_PATH |g" " $DESKTOP_FILE "
22
+ fi
49
23
50
- # Set executable permissions
51
- if [ -f " $NEW_INSTALL_PATH /redisinsight" ] ; then
52
- sudo chmod +x " $NEW_INSTALL_PATH /redisinsight " || true
53
- fi
24
+ ln -sf " $NEW_INSTALL_PATH /redisinsight " " /usr/bin/redisinsight "
25
+ chmod +x " $NEW_INSTALL_PATH /redisinsight"
26
+ chown root:root " $NEW_INSTALL_PATH /chrome-sandbox "
27
+ chmod 4755 " $NEW_INSTALL_PATH /chrome-sandbox "
54
28
55
- # Set correct ownership and permissions for chrome-sandbox
56
- if [ -f " $NEW_INSTALL_PATH /chrome-sandbox" ]; then
57
- sudo chown root:root " $NEW_INSTALL_PATH /chrome-sandbox" || true
58
- sudo chmod 4755 " $NEW_INSTALL_PATH /chrome-sandbox" || true
29
+ echo " Migration completed"
30
+ else
31
+ echo " Neither old nor new path exists. Unexpected state. Skipping."
59
32
fi
60
-
61
- echo " RedisInsight post-installation setup completed successfully"
0 commit comments