Advertisement
HasteBin0

ExpressVPN Update Manual Bash Helper with Automation support!

May 31st, 2024 (edited)
759
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 2.38 KB | Cybersecurity | 0 0
  1. #!/bin/bash
  2.  
  3. # Create directories
  4. mkdir -p ExpressVPN_tmp ExpressVPN_bak
  5.  
  6. # Move existing files to backup directory
  7. mv expressvpn* ExpressVPN_bak
  8. expressvpn status
  9.  
  10. echo "Main: https://www.expressvpn.com/latest#linux ;; Clients: https://www.expressvpn.works/clients/linux/"
  11.  
  12. if [[ "$1" -eq "" ]]; then
  13.     read -p "ExpressVPN Fedora link: " link
  14. else
  15.     link="$1"
  16.     printf "Given ExpressVPN(.Works: %s)\n" "$1"
  17. fi
  18.  
  19. cd ExpressVPN_tmp
  20.  
  21. # Check if the link is HTTPS
  22. if [[ "$link" =~ ^https:// ]]; then
  23.     echo "Detected HTTPS link. Proceeding."
  24. else
  25.     echo "Error: no HTTPS detected. Exiting."
  26.     exit 1
  27. fi
  28.  
  29. # Clear temporary files
  30. rm *
  31.  
  32. # Download the files
  33. echo
  34. wget "$link"
  35. error1=$?
  36. wget "$link.asc"
  37. error2=$?
  38. echo
  39.  
  40. # Check for download errors
  41. if [[ $error1 -ne 0 ]] || [[ $error2 -ne 0 ]]; then
  42.     echo "Exiting due to download errors."
  43.     exit 2
  44. fi
  45.  
  46. # Find RPM and ASC files
  47. file_rpm=$(ls *.rpm)
  48. file_asc=$(ls *.asc)
  49.  
  50. # Check file names
  51. if [[ "$file_rpm" = expressvpn*.rpm ]] && [[ "$file_asc" = "$file_rpm.asc" ]]; then
  52.     printf "Found \"%s\" and \"%s\". Proceeding.\n" "$file_rpm" "$file_asc"
  53. else
  54.     printf "Error: must have expressvpn*.rpm=\"%s\" and expressvpn*.rpm.asc=\"%s\". Exiting.\n" "$file_rpm" "$file_asc"
  55.     exit 3
  56. fi
  57.  
  58. # Calculate file hashes
  59. sha256_rpm=$(sha256sum "$file_rpm")
  60. sha256_asc=$(sha256sum "$file_asc")
  61. sha512_rpm=$(sha512sum "$file_rpm")
  62. sha512_asc=$(sha512sum "$file_asc")
  63.  
  64. printf "The SHA256 of \"%s\" and \"%s\".\nThe SHA512 of \"%s\" and \"%s\".\n" "$sha256_rpm" "$sha256_asc" "$sha512_rpm" "$sha512_asc"
  65.  
  66. echo "Reading \"$file_asc\":"
  67. cat "$file_asc"
  68.  
  69. # Verify the ASC file with GPG
  70. gpg --verify "$file_asc"
  71. if [[ $? -ne 0 ]]; then
  72.     echo "Signature error."
  73.     exit 4
  74. else
  75.     echo "GPG verification successful. Proceeding."
  76. fi
  77.  
  78. # Check root access
  79. if [[ "$(sudo whoami)" = "root" ]]; then
  80.     echo "Root access granted. Proceeding."
  81. else
  82.     echo "Root access denied. Exiting."
  83.     exit 5
  84. fi
  85.  
  86. cd ..
  87.  
  88. # Backup existing files
  89. mv expressvpn* ExpressVPN_bak
  90.  
  91. # Move new files to the current directory
  92. mv ExpressVPN_tmp/* .
  93.  
  94. # Install the RPM package
  95. sudo dnf install -y "$file_rpm"
  96.  
  97. # Upgrade packages and refresh
  98. sudo dnf upgrade -y --refresh
  99.  
  100. # Restart expressvpn service
  101. sudo systemctl restart expressvpn --now
  102.  
  103. # Wait and check on service
  104. sleep 5
  105. sudo systemctl status expressvpn
  106.  
  107. # Connect to expressvpn
  108. expressvpn connect smart
  109.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement