Repository navigation
Expand file tree
/
Copy pathinstall-ubuntu.sh
More file actions
executable file
·52 lines (42 loc) · 1.66 KB
/
Copy pathinstall-ubuntu.sh
File metadata and controls
executable file
·52 lines (42 loc) · 1.66 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#!/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
# Download Heroku's release key
curl -fsS https://cli-assets.heroku.com/channels/stable/apt/release.key -o /tmp/heroku-archive-keyring.asc
# Use apt-key if available, otherwise use keyring method
if command -v apt-key 1>/dev/null 2>&1; then
echo "deb https://cli-assets.heroku.com/channels/stable/apt ./" > /etc/apt/sources.list.d/heroku.list
cat /tmp/heroku-archive-keyring.asc | apt-key add -
else
dpkg -s gpg 1>/dev/null 2>/dev/null || apt-get install -y gpg
mkdir -p /etc/apt/keyrings
# We use the --dearmor flag to convert the ASCII key to GPG format.
# This is necessary because we need to point `signed-by` (in the apt sources
# list) to a GPG formatted key.
gpg --dearmor < /tmp/heroku-archive-keyring.asc > /etc/apt/keyrings/heroku-archive-keyring.gpg
echo "deb [signed-by=/etc/apt/keyrings/heroku-archive-keyring.gpg] https://cli-assets.heroku.com/channels/stable/apt ./" > /etc/apt/sources.list.d/heroku.list
fi
rm -f /tmp/heroku-archive-keyring.asc
# remove toolbelt
(dpkg -s heroku-toolbelt 1>/dev/null 2>/dev/null && (apt-get remove -y heroku-toolbelt heroku || true)) || true
# 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
}