Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #! /bin/env bash
- # Install latest Rstudio Desktop for (Debian)
- # Licence WTFPL
- IF=`
- `
- # # needs packages
- # # util-linux(rev) libxml2-utils(xmllint) gpg coreutils(sha256sum)
- # apt-get install -y util-linux libxml2-utils gpg coreutils curl
- # # for firest time , get gpg key
- gpg --keyserver keyserver.ubuntu.com --recv-keys 3F32EE77E331692F
- # OS type,file type
- # Windows 10/11,.exe/.zip
- # macOS 10.15+,.dmg
- # Ubuntu 18+/Debian 10+,.deb/.tar.gz
- # Fedora 19/Red Hat 7,.rpm/.tar.gz
- # Fedora 34/Red Hat 8,.rpm
- # Debian 9,.deb/.tar.gz
- # OpenSUSE 15,.rpm
- # note Xpath
- # URL
- # //table/tbody/tr[i]/td[2]/a/@href
- # //table/tbody/tr[contains(td[1]/text(), "OS type")]/td[2]/a[contains(@href, "file type")]/@href
- # Hash
- # //table/tbody/tr[i]/td[4]/a/@data-content
- # //table/tbody/tr[contains(td[1]/text(), "OS type"")]/td[2]/a[contains(@href, "file type")]/../../td[4]/a/@data-content
- OS='Debian 10'
- FILETYPE='.deb'
- URL='https://www.rstudio.com/products/rstudio/download/'
- HTML=$(curl $URL)
- 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')
- FIELNAME=$(rev <(echo "$DOWNLOAD_URL") | cut -f1 -d"/" | rev)
- 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')
- curl -OL "$DOWNLOAD_URL"
- hash_check=$(echo "$HASH" "$FILE" | sha256sum --status -c ;echo $?)
- # hash_check=$(printf "%s %s" "$HASH" "$FILE" | sha256sum --status -c ;printf "%s" "$?")
- if [ "$hash_check" -eq 0 ]; then
- #For Debian/Ubuntu
- gdebi "$FIELNAME"
- #For Red Hat/CentOS/SuSE
- # rpm -K $FIELNAME
- else
- echo Hash check was failed"$IF"Plase download again"$IF"Hash exit status "$hash_check"
- # printf "Hash check was failed%sPlase download again%sHash exit status %s" "$IF" "$IF" "$hash_check"
- fi
- # altanative check way for Debian/Ubuntu
- # dpkg-sig --verify $FIELNAME
- # for Red Hat/CentOS/SuSE
- # gpg --export --armor 3F32EE77E331692F > rstudio-signing.key
- # rpm --import rstudio-signing.key
- # rpm -K $FIELNAME
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement