Last active
December 1, 2023 16:38
-
-
Save cderv/f2a42666949d6d816f9ba4cc0b0c0ed6 to your computer and use it in GitHub Desktop.
Update scripts - Ubuntu
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /bin/bash | |
# Using gh cli | |
# check tool requirement | |
if [[ -z $(command -v gh) ]] | |
then | |
echo "Github CLI tool (gh) needs to be installed. See https://cli.github.com/" | |
exit 1 | |
fi | |
if [[ -z $(command -v jq) ]] | |
then | |
echo "jq needs to be installed. See https://stedolan.github.io/jq/" | |
exit 2 | |
fi | |
# check gh config - it must be authenticated to use api. | |
# checking for error no token discarding the rest | |
is_token=$(gh auth token 1> /dev/null 2> >(grep -c 'no oauth token')) | |
if [[ $is_token -gt 0 ]] | |
then | |
echo ">> gh needs to be configured with auth using \`gh auth login\`. See https://cli.github.com/manual/gh_auth_login" | |
exit 3 | |
fi | |
nightlyFolderPrefix="pandoc-nightly-linux-" | |
nightlyBundleName="nightly-linux" | |
releaseBundlePattern="*amd64.deb" | |
releaseFileExt=".deb" | |
if [[ $1 == '--devel' || $1 == '--nightly' ]] | |
then | |
# nightly build | |
echo ">> Downloading latest nightly build of Pandoc..." | |
res=$(gh --repo jgm/pandoc run list -w Nightly --json conclusion,databaseId,createdAt --jq '. | map(select(.conclusion == "success"))[0] | {id: .databaseId, date: .createdAt | fromdate | strftime("%Y-%m-%d")}') | |
lastSuccessfullRunId=$(echo $res | jq -r '.id') | |
folder="$nightlyFolderPrefix$(echo $res | jq -r '.date')" | |
gh --repo jgm/pandoc run download $lastSuccessfullRunId -n $nightlyBundleName | |
[[ -d "pandoc-nightly" ]] && rm -rf pandoc-nightly/ | |
mv $folder pandoc-nightly | |
echo ">> Downloaded in \`pandoc-nightly/\`. Use it directly or add folder to PATH." | |
else | |
# latest release | |
echo ">> Downlading latest stable pandoc version" | |
gh --repo jgm/pandoc release download --pattern $releaseBundlePattern | |
sudo dpkg -i $(ls pandoc-*$releaseFileExt) | |
rm $(ls pandoc-*$releaseFileExt) | |
echo ">> New pandoc version installed" | |
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /bin/bash | |
# Using gh cli | |
prerelease=$1 | |
download_asset () | |
{ | |
local tag='' | |
if [ -n $prerelease ] && [ "$prerelease" = "--prerelease" ]; then | |
tag=$(gh api /repos/quarto-dev/quarto-cli/releases --jq 'map(select(.prerelease and (.draft | not))) | .[0] | .tag_name') | |
echo "Getting quarto latest prerelease ${tag}" | |
else | |
echo "Getting quarto latest release" | |
fi | |
gh --repo quarto-dev/quarto-cli release download $tag --pattern '*amd64.deb' | |
} | |
download_asset | |
sudo dpkg -i $(ls quarto-*.deb) | |
rm $(ls quarto-*.deb) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /bin/bash | |
gh release download -R r-lib/rig --pattern 'rig-linux-[0-9]*.tar.gz' | |
sudo tar xzf $(ls rig-linux-*) -C ~/.local | |
rm $(ls rig-linux-*) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /bin/bash | |
## For Ubuntu 22.04 | |
# Using new API https://dailies.rstudio.com/json-api/ | |
url=$(curl -s https://dailies.rstudio.com/rstudio/latest/index.json | jq -r '.products.server.platforms["jammy-amd64"].link') | |
wget $url | |
sudo gdebi $(basename $url) | |
rm $(basename $url) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment