Created
February 4, 2020 18:30
-
-
Save kholisrag/ffe87d123ab8c87b5a0be805f09af2de to your computer and use it in GitHub Desktop.
Install Digital Ocean doctl latest version automatically (bash script / shell script)
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 | |
function install_doctl() { | |
echo "Install doctl" | |
curl -L $(curl -s https://api.github.com/repos/digitalocean/doctl/releases/latest \ | |
| grep browser_download_url \ | |
| grep linux-amd64 \ | |
| cut -d '"' -f 4) \ | |
| tar xvz | |
mv ./doctl /usr/local/bin | |
} | |
function main () { | |
if [[ $EUID -ne 0 ]]; then | |
sudo $(realpath "$0") | |
exit | |
fi | |
install_doctl | |
echo "All Done..." | |
} | |
main "$@" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
this script will prompt super user password if you running it for non-root user