Skip to content

Instantly share code, notes, and snippets.

@ysaito8015
Created January 14, 2024 13:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ysaito8015/f3d928d82462e440588fbe52d1bab110 to your computer and use it in GitHub Desktop.
Save ysaito8015/f3d928d82462e440588fbe52d1bab110 to your computer and use it in GitHub Desktop.
#!/bin/sh
{
set -e
SUDO=''
if [ "$(id -u)" != "0" ]; then
SUDO='sudo'
echo "This script requires superuser access to install apt packages."
echo "You will be prompted for your password by sudo."
# clear any previous sudo permission
sudo -k
fi
# run inside sudo
$SUDO sh <<SCRIPT
set -ex
# if apt-transport-https is not installed, clear out old sources, update, then install apt-transport-https
dpkg -s apt-transport-https 1>/dev/null 2>/dev/null || \
(echo "" > /etc/apt/sources.list.d/heroku.list \
&& apt-get update \
&& apt-get install -y apt-transport-https)
# add heroku repository to apt
echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/heroku-cli-key.asc] https://cli-assets.heroku.com/channels/stable/apt ./" > /etc/apt/sources.list.d/heroku.list
# remove toolbelt
(dpkg -s heroku-toolbelt 1>/dev/null 2>/dev/null && (apt-get remove -y heroku-toolbelt heroku || true)) || true
# install heroku's release key for package verification
curl -fsSL https://cli-assets.heroku.com/channels/stable/apt/release.key -o /etc/apt/keyrings/heroku-cli-key.asc
# update your sources
apt-get update
# install the toolbelt
apt-get install -y heroku
SCRIPT
# test the CLI
LOCATION=$(which heroku)
echo "heroku installed to $LOCATION"
heroku version
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment