ligo/vendors/tezos-modded/scripts/alphanet.sh

830 lines
22 KiB
Bash
Raw Normal View History

#! /usr/bin/env bash
2017-03-09 17:43:59 +04:00
set -e
2018-01-29 21:26:27 +04:00
if ! which docker > /dev/null 2>&1 ; then
2017-03-09 17:43:59 +04:00
echo "Docker does not seem to be installed."
exit 1
fi
2018-01-29 21:26:27 +04:00
if ! which docker-compose > /dev/null 2>&1 ; then
echo "Docker-compose does not seem to be installed."
exit 1
fi
2017-03-09 17:43:59 +04:00
docker_version="$(docker version -f "{{ .Server.Version }}")"
docker_major="$(echo "$docker_version" | cut -d . -f 1)"
docker_minor="$(echo "$docker_version" | cut -d . -f 2)"
if ([ "$docker_major" -gt 1 ] ||
( [ "$docker_major" -eq 1 ] && [ "$docker_minor" -ge 13 ] )) ; then
docker_1_13=true
else
docker_1_13=false
fi
current_dir="$(pwd -P)"
src_dir="$(cd "$(dirname "$0")" && echo "$current_dir/")"
2017-03-09 17:43:59 +04:00
cd "$src_dir"
2018-01-29 21:26:27 +04:00
update_compose_file() {
2017-03-09 17:43:59 +04:00
2018-07-18 22:27:06 +04:00
update_active_protocol_version
2018-01-29 21:26:27 +04:00
if [ "$#" -ge 2 ] && [ "$1" = "--rpc-port" ] ; then
export_rpc="
- \"$2:8732\""
2018-01-29 21:26:27 +04:00
shift 2
2017-03-09 17:43:59 +04:00
fi
2018-01-29 21:26:27 +04:00
cat > "$docker_compose_yml" <<EOF
2018-03-21 18:19:28 +04:00
version: "2"
2018-07-18 22:27:06 +04:00
volumes:
node_data:
client_data:
2018-01-29 21:26:27 +04:00
services:
node:
image: $docker_image
hostname: node
command: tezos-node --net-addr :$port $@
2018-01-29 21:26:27 +04:00
ports:
- "$port:$port"$export_rpc
expose:
- "8732"
volumes:
- node_data:/var/run/tezos/node
- client_data:/var/run/tezos/client
restart: on-failure
2018-07-18 22:27:06 +04:00
EOF
for proto in $(cat "$active_protocol_versions") ; do
cat >> "$docker_compose_yml" <<EOF
baker-$proto:
2018-01-29 21:26:27 +04:00
image: $docker_image
2018-07-18 22:27:06 +04:00
hostname: baker-$proto
environment:
- PROTOCOL=$proto
2018-01-29 21:26:27 +04:00
command: tezos-baker --max-priority 128
links:
- node
volumes:
- node_data:/var/run/tezos/node:ro
2018-01-29 21:26:27 +04:00
- client_data:/var/run/tezos/client
restart: on-failure
2018-07-18 22:27:06 +04:00
endorser-$proto:
2018-01-29 21:26:27 +04:00
image: $docker_image
2018-07-18 22:27:06 +04:00
hostname: endorser-$proto
environment:
- PROTOCOL=$proto
2018-01-29 21:26:27 +04:00
command: tezos-endorser
links:
- node
volumes:
- client_data:/var/run/tezos/client
restart: on-failure
2018-07-18 22:27:06 +04:00
accuser-$proto:
image: $docker_image
hostname: accuser-$proto
environment:
- PROTOCOL=$proto
command: tezos-accuser
links:
- node
volumes:
- client_data:/var/run/tezos/client
restart: on-failure
2018-01-29 21:26:27 +04:00
EOF
2018-07-18 22:27:06 +04:00
done
2018-01-29 21:26:27 +04:00
}
call_docker_compose() {
docker-compose -f "$docker_compose_yml" -p "$docker_compose_name" "$@"
}
exec_docker() {
if [ -t 0 ] && [ -t 1 ] && [ -t 2 ] && [ -z "$ALPHANET_EMACS" ]; then
local interactive_flags="-it"
else
local interactive_flags="-t"
2017-03-09 17:43:59 +04:00
fi
2018-11-20 16:28:54 +04:00
local node_container="$(container_name "$docker_node_container")"
declare -a container_args=();
tmpdir="/tmp"
for arg in "$@"; do
if [[ "$arg" == 'container:'* ]]; then
local_path="${arg#container:}"
if [[ "$local_path" != '/'* ]]; then
local_path="$current_dir/$local_path"
fi
file_name=$(basename "${local_path}")
docker_path="$tmpdir/$file_name"
2018-11-20 16:28:54 +04:00
docker cp "${local_path}" "$node_container:${docker_path}"
docker exec "$interactive_flags" "$node_container" sudo chown tezos "${docker_path}"
container_args+=("file:$docker_path");
else
container_args+=("${arg}");
fi
done
2018-11-20 16:28:54 +04:00
docker exec "$interactive_flags" -e 'TEZOS_CLIENT_UNSAFE_DISABLE_DISCLAIMER' "$node_container" "${container_args[@]}"
2017-03-09 17:43:59 +04:00
}
## Container ###############################################################
2018-07-18 22:27:06 +04:00
update_active_protocol_version() {
docker run --entrypoint /bin/cat "$docker_image" \
/usr/local/share/tezos/active_protocol_versions > "$active_protocol_versions"
}
may_update_active_protocol_version() {
if [ ! -f "$active_protocol_versions" ] ; then
update_active_protocol_version
fi
}
2017-03-09 17:43:59 +04:00
pull_image() {
2018-01-29 21:26:27 +04:00
if [ "$TEZOS_ALPHANET_DO_NOT_PULL" = "yes" ] \
|| [ "$ALPHANET_EMACS" ] \
|| [ "$docker_image" = "$(echo $docker_image | tr -d '/')" ] ; then
2017-03-09 17:43:59 +04:00
return ;
fi
docker pull "$docker_image"
2018-07-18 22:27:06 +04:00
update_active_protocol_version
2018-01-29 21:26:27 +04:00
date "+%s" > "$docker_pull_timestamp"
2017-03-09 17:43:59 +04:00
}
2018-01-29 21:26:27 +04:00
may_pull_image() {
if [ ! -f "$docker_pull_timestamp" ] \
|| [ 3600 -le $(($(date "+%s") - $(cat $docker_pull_timestamp))) ]; then
pull_image
2017-03-09 17:43:59 +04:00
fi
}
uptodate_container() {
running_image=$(docker inspect \
--format="{{ .Image }}" \
--type=container "$(container_name "$1")")
2017-03-09 17:43:59 +04:00
latest_image=$(docker inspect \
--format="{{ .Id }}" \
--type=image "$docker_image")
[ "$latest_image" = "$running_image" ]
}
2018-07-18 22:27:06 +04:00
uptodate_containers() {
container=$1
if [ ! -z "$container" ]; then
shift 1
uptodate_container $container && uptodate_containers $@
fi
}
2017-03-09 17:43:59 +04:00
assert_container() {
2018-01-29 21:26:27 +04:00
call_docker_compose up --no-start
2017-03-09 17:43:59 +04:00
}
container_name() {
local name="$(docker ps --filter "name=$1" --format "{{.Names}}")"
if [ -n "$name" ]; then echo "$name"; else echo "$1"; fi
}
2018-01-29 21:26:27 +04:00
## Node ####################################################################
check_node_volume() {
docker volume inspect "$docker_node_volume" > /dev/null 2>&1
2017-03-09 17:43:59 +04:00
}
2018-01-29 21:26:27 +04:00
clear_node_volume() {
if check_node; then
echo -e "\033[31mCannot clear data while the node is running.\033[0m"
2017-03-09 17:43:59 +04:00
exit 1
fi
2018-01-29 21:26:27 +04:00
if check_node_volume ; then
docker volume rm "$docker_node_volume" > /dev/null
echo -e "\033[32mThe chain data has been removed from the disk.\033[0m"
else
echo -e "\033[32mNo remaining data to be removed from the disk.\033[0m"
fi
2017-03-09 17:43:59 +04:00
}
check_node() {
2018-01-29 21:26:27 +04:00
res=$(docker inspect \
--format="{{ .State.Running }}" \
--type=container "$(container_name "$docker_node_container")" 2>/dev/null || echo false)
[ "$res" = "true" ]
2017-03-09 17:43:59 +04:00
}
assert_node() {
if ! check_node; then
echo -e "\033[31mNode is not running!\033[0m"
2017-03-09 17:43:59 +04:00
exit 0
fi
}
2018-01-29 21:26:27 +04:00
warn_node_uptodate() {
if ! uptodate_container "$docker_node_container"; then
echo -e "\033[33mThe current node is not the latest available.\033[0m"
fi
}
assert_node_uptodate() {
may_pull_image
assert_node
if ! uptodate_container "$docker_node_container"; then
echo -e "\033[33mThe current node is not the latest available.\033[0m"
exit 1
fi
}
2017-03-09 17:43:59 +04:00
status_node() {
2018-01-29 21:26:27 +04:00
may_pull_image
2017-03-09 17:43:59 +04:00
if check_node; then
echo -e "\033[32mNode is running\033[0m"
2018-01-29 21:26:27 +04:00
warn_node_uptodate
2017-03-09 17:43:59 +04:00
else
echo -e "\033[33mNode is not running\033[0m"
2017-03-09 17:43:59 +04:00
fi
}
start_node() {
2018-01-29 21:26:27 +04:00
pull_image
2017-03-09 17:43:59 +04:00
if check_node; then
2018-01-29 21:26:27 +04:00
echo -e "\033[31mNode is already running\033[0m"
2017-03-09 17:43:59 +04:00
exit 1
fi
2018-01-29 21:26:27 +04:00
update_compose_file "$@"
call_docker_compose up --no-start
call_docker_compose start node
echo -e "\033[32mThe node is now running.\033[0m"
2017-03-09 17:43:59 +04:00
}
log_node() {
2018-01-29 21:26:27 +04:00
may_pull_image
assert_node_uptodate
call_docker_compose logs -f node
2017-03-09 17:43:59 +04:00
}
stop_node() {
2018-01-29 21:26:27 +04:00
if ! check_node; then
echo -e "\033[31mNo node to kill!\033[0m"
exit 1
fi
echo -e "\033[32mStopping the node...\033[0m"
call_docker_compose stop node
2017-03-09 17:43:59 +04:00
}
## Baker ###################################################################
check_baker() {
2018-07-18 22:27:06 +04:00
update_active_protocol_version
bakers="$(sed s/^/baker-/g "$active_protocol_versions")"
docker_baker_containers="$(sed "s/^\(.*\)$/${docker_compose_name}_baker-\1_1/g" "$active_protocol_versions")"
2018-01-29 21:26:27 +04:00
res=$(docker inspect \
--format="{{ .State.Running }}" \
--type=container "$(container_name "$docker_baker_containers")" 2>/dev/null || echo false)
[ "$res" = "true" ]
2017-03-09 17:43:59 +04:00
}
assert_baker() {
if ! check_baker; then
echo -e "\033[31mBaker is not running!\033[0m"
2017-03-09 17:43:59 +04:00
exit 0
fi
}
2018-01-29 21:26:27 +04:00
assert_baker_uptodate() {
assert_baker
2018-07-18 22:27:06 +04:00
if ! uptodate_containers $docker_baker_containers; then
2018-01-29 21:26:27 +04:00
echo -e "\033[33mThe current baker is not the latest available.\033[0m"
exit 1
fi
}
2017-03-09 17:43:59 +04:00
status_baker() {
if check_baker; then
echo -e "\033[32mBaker is running\033[0m"
2018-01-29 21:26:27 +04:00
may_pull_image
2018-07-18 22:27:06 +04:00
if ! uptodate_containers $docker_baker_containers; then
echo -e "\033[33mThe current baker is not the latest available.\033[0m"
fi
2017-03-09 17:43:59 +04:00
else
echo -e "\033[33mBaker is not running\033[0m"
2017-03-09 17:43:59 +04:00
fi
}
start_baker() {
if check_baker; then
2018-01-29 21:26:27 +04:00
echo -e "\033[31mBaker is already running\033[0m"
2017-03-09 17:43:59 +04:00
exit 1
fi
2018-01-29 21:26:27 +04:00
pull_image
assert_node_uptodate
2018-07-18 22:27:06 +04:00
call_docker_compose start $bakers
echo -e "\033[32mThe baker is now running.\033[0m"
2017-03-09 17:43:59 +04:00
}
log_baker() {
2018-01-29 21:26:27 +04:00
may_pull_image
assert_baker_uptodate
2018-07-18 22:27:06 +04:00
call_docker_compose logs -f $bakers
2017-03-09 17:43:59 +04:00
}
stop_baker() {
2018-01-29 21:26:27 +04:00
if ! check_baker; then
echo -e "\033[31mNo baker to kill!\033[0m"
exit 1
fi
echo -e "\033[32mStopping the baker...\033[0m"
2018-07-18 22:27:06 +04:00
call_docker_compose stop $bakers
2017-03-09 17:43:59 +04:00
}
2018-01-29 21:26:27 +04:00
## Endorser ###################################################################
2017-03-09 17:43:59 +04:00
check_endorser() {
2018-07-18 22:27:06 +04:00
update_active_protocol_version
endorsers="$(sed s/^/endorser-/g "$active_protocol_versions")"
docker_endorser_containers="$(sed "s/^\(.*\)$/${docker_compose_name}_endorser-\1_1/g" "$active_protocol_versions")"
2018-01-29 21:26:27 +04:00
res=$(docker inspect \
--format="{{ .State.Running }}" \
--type=container "$(container_name "$docker_endorser_containers")" 2>/dev/null || echo false)
[ "$res" = "true" ]
2017-03-09 17:43:59 +04:00
}
assert_endorser() {
if ! check_endorser; then
echo -e "\033[31mEndorser is not running!\033[0m"
2017-03-09 17:43:59 +04:00
exit 0
fi
}
2018-01-29 21:26:27 +04:00
assert_endorser_uptodate() {
assert_endorser
2018-07-18 22:27:06 +04:00
if ! uptodate_containers $docker_endorser_containers; then
2018-01-29 21:26:27 +04:00
echo -e "\033[33mThe current endorser is not the latest available.\033[0m"
exit 1
fi
}
2017-03-09 17:43:59 +04:00
status_endorser() {
if check_endorser; then
echo -e "\033[32mEndorser is running\033[0m"
2018-01-29 21:26:27 +04:00
may_pull_image
2018-07-18 22:27:06 +04:00
if ! uptodate_containers $docker_endorser_containers; then
echo -e "\033[33mThe current endorser is not the latest available.\033[0m"
fi
2017-03-09 17:43:59 +04:00
else
echo -e "\033[33mEndorser is not running\033[0m"
2017-03-09 17:43:59 +04:00
fi
}
start_endorser() {
if check_endorser; then
2018-01-29 21:26:27 +04:00
echo -e "\033[31mEndorser is already running\033[0m"
2017-03-09 17:43:59 +04:00
exit 1
fi
2018-01-29 21:26:27 +04:00
pull_image
assert_node_uptodate
2018-07-18 22:27:06 +04:00
call_docker_compose start $endorsers
echo -e "\033[32mThe endorser is now running.\033[0m"
2017-03-09 17:43:59 +04:00
}
log_endorser() {
2018-01-29 21:26:27 +04:00
may_pull_image
assert_endorser_uptodate
2018-07-18 22:27:06 +04:00
call_docker_compose logs -f $endorsers
2017-03-09 17:43:59 +04:00
}
stop_endorser() {
2018-07-21 01:10:38 +04:00
if ! check_endorser; then
echo -e "\033[31mNo endorser to kill!\033[0m"
2018-01-29 21:26:27 +04:00
exit 1
fi
2018-07-21 01:10:38 +04:00
echo -e "\033[32mStopping the endorser...\033[0m"
2018-07-18 22:27:06 +04:00
call_docker_compose stop $endorsers
}
## Accuser ###################################################################
check_accuser() {
update_active_protocol_version
accusers="$(sed s/^/accuser-/g "$active_protocol_versions")"
docker_accuser_containers="$(sed "s/^\(.*\)$/${docker_compose_name}_accuser-\1_1/g" "$active_protocol_versions")"
res=$(docker inspect \
--format="{{ .State.Running }}" \
--type=container "$(container_name "$docker_accuser_containers")" 2>/dev/null || echo false)
[ "$res" = "true" ]
2018-07-18 22:27:06 +04:00
}
assert_accuser() {
if ! check_accuser; then
echo -e "\033[31mAccuser is not running!\033[0m"
exit 0
fi
}
assert_accuser_uptodate() {
assert_accuser
if ! uptodate_containers $docker_accuser_containers; then
echo -e "\033[33mThe current accuser is not the latest available.\033[0m"
exit 1
fi
}
status_accuser() {
if check_accuser; then
echo -e "\033[32mAccuser is running\033[0m"
may_pull_image
if ! uptodate_containers $docker_accuser_containers; then
echo -e "\033[33mThe current accuser is not the latest available.\033[0m"
fi
else
echo -e "\033[33mAccuser is not running\033[0m"
fi
}
start_accuser() {
if check_accuser; then
echo -e "\033[31mAccuser is already running\033[0m"
exit 1
fi
pull_image
assert_node_uptodate
call_docker_compose start $accusers
echo -e "\033[32mThe accuser is now running.\033[0m"
}
log_accuser() {
may_pull_image
assert_accuser_uptodate
call_docker_compose logs -f $accusers
}
stop_accuser() {
2018-07-21 01:10:38 +04:00
if ! check_accuser; then
echo -e "\033[31mNo accuser to kill!\033[0m"
2018-07-18 22:27:06 +04:00
exit 1
fi
2018-07-21 01:10:38 +04:00
echo -e "\033[32mStopping the accuser...\033[0m"
2018-07-18 22:27:06 +04:00
call_docker_compose stop $accusers
2017-03-09 17:43:59 +04:00
}
## Misc ####################################################################
run_client() {
2018-01-29 21:26:27 +04:00
assert_node_uptodate
exec_docker "tezos-client" "$@"
}
run_admin_client() {
assert_node_uptodate
exec_docker "tezos-admin-client" "$@"
2017-03-09 17:43:59 +04:00
}
run_shell() {
2018-01-29 21:26:27 +04:00
assert_node_uptodate
if [ $# -eq 0 ]; then
2018-01-29 21:26:27 +04:00
exec_docker /bin/sh
else
2018-01-29 21:26:27 +04:00
exec_docker /bin/sh -c "$@"
fi
2017-03-09 17:43:59 +04:00
}
display_head() {
2018-01-29 21:26:27 +04:00
assert_node_uptodate
2018-08-02 21:08:37 +04:00
exec_docker tezos-client rpc get /chains/main/blocks/head/header
2017-03-09 17:43:59 +04:00
}
## Main ####################################################################
start() {
pull_image
2018-01-29 21:26:27 +04:00
update_compose_file "$@"
2018-07-18 22:27:06 +04:00
call_docker_compose up -d --remove-orphans
2017-03-09 17:43:59 +04:00
warn_script_uptodate
}
2018-01-29 21:26:27 +04:00
stop() {
call_docker_compose down
2017-03-09 17:43:59 +04:00
}
2018-01-29 21:26:27 +04:00
kill_() {
call_docker_compose kill
stop
2017-03-09 17:43:59 +04:00
}
status() {
status_node
status_baker
status_endorser
2018-01-29 21:26:27 +04:00
warn_script_uptodate verbose
2017-03-09 17:43:59 +04:00
}
warn_script_uptodate() {
if [[ $ALPHANET_EMACS ]]; then
return
fi
2018-01-29 21:26:27 +04:00
docker run --entrypoint /bin/cat "$docker_image" \
"/usr/local/share/tezos/alphanet.sh" > ".alphanet.sh.new"
2017-03-09 17:43:59 +04:00
if ! diff .alphanet.sh.new "$0" >/dev/null 2>&1 ; then
echo -e "\033[33mWarning: the container contains a new version of 'alphanet.sh'.\033[0m"
echo -e "\033[33mYou might run '$0 update_script' to synchronize.\033[0m"
2017-03-09 17:43:59 +04:00
elif [ "$1" = "verbose" ] ; then
echo -e "\033[32mThe script is up to date.\033[0m"
2017-03-09 17:43:59 +04:00
fi
rm .alphanet.sh.new
}
update_script() {
2018-01-29 21:26:27 +04:00
docker run --entrypoint /bin/cat "$docker_image" \
"/usr/local/share/tezos/alphanet.sh" > ".alphanet.sh.new"
if ! diff .alphanet.sh.new "$0" >/dev/null 2>&1 ; then
mv .alphanet.sh.new "$0"
echo -e "\033[32mThe script has been updated.\033[0m"
else
rm .alphanet.sh.new
echo -e "\033[32mThe script is up to date.\033[0m"
fi
2017-03-09 17:43:59 +04:00
}
usage() {
echo "Usage: $0 [GLOBAL_OPTIONS] <command> [OPTIONS]"
echo " Main commands:"
echo " $0 start [--rpc-port <int>] [OPTIONS]"
2017-03-09 17:43:59 +04:00
echo " Launch a full Tezos alphanet node in a docker container"
echo " automatically generating a new network identity."
echo " OPTIONS (others than --rpc-port) are directly passed to the"
echo " Tezos node, see '$0 shell tezos-node config --help'"
echo " for more details."
echo " By default, the RPC port is not exported outside the docker"
echo " container. WARNING: when exported some RPCs could be harmful"
echo " (e.g. 'inject_block', 'force_validation', ...), it is"
echo " advised not to export them publicly."
2017-03-09 17:43:59 +04:00
echo " $0 <stop|kill>"
echo " Friendly or brutally stop the node."
echo " $0 restart"
echo " Friendly stop the node, fetch the latest docker image and "
echo " update this script, then start the node again."
echo " The blockchain data are preserved."
echo " $0 clear"
echo " Remove all the blockchain data from the disk (except"
echo " for secret keys and other configuration backup)."
echo " $0 status"
echo " Check that the running node is running and up to date."
echo " Upgrade is automatically done by the start command."
echo " $0 head"
echo " Display info about the current head of the blockchain."
echo " $0 client <COMMAND>"
echo " Pass a command to the tezos client."
echo " $0 update_script"
echo " Replace 'alphanet.sh' with the one found in the docker image."
echo " Advanced commands:"
echo " $0 node <start|stop|status|log>"
echo " $0 baker <start|stop|status|log>"
echo " $0 endorser <start|stop|status|log>"
echo " $0 shell"
echo "Node configuration backup directory: $data_dir"
echo "Global options are currently limited to:"
echo " --port <int>"
echo " change public the port Tezos node"
echo "Container prefix:"
echo " container:<FILE>"
echo " can be used anywhere 'file:<FILE>' is permitted in client commands."
echo " It will cause the referenced file to be copied into the docker conainer."
echo " Files will be renamed, which may make errors difficult to read"
2017-03-09 17:43:59 +04:00
}
## Dispatch ################################################################
if [ "$#" -ge 2 ] && [ "$1" = "--port" ] ; then
port="$2"
2018-01-29 21:26:27 +04:00
suffix="$port"
2017-03-09 17:43:59 +04:00
shift 2
fi
command="$1"
if [ "$#" -eq 0 ] ; then usage ; exit 1; else shift ; fi
case $(basename "$0") in
2018-01-29 21:26:27 +04:00
localnet.sh)
docker_base_dir="$HOME/.tezos-localnet"
docker_image=tezos:latest
docker_compose_base_name=localnet
default_port=14732
;;
zeronet.sh)
docker_base_dir="$HOME/.tezos-zeronet"
docker_image=tezos/tezos:zeronet
docker_compose_base_name=zeronet
default_port=19732
;;
2018-06-30 19:40:28 +04:00
betanet.sh)
2018-09-17 16:15:38 +04:00
if [ -d "$HOME/.tezos-mainnet" ] ; then
echo 'You already upgraded, please only use `mainnet.sh` now.'
exit 1
else
echo 'A new script `mainnet.sh` is now available.'
echo 'The current `betanet.sh` still works, but we recommend that you upgrade.'
fi
2018-06-30 19:40:28 +04:00
docker_base_dir="$HOME/.tezos-betanet"
2018-09-17 16:15:38 +04:00
docker_image=tezos/tezos:mainnet
2018-06-30 19:40:28 +04:00
docker_compose_base_name=betanet
default_port=9732
;;
2018-09-17 16:15:38 +04:00
mainnet.sh)
if [ -d "$HOME/.tezos-betanet" ] ; then
echo 'Folder "'$HOME'/.tezos-betanet" detected.'
echo 'To upgrade to the mainnet script, execute the following commands.'
echo ' `betanet.sh stop`'
echo 'Make sure that your node is stopped using `docker ps`.'
echo ' `mv "'$HOME'/.tezos-betanet" "'$HOME'/.tezos-mainnet"`'
echo ' `mainnet.sh start`'
exit 1
fi
docker_base_dir="$HOME/.tezos-mainnet"
docker_image=tezos/tezos:mainnet
docker_compose_base_name=mainnet
default_port=9732
;;
2018-01-29 21:26:27 +04:00
*)
docker_base_dir="$HOME/.tezos-alphanet"
docker_image=tezos/tezos:alphanet
2018-01-29 21:26:27 +04:00
docker_compose_base_name="alphanet"
default_port=9732
;;
esac
if [ -n "$suffix" ] ; then
mkdir -p "$docker_base_dir"
echo "$port" > "$docker_base_dir/default_port"
elif [ -f "$docker_base_dir/default_port" ]; then
port=$(cat "$docker_base_dir/default_port")
suffix="$port"
else
port=$default_port
fi
docker_dir="$docker_base_dir$suffix"
docker_compose_yml="$docker_dir/docker-compose.yml"
docker_pull_timestamp="$docker_dir/docker_pull.timestamp"
2018-07-18 22:27:06 +04:00
active_protocol_versions="$docker_dir/active_protocol_versions"
2018-01-29 21:26:27 +04:00
docker_compose_name="$docker_compose_base_name$suffix"
docker_node_container=${docker_compose_name}_node_1
docker_node_volume=${docker_compose_name}_node_data
docker_client_volume=${docker_compose_name}_client_data
mkdir -p "$docker_dir"
2017-03-09 17:43:59 +04:00
case "$command" in
## Main
start)
start "$@"
;;
restart)
2018-01-29 21:26:27 +04:00
stop
2017-03-09 17:43:59 +04:00
update_script
export TEZOS_ALPHANET_DO_NOT_PULL=yes
exec "$0" start "$@"
;;
clear)
2018-01-29 21:26:27 +04:00
clear_node_volume
2017-03-09 17:43:59 +04:00
;;
status)
status
;;
stop)
stop
;;
kill)
2018-01-29 21:26:27 +04:00
kill_
2017-03-09 17:43:59 +04:00
;;
## Node
node)
subcommand="$1"
if [ "$#" -eq 0 ] ; then usage ; exit 1; else shift ; fi
case "$subcommand" in
start)
2018-01-29 21:26:27 +04:00
start_node "$@"
2017-03-09 17:43:59 +04:00
;;
status)
status_node
;;
log)
log_node
;;
stop)
stop_node
;;
*)
usage
exit 1
esac ;;
## Baker
baker)
subcommand="$1"
if [ "$#" -eq 0 ] ; then usage ; exit 1; else shift ; fi
case "$subcommand" in
status)
status_baker
;;
start)
start_baker
;;
log)
log_baker
;;
stop)
stop_baker
;;
*)
usage
exit 1
esac ;;
## Endorser
endorser)
subcommand="$1"
if [ "$#" -eq 0 ] ; then usage ; exit 1; else shift ; fi
case "$subcommand" in
status)
status_endorser
;;
start)
start_endorser
;;
log)
log_endorser
;;
stop)
stop_endorser
;;
*)
usage
exit 1
esac ;;
2018-07-18 22:27:06 +04:00
## Accuser
accuser)
subcommand="$1"
if [ "$#" -eq 0 ] ; then usage ; exit 1; else shift ; fi
case "$subcommand" in
status)
status_accuser
;;
start)
start_accuser
;;
log)
log_accuser
;;
stop)
stop_accuser
;;
*)
usage
exit 1
esac ;;
2017-03-09 17:43:59 +04:00
## Misc.
head)
display_head
;;
shell)
run_shell "$@"
2017-03-09 17:43:59 +04:00
;;
client)
run_client "$@"
;;
admin-client)
run_admin_client "$@"
;;
2017-03-09 17:43:59 +04:00
check_script)
2018-01-29 21:26:27 +04:00
warn_script_uptodate verbose
2017-03-09 17:43:59 +04:00
;;
update_script)
update_script
;;
*)
usage
exit 1
;;
esac