mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-12-15 19:02:04 +00:00
2d7cb03120
Since for dowloading some of files wget logging may take 50% of overall log [1]. [1]: https://clickhouse-builds.s3.yandex.net/14315/c32ff4c98cb3b83a12f945eadd180415b7a3b269/clickhouse_build_check/build_log_761119955_1598923036.txt
58 lines
1.9 KiB
Bash
Executable File
58 lines
1.9 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
if [ $# -lt 1 ]
|
|
then
|
|
cat << HELP
|
|
|
|
clickhouse-docker -- open clickhouse-client of desired version in docker container (automatically removed after you exit bash shell).
|
|
|
|
EXAMPLE:
|
|
- start latest version:
|
|
clickhouse-docker latest
|
|
|
|
- start version 20.1:
|
|
clickhouse-docker 20.1
|
|
|
|
- list available versions:
|
|
clickhouse-docker list
|
|
HELP
|
|
exit
|
|
fi
|
|
|
|
param="$1"
|
|
|
|
if [ "${param}" = "list" ]
|
|
then
|
|
# https://stackoverflow.com/a/39454426/1555175
|
|
wget -nv https://registry.hub.docker.com/v1/repositories/yandex/clickhouse-server/tags -O - | sed -e 's/[][]//g' -e 's/"//g' -e 's/ //g' | tr '}' '\n' | awk -F: '{print $3}'
|
|
else
|
|
docker pull yandex/clickhouse-server:${param}
|
|
tmp_dir=$(mktemp -d -t ci-XXXXXXXXXX) # older version require /nonexistent folder to exist to run clickhouse client :D
|
|
chmod 777 ${tmp_dir}
|
|
set -e
|
|
containerid=`docker run -v${tmp_dir}:/nonexistent -d yandex/clickhouse-server:${param}`
|
|
set +e
|
|
while :
|
|
do
|
|
# that trick with init-file allows to start clickhouse client inside bash shell (nice if you need exit to bash, check smth, and get back to clickhouse-client)
|
|
docker exec -it ${containerid} bash -c 'bash --init-file <(echo "clickhouse client -m")'
|
|
|
|
printf "\n\nYou exited the session. What next?\n"
|
|
echo " [Q]uit and remove container."
|
|
echo " [R]estart clickhouse and run clickhouse-client in shell again."
|
|
echo "You can also hit Ctrl+C to exit and keep container running."
|
|
|
|
while :
|
|
do
|
|
read -p "Quit or restart [Q/R]?" choice
|
|
case "$choice" in
|
|
q|Q|exit ) break 2;;
|
|
r|R|restart ) echo "Restarting container ..."; docker restart ${containerid} > /dev/null; break 1;;
|
|
* ) echo "I don't understand. Please type Q or R" ;;
|
|
esac
|
|
done
|
|
done
|
|
docker rm -f ${containerid} > /dev/null
|
|
rm -rf ${tmp_dir}
|
|
fi
|