Created
August 25, 2019 08:10
-
-
Save bryanjhv/6099cd57dd601a8aaa670100b4e0d82f to your computer and use it in GitHub Desktop.
Bash script for downloading VSCode extensions faster
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
#!/usr/bin/env bash | |
if [[ $# -lt 2 ]]; then | |
echo "ERR: Missing arguments." | |
# requires an SSH server | |
# arg1: {package}.{extension}@{version} | |
# arg2 {host} | |
exit 1 | |
fi | |
host=$2 | |
tmp=${1#*.} | |
version=${1#*@} | |
publisher=${1%%.*} | |
extension=${tmp%@*} | |
file=$publisher.$extension-$version.vsix | |
url=http://$publisher.gallery.vsassets.io/_apis/public/gallery/publisher/$publisher/extension/$extension/$version/assetbyname/Microsoft.VisualStudio.Services.VSIXPackage | |
echo "INF: Connecting to host..." | |
rdir=`ssh $host "mktemp -d"` | |
ssh $host ' | |
cd '$rdir' | |
echo "INF: Fetching extension..." | |
wget -q '$url' | |
size=`du -h Microsoft.VisualStudio.Services.VSIXPackage | cut -f1` | |
echo "INF: Original size is ${size}" | |
echo "INF: Unpacking extension..." | |
unzip -q Microsoft.VisualStudio.Services.VSIXPackage | |
rm Microsoft.VisualStudio.Services.VSIXPackage | |
echo "INF: Compressing extension..." | |
XZ_OPTS=-9 tar cfJ etx * | |
size=`du -h etx | cut -f1` | |
echo "INF: Compressed size is ${size}" | |
' | |
back=$PWD | |
ldir=`mktemp -d` | |
cd $ldir | |
echo "INF: Downloading extension..." | |
scp -q $host:$rdir/etx etx | |
echo "INF: Unpacking extension..." | |
tar xfJ etx | |
rm etx | |
echo "INF: Compressing extension..." | |
zip -rq $file * | |
cp $file $back | |
echo "INF: Ready at $back/$file" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment