Skip to content

Commit 0083659

Browse files
author
KIvanow
committed
RI-6690
1 parent dc0d59c commit 0083659

File tree

1 file changed

+45
-13
lines changed

1 file changed

+45
-13
lines changed

scripts/deb-after-install.sh

Lines changed: 45 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -22,27 +22,59 @@ fi
2222
sudo tee /usr/bin/redisinsight > /dev/null << 'EOF'
2323
#!/bin/bash
2424
25-
# Prevent recursion using an environment variable
26-
if [ "$REDISINSIGHT_RUNNING" = "1" ]; then
27-
echo "Error: Recursive call detected. Exiting."
28-
exit 1
29-
fi
30-
export REDISINSIGHT_RUNNING=1
25+
# Log file for debugging
26+
LOG_FILE="/tmp/redisinsight-launcher.log"
27+
28+
# Find the real binary
29+
INSTALL_DIR="/opt/Redis Insight"
30+
31+
# Function to write to log
32+
log() {
33+
echo "$(date): $1" >> "$LOG_FILE"
34+
}
3135
32-
# Change to the application directory (important for many apps)
33-
cd "/opt/Redis Insight" || exit 1
36+
# Start with a clean log
37+
echo "$(date): Launcher started" > "$LOG_FILE"
38+
log "Args: $@"
3439
35-
echo "Launching RedisInsight with args: $@"
36-
# Call the original with a relative path to avoid PATH lookup recursion
37-
./redisinsight "$@"
40+
# Check if the original redisinsight is a script or binary
41+
file_type=$(file -b "$INSTALL_DIR/redisinsight" 2>/dev/null)
42+
log "File type: $file_type"
43+
44+
# Detect Electron apps
45+
if [ -f "$INSTALL_DIR/resources/electron" ]; then
46+
ELECTRON_PATH="$INSTALL_DIR/resources/electron"
47+
log "Found Electron at: $ELECTRON_PATH"
48+
49+
if [ -d "$INSTALL_DIR/resources/app" ]; then
50+
APP_PATH="$INSTALL_DIR/resources/app"
51+
log "Found app directory at: $APP_PATH"
52+
cd "$INSTALL_DIR" && exec "$ELECTRON_PATH" "$APP_PATH" "$@"
53+
exit $?
54+
else
55+
log "No app directory found, executing electron directly"
56+
cd "$INSTALL_DIR" && exec "$ELECTRON_PATH" "$@"
57+
exit $?
58+
fi
59+
elif [ -f "$INSTALL_DIR/redisinsight" ]; then
60+
# Execute the original but avoid PATH search
61+
log "Executing original binary with absolute path"
62+
cd "$INSTALL_DIR" && exec ./redisinsight.real "$@"
63+
exit $?
64+
else
65+
log "ERROR: Could not find executable"
66+
echo "Error: Could not find RedisInsight executable" >&2
67+
exit 1
68+
fi
3869
EOF
3970

4071
# Make the launcher script executable
4172
sudo chmod +x /usr/bin/redisinsight
4273

43-
# Set basic executable permissions (on the original location)
74+
# Rename the original to avoid name collision in PATH
4475
if [ -f "$OLD_INSTALL_PATH/redisinsight" ]; then
45-
sudo chmod +x "$OLD_INSTALL_PATH/redisinsight"
76+
sudo mv "$OLD_INSTALL_PATH/redisinsight" "$OLD_INSTALL_PATH/redisinsight.real"
77+
sudo chmod +x "$OLD_INSTALL_PATH/redisinsight.real"
4678
fi
4779

4880
# Set correct ownership and permissions for chrome-sandbox (on the original location)

0 commit comments

Comments
 (0)