Advertisement
Guest User

Install latest Rstudio Desktop for Debian)

a guest
May 16th, 2022
27
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 2.24 KB | None | 0 0
  1. #! /bin/env bash
  2. # Install latest Rstudio Desktop for (Debian)
  3. # Licence WTFPL
  4.  
  5. IF=`
  6. `
  7.  
  8. # # needs packages
  9. # # util-linux(rev) libxml2-utils(xmllint) gpg coreutils(sha256sum)
  10. # apt-get install -y util-linux libxml2-utils gpg coreutils curl
  11.  
  12. # # for firest time , get gpg key
  13. gpg --keyserver keyserver.ubuntu.com --recv-keys 3F32EE77E331692F
  14.  
  15.  
  16. # OS type,file type
  17. # Windows 10/11,.exe/.zip
  18. # macOS 10.15+,.dmg
  19. # Ubuntu 18+/Debian 10+,.deb/.tar.gz
  20. # Fedora 19/Red Hat 7,.rpm/.tar.gz
  21. # Fedora 34/Red Hat 8,.rpm
  22. # Debian 9,.deb/.tar.gz
  23. # OpenSUSE 15,.rpm
  24.  
  25. # note Xpath
  26. # URL
  27. # //table/tbody/tr[i]/td[2]/a/@href
  28. # //table/tbody/tr[contains(td[1]/text(), "OS type")]/td[2]/a[contains(@href, "file type")]/@href
  29. # Hash
  30. # //table/tbody/tr[i]/td[4]/a/@data-content
  31. # //table/tbody/tr[contains(td[1]/text(), "OS type"")]/td[2]/a[contains(@href, "file type")]/../../td[4]/a/@data-content
  32.  
  33.  
  34. OS='Debian 10'
  35. FILETYPE='.deb'
  36.  
  37. URL='https://www.rstudio.com/products/rstudio/download/'
  38. HTML=$(curl $URL)
  39. DOWNLOAD_URL=$(echo "$HTML" | xmllint --nowarning --xpath '//tbody/tr[contains(td[1]/text(), "'"$OS"'")]/td[2]/a/@href' --html - | sed 's/href="//g;s/"//g;s/\s/\n/g;s/^.?$//g;s/^\n//g')
  40. FIELNAME=$(rev <(echo "$DOWNLOAD_URL") | cut -f1 -d"/" | rev)
  41. HASH=$(echo "$HTML" | xmllint --nowarning --xpath '//table/tbody/tr[contains(td[1]/text(), "'"$OS"'")]/td[2]/a[contains(@href, "'"$FILETYPE"'")]/../../td[4]/a/@data-content' --html - | sed 's/data-content="//g;s/"//g;s/\s/\n/g;s/^.?$//g;s/^\n//g')
  42.  
  43. curl -OL "$DOWNLOAD_URL"
  44. hash_check=$(echo "$HASH"  "$FILE" | sha256sum --status -c ;echo $?)
  45. # hash_check=$(printf "%s  %s" "$HASH" "$FILE" | sha256sum --status -c ;printf "%s" "$?")
  46.  
  47.  
  48. if [ "$hash_check" -eq 0 ]; then
  49.     #For Debian/Ubuntu
  50.     gdebi "$FIELNAME"
  51.     #For Red Hat/CentOS/SuSE
  52.     # rpm -K $FIELNAME
  53. else
  54.     echo Hash check was failed"$IF"Plase download again"$IF"Hash exit status "$hash_check"
  55.     # printf "Hash check was failed%sPlase download again%sHash exit status %s" "$IF" "$IF" "$hash_check"
  56. fi
  57.  
  58. # altanative check way for Debian/Ubuntu
  59. # dpkg-sig --verify $FIELNAME
  60.  
  61. # for Red Hat/CentOS/SuSE
  62. # gpg --export --armor 3F32EE77E331692F > rstudio-signing.key
  63. # rpm --import rstudio-signing.key
  64. # rpm -K $FIELNAME
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement