Created
May 15, 2021 21:16
-
-
Save richardnfag/04d471ba1bbe526768699693f240ba4f to your computer and use it in GitHub Desktop.
Minishift
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
#!/usr/bin/env python3 | |
import tarfile | |
from re import match | |
from json import loads | |
from shutil import move | |
from requests import get | |
response = get( | |
"https://api.github.com/repos/MiniShift/minishift/releases/latest" | |
) | |
assets = loads(response.content)['assets'] | |
os = "linux" | |
arch = "amd64" | |
regular_exp = "minishift-.*-" + os +"-" + arch + ".tgz" | |
url = list(filter( | |
lambda x: match(regular_exp, x['name']), | |
assets | |
))[0]["browser_download_url"] | |
path = url.split('/')[-1] | |
print("Downloading ", path, "...") | |
minishift_file = get(url) | |
with open('/tmp/' + path,'wb') as f: | |
f.write(minishift_file.content) | |
dir_name = "" | |
print("Extracting...") | |
with tarfile.open('/tmp/' + path) as tar: | |
dir_name = tar.firstmember.name.split('/')[0] | |
tar.extractall('/tmp/') | |
print("Installing...") | |
move('/tmp/' + dir_name + '/minishift', '/usr/local/bin/') | |
print("Done!") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment