Advertisement
HasteBin0

Update ExpressVPN Automatically!

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