|
22 | 22 | sudo tee /usr/bin/redisinsight > /dev/null << 'EOF'
|
23 | 23 | #!/bin/bash
|
24 | 24 |
|
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 | +} |
31 | 35 |
|
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: $@" |
34 | 39 |
|
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 |
38 | 69 | EOF
|
39 | 70 |
|
40 | 71 | # Make the launcher script executable
|
41 | 72 | sudo chmod +x /usr/bin/redisinsight
|
42 | 73 |
|
43 |
| -# Set basic executable permissions (on the original location) |
| 74 | +# Rename the original to avoid name collision in PATH |
44 | 75 | 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" |
46 | 78 | fi
|
47 | 79 |
|
48 | 80 | # Set correct ownership and permissions for chrome-sandbox (on the original location)
|
|
0 commit comments