Last active
May 17, 2024 09:49
-
-
Save cderv/f2a42666949d6d816f9ba4cc0b0c0ed6 to your computer and use it in GitHub Desktop.
Update scripts - Ubuntu
This file contains hidden or 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 hidden or 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 hidden or 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 dpastoor/qvm --pattern 'qvm_Linux_x86_64.tar.gz' -O /tmp/qvm.tar.gz | |
sudo tar xzf /tmp/qvm.tar.gz qvm | |
sudo mv qvm ~/.local/bin/qvm | |
sudo chmod +x ~/.local/bin/qvm | |
rm /tmp/qvm.tar.gz | |
# Add to .bashrc or profile this command | |
# Run Quarto version from qvm install | |
# qv() { | |
# # check if function has 1 or more argument | |
# if [ "$#" -lt 1 ]; then | |
# echo "qv requires at least one argument" | |
# exit 1 | |
# fi | |
# # check if function has more than 1 argument and if so set a variable to change behavior later | |
# if [ "$#" -gt 1 ]; then | |
# local has_render_args=1 | |
# fi | |
# local version="$1" | |
# # Add v prefix if not present | |
# if [[ ! "$version" =~ ^v ]]; then | |
# version="v$version" | |
# fi | |
# local version_path="$(qvm path versions)/$version" | |
# if [ ! -d "$version_path" ]; then | |
# if [ "$has_render_args" = "1" ]; then | |
# qvm install "$version" | |
# | |
# else | |
# # Throw an error that this version is not installed | |
# echo "Version $version is not installed" | |
# return 1 | |
# fi | |
# fi | |
# if [ "$has_render_args" = "1" ]; then | |
# "$version_path/bin/quarto" ${@:2} | |
# else | |
# echo "$version_path/bin/quarto" | |
# fi | |
# } |
This file contains hidden or 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 hidden or 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) |
This file contains hidden or 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 TheWaWaR/simple-http-server --pattern 'x86_64-unknown-linux-musl-simple-http-server' -O ~/.local/bin/simple-http-server --clobber | |
chmod +x ~/.local/bin/simple-http-server |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment