redis.sh 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. #!/bin/bash
  2. # Define paths
  3. bin_dir=~/.bin
  4. bin_file="${bin_dir}/redis"
  5. # Create directory if it doesn't exist
  6. mkdir -p "${bin_dir}"
  7. # Set current working directory
  8. cd "${bin_dir}"
  9. if [ ! -f "${bin_file}" ]; then
  10. notify-send -u normal "⏬ Redis Desktop Manager" "Downloading..."
  11. # Get latest release info and parse with proper JSON handling
  12. release_info=$(curl -s https://api.github.com/repos/qishibo/AnotherRedisDesktopManager/releases/latest)
  13. # Determine system architecture
  14. arch=$(uname -m)
  15. if [ "${arch}" = "x86_64" ]; then
  16. arch_pattern="x86_64"
  17. elif [ "${arch}" = "aarch64" ]; then
  18. arch_pattern="arm64"
  19. else
  20. echo "Unsupported architecture: ${arch}"
  21. exit 1
  22. fi
  23. # Find appropriate AppImage for this architecture
  24. filename=$(echo "${release_info}" | jq -r ".assets[].name" | grep "AppImage" | grep "${arch_pattern}")
  25. echo "Selected filename: ${filename}"
  26. # Get download URL
  27. fileurl=$(echo "${release_info}" | jq -r --arg filename "${filename}" '.assets[] | select(.name == $filename) | .browser_download_url')
  28. echo "Download URL: ${fileurl}"
  29. # Download and make executable
  30. if [ -n "${fileurl}" ] && [ "${fileurl}" != "null" ]; then
  31. wget -q --show-progress -O "${bin_file}" "${fileurl}"
  32. chmod +x "${bin_file}"
  33. echo "Successfully downloaded Redis Desktop Manager"
  34. else
  35. echo "Failed to find download URL for architecture: ${arch}"
  36. exit 1
  37. fi
  38. fi
  39. # Execute with parameters if provided
  40. "${bin_file}" -f ${1:+"-i"} ${1:+"$1"} ${2:+"-o"} ${2:+"$2"}