@@ -5,13 +5,20 @@ OLD_INSTALL_PATH="/opt/Redis Insight"
5
5
NEW_INSTALL_PATH=" /opt/redisinsight"
6
6
DESKTOP_FILE=" /usr/share/applications/redisinsight.desktop"
7
7
8
- # Try to gracefully terminate any running instances
9
- if pgrep redisinsight > /dev/null; then
10
- echo " RedisInsight is running, attempting to terminate gracefully"
11
- pkill redisinsight || true
12
- # Give it a moment to shut down
13
- sleep 2
14
- fi
8
+
9
+ echo " Checking for running RedisInsight instances..."
10
+ RUNNING_PIDS=$( pgrep -f " $NEW_INSTALL_PATH /redisinsight" || pgrep -f " $OLD_INSTALL_PATH /redisinsight" || true)
11
+
12
+ OUR_PID=$$
13
+ for PID in $RUNNING_PIDS ; do
14
+ if ! ps -o pid= --ppid $OUR_PID | grep -q $PID ; then
15
+ echo " Found running RedisInsight instance (PID: $PID ), attempting to terminate..."
16
+ kill $PID 2> /dev/null || true
17
+ fi
18
+ done
19
+
20
+ # Brief pause to let processes terminate
21
+ sleep 1
15
22
16
23
# Handle update case: redisinsight exists, Redis Insight exists too
17
24
# This means that we are in an update scenario
@@ -29,9 +36,13 @@ if [ -d "$NEW_INSTALL_PATH" ] && [ -d "$OLD_INSTALL_PATH" ]; then
29
36
30
37
# Ensure binary link and permissions
31
38
ln -sf " $NEW_INSTALL_PATH /redisinsight" " /usr/bin/redisinsight" || true
32
- chmod +x " $NEW_INSTALL_PATH /redisinsight" || true
33
- chown root:root " $NEW_INSTALL_PATH /chrome-sandbox" || true
34
- chmod 4755 " $NEW_INSTALL_PATH /chrome-sandbox" || true
39
+ if [ -f " $NEW_INSTALL_PATH /redisinsight" ]; then
40
+ chmod +x " $NEW_INSTALL_PATH /redisinsight" || true
41
+ fi
42
+ if [ -f " $NEW_INSTALL_PATH /chrome-sandbox" ]; then
43
+ chown root:root " $NEW_INSTALL_PATH /chrome-sandbox" || true
44
+ chmod 4755 " $NEW_INSTALL_PATH /chrome-sandbox" || true
45
+ fi
35
46
36
47
echo " Update handled successfully"
37
48
exit 0
@@ -43,9 +54,13 @@ if [ -d "$NEW_INSTALL_PATH" ] && [ ! -d "$OLD_INSTALL_PATH" ]; then
43
54
44
55
# Ensure binary link and permissions
45
56
ln -sf " $NEW_INSTALL_PATH /redisinsight" " /usr/bin/redisinsight" || true
46
- chmod +x " $NEW_INSTALL_PATH /redisinsight" || true
47
- chown root:root " $NEW_INSTALL_PATH /chrome-sandbox" || true
48
- chmod 4755 " $NEW_INSTALL_PATH /chrome-sandbox" || true
57
+ if [ -f " $NEW_INSTALL_PATH /redisinsight" ]; then
58
+ chmod +x " $NEW_INSTALL_PATH /redisinsight" || true
59
+ fi
60
+ if [ -f " $NEW_INSTALL_PATH /chrome-sandbox" ]; then
61
+ chown root:root " $NEW_INSTALL_PATH /chrome-sandbox" || true
62
+ chmod 4755 " $NEW_INSTALL_PATH /chrome-sandbox" || true
63
+ fi
49
64
50
65
echo " Installation/update completed successfully"
51
66
exit 0
@@ -66,9 +81,13 @@ if [ ! -d "$NEW_INSTALL_PATH" ] && [ -d "$OLD_INSTALL_PATH" ]; then
66
81
67
82
# Ensure binary link and permissions
68
83
ln -sf " $NEW_INSTALL_PATH /redisinsight" " /usr/bin/redisinsight" || true
69
- chmod +x " $NEW_INSTALL_PATH /redisinsight" || true
70
- chown root:root " $NEW_INSTALL_PATH /chrome-sandbox" || true
71
- chmod 4755 " $NEW_INSTALL_PATH /chrome-sandbox" || true
84
+ if [ -f " $NEW_INSTALL_PATH /redisinsight" ]; then
85
+ chmod +x " $NEW_INSTALL_PATH /redisinsight" || true
86
+ fi
87
+ if [ -f " $NEW_INSTALL_PATH /chrome-sandbox" ]; then
88
+ chown root:root " $NEW_INSTALL_PATH /chrome-sandbox" || true
89
+ chmod 4755 " $NEW_INSTALL_PATH /chrome-sandbox" || true
90
+ fi
72
91
73
92
echo " Migration completed successfully"
74
93
exit 0
0 commit comments