-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy pathsetup_apt
executable file
·38 lines (28 loc) · 1.58 KB
/
setup_apt
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
#!/bin/bash
# Inspired by https://gist.github.com/petere/6023944
set -eux
# Read properties files for common properties for tools
SCRIPTPATH="$( cd -- "$(dirname "$0")" >/dev/null 2>&1 ; pwd -P )"
TOOLS_DIR=${1:-"${SCRIPTPATH}"}
source "${TOOLS_DIR}"/toolsvars
# import the PostgreSQL repository key
wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add -
# wtf, Google?
sudo rm -f /etc/apt/sources.list.d/google-chrome*
sudo rm -f /etc/apt/sources.list.d/pgdg.list
# add the PostgreSQL repository
sudo sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt/ $(lsb_release -cs)-pgdg main" >> /etc/apt/sources.list.d/postgresql.list'
# Since pg14 is the latest stable postgres version, we need to install beta version repo.
# After pg 15 become stable change this parameter into 15.
if [ "${PGVERSION%%.*}" -gt "${LATEST_STABLE_PG_VERSION}" ]; then
# add a PostgreSQL testing repository
echo "Adding test repository"
# Used tee because of this check: https://github.com/koalaman/shellcheck/wiki/SC2024
echo "deb http://apt.postgresql.org/pub/repos/apt/ $(lsb_release -cs)-pgdg-testing main ${PGVERSION}" | sudo tee -a /etc/apt/sources.list.d/postgresql.list > /dev/null
echo "Package: *\nPin: release n=$(lsb_release -cs)-pgdg-testing\nPin-Priority: 600" | sudo tee -a /etc/apt/preferences.d/postgresql.pref > /dev/null
fi
# update package index files from sources
sudo apt-get update -qq
# remove traces of PostgreSQL versions
# see: postgresql.org/message-id/[email protected]
sudo update-alternatives --remove-all postmaster.1.gz