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
4 changes: 2 additions & 2 deletions install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,7 @@ install_mineradm() {
local new_version
new_version=$(get_mineradm_version "$src_utils_sh")

log_info "--- Starting CESS mineradm installation (v$new_version) ---"
log_info "--- Starting CESS mineradm installation ($new_version) ---"

if [ -f "$install_dir/config.yaml" ] && [ "$retain_config" != "true" ]; then
confirm_config_overwrite "$old_version"
Expand All @@ -308,7 +308,7 @@ install_mineradm() {
setup_bash_completion
attempt_enable_docker_api

log_success "CESS mineradm v$new_version installed successfully!"
log_success "CESS mineradm $new_version installed successfully!"
}

main() {
Expand Down
7 changes: 5 additions & 2 deletions scripts/completion.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ _mineradm_completions() {
prev2="${COMP_WORDS[COMP_CWORD - 2]}"

if [[ ${COMP_CWORD} -eq 1 ]]; then
opts="miners cacher stop restart down status pullimg purge config profile tools help"
opts="miners cacher stop restart down status pullimg purge config profile tools version increase help"
else
case "$prev" in
miners)
Expand All @@ -23,11 +23,14 @@ _mineradm_completions() {
increase)
opts="staking space"
;;
config)
opts="show generate help"
;;
esac
fi

COMPREPLY=($(compgen -W "${opts}" -- ${cur}))
return 0
}

complete -F _mineradm_completions mineradm
complete -F _mineradm_completions mineradm
55 changes: 19 additions & 36 deletions scripts/config.sh
Original file line number Diff line number Diff line change
Expand Up @@ -76,20 +76,22 @@ prepare_build_dir() {
run_config_generator() {
log_info "Running config generator..."
pullimg # Ensure latest images are used


local cidfile=$(mktemp)
rm $cidfile

local cg_image="cesslab/config-gen:$profile"
local cidfile
cidfile=$(mktemp)

# The trap ensures the container is removed even if the script fails.
trap 'docker rm -f "$(cat "$cidfile")" &>/dev/null || true; rm -f "$cidfile"' EXIT

docker run --cidfile "$cidfile" \
-v "$base_dir/etc:/opt/app/etc" \
-v "$build_dir/.tmp:/opt/app/.tmp" \
-v "$config_path:/opt/app/config.yaml" \
"$cg_image"

docker run --cidfile $cidfile -v $base_dir/etc:/opt/app/etc -v $build_dir/.tmp:/opt/app/.tmp -v $config_path:/opt/app/config.yaml $cg_image

local res="$?"
local cid=$(cat $cidfile)
docker rm $cid

if [ "$res" -ne "0" ]; then
log_err "Failed to generate configurations, please check your config file and try again."
exit 1
fi

log_success "Config generator finished."
}

Expand Down Expand Up @@ -133,16 +135,6 @@ deploy_generated_configs() {
log_success "All configurations deployed."
}

# Patches the generated docker-compose.yaml for compatibility.
patch_compose_file() {
log_info "Patching docker-compose.yaml..."
# This sed command removes extra single quotes from the 'test' command array,
# which can cause issues with some Docker versions.
# e.g., '["CMD", "nc", ...]' -> ["CMD", "nc", ...]
sed -i "s/'\([\"CMD\".*\)'/\1/" "$compose_yaml"
log_success "docker-compose.yaml patched."
}

# Main function to generate all configuration files.
config_generate() {
log_info "--- Starting Configuration Generation ---"
Expand All @@ -151,18 +143,15 @@ config_generate() {
prepare_build_dir
run_config_generator
deploy_generated_configs
patch_compose_file


log_success "Configuration generation complete. Docker Compose file is at: $compose_yaml"
}

# --- Main Execution ---

mode=$(yq eval ".node.mode" "$config_path")
# Main router for the 'config' command.
config() {
# Set default mode if not valid
local mode
mode=$(yq eval ".node.mode" "$config_path")
if [ "$mode" != "multiminer" ]; then
log_info "The mode in $config_path is invalid, setting value to: multiminer"
yq -i eval '.node.mode="multiminer"' "$config_path"
Expand All @@ -171,18 +160,12 @@ config() {
case "${1:-help}" in
-s | show)
config_show
;;n -g | generate)
;;
-g | generate)
config_generate
;;
-h | help | *)
config_help
;;
esac
}

# If run directly, execute the main function.
if [[ "${BASH_SOURCE[0]}" == "${0}" ]]; then
# Load profile from config before running.
load_profile
config "$@"
fi
Loading
Loading