Skip to content

Commit c724728

Browse files
author
KIvanow
committed
RI-6690 testing different script approach
1 parent da2f541 commit c724728

File tree

1 file changed

+35
-16
lines changed

1 file changed

+35
-16
lines changed

scripts/deb-after-install.sh

Lines changed: 35 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,20 @@ OLD_INSTALL_PATH="/opt/Redis Insight"
55
NEW_INSTALL_PATH="/opt/redisinsight"
66
DESKTOP_FILE="/usr/share/applications/redisinsight.desktop"
77

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
1522

1623
# Handle update case: redisinsight exists, Redis Insight exists too
1724
# This means that we are in an update scenario
@@ -29,9 +36,13 @@ if [ -d "$NEW_INSTALL_PATH" ] && [ -d "$OLD_INSTALL_PATH" ]; then
2936

3037
# Ensure binary link and permissions
3138
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
3546

3647
echo "Update handled successfully"
3748
exit 0
@@ -43,9 +54,13 @@ if [ -d "$NEW_INSTALL_PATH" ] && [ ! -d "$OLD_INSTALL_PATH" ]; then
4354

4455
# Ensure binary link and permissions
4556
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
4964

5065
echo "Installation/update completed successfully"
5166
exit 0
@@ -66,9 +81,13 @@ if [ ! -d "$NEW_INSTALL_PATH" ] && [ -d "$OLD_INSTALL_PATH" ]; then
6681

6782
# Ensure binary link and permissions
6883
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
7291

7392
echo "Migration completed successfully"
7493
exit 0

0 commit comments

Comments
 (0)