-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall-timescaledb.sh
More file actions
28 lines (19 loc) · 927 Bytes
/
install-timescaledb.sh
File metadata and controls
28 lines (19 loc) · 927 Bytes
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
#!/bin/bash
source ./.env
declare -r PGV=$(apt-cache policy postgresql-$VERSION | grep -e Installed: | cut -d' ' -f4)
if [[ -z "$PGV" ]] || [[ $PGV == "(none)" ]]; then
echo "Error Postgres did not install"
exit
fi
# Create the repository configuration file:
apt -y install gpg
sh -c 'echo "deb https://packagecloud.io/timescale/timescaledb/ubuntu/ $(lsb_release -c -s) main" | sudo tee /etc/apt/sources.list.d/timescaledb.list'
wget --quiet -O - https://packagecloud.io/timescale/timescaledb/gpgkey | sudo gpg --dearmor -o /etc/apt/trusted.gpg.d/timescaledb.gpg
# Update the package lists:
apt update
# Install the latest version of PostgreSQL:
# If you want a specific version, use 'postgresql-16' or similar instead of 'postgresql'
apt -y install timescaledb-2-postgresql-$VERSION
timescaledb-tune -y
sudo systemctl restart postgresql
su - postgres -c "psql -c 'CREATE EXTENSION IF NOT EXISTS timescaledb'"