|
1 | 1 | #!/bin/bash |
2 | 2 |
|
| 3 | +# This script installs and starts a specific version of ClickHouse server. |
| 4 | +# Set CH_RELEASE to the desired release. Examples: |
| 5 | +# |
| 6 | +# CH_RELEASE=25.9.3.48-stable |
| 7 | +# CH_RELEASE=25.8.10.7-lts |
| 8 | + |
3 | 9 | set -e |
4 | 10 |
|
| 11 | +# Fetch latest version if not specified. |
5 | 12 | # https://clickhouse.com/docs/install |
6 | | -export DEBIAN_FRONTEND=noninteractive |
7 | | -apt-get update -qq |
8 | | -apt-get install -y apt-transport-https ca-certificates curl gnupg |
9 | | - |
10 | | -# Download the ClickHouse GPG key and store it in the keyring |
11 | | -curl -fsSL 'https://packages.clickhouse.com/rpm/lts/repodata/repomd.xml.key' \ |
12 | | - | gpg --dearmor -o /usr/share/keyrings/clickhouse-keyring.gpg |
| 13 | +if [ -z "$CH_RELEASE" ]; then |
| 14 | + tsv_url=https://raw.githubusercontent.com/ClickHouse/ClickHouse/master/utils/list-versions/version_date.tsv |
| 15 | + CH_RELEASE=$(curl -sL "$tsv_url" | grep -Eo '[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+-(stable|lts)' | sort -V -r | head -n 1) |
| 16 | + # List versions: curl -sL "$tsv_url" | grep -E 'stable|lts' |
| 17 | +fi |
13 | 18 |
|
14 | | -# Get the system architecture |
| 19 | +CH_VERSION="${CH_RELEASE%-*}" |
15 | 20 | ARCH=$(dpkg --print-architecture) |
| 21 | +base_url="https://github.com/ClickHouse/ClickHouse/releases/download/v${CH_RELEASE}" |
| 22 | + |
| 23 | +printf "==== ClickHouse %s for %s =====\n\n" "$CH_VERSION" "$ARCH" |
| 24 | +cd "${TMPDIR-/tmp}" |
| 25 | + |
| 26 | +# Prevent prompt for password. |
| 27 | +export DEBIAN_FRONTEND=noninteractive |
16 | 28 |
|
17 | | -# Add the ClickHouse repository to apt sources |
18 | | -echo "deb [signed-by=/usr/share/keyrings/clickhouse-keyring.gpg arch=${ARCH}] https://packages.clickhouse.com/deb stable main" \ |
19 | | - | tee /etc/apt/sources.list.d/clickhouse.list |
| 29 | +# Install the packages. |
| 30 | +for pkg in clickhouse-common-static clickhouse-server; do |
| 31 | + printf "---- Installing %s ----\n\n" "$pkg" |
| 32 | + curl -sLo "${pkg}.deb" "${base_url}/${pkg}_${CH_VERSION}_${ARCH}.deb" |
| 33 | + dpkg -i "${pkg}.deb" |
| 34 | + rm "${pkg}.deb" |
| 35 | +done |
20 | 36 |
|
21 | | -# Update apt package lists |
22 | | -apt-get update -qq |
23 | | -apt-get install -y clickhouse-server |
24 | | -service clickhouse-server start |
| 37 | +printf "---- Starting ClickHouse %s ----\n" "$CH_VERSION" |
| 38 | +clickhouse start |
0 commit comments