|
|
#!/usr/bin/env bash
|
|
|
# This script was generated by bashly 0.8.10 (https://bashly.dannyb.co)
|
|
|
# Modifying it manually is not recommended
|
|
|
|
|
|
# :wrapper.bash3_bouncer
|
|
|
if [[ "${BASH_VERSINFO:-0}" -lt 4 ]]; then
|
|
|
printf "bash version 4 or higher is required\n" >&2
|
|
|
exit 1
|
|
|
fi
|
|
|
|
|
|
# :command.master_script
|
|
|
|
|
|
# :command.version_command
|
|
|
version_command() {
|
|
|
echo "$version"
|
|
|
}
|
|
|
|
|
|
# :command.usage
|
|
|
rccontrol_usage() {
|
|
|
if [[ -n $long_usage ]]; then
|
|
|
printf "rccontrol - RhodeCode Control - CLI for manaing RhodeCode Cluster Stack\n"
|
|
|
echo
|
|
|
|
|
|
else
|
|
|
printf "rccontrol - RhodeCode Control - CLI for manaing RhodeCode Cluster Stack\n"
|
|
|
echo
|
|
|
|
|
|
fi
|
|
|
|
|
|
printf "Usage:\n"
|
|
|
printf " rccontrol [OPTIONS] COMMAND\n"
|
|
|
printf " rccontrol [COMMAND] --help | -h\n"
|
|
|
printf " rccontrol --version | -v\n"
|
|
|
echo
|
|
|
# :command.usage_commands
|
|
|
printf "Commands:\n"
|
|
|
echo " self-update update rccontrol and it's docker definitions"
|
|
|
echo " bootstrap Bootstrap this machine, check docker version and install rhodecode-network"
|
|
|
echo " stack run one of available cluster stacks, use -h for more details"
|
|
|
echo " stack-status show stack status"
|
|
|
echo " stack-upgrade upgrade ALL stack status"
|
|
|
echo
|
|
|
printf "Build Commands:\n"
|
|
|
echo " get-build-artifacts Fetch Artifacts to run installer based build"
|
|
|
echo " build Build RhodeCode image from installer"
|
|
|
echo " get-build-source Fetch RhodeCode sources, store in .source dir to run a source-based builds"
|
|
|
echo " build-source Build RhodeCode image from source, requires upgrade-source initially"
|
|
|
echo
|
|
|
printf "CLI Commands:\n"
|
|
|
echo " cli-redis CLI"
|
|
|
echo " cli-db CLI"
|
|
|
echo " cli-db-upgrade CLI"
|
|
|
echo
|
|
|
printf "Backup Commands:\n"
|
|
|
echo " backup-db CLI"
|
|
|
echo " backup-data CLI"
|
|
|
echo
|
|
|
|
|
|
# :command.long_usage
|
|
|
if [[ -n $long_usage ]]; then
|
|
|
printf "Options:\n"
|
|
|
|
|
|
# :command.usage_fixed_flags
|
|
|
echo " --help, -h"
|
|
|
printf " Show this help\n"
|
|
|
echo
|
|
|
echo " --version, -v"
|
|
|
printf " Show version number\n"
|
|
|
echo
|
|
|
|
|
|
# :command.usage_flags
|
|
|
# :flag.usage
|
|
|
echo " --debug"
|
|
|
printf " Enable debug and detailed output\n"
|
|
|
echo
|
|
|
|
|
|
# :command.usage_environment_variables
|
|
|
printf "Environment Variables:\n"
|
|
|
|
|
|
# :environment_variable.usage
|
|
|
echo " AUTH_TOKEN"
|
|
|
printf " Set your RhodeCode AUTH Token\n"
|
|
|
echo
|
|
|
|
|
|
# :environment_variable.usage
|
|
|
echo " RC_CLI_VERSION_NAME"
|
|
|
printf " default version to build and install\n"
|
|
|
printf " Default: 4.27.0\n"
|
|
|
echo
|
|
|
|
|
|
# :environment_variable.usage
|
|
|
echo " RC_STACK_ROUTER_EXT"
|
|
|
printf "\n"
|
|
|
printf " Default: .custom/docker-compose-router.override.yaml\n"
|
|
|
echo
|
|
|
|
|
|
# :environment_variable.usage
|
|
|
echo " RC_STACK_METRICS_EXT"
|
|
|
printf "\n"
|
|
|
printf " Default: .custom/docker-compose-metrics.override.yaml\n"
|
|
|
echo
|
|
|
|
|
|
# :environment_variable.usage
|
|
|
echo " RC_STACK_SERVICES_EXT"
|
|
|
printf "\n"
|
|
|
printf " Default: .custom/docker-compose-services.override.yaml\n"
|
|
|
echo
|
|
|
|
|
|
# :environment_variable.usage
|
|
|
echo " RC_STACK_RHODECODE_EXT"
|
|
|
printf "\n"
|
|
|
printf " Default: .custom/docker-compose-apps.override.yaml\n"
|
|
|
echo
|
|
|
|
|
|
# :command.footer
|
|
|
printf "RhodeCode Inc 2022\n\n"
|
|
|
echo
|
|
|
|
|
|
fi
|
|
|
}
|
|
|
|
|
|
# :command.usage
|
|
|
rccontrol_self_update_usage() {
|
|
|
if [[ -n $long_usage ]]; then
|
|
|
printf "rccontrol self-update - update rccontrol and it's docker definitions\n"
|
|
|
echo
|
|
|
|
|
|
else
|
|
|
printf "rccontrol self-update - update rccontrol and it's docker definitions\n"
|
|
|
echo
|
|
|
|
|
|
fi
|
|
|
|
|
|
printf "Usage:\n"
|
|
|
printf " rccontrol self-update [OPTIONS]\n"
|
|
|
printf " rccontrol self-update --help | -h\n"
|
|
|
echo
|
|
|
|
|
|
# :command.long_usage
|
|
|
if [[ -n $long_usage ]]; then
|
|
|
printf "Options:\n"
|
|
|
|
|
|
# :command.usage_fixed_flags
|
|
|
echo " --help, -h"
|
|
|
printf " Show this help\n"
|
|
|
echo
|
|
|
|
|
|
# :command.usage_flags
|
|
|
# :flag.usage
|
|
|
echo " --auth-token AUTH_TOKEN"
|
|
|
printf " Optionally specify AUTH TOKEN to obtain sources\n"
|
|
|
echo
|
|
|
|
|
|
# :flag.usage
|
|
|
echo " --server-url SERVER_URL"
|
|
|
printf " Specify RhodeCode server location where projects should be downloaded\n"
|
|
|
printf " Default: https://code.rhodecode.com\n"
|
|
|
echo
|
|
|
|
|
|
fi
|
|
|
}
|
|
|
|
|
|
# :command.usage
|
|
|
rccontrol_bootstrap_usage() {
|
|
|
if [[ -n $long_usage ]]; then
|
|
|
printf "rccontrol bootstrap - Bootstrap this machine, check docker version and install rhodecode-network\n"
|
|
|
echo
|
|
|
|
|
|
else
|
|
|
printf "rccontrol bootstrap - Bootstrap this machine, check docker version and install rhodecode-network\n"
|
|
|
echo
|
|
|
|
|
|
fi
|
|
|
|
|
|
printf "Alias: install\n"
|
|
|
echo
|
|
|
|
|
|
printf "Usage:\n"
|
|
|
printf " rccontrol bootstrap [OPTIONS]\n"
|
|
|
printf " rccontrol bootstrap --help | -h\n"
|
|
|
echo
|
|
|
|
|
|
# :command.long_usage
|
|
|
if [[ -n $long_usage ]]; then
|
|
|
printf "Options:\n"
|
|
|
|
|
|
# :command.usage_fixed_flags
|
|
|
echo " --help, -h"
|
|
|
printf " Show this help\n"
|
|
|
echo
|
|
|
|
|
|
# :command.usage_flags
|
|
|
# :flag.usage
|
|
|
echo " --force, -f"
|
|
|
printf " Overwrite existing files\n"
|
|
|
echo
|
|
|
|
|
|
# :flag.usage
|
|
|
echo " --auth-token AUTH_TOKEN"
|
|
|
printf " Optionally specify AUTH TOKEN to obtain sources\n"
|
|
|
echo
|
|
|
|
|
|
# :flag.usage
|
|
|
echo " --server-url SERVER_URL"
|
|
|
printf " Specify RhodeCode server location where projects should be downloaded\n"
|
|
|
printf " Default: https://code.rhodecode.com\n"
|
|
|
echo
|
|
|
|
|
|
# :command.usage_examples
|
|
|
printf "Examples:\n"
|
|
|
printf " rccontrol3 bootstrap\n"
|
|
|
printf " rccontrol3 bootstrap --force\n"
|
|
|
echo
|
|
|
|
|
|
fi
|
|
|
}
|
|
|
|
|
|
# :command.usage
|
|
|
rccontrol_get_build_artifacts_usage() {
|
|
|
if [[ -n $long_usage ]]; then
|
|
|
printf "rccontrol get-build-artifacts - Fetch Artifacts to run installer based build\n"
|
|
|
echo
|
|
|
|
|
|
else
|
|
|
printf "rccontrol get-build-artifacts - Fetch Artifacts to run installer based build\n"
|
|
|
echo
|
|
|
|
|
|
fi
|
|
|
|
|
|
printf "Usage:\n"
|
|
|
printf " rccontrol get-build-artifacts [OPTIONS]\n"
|
|
|
printf " rccontrol get-build-artifacts --help | -h\n"
|
|
|
echo
|
|
|
|
|
|
# :command.long_usage
|
|
|
if [[ -n $long_usage ]]; then
|
|
|
printf "Options:\n"
|
|
|
|
|
|
# :command.usage_fixed_flags
|
|
|
echo " --help, -h"
|
|
|
printf " Show this help\n"
|
|
|
echo
|
|
|
|
|
|
# :command.usage_flags
|
|
|
# :flag.usage
|
|
|
echo " --auth AUTH"
|
|
|
printf " Specify custom auth for curl e.g -u admin:secret\n"
|
|
|
printf " Default: \n"
|
|
|
echo
|
|
|
|
|
|
# :flag.usage
|
|
|
echo " --installer-url INSTALLER_URL"
|
|
|
printf " Installer Download URL\n"
|
|
|
printf " Default: https://dls.rhodecode.com/dls/N2E2ZTY1NzA3NjYxNDA2NTc1NjI3MTcyNzA2MjcxNzIyZTcwNjI3YQ==/rhodecode-control/latest-linux-ee\n"
|
|
|
echo
|
|
|
|
|
|
# :flag.usage
|
|
|
echo " --manifest-url MANIFEST_URL"
|
|
|
printf " Manifest file url\n"
|
|
|
printf " Default: https://dls.rhodecode.com/linux/MANIFEST\n"
|
|
|
echo
|
|
|
|
|
|
# :flag.usage
|
|
|
echo " --version-name VERSION_NAME"
|
|
|
printf " Specify custom build ver e.g $RC_CLI_VERSION_NAME\n"
|
|
|
printf " Default: $RC_CLI_VERSION_NAME\n"
|
|
|
echo
|
|
|
|
|
|
fi
|
|
|
}
|
|
|
|
|
|
# :command.usage
|
|
|
rccontrol_build_usage() {
|
|
|
if [[ -n $long_usage ]]; then
|
|
|
printf "rccontrol build - Build RhodeCode image from installer\n"
|
|
|
echo
|
|
|
|
|
|
else
|
|
|
printf "rccontrol build - Build RhodeCode image from installer\n"
|
|
|
echo
|
|
|
|
|
|
fi
|
|
|
|
|
|
printf "Usage:\n"
|
|
|
printf " rccontrol build [OPTIONS]\n"
|
|
|
printf " rccontrol build --help | -h\n"
|
|
|
echo
|
|
|
|
|
|
# :command.long_usage
|
|
|
if [[ -n $long_usage ]]; then
|
|
|
printf "Options:\n"
|
|
|
|
|
|
# :command.usage_fixed_flags
|
|
|
echo " --help, -h"
|
|
|
printf " Show this help\n"
|
|
|
echo
|
|
|
|
|
|
# :command.usage_flags
|
|
|
# :flag.usage
|
|
|
echo " --version-name VERSION_NAME"
|
|
|
printf " Specify custom build ver e.g $RC_CLI_VERSION_NAME\n"
|
|
|
printf " Default: $RC_CLI_VERSION_NAME\n"
|
|
|
echo
|
|
|
|
|
|
fi
|
|
|
}
|
|
|
|
|
|
# :command.usage
|
|
|
rccontrol_get_build_source_usage() {
|
|
|
if [[ -n $long_usage ]]; then
|
|
|
printf "rccontrol get-build-source - Fetch RhodeCode sources, store in .source dir to run a source-based builds\n"
|
|
|
echo
|
|
|
|
|
|
else
|
|
|
printf "rccontrol get-build-source - Fetch RhodeCode sources, store in .source dir to run a source-based builds\n"
|
|
|
echo
|
|
|
|
|
|
fi
|
|
|
|
|
|
printf "Usage:\n"
|
|
|
printf " rccontrol get-build-source REVISION [OPTIONS]\n"
|
|
|
printf " rccontrol get-build-source --help | -h\n"
|
|
|
echo
|
|
|
|
|
|
# :command.long_usage
|
|
|
if [[ -n $long_usage ]]; then
|
|
|
printf "Options:\n"
|
|
|
|
|
|
# :command.usage_fixed_flags
|
|
|
echo " --help, -h"
|
|
|
printf " Show this help\n"
|
|
|
echo
|
|
|
|
|
|
# :command.usage_flags
|
|
|
# :flag.usage
|
|
|
echo " --auth-token AUTH_TOKEN"
|
|
|
printf " Specify AUTH TOKEN to obtain sources\n"
|
|
|
echo
|
|
|
|
|
|
# :flag.usage
|
|
|
echo " --server-url SERVER_URL"
|
|
|
printf " Specify RhodeCode server location where projects should be downloaded\n"
|
|
|
printf " Default: https://code.rhodecode.com\n"
|
|
|
echo
|
|
|
|
|
|
# :command.usage_args
|
|
|
printf "Arguments:\n"
|
|
|
|
|
|
# :argument.usage
|
|
|
echo " REVISION"
|
|
|
printf " revision to download\n"
|
|
|
echo
|
|
|
|
|
|
# :command.usage_examples
|
|
|
printf "Examples:\n"
|
|
|
printf " rccontrol3 get-sources $RC_CLI_VERSION_NAME\n"
|
|
|
printf " rccontrol3 get-sources default --auth-token xyxyxyx --server-url\n https://secret.repo/\n"
|
|
|
echo
|
|
|
|
|
|
fi
|
|
|
}
|
|
|
|
|
|
# :command.usage
|
|
|
rccontrol_build_source_usage() {
|
|
|
if [[ -n $long_usage ]]; then
|
|
|
printf "rccontrol build-source - Build RhodeCode image from source, requires upgrade-source initially\n"
|
|
|
echo
|
|
|
|
|
|
else
|
|
|
printf "rccontrol build-source - Build RhodeCode image from source, requires upgrade-source initially\n"
|
|
|
echo
|
|
|
|
|
|
fi
|
|
|
|
|
|
printf "Usage:\n"
|
|
|
printf " rccontrol build-source [OPTIONS]\n"
|
|
|
printf " rccontrol build-source --help | -h\n"
|
|
|
echo
|
|
|
|
|
|
# :command.long_usage
|
|
|
if [[ -n $long_usage ]]; then
|
|
|
printf "Options:\n"
|
|
|
|
|
|
# :command.usage_fixed_flags
|
|
|
echo " --help, -h"
|
|
|
printf " Show this help\n"
|
|
|
echo
|
|
|
|
|
|
# :command.usage_flags
|
|
|
# :flag.usage
|
|
|
echo " --version-name VERSION_NAME"
|
|
|
printf " Specify custom build ver e.g $RC_CLI_VERSION_NAME\n"
|
|
|
printf " Default: $RC_CLI_VERSION_NAME\n"
|
|
|
echo
|
|
|
|
|
|
# :command.usage_examples
|
|
|
printf "Examples:\n"
|
|
|
printf " build foo\n"
|
|
|
echo
|
|
|
|
|
|
fi
|
|
|
}
|
|
|
|
|
|
# :command.usage
|
|
|
rccontrol_stack_usage() {
|
|
|
if [[ -n $long_usage ]]; then
|
|
|
printf "rccontrol stack - run one of available cluster stacks, use -h for more details\n"
|
|
|
echo
|
|
|
|
|
|
else
|
|
|
printf "rccontrol stack - run one of available cluster stacks, use -h for more details\n"
|
|
|
echo
|
|
|
|
|
|
fi
|
|
|
|
|
|
printf "Usage:\n"
|
|
|
printf " rccontrol stack NAME [SERVICES PARAMS...]\n"
|
|
|
printf " rccontrol stack --help | -h\n"
|
|
|
echo
|
|
|
|
|
|
# :command.long_usage
|
|
|
if [[ -n $long_usage ]]; then
|
|
|
printf "Options:\n"
|
|
|
|
|
|
# :command.usage_fixed_flags
|
|
|
echo " --help, -h"
|
|
|
printf " Show this help\n"
|
|
|
echo
|
|
|
|
|
|
# :command.usage_args
|
|
|
printf "Arguments:\n"
|
|
|
|
|
|
# :argument.usage
|
|
|
echo " NAME"
|
|
|
printf " Stack name\n"
|
|
|
printf " Allowed: router, metrics, services, rhodecode\n"
|
|
|
echo
|
|
|
|
|
|
echo " SERVICES PARAMS..."
|
|
|
printf " Additional arguments or flags for services command\n"
|
|
|
echo
|
|
|
|
|
|
# :command.usage_examples
|
|
|
printf "Examples:\n"
|
|
|
printf " - ./rccontrol3 stack router up # run router stack with output to\n console\n - ./rccontrol3 stack router up --detach # run router stack detached\n - ./rccontrol3 stack router down # stop whole router stack\n - ./rccontrol3 stack router ps # check status of router stack\n - ./rccontrol3 stack router -f docker-overrides.yaml up -d # run router stack\n with your overrides\n"
|
|
|
echo
|
|
|
|
|
|
fi
|
|
|
}
|
|
|
|
|
|
# :command.usage
|
|
|
rccontrol_stack_status_usage() {
|
|
|
if [[ -n $long_usage ]]; then
|
|
|
printf "rccontrol stack-status - show stack status\n"
|
|
|
echo
|
|
|
|
|
|
else
|
|
|
printf "rccontrol stack-status - show stack status\n"
|
|
|
echo
|
|
|
|
|
|
fi
|
|
|
|
|
|
printf "Alias: status\n"
|
|
|
echo
|
|
|
|
|
|
printf "Usage:\n"
|
|
|
printf " rccontrol stack-status\n"
|
|
|
printf " rccontrol stack-status --help | -h\n"
|
|
|
echo
|
|
|
|
|
|
# :command.long_usage
|
|
|
if [[ -n $long_usage ]]; then
|
|
|
printf "Options:\n"
|
|
|
|
|
|
# :command.usage_fixed_flags
|
|
|
echo " --help, -h"
|
|
|
printf " Show this help\n"
|
|
|
echo
|
|
|
|
|
|
fi
|
|
|
}
|
|
|
|
|
|
# :command.usage
|
|
|
rccontrol_stack_upgrade_usage() {
|
|
|
if [[ -n $long_usage ]]; then
|
|
|
printf "rccontrol stack-upgrade - upgrade ALL stack status\n"
|
|
|
echo
|
|
|
|
|
|
else
|
|
|
printf "rccontrol stack-upgrade - upgrade ALL stack status\n"
|
|
|
echo
|
|
|
|
|
|
fi
|
|
|
|
|
|
printf "Usage:\n"
|
|
|
printf " rccontrol stack-upgrade\n"
|
|
|
printf " rccontrol stack-upgrade --help | -h\n"
|
|
|
echo
|
|
|
|
|
|
# :command.long_usage
|
|
|
if [[ -n $long_usage ]]; then
|
|
|
printf "Options:\n"
|
|
|
|
|
|
# :command.usage_fixed_flags
|
|
|
echo " --help, -h"
|
|
|
printf " Show this help\n"
|
|
|
echo
|
|
|
|
|
|
fi
|
|
|
}
|
|
|
|
|
|
# :command.usage
|
|
|
rccontrol_cli_redis_usage() {
|
|
|
if [[ -n $long_usage ]]; then
|
|
|
printf "rccontrol cli-redis - CLI\n"
|
|
|
echo
|
|
|
|
|
|
else
|
|
|
printf "rccontrol cli-redis - CLI\n"
|
|
|
echo
|
|
|
|
|
|
fi
|
|
|
|
|
|
printf "Usage:\n"
|
|
|
printf " rccontrol cli-redis\n"
|
|
|
printf " rccontrol cli-redis --help | -h\n"
|
|
|
echo
|
|
|
|
|
|
# :command.long_usage
|
|
|
if [[ -n $long_usage ]]; then
|
|
|
printf "Options:\n"
|
|
|
|
|
|
# :command.usage_fixed_flags
|
|
|
echo " --help, -h"
|
|
|
printf " Show this help\n"
|
|
|
echo
|
|
|
|
|
|
fi
|
|
|
}
|
|
|
|
|
|
# :command.usage
|
|
|
rccontrol_cli_db_usage() {
|
|
|
if [[ -n $long_usage ]]; then
|
|
|
printf "rccontrol cli-db - CLI\n"
|
|
|
echo
|
|
|
|
|
|
else
|
|
|
printf "rccontrol cli-db - CLI\n"
|
|
|
echo
|
|
|
|
|
|
fi
|
|
|
|
|
|
printf "Usage:\n"
|
|
|
printf " rccontrol cli-db\n"
|
|
|
printf " rccontrol cli-db --help | -h\n"
|
|
|
echo
|
|
|
|
|
|
# :command.long_usage
|
|
|
if [[ -n $long_usage ]]; then
|
|
|
printf "Options:\n"
|
|
|
|
|
|
# :command.usage_fixed_flags
|
|
|
echo " --help, -h"
|
|
|
printf " Show this help\n"
|
|
|
echo
|
|
|
|
|
|
fi
|
|
|
}
|
|
|
|
|
|
# :command.usage
|
|
|
rccontrol_cli_db_upgrade_usage() {
|
|
|
if [[ -n $long_usage ]]; then
|
|
|
printf "rccontrol cli-db-upgrade - CLI\n"
|
|
|
echo
|
|
|
|
|
|
else
|
|
|
printf "rccontrol cli-db-upgrade - CLI\n"
|
|
|
echo
|
|
|
|
|
|
fi
|
|
|
|
|
|
printf "Usage:\n"
|
|
|
printf " rccontrol cli-db-upgrade\n"
|
|
|
printf " rccontrol cli-db-upgrade --help | -h\n"
|
|
|
echo
|
|
|
|
|
|
# :command.long_usage
|
|
|
if [[ -n $long_usage ]]; then
|
|
|
printf "Options:\n"
|
|
|
|
|
|
# :command.usage_fixed_flags
|
|
|
echo " --help, -h"
|
|
|
printf " Show this help\n"
|
|
|
echo
|
|
|
|
|
|
fi
|
|
|
}
|
|
|
|
|
|
# :command.usage
|
|
|
rccontrol__completions_usage() {
|
|
|
if [[ -n $long_usage ]]; then
|
|
|
printf "rccontrol _completions - Generate completions, eval "$(./rccontrol _completions)"\n"
|
|
|
echo
|
|
|
|
|
|
else
|
|
|
printf "rccontrol _completions - Generate completions, eval "$(./rccontrol _completions)"\n"
|
|
|
echo
|
|
|
|
|
|
fi
|
|
|
|
|
|
printf "Usage:\n"
|
|
|
printf " rccontrol _completions\n"
|
|
|
printf " rccontrol _completions --help | -h\n"
|
|
|
echo
|
|
|
|
|
|
# :command.long_usage
|
|
|
if [[ -n $long_usage ]]; then
|
|
|
printf "Options:\n"
|
|
|
|
|
|
# :command.usage_fixed_flags
|
|
|
echo " --help, -h"
|
|
|
printf " Show this help\n"
|
|
|
echo
|
|
|
|
|
|
fi
|
|
|
}
|
|
|
|
|
|
# :command.usage
|
|
|
rccontrol_backup_db_usage() {
|
|
|
if [[ -n $long_usage ]]; then
|
|
|
printf "rccontrol backup-db - CLI\n"
|
|
|
echo
|
|
|
|
|
|
else
|
|
|
printf "rccontrol backup-db - CLI\n"
|
|
|
echo
|
|
|
|
|
|
fi
|
|
|
|
|
|
printf "Usage:\n"
|
|
|
printf " rccontrol backup-db\n"
|
|
|
printf " rccontrol backup-db --help | -h\n"
|
|
|
echo
|
|
|
|
|
|
# :command.long_usage
|
|
|
if [[ -n $long_usage ]]; then
|
|
|
printf "Options:\n"
|
|
|
|
|
|
# :command.usage_fixed_flags
|
|
|
echo " --help, -h"
|
|
|
printf " Show this help\n"
|
|
|
echo
|
|
|
|
|
|
# :command.usage_examples
|
|
|
printf "Examples:\n"
|
|
|
printf " ./rccontrol backup-db\n"
|
|
|
echo
|
|
|
|
|
|
fi
|
|
|
}
|
|
|
|
|
|
# :command.usage
|
|
|
rccontrol_backup_data_usage() {
|
|
|
if [[ -n $long_usage ]]; then
|
|
|
printf "rccontrol backup-data - CLI\n"
|
|
|
echo
|
|
|
|
|
|
else
|
|
|
printf "rccontrol backup-data - CLI\n"
|
|
|
echo
|
|
|
|
|
|
fi
|
|
|
|
|
|
printf "Usage:\n"
|
|
|
printf " rccontrol backup-data\n"
|
|
|
printf " rccontrol backup-data --help | -h\n"
|
|
|
echo
|
|
|
|
|
|
# :command.long_usage
|
|
|
if [[ -n $long_usage ]]; then
|
|
|
printf "Options:\n"
|
|
|
|
|
|
# :command.usage_fixed_flags
|
|
|
echo " --help, -h"
|
|
|
printf " Show this help\n"
|
|
|
echo
|
|
|
|
|
|
fi
|
|
|
}
|
|
|
|
|
|
# :command.normalize_input
|
|
|
normalize_input() {
|
|
|
local arg flags
|
|
|
|
|
|
while [[ $# -gt 0 ]]; do
|
|
|
arg="$1"
|
|
|
if [[ $arg =~ ^(--[a-zA-Z0-9_\-]+)=(.+)$ ]]; then
|
|
|
input+=("${BASH_REMATCH[1]}")
|
|
|
input+=("${BASH_REMATCH[2]}")
|
|
|
elif [[ $arg =~ ^(-[a-zA-Z0-9])=(.+)$ ]]; then
|
|
|
input+=("${BASH_REMATCH[1]}")
|
|
|
input+=("${BASH_REMATCH[2]}")
|
|
|
elif [[ $arg =~ ^-([a-zA-Z0-9][a-zA-Z0-9]+)$ ]]; then
|
|
|
flags="${BASH_REMATCH[1]}"
|
|
|
for (( i=0 ; i < ${#flags} ; i++ )); do
|
|
|
input+=("-${flags:i:1}")
|
|
|
done
|
|
|
else
|
|
|
input+=("$arg")
|
|
|
fi
|
|
|
|
|
|
shift
|
|
|
done
|
|
|
}
|
|
|
# :command.inspect_args
|
|
|
inspect_args() {
|
|
|
readarray -t sorted_keys < <(printf '%s\n' "${!args[@]}" | sort)
|
|
|
if (( ${#args[@]} )); then
|
|
|
echo args:
|
|
|
for k in "${sorted_keys[@]}"; do echo "- \${args[$k]} = ${args[$k]}"; done
|
|
|
else
|
|
|
echo args: none
|
|
|
fi
|
|
|
|
|
|
if (( ${#other_args[@]} )); then
|
|
|
echo
|
|
|
echo other_args:
|
|
|
echo "- \${other_args[*]} = ${other_args[*]}"
|
|
|
for i in "${!other_args[@]}"; do
|
|
|
echo "- \${other_args[$i]} = ${other_args[$i]}"
|
|
|
done
|
|
|
fi
|
|
|
}
|
|
|
|
|
|
# :command.user_lib
|
|
|
# src/lib/colors.sh
|
|
|
print_in_color() {
|
|
|
local color="$1"
|
|
|
shift
|
|
|
if [[ -z ${NO_COLOR+x} ]]; then
|
|
|
printf "$color%b\e[0m\n" "$*";
|
|
|
else
|
|
|
printf "%b\n" "$*";
|
|
|
fi
|
|
|
}
|
|
|
|
|
|
red() { print_in_color "\e[31m" "$*"; }
|
|
|
green() { print_in_color "\e[32m" "$*"; }
|
|
|
yellow() { print_in_color "\e[33m" "$*"; }
|
|
|
blue() { print_in_color "\e[34m" "$*"; }
|
|
|
magenta() { print_in_color "\e[35m" "$*"; }
|
|
|
cyan() { print_in_color "\e[36m" "$*"; }
|
|
|
bold() { print_in_color "\e[1m" "$*"; }
|
|
|
underlined() { print_in_color "\e[4m" "$*"; }
|
|
|
red_bold() { print_in_color "\e[1;31m" "$*"; }
|
|
|
green_bold() { print_in_color "\e[1;32m" "$*"; }
|
|
|
yellow_bold() { print_in_color "\e[1;33m" "$*"; }
|
|
|
blue_bold() { print_in_color "\e[1;34m" "$*"; }
|
|
|
magenta_bold() { print_in_color "\e[1;35m" "$*"; }
|
|
|
cyan_bold() { print_in_color "\e[1;36m" "$*"; }
|
|
|
red_underlined() { print_in_color "\e[4;31m" "$*"; }
|
|
|
green_underlined() { print_in_color "\e[4;32m" "$*"; }
|
|
|
yellow_underlined() { print_in_color "\e[4;33m" "$*"; }
|
|
|
blue_underlined() { print_in_color "\e[4;34m" "$*"; }
|
|
|
magenta_underlined() { print_in_color "\e[4;35m" "$*"; }
|
|
|
cyan_underlined() { print_in_color "\e[4;36m" "$*"; }
|
|
|
|
|
|
# src/lib/config.sh
|
|
|
config_init() {
|
|
|
CONFIG_FILE=${CONFIG_FILE:=config.ini}
|
|
|
[[ -f "$CONFIG_FILE" ]] || touch "$CONFIG_FILE"
|
|
|
}
|
|
|
|
|
|
config_get() {
|
|
|
local key=$1
|
|
|
local regex="^$key *= *(.+)$"
|
|
|
local value=""
|
|
|
|
|
|
config_init
|
|
|
|
|
|
while IFS= read -r line || [ -n "$line" ]; do
|
|
|
if [[ $line =~ $regex ]]; then
|
|
|
value="${BASH_REMATCH[1]}"
|
|
|
break
|
|
|
fi
|
|
|
done < "$CONFIG_FILE"
|
|
|
|
|
|
echo "$value"
|
|
|
}
|
|
|
|
|
|
config_set() {
|
|
|
local key=$1
|
|
|
shift
|
|
|
local value="$*"
|
|
|
|
|
|
config_init
|
|
|
|
|
|
local regex="^($key) *= *.+$"
|
|
|
local output=""
|
|
|
local found_key=""
|
|
|
local newline
|
|
|
|
|
|
while IFS= read -r line || [ -n "$line" ]; do
|
|
|
newline=$line
|
|
|
if [[ $line =~ $regex ]]; then
|
|
|
found_key="${BASH_REMATCH[1]}"
|
|
|
newline="$key = $value"
|
|
|
output="$output$newline\n"
|
|
|
elif [[ $line ]]; then
|
|
|
output="$output$line\n"
|
|
|
fi
|
|
|
done < "$CONFIG_FILE"
|
|
|
|
|
|
if [[ -z $found_key ]]; then
|
|
|
output="$output$key = $value\n"
|
|
|
fi
|
|
|
|
|
|
printf "%b\n" "$output" > "$CONFIG_FILE"
|
|
|
}
|
|
|
|
|
|
config_del() {
|
|
|
local key=$1
|
|
|
|
|
|
local regex="^($key) *="
|
|
|
local output=""
|
|
|
|
|
|
config_init
|
|
|
|
|
|
while IFS= read -r line || [ -n "$line" ]; do
|
|
|
if [[ $line ]] && [[ ! $line =~ $regex ]]; then
|
|
|
output="$output$line\n"
|
|
|
fi
|
|
|
done < "$CONFIG_FILE"
|
|
|
|
|
|
printf "%b\n" "$output" > "$CONFIG_FILE"
|
|
|
}
|
|
|
|
|
|
config_show() {
|
|
|
config_init
|
|
|
cat "$CONFIG_FILE"
|
|
|
}
|
|
|
|
|
|
config_keys() {
|
|
|
local regex="^([a-zA-Z0-9_\-\/\.]+) *="
|
|
|
|
|
|
config_init
|
|
|
|
|
|
local keys=()
|
|
|
local key
|
|
|
|
|
|
while IFS= read -r line || [ -n "$line" ]; do
|
|
|
if [[ $line =~ $regex ]]; then
|
|
|
key="${BASH_REMATCH[1]}"
|
|
|
keys+=("$key")
|
|
|
fi
|
|
|
done < "$CONFIG_FILE"
|
|
|
echo "${keys[@]}"
|
|
|
}
|
|
|
|
|
|
config_has_key() {
|
|
|
[[ $(config_get "$1") ]]
|
|
|
}
|
|
|
|
|
|
# src/lib/sample_function.sh
|
|
|
|
|
|
docker_ping_host() {
|
|
|
PING_HOST="$1"
|
|
|
docker run --network rhodecode_network --rm alpine ping "$PING_HOST"
|
|
|
}
|
|
|
|
|
|
check_bootstrap() {
|
|
|
# Avoid destroying bootstrapping by simple start/stop
|
|
|
if [[ ! -e $BOOTSTRAP_FILE ]]; then
|
|
|
echo "$(yellow WARNING:) initial bootstrap file $BOOTSTRAP_FILE not found !"
|
|
|
echo "$(yellow NOTICE:) Please run ./rccontrol bootstrap first"
|
|
|
exit
|
|
|
fi
|
|
|
}
|
|
|
|
|
|
# src/lib/send_completions.sh
|
|
|
send_completions() {
|
|
|
echo $'# rccontrol3 completion -*- shell-script -*-'
|
|
|
echo $''
|
|
|
echo $'# This bash completions script was generated by'
|
|
|
echo $'# completely (https://github.com/dannyben/completely)'
|
|
|
echo $'# Modifying it manually is not recommended'
|
|
|
echo $''
|
|
|
echo $'_rccontrol3_completions_filter() {'
|
|
|
echo $' local words="$1"'
|
|
|
echo $' local cur=${COMP_WORDS[COMP_CWORD]}'
|
|
|
echo $' local result=()'
|
|
|
echo $''
|
|
|
echo $' if [[ "${cur:0:1}" == "-" ]]; then'
|
|
|
echo $' echo "$words"'
|
|
|
echo $' '
|
|
|
echo $' else'
|
|
|
echo $' for word in $words; do'
|
|
|
echo $' [[ "${word:0:1}" != "-" ]] && result+=("$word")'
|
|
|
echo $' done'
|
|
|
echo $''
|
|
|
echo $' echo "${result[*]}"'
|
|
|
echo $''
|
|
|
echo $' fi'
|
|
|
echo $'}'
|
|
|
echo $''
|
|
|
echo $'_rccontrol3_completions() {'
|
|
|
echo $' local cur=${COMP_WORDS[COMP_CWORD]}'
|
|
|
echo $' local compwords=("${COMP_WORDS[@]:1:$COMP_CWORD-1}")'
|
|
|
echo $' local compline="${compwords[*]}"'
|
|
|
echo $''
|
|
|
echo $' case "$compline" in'
|
|
|
echo $' \'upgrade-source\'*)'
|
|
|
echo $' while read -r; do COMPREPLY+=( "$REPLY" ); done < <( compgen -W "$(_rccontrol3_completions_filter "--auth-token --help --server-url -h")" -- "$cur" )'
|
|
|
echo $' ;;'
|
|
|
echo $''
|
|
|
echo $' \'build-source\'*)'
|
|
|
echo $' while read -r; do COMPREPLY+=( "$REPLY" ); done < <( compgen -W "$(_rccontrol3_completions_filter "--help --version-name -h")" -- "$cur" )'
|
|
|
echo $' ;;'
|
|
|
echo $''
|
|
|
echo $' \'self-update\'*)'
|
|
|
echo $' while read -r; do COMPREPLY+=( "$REPLY" ); done < <( compgen -W "$(_rccontrol3_completions_filter "--auth-token --help --server-url -h")" -- "$cur" )'
|
|
|
echo $' ;;'
|
|
|
echo $''
|
|
|
echo $' \'bootstrap\'*)'
|
|
|
echo $' while read -r; do COMPREPLY+=( "$REPLY" ); done < <( compgen -W "$(_rccontrol3_completions_filter "--auth-token --force --help --server-url -f -h")" -- "$cur" )'
|
|
|
echo $' ;;'
|
|
|
echo $''
|
|
|
echo $' \'build\'*)'
|
|
|
echo $' while read -r; do COMPREPLY+=( "$REPLY" ); done < <( compgen -W "$(_rccontrol3_completions_filter "--help --version-name -h")" -- "$cur" )'
|
|
|
echo $' ;;'
|
|
|
echo $''
|
|
|
echo $' \'stack\'*)'
|
|
|
echo $' while read -r; do COMPREPLY+=( "$REPLY" ); done < <( compgen -W "$(_rccontrol3_completions_filter "--help -h metrics rhodecode router services")" -- "$cur" )'
|
|
|
echo $' ;;'
|
|
|
echo $''
|
|
|
echo $' *)'
|
|
|
echo $' while read -r; do COMPREPLY+=( "$REPLY" ); done < <( compgen -W "$(_rccontrol3_completions_filter "--help --version -h -v bootstrap build build-source self-update stack upgrade-source")" -- "$cur" )'
|
|
|
echo $' ;;'
|
|
|
echo $''
|
|
|
echo $' esac'
|
|
|
echo $'} &&'
|
|
|
echo $'complete -F _rccontrol3_completions rccontrol3'
|
|
|
echo $''
|
|
|
echo $'# ex: filetype=sh'
|
|
|
}
|
|
|
|
|
|
# src/lib/validate_stack_exists.sh
|
|
|
|
|
|
validate_stack_exists() {
|
|
|
err=""
|
|
|
invalid="1"
|
|
|
|
|
|
for item in $VALID_SERVICES
|
|
|
do
|
|
|
if [ "$1" == "$item" ]; then
|
|
|
invalid=""
|
|
|
break
|
|
|
fi
|
|
|
done
|
|
|
|
|
|
if [[ -n $invalid ]]; then
|
|
|
err="command '$1' not in list of $VALID_SERVICES"
|
|
|
fi
|
|
|
|
|
|
echo $err
|
|
|
}
|
|
|
|
|
|
# :command.command_functions
|
|
|
# :command.function
|
|
|
rccontrol_self_update_command() {
|
|
|
# src/self_update_command.sh
|
|
|
check_bootstrap
|
|
|
|
|
|
echo "# this file is located in 'src/self_update_command.sh'"
|
|
|
echo "# code for 'rccontrol3 self-update' goes here"
|
|
|
echo "# you can edit it freely and regenerate (it will not be overwritten)"
|
|
|
inspect_args
|
|
|
|
|
|
}
|
|
|
|
|
|
# :command.function
|
|
|
rccontrol_bootstrap_command() {
|
|
|
# src/bootstrap_command.sh
|
|
|
DEBUG=${args[--debug]}
|
|
|
force=${args[--force]}
|
|
|
|
|
|
check_bash_version() {
|
|
|
|
|
|
if [ ! "${BASH_VERSINFO:-0}" -ge 4 ]; then
|
|
|
echo "$(red Bash version 4 or greater is required, please update your bash version!)"
|
|
|
exit
|
|
|
fi
|
|
|
}
|
|
|
|
|
|
check_docker() {
|
|
|
(which docker || which docker.io) &>/dev/null
|
|
|
}
|
|
|
|
|
|
check_and_install_docker() {
|
|
|
failMsg="Failed to find docker on your PATH"
|
|
|
|
|
|
if ! check_docker; then
|
|
|
echo "$failMsg"
|
|
|
read -p "Enter to install Docker directly from https://get.docker.com/ or Ctrl+C to exit"
|
|
|
curl https://get.docker.com/ | sh
|
|
|
|
|
|
if ! check_docker; then
|
|
|
echo "$failMsg"
|
|
|
echo "Docker install failed. Quitting."
|
|
|
exit
|
|
|
fi
|
|
|
fi
|
|
|
}
|
|
|
|
|
|
docker_bootstrap() {
|
|
|
check_and_install_docker
|
|
|
echo 'Docker: Running bootstrap.'
|
|
|
|
|
|
echo "Docker: creating network 'rc_datavolume'"
|
|
|
docker volume create --name=rc_datavolume
|
|
|
echo "Docker: done"
|
|
|
echo ""
|
|
|
|
|
|
echo "Docker: creating network 'rhodecode_network'"
|
|
|
docker network inspect rhodecode_network >/dev/null 2>&1 || docker network create rhodecode_network
|
|
|
echo "Docker: done"
|
|
|
echo ""
|
|
|
|
|
|
echo "Docker: creating loki logging"
|
|
|
loki_driver=$(docker plugin ls --format {{.Name}} --filter enabled=true | grep loki || echo "")
|
|
|
if [[ $loki_driver == "" ]]; then
|
|
|
docker plugin install grafana/loki-docker-driver:latest --alias loki --grant-all-permissions
|
|
|
else
|
|
|
echo "Docker: loki driver already exists"
|
|
|
fi
|
|
|
}
|
|
|
|
|
|
definitions_bootstrap() {
|
|
|
|
|
|
SOURCE_DIR=$PWD
|
|
|
RHODECODE_DOCKER_HASH='master'
|
|
|
|
|
|
AUTH_TOKEN=${args[--auth-token]}
|
|
|
SERVER_URL=${args[--server-url]}
|
|
|
|
|
|
DEFINITIONS_EXIST=""
|
|
|
CHECK_FILES="rccontrol .env docker-compose-services.yaml docker-compose-apps.yaml"
|
|
|
for check_file in $CHECK_FILES; do
|
|
|
if [[ -f "$check_file" ]]; then
|
|
|
DEFINITIONS_EXIST="1"
|
|
|
fi
|
|
|
done
|
|
|
|
|
|
if [[ -n $DEFINITIONS_EXIST && ! $force ]]; then
|
|
|
echo "$(yellow skipping docker defs creation, existing files found. Use --force to create them anyway)"
|
|
|
return
|
|
|
fi
|
|
|
|
|
|
if [[ -n $DEFINITIONS_EXIST ]]; then
|
|
|
echo "$(yellow docker definitions exists, are you sure to force re-create them?)"
|
|
|
while true; do
|
|
|
read -p "Would you like to continue with overriding file? [yn] " yn
|
|
|
case $yn in
|
|
|
[Yy]*) return 2 ;;
|
|
|
[Nn]*) exit ;;
|
|
|
*) echo "Please answer y or n." ;;
|
|
|
esac
|
|
|
done
|
|
|
fi
|
|
|
|
|
|
exit
|
|
|
|
|
|
# download sources
|
|
|
echo "Files: download rhodecode docker definitions from $SERVER_URL"
|
|
|
echo ""
|
|
|
|
|
|
if [ $DEBUG ]; then
|
|
|
echo "downloading: $SERVER_URL/rhodecode-enterprise-docker/archive/$RHODECODE_DOCKER_HASH.tgz?with_hash=0"
|
|
|
curl --header "X-Rc-Auth-Token: $AUTH_TOKEN" -L $SERVER_URL/rhodecode-enterprise-docker/archive/$RHODECODE_DOCKER_HASH.tgz?with_hash=0 | tar -xz -C $SOURCE_DIR
|
|
|
|
|
|
echo "running CP $SOURCE_DIR/*rhodecode-enterprise-docker-plain/* $SOURCE_DIR"
|
|
|
cp -v -r -f --update --backup=numbered $SOURCE_DIR/*rhodecode-enterprise-docker-plain/* $SOURCE_DIR
|
|
|
|
|
|
echo "removing $SOURCE_DIR/*rhodecode-enterprise-docker-plain"
|
|
|
rm -r $SOURCE_DIR/*rhodecode-enterprise-docker-plain
|
|
|
else
|
|
|
curl -s --header "X-Rc-Auth-Token: $AUTH_TOKEN" -L $SERVER_URL/rhodecode-enterprise-docker/archive/$RHODECODE_DOCKER_HASH.tgz?with_hash=0 | tar -xz -C $SOURCE_DIR
|
|
|
|
|
|
cp -r -f --update --backup=numbered $SOURCE_DIR/*rhodecode-enterprise-docker-plain/* $SOURCE_DIR
|
|
|
|
|
|
rm -r $SOURCE_DIR/*rhodecode-enterprise-docker-plain
|
|
|
fi
|
|
|
|
|
|
echo "$(green_bold DONE: docker definitions extracted to $SOURCE_DIR)"
|
|
|
}
|
|
|
|
|
|
config_bootstrap() {
|
|
|
|
|
|
if [[ ! -f "$CONFIG_FILE" ]]; then
|
|
|
echo "init config at: $CONFIG_FILE"
|
|
|
config_init
|
|
|
else
|
|
|
echo "re-using config at: $CONFIG_FILE"
|
|
|
fi
|
|
|
|
|
|
if ! config_has_key "rc_encrypted_secret" ; then
|
|
|
key=$(echo $RANDOM | md5sum | head -c 32)
|
|
|
config_set "rc_encrypted_secret" $key
|
|
|
fi
|
|
|
|
|
|
if ! config_has_key "rc_db_url" ; then
|
|
|
key=$(echo $RANDOM | md5sum | head -c 32)
|
|
|
config_set "rc_db_url" "postgresql://$DB_USER:$key@database/$DB_NAME"
|
|
|
fi
|
|
|
|
|
|
if ! config_has_key "rc_license_token" ; then
|
|
|
config_set "rc_license_token" abra-cada-bra1-rce4
|
|
|
fi
|
|
|
|
|
|
if ! config_has_key "rc_base_url" ; then
|
|
|
config_set "rc_base_url" http://docker-dev
|
|
|
fi
|
|
|
|
|
|
if ! config_has_key "rc_log_formatter" ; then
|
|
|
# json is another option
|
|
|
config_set "rc_log_formatter" generic
|
|
|
fi
|
|
|
|
|
|
if ! config_has_key "rc_use_celery" ; then
|
|
|
config_set "rc_use_celery" true
|
|
|
fi
|
|
|
|
|
|
BOOTSTRAP_RUNTIME_ENV=$PWD/.custom/.runtime.env
|
|
|
if [[ ! -f "$BOOTSTRAP_RUNTIME_ENV" ]]; then
|
|
|
echo "init runtime env config at: $BOOTSTRAP_RUNTIME_ENV"
|
|
|
touch BOOTSTRAP_RUNTIME_ENV
|
|
|
|
|
|
#ENV_EXPAND=""
|
|
|
for k in $(config_keys); do
|
|
|
k_upper=${k^^}
|
|
|
echo "$k_upper='$(config_get "$k")'" >> $BOOTSTRAP_RUNTIME_ENV
|
|
|
done
|
|
|
|
|
|
fi
|
|
|
}
|
|
|
|
|
|
cur_date=$(date '+%Y-%m-%d %H:%M:%S')
|
|
|
|
|
|
check_bash_version
|
|
|
|
|
|
if [[ ! -e $BOOTSTRAP_FILE ]]; then
|
|
|
echo "initial bootstrap file $BOOTSTRAP_FILE not found !"
|
|
|
|
|
|
docker_bootstrap
|
|
|
definitions_bootstrap
|
|
|
config_bootstrap
|
|
|
|
|
|
echo "$cur_date" > "$BOOTSTRAP_FILE"
|
|
|
|
|
|
else
|
|
|
if [ $force ]; then
|
|
|
|
|
|
docker_bootstrap $force
|
|
|
definitions_bootstrap $force ## TODO: remove old
|
|
|
config_bootstrap $force
|
|
|
|
|
|
echo "$cur_date" > "$BOOTSTRAP_FILE"
|
|
|
|
|
|
exit
|
|
|
fi
|
|
|
|
|
|
echo "bootstrap file $BOOTSTRAP_FILE was found add --force to force bootstrap"
|
|
|
fi
|
|
|
|
|
|
get_started
|
|
|
}
|
|
|
|
|
|
# :command.function
|
|
|
rccontrol_get_build_artifacts_command() {
|
|
|
# src/get_build_artifacts_command.sh
|
|
|
check_bootstrap
|
|
|
|
|
|
DEBUG=${args[--debug]}
|
|
|
AUTH=${args[--auth]}
|
|
|
INSTALLER_URL=${args[--installer-url]}
|
|
|
MANIFEST_URL=${args[--manifest-url]}
|
|
|
RC_VERSION=${args[--version-name]}
|
|
|
VER=$RC_VERSION
|
|
|
|
|
|
CACHE_DIR=$PWD/.cache
|
|
|
VER_REGEX="$VER+x86_64"
|
|
|
|
|
|
echo "Downloading Artifacts for version: $VER"
|
|
|
|
|
|
echo "1/4 Checking available downloads from MANIFEST file"
|
|
|
|
|
|
ARTS=$(curl -s $AUTH $MANIFEST_URL | grep --ignore-case "$VER_REGEX" | cut -d ' ' -f 2)
|
|
|
|
|
|
if [[ $DEBUG ]]; then
|
|
|
echo "DEBUG START"
|
|
|
curl -s $AUTH $MANIFEST_URL | grep --ignore-case "$VER_REGEX" || echo "no regex match"
|
|
|
curl -s $AUTH $MANIFEST_URL | grep --ignore-case "$VER_REGEX" | cut -d ' ' -f 2
|
|
|
echo "Found following artifacts:"
|
|
|
echo $ARTS
|
|
|
echo "DEBUG END"
|
|
|
fi
|
|
|
|
|
|
if [[ $ARTS == "" ]]; then
|
|
|
MSG="Failed to found any MANIFEST entries for version $VER make sure there exists release with that version or use --version to specify different version"
|
|
|
echo "$(red $MSG)"
|
|
|
exit
|
|
|
fi
|
|
|
|
|
|
echo "2/4 Downloading locale-archive"
|
|
|
curl -L https://dls.rhodecode.com/assets/locale-archive -J -O
|
|
|
mv -v locale-archive "$CACHE_DIR"
|
|
|
|
|
|
# vcsserver/ce/ee
|
|
|
echo "3/4 Downloading installer artifacts"
|
|
|
for url in $ARTS; do
|
|
|
echo "Downloading $url with $AUTH"
|
|
|
curl $AUTH --fail-early -L ${url} -J -O
|
|
|
done
|
|
|
|
|
|
#for url in $(curl -s $MANIFEST_URL | grep --ignore-case -E 'control.+\+x86_64' | cut -d ' ' -f 2); do
|
|
|
# echo "Downloading $url"
|
|
|
# curl -L ${url} -J -O
|
|
|
#done
|
|
|
|
|
|
echo "4/4 Downloading installer from $INSTALLER_URL"
|
|
|
curl $AUTH -L $INSTALLER_URL -J -O
|
|
|
|
|
|
INSTALLER=$(ls -Art RhodeCode-installer-* | tail -n 1)
|
|
|
if [[ -n $INSTALLER ]]; then
|
|
|
chmod +x "${INSTALLER}"
|
|
|
fi
|
|
|
|
|
|
echo "Copying artifacts into $CACHE_DIR"
|
|
|
|
|
|
mv -v "${INSTALLER}" $CACHE_DIR
|
|
|
mv -v *.bz2 $CACHE_DIR
|
|
|
ls -lh $CACHE_DIR
|
|
|
|
|
|
}
|
|
|
|
|
|
# :command.function
|
|
|
rccontrol_build_command() {
|
|
|
# src/build_command.sh
|
|
|
check_bootstrap
|
|
|
|
|
|
rc_version=${args[--version-name]}
|
|
|
export RC_VERSION=$rc_version
|
|
|
eval "echo INSTALLER BASED BUILDING${RC_VERSION}"
|
|
|
|
|
|
RC_VERSION=$rc_version ./rccontrol stack rhodecode build --progress plain rhodecode
|
|
|
|
|
|
}
|
|
|
|
|
|
# :command.function
|
|
|
rccontrol_get_build_source_command() {
|
|
|
# src/get_build_source_command.sh
|
|
|
check_bootstrap
|
|
|
|
|
|
AUTH_TOKEN=${args[--auth-token]}
|
|
|
SERVER_URL=${args[--server-url]}
|
|
|
revision=${args[revision]}
|
|
|
|
|
|
SOURCE_DIR=$PWD/.source
|
|
|
|
|
|
RHODECODE_VCS_HASH=$revision
|
|
|
RHODECODE_CE_HASH=$revision
|
|
|
RHODECODE_EE_HASH=$revision
|
|
|
|
|
|
# download sources
|
|
|
echo "** download rhodecode source for build from $SERVER_URL **"
|
|
|
|
|
|
curl --header "X-Rc-Auth-Token: $AUTH_TOKEN" -L $SERVER_URL/rhodecode-vcsserver/archive/$RHODECODE_VCS_HASH.tgz?with_hash=0 | tar -xz -C $SOURCE_DIR
|
|
|
curl --header "X-Rc-Auth-Token: $AUTH_TOKEN" -L $SERVER_URL/rhodecode-enterprise-ce/archive/$RHODECODE_CE_HASH.tgz?with_hash=0 | tar -xz -C $SOURCE_DIR
|
|
|
#TODO: fix just CE build...
|
|
|
curl --header "X-Rc-Auth-Token: $AUTH_TOKEN" -L $SERVER_URL/rhodecode-enterprise-ee/archive/$RHODECODE_EE_HASH.tgz?with_hash=0 | tar -xz -C $SOURCE_DIR
|
|
|
|
|
|
rm -rf $SOURCE_DIR/rhodecode-vcsserver && mv $SOURCE_DIR/*rhodecode-vcsserver-plain $SOURCE_DIR/rhodecode-vcsserver
|
|
|
rm -rf $SOURCE_DIR/rhodecode-enterprise-ce && mv $SOURCE_DIR/*rhodecode-enterprise-ce-plain $SOURCE_DIR/rhodecode-enterprise-ce
|
|
|
rm -rf $SOURCE_DIR/rhodecode-enterprise-ee && cp -r $SOURCE_DIR/*rhodecode-enterprise-ee-plain $SOURCE_DIR/rhodecode-enterprise-ee
|
|
|
|
|
|
echo "downloading sources done to $SOURCE_DIR"
|
|
|
|
|
|
}
|
|
|
|
|
|
# :command.function
|
|
|
rccontrol_build_source_command() {
|
|
|
# src/build_source_command.sh
|
|
|
check_bootstrap
|
|
|
|
|
|
rc_version=${args[--version-name]}
|
|
|
export RC_VERSION=$rc_version
|
|
|
eval "echo SOURCE BASED BUILDING${RC_VERSION}"
|
|
|
|
|
|
RC_VERSION=$rc_version ./rccontrol stack rhodecode -f docker-compose-apps.source.yaml build --progress plain rhodecode
|
|
|
|
|
|
}
|
|
|
|
|
|
# :command.function
|
|
|
rccontrol_stack_command() {
|
|
|
# src/stack_command.sh
|
|
|
check_bootstrap
|
|
|
|
|
|
DEBUG=${args[--debug]}
|
|
|
service_name=${args[name]}
|
|
|
|
|
|
if [[ ! -f $RC_STACK_ROUTER_EXT ]]; then
|
|
|
RC_STACK_ROUTER_EXT=""
|
|
|
else
|
|
|
RC_STACK_ROUTER_EXT="-f $RC_STACK_ROUTER_EXT"
|
|
|
fi
|
|
|
|
|
|
CMD_ROUTER="\
|
|
|
docker compose \
|
|
|
--env-file $ENV_FILE \
|
|
|
$ENV_EXPAND \
|
|
|
-p rc_cluster_router \
|
|
|
-f docker-compose-base.yaml \
|
|
|
-f docker-compose-router.yaml $RC_STACK_ROUTER_EXT"
|
|
|
|
|
|
if [[ ! -f $RC_STACK_SERVICES_EXT ]]; then
|
|
|
RC_STACK_SERVICES_EXT_LCL=""
|
|
|
else
|
|
|
RC_STACK_SERVICES_EXT_LCL="-f $RC_STACK_SERVICES_EXT"
|
|
|
fi
|
|
|
|
|
|
RC_STACK_PROFILES="--profile postgres --profile redis --profile elasticsearch --profile channelstream"
|
|
|
|
|
|
CMD_SERVICES="\
|
|
|
docker compose \
|
|
|
--env-file $ENV_FILE \
|
|
|
$ENV_EXPAND \
|
|
|
$RC_STACK_PROFILES \
|
|
|
-p rc_cluster_services \
|
|
|
-f docker-compose-base.yaml \
|
|
|
-f docker-compose-services.yaml $RC_STACK_SERVICES_EXT_LCL"
|
|
|
|
|
|
if [[ ! -f $RC_STACK_METRICS_EXT ]]; then
|
|
|
RC_STACK_METRICS_EXT_LCL=""
|
|
|
else
|
|
|
RC_STACK_METRICS_EXT_LCL="-f $RC_STACK_METRICS_EXT"
|
|
|
fi
|
|
|
|
|
|
CMD_METRICS="\
|
|
|
docker compose \
|
|
|
--env-file $ENV_FILE \
|
|
|
$ENV_EXPAND \
|
|
|
-p rc_cluster_metrics \
|
|
|
-f docker-compose-base.yaml \
|
|
|
-f docker-compose-metrics.yaml $RC_STACK_METRICS_EXT_LCL"
|
|
|
|
|
|
if [[ ! -f $RC_STACK_RHODECODE_EXT ]]; then
|
|
|
RC_STACK_RHODECODE_EXT_LCL=""
|
|
|
else
|
|
|
RC_STACK_RHODECODE_EXT_LCL="-f $RC_STACK_RHODECODE_EXT"
|
|
|
fi
|
|
|
|
|
|
CMD_RHODECODE="\
|
|
|
docker compose \
|
|
|
--env-file $ENV_FILE \
|
|
|
$ENV_EXPAND \
|
|
|
-p rc_cluster_apps \
|
|
|
-f docker-compose-base.yaml \
|
|
|
-f docker-compose-apps.yaml $RC_STACK_RHODECODE_EXT_LCL"
|
|
|
|
|
|
CMD_RHODECODE_SOURCE="\
|
|
|
docker compose \
|
|
|
--env-file $ENV_FILE \
|
|
|
$ENV_EXPAND \
|
|
|
-p rc_cluster_apps \
|
|
|
-f docker-compose-base.yaml \
|
|
|
-f docker-compose-apps.yaml \
|
|
|
-f docker-compose-apps.source.yaml $RC_STACK_RHODECODE_EXT_LCL"
|
|
|
|
|
|
case $service_name in
|
|
|
|
|
|
services )
|
|
|
if [[ $DEBUG ]]; then
|
|
|
echo "---"
|
|
|
echo "stacks docker: $RC_STACK_SERVICES_EXT_LCL"
|
|
|
echo "running command: ${CMD_SERVICES}"
|
|
|
echo "ARGS: ${other_args[*]}"
|
|
|
echo "---"
|
|
|
fi
|
|
|
|
|
|
eval "${CMD_SERVICES} ${other_args[*]}"
|
|
|
exit
|
|
|
;;
|
|
|
router )
|
|
|
if [[ $DEBUG ]]; then
|
|
|
echo "---"
|
|
|
echo "stacks docker: $RC_STACK_ROUTER_EXT_LCL"
|
|
|
echo "running command: ${CMD_ROUTER}"
|
|
|
echo "ARGS: ${other_args[*]}"
|
|
|
echo "---"
|
|
|
fi
|
|
|
eval "${CMD_ROUTER} ${other_args[*]}"
|
|
|
exit
|
|
|
;;
|
|
|
metrics )
|
|
|
if [[ $DEBUG ]]; then
|
|
|
echo "---"
|
|
|
echo "stacks docker: $RC_STACK_METRICS_EXT_LCL"
|
|
|
echo "running command: ${CMD_METRICS}"
|
|
|
echo "ARGS: ${other_args[*]}"
|
|
|
echo "---"
|
|
|
fi
|
|
|
eval "${CMD_METRICS} ${other_args[*]}"
|
|
|
exit
|
|
|
;;
|
|
|
rhodecode )
|
|
|
if [[ $DEBUG ]]; then
|
|
|
echo "---"
|
|
|
echo "stacks docker: $RC_STACK_RHODECODE_EXT_LCL"
|
|
|
echo "running command: ${CMD_RHODECODE}"
|
|
|
echo "ARGS: ${other_args[*]}"
|
|
|
echo "---"
|
|
|
fi
|
|
|
eval "${CMD_RHODECODE} ${other_args[*]}"
|
|
|
exit
|
|
|
;;
|
|
|
esac
|
|
|
|
|
|
}
|
|
|
|
|
|
# :command.function
|
|
|
rccontrol_stack_status_command() {
|
|
|
# src/stack_status_command.sh
|
|
|
check_bootstrap
|
|
|
DEBUG=${args[--debug]}
|
|
|
if [[ $DEBUG ]]; then
|
|
|
echo "---"
|
|
|
|
|
|
ps_cmd=$(docker ps --filter=name=rc_cluster --format="{{.ID}}")
|
|
|
|
|
|
for service in $ps_cmd; do
|
|
|
|
|
|
servicename=`docker inspect --format '{{ .Name }}' $service`
|
|
|
servicename=${servicename:1}
|
|
|
echo $servicename
|
|
|
docker inspect $service --format='{{.State.Status}}: {{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}'
|
|
|
echo ""
|
|
|
|
|
|
done
|
|
|
fi
|
|
|
echo "---"
|
|
|
docker ps --filter=name=rc_cluster --format="table {{.ID}}\\t{{.Image}}\\t{{.Status}}\\t{{.Names}}\\t{{.Ports}}"
|
|
|
}
|
|
|
|
|
|
# :command.function
|
|
|
rccontrol_stack_upgrade_command() {
|
|
|
# src/stack_upgrade_command.sh
|
|
|
check_bootstrap
|
|
|
|
|
|
echo "# this file is located in 'src/stack_upgrade_command.sh'"
|
|
|
echo "# code for 'rccontrol stack-upgrade' goes here"
|
|
|
echo "# you can edit it freely and regenerate (it will not be overwritten)"
|
|
|
inspect_args
|
|
|
|
|
|
}
|
|
|
|
|
|
# :command.function
|
|
|
rccontrol_cli_redis_command() {
|
|
|
# src/cli_redis_command.sh
|
|
|
check_bootstrap
|
|
|
|
|
|
DEBUG=${args[--debug]}
|
|
|
|
|
|
target_container=rc_cluster_services-redis-1
|
|
|
docker_id=$(docker ps --filter name=$target_container -q)
|
|
|
|
|
|
if [[ $DEBUG ]]; then
|
|
|
echo "container id: $docker_id, based on $target_container filter"
|
|
|
docker ps
|
|
|
fi
|
|
|
|
|
|
if [ "$docker_id" == "" ]; then
|
|
|
MSG="Cannot find container ID with name $target_container"
|
|
|
echo "$(red $MSG)"
|
|
|
exit
|
|
|
fi
|
|
|
|
|
|
if [[ $DEBUG ]]; then
|
|
|
echo "Running |docker exec --interactive --tty $docker_id $CMD|"
|
|
|
echo "docker exec --interactive --tty $docker_id /bin/bash -c 'redis-cli'"
|
|
|
fi
|
|
|
|
|
|
eval "docker exec --interactive --tty $docker_id /bin/bash -c 'redis-cli'"
|
|
|
|
|
|
}
|
|
|
|
|
|
# :command.function
|
|
|
rccontrol_cli_db_command() {
|
|
|
# src/cli_db_command.sh
|
|
|
check_bootstrap
|
|
|
|
|
|
DEBUG=${args[--debug]}
|
|
|
|
|
|
target_container=rc_cluster_services-database-1
|
|
|
docker_id=$(docker ps --filter name=$target_container -q)
|
|
|
|
|
|
if [[ $DEBUG ]]; then
|
|
|
echo "container id: $docker_id, based on $target_container filter"
|
|
|
docker ps
|
|
|
fi
|
|
|
|
|
|
if [ "$docker_id" == "" ]; then
|
|
|
MSG="Cannot find container ID with name $target_container"
|
|
|
echo "$(red $MSG)"
|
|
|
exit
|
|
|
fi
|
|
|
|
|
|
if [[ $DEBUG ]]; then
|
|
|
echo "Running |docker exec --interactive --tty $docker_id $CMD|"
|
|
|
echo "docker exec --interactive --tty $docker_id /bin/bash -c 'PGPASSWORD=$DB_PASSWORD psql --username=$DB_USER --dbname=$DB_NAME'"
|
|
|
fi
|
|
|
|
|
|
eval "docker exec --interactive --tty $docker_id /bin/bash -c 'PGPASSWORD=$DB_PASSWORD psql --username=$DB_USER --dbname=$DB_NAME'"
|
|
|
|
|
|
}
|
|
|
|
|
|
# :command.function
|
|
|
rccontrol_cli_db_upgrade_command() {
|
|
|
# src/cli_db_upgrade_command.sh
|
|
|
check_bootstrap
|
|
|
|
|
|
DEBUG=${args[--debug]}
|
|
|
|
|
|
target_container=rc_cluster_apps-rhodecode-1
|
|
|
docker_id=$(docker ps --filter name=$target_container -q)
|
|
|
|
|
|
if [[ $DEBUG ]]; then
|
|
|
echo "container id: $docker_id, based on $target_container filter"
|
|
|
docker ps
|
|
|
fi
|
|
|
|
|
|
if [ "$docker_id" == "" ]; then
|
|
|
MSG="Cannot find container ID with name $target_container"
|
|
|
echo "$(red $MSG)"
|
|
|
exit
|
|
|
fi
|
|
|
|
|
|
if [[ $DEBUG ]]; then
|
|
|
echo "./rccontrol stack rhodecode exec rhodecode /usr/local/bin/rhodecode_bin/bin/rc-upgrade-db /etc/rhodecode/conf/rhodecode.optimized.ini --force-yes"
|
|
|
fi
|
|
|
|
|
|
./rccontrol stack rhodecode exec rhodecode /usr/local/bin/rhodecode_bin/bin/rc-upgrade-db /etc/rhodecode/conf/rhodecode.optimized.ini --force-yes
|
|
|
}
|
|
|
|
|
|
# :command.function
|
|
|
rccontrol__completions_command() {
|
|
|
# src/_completions_command.sh
|
|
|
send_completions
|
|
|
}
|
|
|
|
|
|
# :command.function
|
|
|
rccontrol_backup_db_command() {
|
|
|
# src/backup_db_command.sh
|
|
|
check_bootstrap
|
|
|
|
|
|
DEBUG=${args[--debug]}
|
|
|
DESTINATION=${args[destination]}
|
|
|
|
|
|
target_container=rc_cluster_services-database-1
|
|
|
|
|
|
docker_id=$(docker ps --filter name=$target_container -q)
|
|
|
backup_name=rc_db_dump-$(date +%Y-%m-%d).tar.gz
|
|
|
|
|
|
echo "creating backup $backup_name"
|
|
|
|
|
|
if [[ $DEBUG ]]; then
|
|
|
echo "container id: $docker_id, based on $target_container filter"
|
|
|
docker ps
|
|
|
echo "---"
|
|
|
fi
|
|
|
|
|
|
#image_id=$(docker inspect "$docker_id" --format {{.Image}} | cut -c 8-)
|
|
|
#
|
|
|
#if [[ $DEBUG ]]; then
|
|
|
# echo "image id: $image_id, based on $target_container filter"
|
|
|
# docker image ls
|
|
|
# echo "---"
|
|
|
#fi
|
|
|
|
|
|
if [ "$docker_id" == "" ]; then
|
|
|
MSG="Cannot find container ID with name $target_container"
|
|
|
echo "$(red $MSG)"
|
|
|
exit
|
|
|
fi
|
|
|
|
|
|
#if [ "image_id" == "" ]; then
|
|
|
# MSG="Cannot find image ID with name $target_container"
|
|
|
# echo "$(red $MSG)"
|
|
|
# exit
|
|
|
#fi
|
|
|
|
|
|
if [[ $DEBUG ]]; then
|
|
|
echo "docker exec -e PGPASSWORD=$DB_PASSWORD $docker_id /bin/bash -c 'pg_dump --inserts -U $DB_USER -h 127.0.0.1 --dbname=$DB_NAME | gzip > /var/rc-data-dump/$backup_name'"
|
|
|
fi
|
|
|
|
|
|
eval "docker exec -e PGPASSWORD=$DB_PASSWORD $docker_id /bin/bash -c 'pg_dump --inserts -U $DB_USER -h 127.0.0.1 --dbname=$DB_NAME | gzip > /var/rc-data-dump/$backup_name'"
|
|
|
echo "$(green Backup created in /var/rc-data-dump/ mount !)"
|
|
|
|
|
|
}
|
|
|
|
|
|
# :command.function
|
|
|
rccontrol_backup_data_command() {
|
|
|
# src/backup_data_command.sh
|
|
|
echo "# this file is located in 'src/backup_data_command.sh'"
|
|
|
echo "# code for 'rccontrol backup-data' goes here"
|
|
|
echo "# you can edit it freely and regenerate (it will not be overwritten)"
|
|
|
inspect_args
|
|
|
|
|
|
}
|
|
|
|
|
|
# :command.parse_requirements
|
|
|
parse_requirements() {
|
|
|
# :command.fixed_flags_filter
|
|
|
case "${1:-}" in
|
|
|
--version | -v )
|
|
|
version_command
|
|
|
exit
|
|
|
;;
|
|
|
|
|
|
--help | -h )
|
|
|
long_usage=yes
|
|
|
rccontrol_usage
|
|
|
exit
|
|
|
;;
|
|
|
|
|
|
# :flag.case
|
|
|
--debug )
|
|
|
|
|
|
# :flag.case_no_arg
|
|
|
args[--debug]=1
|
|
|
shift
|
|
|
;;
|
|
|
|
|
|
esac
|
|
|
|
|
|
# :command.environment_variables_filter
|
|
|
# :command.environment_variables_default
|
|
|
export RC_CLI_VERSION_NAME="${RC_CLI_VERSION_NAME:-4.27.0}"
|
|
|
export RC_STACK_ROUTER_EXT="${RC_STACK_ROUTER_EXT:-.custom/docker-compose-router.override.yaml}"
|
|
|
export RC_STACK_METRICS_EXT="${RC_STACK_METRICS_EXT:-.custom/docker-compose-metrics.override.yaml}"
|
|
|
export RC_STACK_SERVICES_EXT="${RC_STACK_SERVICES_EXT:-.custom/docker-compose-services.override.yaml}"
|
|
|
export RC_STACK_RHODECODE_EXT="${RC_STACK_RHODECODE_EXT:-.custom/docker-compose-apps.override.yaml}"
|
|
|
|
|
|
# :command.command_filter
|
|
|
action=${1:-}
|
|
|
|
|
|
case $action in
|
|
|
-* )
|
|
|
;;
|
|
|
|
|
|
self-update )
|
|
|
action="self-update"
|
|
|
shift
|
|
|
rccontrol_self_update_parse_requirements "$@"
|
|
|
shift $#
|
|
|
;;
|
|
|
|
|
|
bootstrap | install )
|
|
|
action="bootstrap"
|
|
|
shift
|
|
|
rccontrol_bootstrap_parse_requirements "$@"
|
|
|
shift $#
|
|
|
;;
|
|
|
|
|
|
get-build-artifacts )
|
|
|
action="get-build-artifacts"
|
|
|
shift
|
|
|
rccontrol_get_build_artifacts_parse_requirements "$@"
|
|
|
shift $#
|
|
|
;;
|
|
|
|
|
|
build )
|
|
|
action="build"
|
|
|
shift
|
|
|
rccontrol_build_parse_requirements "$@"
|
|
|
shift $#
|
|
|
;;
|
|
|
|
|
|
get-build-source )
|
|
|
action="get-build-source"
|
|
|
shift
|
|
|
rccontrol_get_build_source_parse_requirements "$@"
|
|
|
shift $#
|
|
|
;;
|
|
|
|
|
|
build-source )
|
|
|
action="build-source"
|
|
|
shift
|
|
|
rccontrol_build_source_parse_requirements "$@"
|
|
|
shift $#
|
|
|
;;
|
|
|
|
|
|
stack )
|
|
|
action="stack"
|
|
|
shift
|
|
|
rccontrol_stack_parse_requirements "$@"
|
|
|
shift $#
|
|
|
;;
|
|
|
|
|
|
stack-status | status )
|
|
|
action="stack-status"
|
|
|
shift
|
|
|
rccontrol_stack_status_parse_requirements "$@"
|
|
|
shift $#
|
|
|
;;
|
|
|
|
|
|
stack-upgrade )
|
|
|
action="stack-upgrade"
|
|
|
shift
|
|
|
rccontrol_stack_upgrade_parse_requirements "$@"
|
|
|
shift $#
|
|
|
;;
|
|
|
|
|
|
cli-redis )
|
|
|
action="cli-redis"
|
|
|
shift
|
|
|
rccontrol_cli_redis_parse_requirements "$@"
|
|
|
shift $#
|
|
|
;;
|
|
|
|
|
|
cli-db )
|
|
|
action="cli-db"
|
|
|
shift
|
|
|
rccontrol_cli_db_parse_requirements "$@"
|
|
|
shift $#
|
|
|
;;
|
|
|
|
|
|
cli-db-upgrade )
|
|
|
action="cli-db-upgrade"
|
|
|
shift
|
|
|
rccontrol_cli_db_upgrade_parse_requirements "$@"
|
|
|
shift $#
|
|
|
;;
|
|
|
|
|
|
_completions )
|
|
|
action="_completions"
|
|
|
shift
|
|
|
rccontrol__completions_parse_requirements "$@"
|
|
|
shift $#
|
|
|
;;
|
|
|
|
|
|
backup-db )
|
|
|
action="backup-db"
|
|
|
shift
|
|
|
rccontrol_backup_db_parse_requirements "$@"
|
|
|
shift $#
|
|
|
;;
|
|
|
|
|
|
backup-data )
|
|
|
action="backup-data"
|
|
|
shift
|
|
|
rccontrol_backup_data_parse_requirements "$@"
|
|
|
shift $#
|
|
|
;;
|
|
|
|
|
|
# :command.command_fallback
|
|
|
"" )
|
|
|
rccontrol_usage >&2
|
|
|
exit 1
|
|
|
;;
|
|
|
|
|
|
* )
|
|
|
printf "invalid command: %s\n" "$action" >&2
|
|
|
exit 1
|
|
|
;;
|
|
|
|
|
|
esac
|
|
|
|
|
|
# :command.parse_requirements_while
|
|
|
while [[ $# -gt 0 ]]; do
|
|
|
key="$1"
|
|
|
case "$key" in
|
|
|
|
|
|
-?* )
|
|
|
printf "invalid option: %s\n" "$key" >&2
|
|
|
exit 1
|
|
|
;;
|
|
|
|
|
|
* )
|
|
|
# :command.parse_requirements_case
|
|
|
# :command.parse_requirements_case_simple
|
|
|
printf "invalid argument: %s\n" "$key" >&2
|
|
|
exit 1
|
|
|
|
|
|
;;
|
|
|
|
|
|
esac
|
|
|
done
|
|
|
|
|
|
}
|
|
|
|
|
|
# :command.parse_requirements
|
|
|
rccontrol_self_update_parse_requirements() {
|
|
|
# :command.fixed_flags_filter
|
|
|
case "${1:-}" in
|
|
|
--help | -h )
|
|
|
long_usage=yes
|
|
|
rccontrol_self_update_usage
|
|
|
exit
|
|
|
;;
|
|
|
|
|
|
esac
|
|
|
|
|
|
# :command.dependencies_filter
|
|
|
if ! [[ -x "$(command -v curl)" ]]; then
|
|
|
printf "missing dependency: curl\n" >&2
|
|
|
exit 1
|
|
|
fi
|
|
|
if ! [[ -x "$(command -v tar)" ]]; then
|
|
|
printf "missing dependency: tar\n" >&2
|
|
|
exit 1
|
|
|
fi
|
|
|
|
|
|
# :command.command_filter
|
|
|
action="self-update"
|
|
|
|
|
|
# :command.parse_requirements_while
|
|
|
while [[ $# -gt 0 ]]; do
|
|
|
key="$1"
|
|
|
case "$key" in
|
|
|
# :flag.case
|
|
|
--auth-token )
|
|
|
|
|
|
# :flag.case_arg
|
|
|
if [[ -n ${2+x} ]]; then
|
|
|
|
|
|
args[--auth-token]="$2"
|
|
|
shift
|
|
|
shift
|
|
|
else
|
|
|
printf "%s\n" "--auth-token requires an argument: --auth-token AUTH_TOKEN" >&2
|
|
|
exit 1
|
|
|
fi
|
|
|
;;
|
|
|
|
|
|
# :flag.case
|
|
|
--server-url )
|
|
|
|
|
|
# :flag.case_arg
|
|
|
if [[ -n ${2+x} ]]; then
|
|
|
|
|
|
args[--server-url]="$2"
|
|
|
shift
|
|
|
shift
|
|
|
else
|
|
|
printf "%s\n" "--server-url requires an argument: --server-url SERVER_URL" >&2
|
|
|
exit 1
|
|
|
fi
|
|
|
;;
|
|
|
|
|
|
-?* )
|
|
|
printf "invalid option: %s\n" "$key" >&2
|
|
|
exit 1
|
|
|
;;
|
|
|
|
|
|
* )
|
|
|
# :command.parse_requirements_case
|
|
|
# :command.parse_requirements_case_simple
|
|
|
printf "invalid argument: %s\n" "$key" >&2
|
|
|
exit 1
|
|
|
|
|
|
;;
|
|
|
|
|
|
esac
|
|
|
done
|
|
|
|
|
|
# :command.default_assignments
|
|
|
[[ -n ${args[--server-url]:-} ]] || args[--server-url]="https://code.rhodecode.com"
|
|
|
|
|
|
}
|
|
|
|
|
|
# :command.parse_requirements
|
|
|
rccontrol_bootstrap_parse_requirements() {
|
|
|
# :command.fixed_flags_filter
|
|
|
case "${1:-}" in
|
|
|
--help | -h )
|
|
|
long_usage=yes
|
|
|
rccontrol_bootstrap_usage
|
|
|
exit
|
|
|
;;
|
|
|
|
|
|
esac
|
|
|
|
|
|
# :command.dependencies_filter
|
|
|
if ! [[ -x "$(command -v curl)" ]]; then
|
|
|
printf "missing dependency: curl\n" >&2
|
|
|
exit 1
|
|
|
fi
|
|
|
if ! [[ -x "$(command -v tar)" ]]; then
|
|
|
printf "missing dependency: tar\n" >&2
|
|
|
exit 1
|
|
|
fi
|
|
|
if ! [[ -x "$(command -v md5sum)" ]]; then
|
|
|
printf "missing dependency: md5sum\n" >&2
|
|
|
exit 1
|
|
|
fi
|
|
|
|
|
|
# :command.command_filter
|
|
|
action="bootstrap"
|
|
|
|
|
|
# :command.parse_requirements_while
|
|
|
while [[ $# -gt 0 ]]; do
|
|
|
key="$1"
|
|
|
case "$key" in
|
|
|
# :flag.case
|
|
|
--force | -f )
|
|
|
|
|
|
# :flag.case_no_arg
|
|
|
args[--force]=1
|
|
|
shift
|
|
|
;;
|
|
|
|
|
|
# :flag.case
|
|
|
--auth-token )
|
|
|
|
|
|
# :flag.case_arg
|
|
|
if [[ -n ${2+x} ]]; then
|
|
|
|
|
|
args[--auth-token]="$2"
|
|
|
shift
|
|
|
shift
|
|
|
else
|
|
|
printf "%s\n" "--auth-token requires an argument: --auth-token AUTH_TOKEN" >&2
|
|
|
exit 1
|
|
|
fi
|
|
|
;;
|
|
|
|
|
|
# :flag.case
|
|
|
--server-url )
|
|
|
|
|
|
# :flag.case_arg
|
|
|
if [[ -n ${2+x} ]]; then
|
|
|
|
|
|
args[--server-url]="$2"
|
|
|
shift
|
|
|
shift
|
|
|
else
|
|
|
printf "%s\n" "--server-url requires an argument: --server-url SERVER_URL" >&2
|
|
|
exit 1
|
|
|
fi
|
|
|
;;
|
|
|
|
|
|
-?* )
|
|
|
printf "invalid option: %s\n" "$key" >&2
|
|
|
exit 1
|
|
|
;;
|
|
|
|
|
|
* )
|
|
|
# :command.parse_requirements_case
|
|
|
# :command.parse_requirements_case_simple
|
|
|
printf "invalid argument: %s\n" "$key" >&2
|
|
|
exit 1
|
|
|
|
|
|
;;
|
|
|
|
|
|
esac
|
|
|
done
|
|
|
|
|
|
# :command.default_assignments
|
|
|
[[ -n ${args[--server-url]:-} ]] || args[--server-url]="https://code.rhodecode.com"
|
|
|
|
|
|
}
|
|
|
|
|
|
# :command.parse_requirements
|
|
|
rccontrol_get_build_artifacts_parse_requirements() {
|
|
|
# :command.fixed_flags_filter
|
|
|
case "${1:-}" in
|
|
|
--help | -h )
|
|
|
long_usage=yes
|
|
|
rccontrol_get_build_artifacts_usage
|
|
|
exit
|
|
|
;;
|
|
|
|
|
|
esac
|
|
|
|
|
|
# :command.command_filter
|
|
|
action="get-build-artifacts"
|
|
|
|
|
|
# :command.parse_requirements_while
|
|
|
while [[ $# -gt 0 ]]; do
|
|
|
key="$1"
|
|
|
case "$key" in
|
|
|
# :flag.case
|
|
|
--auth )
|
|
|
|
|
|
# :flag.case_arg
|
|
|
if [[ -n ${2+x} ]]; then
|
|
|
|
|
|
args[--auth]="$2"
|
|
|
shift
|
|
|
shift
|
|
|
else
|
|
|
printf "%s\n" "--auth requires an argument: --auth AUTH" >&2
|
|
|
exit 1
|
|
|
fi
|
|
|
;;
|
|
|
|
|
|
# :flag.case
|
|
|
--installer-url )
|
|
|
|
|
|
# :flag.case_arg
|
|
|
if [[ -n ${2+x} ]]; then
|
|
|
|
|
|
args[--installer-url]="$2"
|
|
|
shift
|
|
|
shift
|
|
|
else
|
|
|
printf "%s\n" "--installer-url requires an argument: --installer-url INSTALLER_URL" >&2
|
|
|
exit 1
|
|
|
fi
|
|
|
;;
|
|
|
|
|
|
# :flag.case
|
|
|
--manifest-url )
|
|
|
|
|
|
# :flag.case_arg
|
|
|
if [[ -n ${2+x} ]]; then
|
|
|
|
|
|
args[--manifest-url]="$2"
|
|
|
shift
|
|
|
shift
|
|
|
else
|
|
|
printf "%s\n" "--manifest-url requires an argument: --manifest-url MANIFEST_URL" >&2
|
|
|
exit 1
|
|
|
fi
|
|
|
;;
|
|
|
|
|
|
# :flag.case
|
|
|
--version-name )
|
|
|
|
|
|
# :flag.case_arg
|
|
|
if [[ -n ${2+x} ]]; then
|
|
|
|
|
|
args[--version-name]="$2"
|
|
|
shift
|
|
|
shift
|
|
|
else
|
|
|
printf "%s\n" "--version-name requires an argument: --version-name VERSION_NAME" >&2
|
|
|
exit 1
|
|
|
fi
|
|
|
;;
|
|
|
|
|
|
-?* )
|
|
|
printf "invalid option: %s\n" "$key" >&2
|
|
|
exit 1
|
|
|
;;
|
|
|
|
|
|
* )
|
|
|
# :command.parse_requirements_case
|
|
|
# :command.parse_requirements_case_simple
|
|
|
printf "invalid argument: %s\n" "$key" >&2
|
|
|
exit 1
|
|
|
|
|
|
;;
|
|
|
|
|
|
esac
|
|
|
done
|
|
|
|
|
|
# :command.default_assignments
|
|
|
[[ -n ${args[--auth]:-} ]] || args[--auth]=""
|
|
|
[[ -n ${args[--installer-url]:-} ]] || args[--installer-url]="https://dls.rhodecode.com/dls/N2E2ZTY1NzA3NjYxNDA2NTc1NjI3MTcyNzA2MjcxNzIyZTcwNjI3YQ==/rhodecode-control/latest-linux-ee"
|
|
|
[[ -n ${args[--manifest-url]:-} ]] || args[--manifest-url]="https://dls.rhodecode.com/linux/MANIFEST"
|
|
|
[[ -n ${args[--version-name]:-} ]] || args[--version-name]="$RC_CLI_VERSION_NAME"
|
|
|
|
|
|
}
|
|
|
|
|
|
# :command.parse_requirements
|
|
|
rccontrol_build_parse_requirements() {
|
|
|
# :command.fixed_flags_filter
|
|
|
case "${1:-}" in
|
|
|
--help | -h )
|
|
|
long_usage=yes
|
|
|
rccontrol_build_usage
|
|
|
exit
|
|
|
;;
|
|
|
|
|
|
esac
|
|
|
|
|
|
# :command.command_filter
|
|
|
action="build"
|
|
|
|
|
|
# :command.parse_requirements_while
|
|
|
while [[ $# -gt 0 ]]; do
|
|
|
key="$1"
|
|
|
case "$key" in
|
|
|
# :flag.case
|
|
|
--version-name )
|
|
|
|
|
|
# :flag.case_arg
|
|
|
if [[ -n ${2+x} ]]; then
|
|
|
|
|
|
args[--version-name]="$2"
|
|
|
shift
|
|
|
shift
|
|
|
else
|
|
|
printf "%s\n" "--version-name requires an argument: --version-name VERSION_NAME" >&2
|
|
|
exit 1
|
|
|
fi
|
|
|
;;
|
|
|
|
|
|
-?* )
|
|
|
printf "invalid option: %s\n" "$key" >&2
|
|
|
exit 1
|
|
|
;;
|
|
|
|
|
|
* )
|
|
|
# :command.parse_requirements_case
|
|
|
# :command.parse_requirements_case_simple
|
|
|
printf "invalid argument: %s\n" "$key" >&2
|
|
|
exit 1
|
|
|
|
|
|
;;
|
|
|
|
|
|
esac
|
|
|
done
|
|
|
|
|
|
# :command.default_assignments
|
|
|
[[ -n ${args[--version-name]:-} ]] || args[--version-name]="$RC_CLI_VERSION_NAME"
|
|
|
|
|
|
}
|
|
|
|
|
|
# :command.parse_requirements
|
|
|
rccontrol_get_build_source_parse_requirements() {
|
|
|
# :command.fixed_flags_filter
|
|
|
case "${1:-}" in
|
|
|
--help | -h )
|
|
|
long_usage=yes
|
|
|
rccontrol_get_build_source_usage
|
|
|
exit
|
|
|
;;
|
|
|
|
|
|
esac
|
|
|
|
|
|
# :command.dependencies_filter
|
|
|
if ! [[ -x "$(command -v curl)" ]]; then
|
|
|
printf "missing dependency: curl\n" >&2
|
|
|
exit 1
|
|
|
fi
|
|
|
if ! [[ -x "$(command -v tar)" ]]; then
|
|
|
printf "missing dependency: tar\n" >&2
|
|
|
exit 1
|
|
|
fi
|
|
|
|
|
|
# :command.command_filter
|
|
|
action="get-build-source"
|
|
|
|
|
|
# :command.parse_requirements_while
|
|
|
while [[ $# -gt 0 ]]; do
|
|
|
key="$1"
|
|
|
case "$key" in
|
|
|
# :flag.case
|
|
|
--auth-token )
|
|
|
|
|
|
# :flag.case_arg
|
|
|
if [[ -n ${2+x} ]]; then
|
|
|
|
|
|
args[--auth-token]="$2"
|
|
|
shift
|
|
|
shift
|
|
|
else
|
|
|
printf "%s\n" "--auth-token requires an argument: --auth-token AUTH_TOKEN" >&2
|
|
|
exit 1
|
|
|
fi
|
|
|
;;
|
|
|
|
|
|
# :flag.case
|
|
|
--server-url )
|
|
|
|
|
|
# :flag.case_arg
|
|
|
if [[ -n ${2+x} ]]; then
|
|
|
|
|
|
args[--server-url]="$2"
|
|
|
shift
|
|
|
shift
|
|
|
else
|
|
|
printf "%s\n" "--server-url requires an argument: --server-url SERVER_URL" >&2
|
|
|
exit 1
|
|
|
fi
|
|
|
;;
|
|
|
|
|
|
-?* )
|
|
|
printf "invalid option: %s\n" "$key" >&2
|
|
|
exit 1
|
|
|
;;
|
|
|
|
|
|
* )
|
|
|
# :command.parse_requirements_case
|
|
|
# :command.parse_requirements_case_simple
|
|
|
if [[ -z ${args[revision]+x} ]]; then
|
|
|
|
|
|
args[revision]=$1
|
|
|
shift
|
|
|
else
|
|
|
printf "invalid argument: %s\n" "$key" >&2
|
|
|
exit 1
|
|
|
fi
|
|
|
|
|
|
;;
|
|
|
|
|
|
esac
|
|
|
done
|
|
|
|
|
|
# :command.required_args_filter
|
|
|
if [[ -z ${args[revision]+x} ]]; then
|
|
|
printf "missing required argument: REVISION\nusage: rccontrol get-build-source REVISION [OPTIONS]\n" >&2
|
|
|
exit 1
|
|
|
fi
|
|
|
|
|
|
# :command.default_assignments
|
|
|
[[ -n ${args[--server-url]:-} ]] || args[--server-url]="https://code.rhodecode.com"
|
|
|
|
|
|
}
|
|
|
|
|
|
# :command.parse_requirements
|
|
|
rccontrol_build_source_parse_requirements() {
|
|
|
# :command.fixed_flags_filter
|
|
|
case "${1:-}" in
|
|
|
--help | -h )
|
|
|
long_usage=yes
|
|
|
rccontrol_build_source_usage
|
|
|
exit
|
|
|
;;
|
|
|
|
|
|
esac
|
|
|
|
|
|
# :command.command_filter
|
|
|
action="build-source"
|
|
|
|
|
|
# :command.parse_requirements_while
|
|
|
while [[ $# -gt 0 ]]; do
|
|
|
key="$1"
|
|
|
case "$key" in
|
|
|
# :flag.case
|
|
|
--version-name )
|
|
|
|
|
|
# :flag.case_arg
|
|
|
if [[ -n ${2+x} ]]; then
|
|
|
|
|
|
args[--version-name]="$2"
|
|
|
shift
|
|
|
shift
|
|
|
else
|
|
|
printf "%s\n" "--version-name requires an argument: --version-name VERSION_NAME" >&2
|
|
|
exit 1
|
|
|
fi
|
|
|
;;
|
|
|
|
|
|
-?* )
|
|
|
printf "invalid option: %s\n" "$key" >&2
|
|
|
exit 1
|
|
|
;;
|
|
|
|
|
|
* )
|
|
|
# :command.parse_requirements_case
|
|
|
# :command.parse_requirements_case_simple
|
|
|
printf "invalid argument: %s\n" "$key" >&2
|
|
|
exit 1
|
|
|
|
|
|
;;
|
|
|
|
|
|
esac
|
|
|
done
|
|
|
|
|
|
# :command.default_assignments
|
|
|
[[ -n ${args[--version-name]:-} ]] || args[--version-name]="$RC_CLI_VERSION_NAME"
|
|
|
|
|
|
}
|
|
|
|
|
|
# :command.parse_requirements
|
|
|
rccontrol_stack_parse_requirements() {
|
|
|
# :command.fixed_flags_filter
|
|
|
case "${1:-}" in
|
|
|
--help | -h )
|
|
|
long_usage=yes
|
|
|
rccontrol_stack_usage
|
|
|
exit
|
|
|
;;
|
|
|
|
|
|
esac
|
|
|
|
|
|
# :command.command_filter
|
|
|
action="stack"
|
|
|
|
|
|
# :command.parse_requirements_while
|
|
|
while [[ $# -gt 0 ]]; do
|
|
|
key="$1"
|
|
|
case "$key" in
|
|
|
|
|
|
-?* )
|
|
|
other_args+=("$1")
|
|
|
shift
|
|
|
;;
|
|
|
|
|
|
* )
|
|
|
# :command.parse_requirements_case
|
|
|
# :command.parse_requirements_case_catch_all
|
|
|
if [[ -z ${args[name]+x} ]]; then
|
|
|
|
|
|
args[name]=$1
|
|
|
shift
|
|
|
else
|
|
|
other_args+=("$1")
|
|
|
shift
|
|
|
fi
|
|
|
|
|
|
;;
|
|
|
|
|
|
esac
|
|
|
done
|
|
|
|
|
|
# :command.required_args_filter
|
|
|
if [[ -z ${args[name]+x} ]]; then
|
|
|
printf "missing required argument: NAME\nusage: rccontrol stack NAME [SERVICES PARAMS...]\n" >&2
|
|
|
exit 1
|
|
|
fi
|
|
|
|
|
|
# :command.whitelist_filter
|
|
|
if [[ ! ${args[name]} =~ ^(router|metrics|services|rhodecode)$ ]]; then
|
|
|
printf "%s\n" "name must be one of: router, metrics, services, rhodecode" >&2
|
|
|
exit 1
|
|
|
fi
|
|
|
|
|
|
}
|
|
|
|
|
|
# :command.parse_requirements
|
|
|
rccontrol_stack_status_parse_requirements() {
|
|
|
# :command.fixed_flags_filter
|
|
|
case "${1:-}" in
|
|
|
--help | -h )
|
|
|
long_usage=yes
|
|
|
rccontrol_stack_status_usage
|
|
|
exit
|
|
|
;;
|
|
|
|
|
|
esac
|
|
|
|
|
|
# :command.command_filter
|
|
|
action="stack-status"
|
|
|
|
|
|
# :command.parse_requirements_while
|
|
|
while [[ $# -gt 0 ]]; do
|
|
|
key="$1"
|
|
|
case "$key" in
|
|
|
|
|
|
-?* )
|
|
|
printf "invalid option: %s\n" "$key" >&2
|
|
|
exit 1
|
|
|
;;
|
|
|
|
|
|
* )
|
|
|
# :command.parse_requirements_case
|
|
|
# :command.parse_requirements_case_simple
|
|
|
printf "invalid argument: %s\n" "$key" >&2
|
|
|
exit 1
|
|
|
|
|
|
;;
|
|
|
|
|
|
esac
|
|
|
done
|
|
|
|
|
|
}
|
|
|
|
|
|
# :command.parse_requirements
|
|
|
rccontrol_stack_upgrade_parse_requirements() {
|
|
|
# :command.fixed_flags_filter
|
|
|
case "${1:-}" in
|
|
|
--help | -h )
|
|
|
long_usage=yes
|
|
|
rccontrol_stack_upgrade_usage
|
|
|
exit
|
|
|
;;
|
|
|
|
|
|
esac
|
|
|
|
|
|
# :command.command_filter
|
|
|
action="stack-upgrade"
|
|
|
|
|
|
# :command.parse_requirements_while
|
|
|
while [[ $# -gt 0 ]]; do
|
|
|
key="$1"
|
|
|
case "$key" in
|
|
|
|
|
|
-?* )
|
|
|
printf "invalid option: %s\n" "$key" >&2
|
|
|
exit 1
|
|
|
;;
|
|
|
|
|
|
* )
|
|
|
# :command.parse_requirements_case
|
|
|
# :command.parse_requirements_case_simple
|
|
|
printf "invalid argument: %s\n" "$key" >&2
|
|
|
exit 1
|
|
|
|
|
|
;;
|
|
|
|
|
|
esac
|
|
|
done
|
|
|
|
|
|
}
|
|
|
|
|
|
# :command.parse_requirements
|
|
|
rccontrol_cli_redis_parse_requirements() {
|
|
|
# :command.fixed_flags_filter
|
|
|
case "${1:-}" in
|
|
|
--help | -h )
|
|
|
long_usage=yes
|
|
|
rccontrol_cli_redis_usage
|
|
|
exit
|
|
|
;;
|
|
|
|
|
|
esac
|
|
|
|
|
|
# :command.command_filter
|
|
|
action="cli-redis"
|
|
|
|
|
|
# :command.parse_requirements_while
|
|
|
while [[ $# -gt 0 ]]; do
|
|
|
key="$1"
|
|
|
case "$key" in
|
|
|
|
|
|
-?* )
|
|
|
printf "invalid option: %s\n" "$key" >&2
|
|
|
exit 1
|
|
|
;;
|
|
|
|
|
|
* )
|
|
|
# :command.parse_requirements_case
|
|
|
# :command.parse_requirements_case_simple
|
|
|
printf "invalid argument: %s\n" "$key" >&2
|
|
|
exit 1
|
|
|
|
|
|
;;
|
|
|
|
|
|
esac
|
|
|
done
|
|
|
|
|
|
}
|
|
|
|
|
|
# :command.parse_requirements
|
|
|
rccontrol_cli_db_parse_requirements() {
|
|
|
# :command.fixed_flags_filter
|
|
|
case "${1:-}" in
|
|
|
--help | -h )
|
|
|
long_usage=yes
|
|
|
rccontrol_cli_db_usage
|
|
|
exit
|
|
|
;;
|
|
|
|
|
|
esac
|
|
|
|
|
|
# :command.command_filter
|
|
|
action="cli-db"
|
|
|
|
|
|
# :command.parse_requirements_while
|
|
|
while [[ $# -gt 0 ]]; do
|
|
|
key="$1"
|
|
|
case "$key" in
|
|
|
|
|
|
-?* )
|
|
|
printf "invalid option: %s\n" "$key" >&2
|
|
|
exit 1
|
|
|
;;
|
|
|
|
|
|
* )
|
|
|
# :command.parse_requirements_case
|
|
|
# :command.parse_requirements_case_simple
|
|
|
printf "invalid argument: %s\n" "$key" >&2
|
|
|
exit 1
|
|
|
|
|
|
;;
|
|
|
|
|
|
esac
|
|
|
done
|
|
|
|
|
|
}
|
|
|
|
|
|
# :command.parse_requirements
|
|
|
rccontrol_cli_db_upgrade_parse_requirements() {
|
|
|
# :command.fixed_flags_filter
|
|
|
case "${1:-}" in
|
|
|
--help | -h )
|
|
|
long_usage=yes
|
|
|
rccontrol_cli_db_upgrade_usage
|
|
|
exit
|
|
|
;;
|
|
|
|
|
|
esac
|
|
|
|
|
|
# :command.command_filter
|
|
|
action="cli-db-upgrade"
|
|
|
|
|
|
# :command.parse_requirements_while
|
|
|
while [[ $# -gt 0 ]]; do
|
|
|
key="$1"
|
|
|
case "$key" in
|
|
|
|
|
|
-?* )
|
|
|
printf "invalid option: %s\n" "$key" >&2
|
|
|
exit 1
|
|
|
;;
|
|
|
|
|
|
* )
|
|
|
# :command.parse_requirements_case
|
|
|
# :command.parse_requirements_case_simple
|
|
|
printf "invalid argument: %s\n" "$key" >&2
|
|
|
exit 1
|
|
|
|
|
|
;;
|
|
|
|
|
|
esac
|
|
|
done
|
|
|
|
|
|
}
|
|
|
|
|
|
# :command.parse_requirements
|
|
|
rccontrol__completions_parse_requirements() {
|
|
|
# :command.fixed_flags_filter
|
|
|
case "${1:-}" in
|
|
|
--help | -h )
|
|
|
long_usage=yes
|
|
|
rccontrol__completions_usage
|
|
|
exit
|
|
|
;;
|
|
|
|
|
|
esac
|
|
|
|
|
|
# :command.command_filter
|
|
|
action="_completions"
|
|
|
|
|
|
# :command.parse_requirements_while
|
|
|
while [[ $# -gt 0 ]]; do
|
|
|
key="$1"
|
|
|
case "$key" in
|
|
|
|
|
|
-?* )
|
|
|
printf "invalid option: %s\n" "$key" >&2
|
|
|
exit 1
|
|
|
;;
|
|
|
|
|
|
* )
|
|
|
# :command.parse_requirements_case
|
|
|
# :command.parse_requirements_case_simple
|
|
|
printf "invalid argument: %s\n" "$key" >&2
|
|
|
exit 1
|
|
|
|
|
|
;;
|
|
|
|
|
|
esac
|
|
|
done
|
|
|
|
|
|
}
|
|
|
|
|
|
# :command.parse_requirements
|
|
|
rccontrol_backup_db_parse_requirements() {
|
|
|
# :command.fixed_flags_filter
|
|
|
case "${1:-}" in
|
|
|
--help | -h )
|
|
|
long_usage=yes
|
|
|
rccontrol_backup_db_usage
|
|
|
exit
|
|
|
;;
|
|
|
|
|
|
esac
|
|
|
|
|
|
# :command.dependencies_filter
|
|
|
if ! [[ -x "$(command -v tar)" ]]; then
|
|
|
printf "missing dependency: tar\n" >&2
|
|
|
exit 1
|
|
|
fi
|
|
|
if ! [[ -x "$(command -v gzip)" ]]; then
|
|
|
printf "missing dependency: gzip\n" >&2
|
|
|
exit 1
|
|
|
fi
|
|
|
|
|
|
# :command.command_filter
|
|
|
action="backup-db"
|
|
|
|
|
|
# :command.parse_requirements_while
|
|
|
while [[ $# -gt 0 ]]; do
|
|
|
key="$1"
|
|
|
case "$key" in
|
|
|
|
|
|
-?* )
|
|
|
printf "invalid option: %s\n" "$key" >&2
|
|
|
exit 1
|
|
|
;;
|
|
|
|
|
|
* )
|
|
|
# :command.parse_requirements_case
|
|
|
# :command.parse_requirements_case_simple
|
|
|
printf "invalid argument: %s\n" "$key" >&2
|
|
|
exit 1
|
|
|
|
|
|
;;
|
|
|
|
|
|
esac
|
|
|
done
|
|
|
|
|
|
}
|
|
|
|
|
|
# :command.parse_requirements
|
|
|
rccontrol_backup_data_parse_requirements() {
|
|
|
# :command.fixed_flags_filter
|
|
|
case "${1:-}" in
|
|
|
--help | -h )
|
|
|
long_usage=yes
|
|
|
rccontrol_backup_data_usage
|
|
|
exit
|
|
|
;;
|
|
|
|
|
|
esac
|
|
|
|
|
|
# :command.dependencies_filter
|
|
|
if ! [[ -x "$(command -v tar)" ]]; then
|
|
|
printf "missing dependency: tar\n" >&2
|
|
|
exit 1
|
|
|
fi
|
|
|
|
|
|
# :command.command_filter
|
|
|
action="backup-data"
|
|
|
|
|
|
# :command.parse_requirements_while
|
|
|
while [[ $# -gt 0 ]]; do
|
|
|
key="$1"
|
|
|
case "$key" in
|
|
|
|
|
|
-?* )
|
|
|
printf "invalid option: %s\n" "$key" >&2
|
|
|
exit 1
|
|
|
;;
|
|
|
|
|
|
* )
|
|
|
# :command.parse_requirements_case
|
|
|
# :command.parse_requirements_case_simple
|
|
|
printf "invalid argument: %s\n" "$key" >&2
|
|
|
exit 1
|
|
|
|
|
|
;;
|
|
|
|
|
|
esac
|
|
|
done
|
|
|
|
|
|
}
|
|
|
|
|
|
# :command.initialize
|
|
|
initialize() {
|
|
|
version="4.28.0.REL20221101"
|
|
|
long_usage=''
|
|
|
set -e
|
|
|
|
|
|
# :command.environment_variables_default
|
|
|
export RC_CLI_VERSION_NAME="${RC_CLI_VERSION_NAME:-4.27.0}"
|
|
|
export RC_STACK_ROUTER_EXT="${RC_STACK_ROUTER_EXT:-.custom/docker-compose-router.override.yaml}"
|
|
|
export RC_STACK_METRICS_EXT="${RC_STACK_METRICS_EXT:-.custom/docker-compose-metrics.override.yaml}"
|
|
|
export RC_STACK_SERVICES_EXT="${RC_STACK_SERVICES_EXT:-.custom/docker-compose-services.override.yaml}"
|
|
|
export RC_STACK_RHODECODE_EXT="${RC_STACK_RHODECODE_EXT:-.custom/docker-compose-apps.override.yaml}"
|
|
|
|
|
|
# src/initialize.sh
|
|
|
|
|
|
ENV_FILE=$PWD/.env
|
|
|
|
|
|
# bootstrap file is a config file at the same time
|
|
|
BOOTSTRAP_FILE='.rccontrol-bootstrap'
|
|
|
CONFIG_FILE='.rccontrol.ini'
|
|
|
|
|
|
VALID_SERVICES="router metrics services rhodecode"
|
|
|
DOCKER_DEFS_WORK_DIR="docker_defs"
|
|
|
|
|
|
#echo "1 ----"
|
|
|
#echo $RC_STACK_SERVICES_EXT
|
|
|
#echo $RC_STACK_METRICS_EXT
|
|
|
#echo "1 -----"
|
|
|
|
|
|
#echo '2 ----'
|
|
|
#grep -v -e '^#' "$ENV_FILE" | xargs -I {} echo \'{}\'
|
|
|
#echo '2 ----'
|
|
|
|
|
|
#expose env vars from rccontrol donfig
|
|
|
#if [[ -f $ENV_FILE ]]; then
|
|
|
# eval $(grep -v -e '^#' "$ENV_FILE" | xargs -I {} echo export \'{}\')
|
|
|
#fi
|
|
|
|
|
|
#ENV_EXPAND=""
|
|
|
#for k in $(config_keys); do
|
|
|
# k_upper=${k^^}
|
|
|
# env_entry="-e $k_upper='$(config_get "$k")' "
|
|
|
# ENV_EXPAND+=$env_entry;
|
|
|
# #echo $env_expand
|
|
|
#done
|
|
|
|
|
|
#
|
|
|
#echo "3 ----"
|
|
|
#echo $RC_STACK_SERVICES_EXT
|
|
|
#echo $RC_STACK_METRICS_EXT
|
|
|
#echo $RC_STACK_RHODECODE_EXT
|
|
|
#echo "3 -----"
|
|
|
|
|
|
#env | grep RC_
|
|
|
|
|
|
# backup files from a docker volume into /tmp/backup.tar.gz
|
|
|
docker-volume-backup-compressed() {
|
|
|
docker run --rm -v /tmp:/backup --volumes-from "$1" debian:jessie tar -czvf /backup/backup.tar.gz "${@:2}"
|
|
|
}
|
|
|
|
|
|
# restore files from /tmp/backup.tar.gz into a docker volume
|
|
|
docker-volume-restore-compressed() {
|
|
|
docker run --rm -v /tmp:/backup --volumes-from "$1" debian:jessie tar -xzvf /backup/backup.tar.gz "${@:2}"
|
|
|
echo "Double checking files..."
|
|
|
docker run --rm -v /tmp:/backup --volumes-from "$1" debian:jessie ls -lh "${@:2}"
|
|
|
}
|
|
|
|
|
|
# backup files from a docker volume into /tmp/backup.tar
|
|
|
docker-volume-backup() {
|
|
|
docker run --rm -v /tmp:/backup --volumes-from "$1" busybox tar -cvf /backup/backup.tar "${@:2}"
|
|
|
}
|
|
|
|
|
|
# restore files from /tmp/backup.tar into a docker volume
|
|
|
docker-volume-restore() {
|
|
|
docker run --rm -v /tmp:/backup --volumes-from "$1" busybox tar -xvf /backup/backup.tar "${@:2}"
|
|
|
echo "Double checking files..."
|
|
|
docker run --rm -v /tmp:/backup --volumes-from "$1" busybox ls -lh "${@:2}"
|
|
|
}
|
|
|
|
|
|
get_started() {
|
|
|
echo ""
|
|
|
echo "~~~~ $(green Bootstrap completed) ~~~~"
|
|
|
echo "To start using RhodeCode run the following stacks using ./rccontrol stack [STACK_NAME]"
|
|
|
echo ""
|
|
|
echo "$(yellow_bold [Optional]): run the edge router to control domain and SSL"
|
|
|
echo "./rccontrol stack router up --detach"
|
|
|
echo ""
|
|
|
echo "$(green_bold [Mandatory]): run the services, like database, redis, channelstream etc..."
|
|
|
echo "./rccontrol stack services up --detach"
|
|
|
echo ""
|
|
|
echo "$(green_bold [Mandatory]): run the rhodecode app stack"
|
|
|
echo "./rccontrol stack rhodecode up --detach"
|
|
|
echo ""
|
|
|
echo "$(yellow_bold [Optional]): run the monitoring stack, this includes grafana/promethues logging/metrics system"
|
|
|
echo "./rccontrol stack metrics up --detach"
|
|
|
echo ""
|
|
|
echo "check services status/ports"
|
|
|
echo "./rccontrol status"
|
|
|
}
|
|
|
}
|
|
|
|
|
|
# :command.run
|
|
|
run() {
|
|
|
declare -A args=()
|
|
|
declare -a other_args=()
|
|
|
declare -a input=()
|
|
|
normalize_input "$@"
|
|
|
parse_requirements "${input[@]}"
|
|
|
|
|
|
if [[ $action == "self-update" ]]; then
|
|
|
if [[ ${args[--help]:-} ]]; then
|
|
|
long_usage=yes
|
|
|
rccontrol_self_update_usage
|
|
|
else
|
|
|
rccontrol_self_update_command
|
|
|
fi
|
|
|
|
|
|
elif [[ $action == "bootstrap" ]]; then
|
|
|
if [[ ${args[--help]:-} ]]; then
|
|
|
long_usage=yes
|
|
|
rccontrol_bootstrap_usage
|
|
|
else
|
|
|
rccontrol_bootstrap_command
|
|
|
fi
|
|
|
|
|
|
elif [[ $action == "get-build-artifacts" ]]; then
|
|
|
if [[ ${args[--help]:-} ]]; then
|
|
|
long_usage=yes
|
|
|
rccontrol_get_build_artifacts_usage
|
|
|
else
|
|
|
rccontrol_get_build_artifacts_command
|
|
|
fi
|
|
|
|
|
|
elif [[ $action == "build" ]]; then
|
|
|
if [[ ${args[--help]:-} ]]; then
|
|
|
long_usage=yes
|
|
|
rccontrol_build_usage
|
|
|
else
|
|
|
rccontrol_build_command
|
|
|
fi
|
|
|
|
|
|
elif [[ $action == "get-build-source" ]]; then
|
|
|
if [[ ${args[--help]:-} ]]; then
|
|
|
long_usage=yes
|
|
|
rccontrol_get_build_source_usage
|
|
|
else
|
|
|
rccontrol_get_build_source_command
|
|
|
fi
|
|
|
|
|
|
elif [[ $action == "build-source" ]]; then
|
|
|
if [[ ${args[--help]:-} ]]; then
|
|
|
long_usage=yes
|
|
|
rccontrol_build_source_usage
|
|
|
else
|
|
|
rccontrol_build_source_command
|
|
|
fi
|
|
|
|
|
|
elif [[ $action == "stack" ]]; then
|
|
|
if [[ ${args[--help]:-} ]]; then
|
|
|
long_usage=yes
|
|
|
rccontrol_stack_usage
|
|
|
else
|
|
|
rccontrol_stack_command
|
|
|
fi
|
|
|
|
|
|
elif [[ $action == "stack-status" ]]; then
|
|
|
if [[ ${args[--help]:-} ]]; then
|
|
|
long_usage=yes
|
|
|
rccontrol_stack_status_usage
|
|
|
else
|
|
|
rccontrol_stack_status_command
|
|
|
fi
|
|
|
|
|
|
elif [[ $action == "stack-upgrade" ]]; then
|
|
|
if [[ ${args[--help]:-} ]]; then
|
|
|
long_usage=yes
|
|
|
rccontrol_stack_upgrade_usage
|
|
|
else
|
|
|
rccontrol_stack_upgrade_command
|
|
|
fi
|
|
|
|
|
|
elif [[ $action == "cli-redis" ]]; then
|
|
|
if [[ ${args[--help]:-} ]]; then
|
|
|
long_usage=yes
|
|
|
rccontrol_cli_redis_usage
|
|
|
else
|
|
|
rccontrol_cli_redis_command
|
|
|
fi
|
|
|
|
|
|
elif [[ $action == "cli-db" ]]; then
|
|
|
if [[ ${args[--help]:-} ]]; then
|
|
|
long_usage=yes
|
|
|
rccontrol_cli_db_usage
|
|
|
else
|
|
|
rccontrol_cli_db_command
|
|
|
fi
|
|
|
|
|
|
elif [[ $action == "cli-db-upgrade" ]]; then
|
|
|
if [[ ${args[--help]:-} ]]; then
|
|
|
long_usage=yes
|
|
|
rccontrol_cli_db_upgrade_usage
|
|
|
else
|
|
|
rccontrol_cli_db_upgrade_command
|
|
|
fi
|
|
|
|
|
|
elif [[ $action == "_completions" ]]; then
|
|
|
if [[ ${args[--help]:-} ]]; then
|
|
|
long_usage=yes
|
|
|
rccontrol__completions_usage
|
|
|
else
|
|
|
rccontrol__completions_command
|
|
|
fi
|
|
|
|
|
|
elif [[ $action == "backup-db" ]]; then
|
|
|
if [[ ${args[--help]:-} ]]; then
|
|
|
long_usage=yes
|
|
|
rccontrol_backup_db_usage
|
|
|
else
|
|
|
rccontrol_backup_db_command
|
|
|
fi
|
|
|
|
|
|
elif [[ $action == "backup-data" ]]; then
|
|
|
if [[ ${args[--help]:-} ]]; then
|
|
|
long_usage=yes
|
|
|
rccontrol_backup_data_usage
|
|
|
else
|
|
|
rccontrol_backup_data_command
|
|
|
fi
|
|
|
|
|
|
elif [[ $action == "root" ]]; then
|
|
|
root_command
|
|
|
fi
|
|
|
}
|
|
|
|
|
|
initialize
|
|
|
run "$@"
|
|
|
|