Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
70 changes: 14 additions & 56 deletions start-node.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/bin/bash

# errors are handled gracefully to tell the user
# set -euo pipefail
set -euo pipefail

# ----------------------------------------
ALLOW_MAINNET_EXTERNAL="false"
Expand Down Expand Up @@ -132,7 +132,7 @@ select connection_type in "${connection_options[@]}"; do
done

# Define the list of available networks
available_networks=("mainnet" "preprod" "preview" "sanchonet-pig" "sanchonet-chicken")
available_networks=("mainnet" "preprod" "preview" "sanchonet")


# If user selected external node configuration
Expand Down Expand Up @@ -233,7 +233,7 @@ echo
echo -e "${CYAN}Setting up Docker node...${NC}"

# Define the list of available node versions
available_versions=( "10.5.3" "10.5.1")
available_versions=( "10.5.3" "10.5.4" "10.6.2" )

# Initialize variables to avoid unbound variable errors
network=""
Expand Down Expand Up @@ -283,11 +283,7 @@ else
fi

# Normalize network name for directory/container naming
# sanchonet-pig and sanchonet-chicken both normalize to sanchonet
network_normalized="$network"
if [ "$network" = "sanchonet-pig" ] || [ "$network" = "sanchonet-chicken" ]; then
network_normalized="sanchonet"
fi

# Function to assign a unique port based on version
# This ensures different versions on the same network use different ports
Expand Down Expand Up @@ -395,7 +391,7 @@ dumps_dir="$base_dir/dumps/$network_normalized"
utilities_dir="$base_dir/utilities"

# Base URL for node config files
if [ "$network" = "sanchonet-pig" ] || [ "$network" = "sanchonet-chicken" ]; then
if [ "$network" = "sanchonet" ]; then
config_base_url="https://raw.githubusercontent.com/Hornan7/SanchoNet-Tutorials/refs/heads/main/genesis/"
else
config_base_url="https://book.play.dev.cardano.org/environments/$network/"
Expand Down Expand Up @@ -447,9 +443,18 @@ config_files=(
"alonzo-genesis.json"
"conway-genesis.json"
"peer-snapshot.json"
"guardrails-script.plutus"
)

# add dijkstra-genesis.json for 10.6.2
if [ "$node_version" = "10.6.2" ]; then
config_files+=("dijkstra-genesis.json")
fi

# add checkpoints.json for preview and mainnet (not available for sanchonet or preprod)
if [ "$network" = "preview" ] || [ "$network" = "mainnet" ]; then
config_files+=("checkpoints.json")
fi

# Change directory to the config directory and download files
echo -e "${CYAN}Downloading configuration files...${NC}"
cd "$config_dir" || exit
Expand All @@ -463,53 +468,6 @@ for file in "${config_files[@]}"; do
curl --silent -O -J -L "${config_base_url}${file}"
done

# Create custom topology.json for sanchonet-chicken
if [ "$network" = "sanchonet-chicken" ]; then
echo -e "${BLUE}Creating custom topology.json for sanchonet-chicken${NC}"
cat > topology.json << 'EOF'
{
"bootstrapPeers": [
{
"address": "sanchorelay1.intertreecryptoconsultants.com",
"port": 6002
}
],
"localRoots": [
{
"accessPoints": [
{
"address": "sanchorelay1.intertreecryptoconsultants.com",
"port": 6002
},
{
"address": "9.tcp.eu.ngrok.io",
"port": 20802
},
{
"address": "34.19.153.32",
"port": 6002
},
{
"address": "relay.hephy.io",
"port": 9000
}
],
"advertise": false,
"trustable": true,
"valency": 4
}
],
"publicRoots": [
{
"accessPoints": [],
"advertise": false
}
],
"useLedgerAfterSlot": -1
}
EOF
fi

# Return to the base directory
cd "$base_dir" || exit

Expand Down
61 changes: 52 additions & 9 deletions stop-nodes.sh
Original file line number Diff line number Diff line change
@@ -1,23 +1,66 @@
#!/bin/bash
set -euo pipefail

# Stop all cardano node containers matching the pattern node-*-*-container
# This handles versioned containers (e.g., node-preprod-10.5.3-container)
echo "Stopping all Cardano node containers..."
# Define colors
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[0;33m'
BLUE='\033[0;34m'
CYAN='\033[0;36m'
NC='\033[0m' # No color

# Get all running containers and filter for node-*-*-container pattern
# Get all running containers matching the node pattern
containers=$(docker ps --format "{{.Names}}" | grep -E "^node-[^-]+-[^-]+-container$" || true)

if [ -z "$containers" ]; then
echo "No Cardano node containers found running."
echo -e "${YELLOW}No Cardano node containers found running.${NC}"
exit 0
fi

# Stop each container
for container in $containers; do
echo "Stopping container: $container"
# Convert to array (compatible with Bash 3.x on macOS)
container_list=()
while IFS= read -r line; do
container_list+=("$line")
done <<< "$containers"
count=${#container_list[@]}

# Non-interactive mode (CI or piped input): stop all containers automatically
if [ ! -t 0 ] && [ ! -t 1 ]; then
echo "Stopping all Cardano node containers..."
stop_list=("${container_list[@]}")
else
# Interactive mode: let user choose
echo -e "${CYAN}Running Cardano node containers:${NC}"
for i in "${!container_list[@]}"; do
echo -e " ${GREEN}$((i + 1))${NC}) ${BLUE}${container_list[$i]}${NC}"
done
echo -e " ${GREEN}$((count + 1))${NC}) ${RED}Stop all${NC}"
echo

echo -e "${CYAN}Select a container to stop (1-$((count + 1))):${NC}"
read -r choice < /dev/tty

# Validate input
if ! [[ "$choice" =~ ^[0-9]+$ ]] || [ "$choice" -lt 1 ] || [ "$choice" -gt $((count + 1)) ]; then
echo -e "${RED}Invalid selection.${NC}"
exit 1
fi

# Build list of containers to stop
if [ "$choice" -eq $((count + 1)) ]; then
stop_list=("${container_list[@]}")
else
stop_list=("${container_list[$((choice - 1))]}")
fi
fi

# Stop and remove selected containers
for container in "${stop_list[@]}"; do
echo -e "${YELLOW}Stopping: $container${NC}"
docker stop "$container" 2>/dev/null || true
docker rm "$container" 2>/dev/null || true
echo -e "${GREEN}Stopped: $container${NC}"
done

echo "All Cardano node containers stopped."
echo
echo -e "${GREEN}Done.${NC}"
Loading