diff --git a/scripts/cloudron-support b/scripts/cloudron-support index 1f3fb98c6..a4be07d85 100755 --- a/scripts/cloudron-support +++ b/scripts/cloudron-support @@ -22,6 +22,9 @@ readonly HELP_MESSAGE=" See https://docs.cloudron.io/troubleshooting for more information on troubleshooting. Options: + --apply-db-migrations Applies all pending DB migrations + --check-db-migrations Checks if the DB migrations are up to date + --check-services Checks if services/addons are running and healthy. --disable-dnssec Disable DNSSEC --enable-remote-support Enable SSH Remote Access for the Cloudron support team --disable-remote-support Disable SSH Remote Access for the Cloudron support team @@ -31,9 +34,6 @@ readonly HELP_MESSAGE=" --recreate-containers Deletes all existing containers and recreates them without loss of data --recreate-docker Deletes docker storage (containers and images) and recreates it without loss of data --send-diagnostics Collects server diagnostics and uploads it to ${PASTEBIN} - --check-db-migration Checks if the DB migrations are up to date. - --apply-db-migration Applys all pending DB migrations. - --check-cloudron-services Checks if all Cloudron services are running and healthy. --troubleshoot Dashboard down? Run tests to identify the potential problem --unbound-use-external-dns Forwards all Unbound requests to Google (8.8.8.8) and Cloudflare (1.1.1.1) DNS servers. Unbound is the internal DNS server used for recursive DNS queries. This is only needed @@ -637,14 +637,14 @@ function troubleshoot() { check_nginx # requires mysql to be checked check_dashboard_cert check_dashboard_site_loopback # checks website via loopback + check_db_migrations + check_services check_box check_netplan check_dns check_dashboard_site_domain # check website via domain name check_expired_domain check_unbound # this is less fatal after 8.0 - check_db_migration - check_cloudron_services } function cleanup_disk_space() { @@ -849,24 +849,23 @@ function apply_patch() { echo "Patch applied" } -function check_db_migration() { +function check_db_migrations() { local -r last_migration_from_db="$(mysql -NB -uroot -ppassword -e "SELECT name FROM box.migrations ORDER BY run_on DESC LIMIT 1" 2>/dev/null).js" local -r last_migration_file="/$(ls --ignore schema.sql --ignore initial-schema.sql /home/yellowtent/box/migrations/ | sort | tail -1)" if [[ "${last_migration_from_db}" != "${last_migration_file}" ]]; then fail "Database migrations are pending. Last migration in DB: ${last_migration_from_db}. Last migration file: ${last_migration_file}." - info "Please run 'cloudron-support --apply-db-migration' to apply the migrations." + info "Please run 'cloudron-support --apply-db-migrations' to apply the migrations." else success "No pending database migrations" fi } -function apply_db_migration() { +function apply_db_migrations() { echo "Applying pending database migrations" bash /home/yellowtent/box/setup/start.sh && success "Database migrations applied successfully" || fail "Database migrations failed" } -function check_cloudron_services() { - +function check_services() { local services=("mysql" "postgresql" "mongodb" "mail" "graphite") local service_ip=("172.18.30.1" "172.18.30.2" "172.18.30.3" "172.18.30.4" "172.18.30.5") local service_port=("3000" "3000" "3000" "3000" "2003") @@ -874,36 +873,36 @@ function check_cloudron_services() { for service in "${!services[@]}"; do # Check if container is running if [[ $(docker inspect ${services[$service]} --format={{.State.Status}}) != "running" ]]; then - fail "${services[$service]} container is not running!" + fail "Service '${services[$service]}' container is not running!" continue fi # Check if service is reachable with simple nc check if ! nc -z -w5 ${service_ip[$service]} ${service_port[$service]} 2>/dev/null; then - fail "${services[$service]} is not reachable" + fail "Service '${services[$service]}' is not reachable" continue fi # Curl the healthcheck endpoint if [[ ${services[$service]} != "graphite" ]]; then if ! grep -q "true" <<< $(curl --fail -s "http://${service_ip[$service]}:${service_port[$service]}/healthcheck"); then - fail "${services[$service]} healthcheck failed" + fail "Service '${services[$service]}' healthcheck failed" continue fi else # Graphite has a different healthcheck endpoint and needs to be checked differently if ! grep -q "Graphite Dashboard" <<< "$(curl --fail -s http://${service_ip[$service]}:8000/graphite-web/dashboard)"; then - fail "${services[$service]} healthcheck failed" + fail "Service '${services[$service]}' healthcheck failed" continue fi fi - success "${services[$service]} is running and healthy" + success "Service '${services[$service]}' is running and healthy" done } check_disk_space -args=$(getopt -o "" -l "admin-login,disable-dnssec,enable-remote-support,disable-remote-support,help,owner-login,patch:,recreate-containers,recreate-docker,fix-docker-version,send-diagnostics,unbound-use-external-dns,troubleshoot,check-db-migration,apply-db-migration,check-cloudron-services" -n "$0" -- "$@") +args=$(getopt -o "" -l "admin-login,disable-dnssec,enable-remote-support,disable-remote-support,help,owner-login,patch:,recreate-containers,recreate-docker,fix-docker-version,send-diagnostics,unbound-use-external-dns,troubleshoot,check-db-migrations,apply-db-migrations,check-services" -n "$0" -- "$@") eval set -- "${args}" while true; do @@ -924,9 +923,9 @@ while true; do --recreate-containers) recreate_containers; exit 0;; --recreate-docker) recreate_docker; exit 0;; --fix-docker-version) fix_docker_version; exit 0;; - --check-db-migration) check_db_migration; exit 0;; - --apply-db-migration) apply_db_migration; exit 0;; - --check-cloudron-services) check_cloudron_services; exit 0;; + --check-db-migrations) check_db_migrations; exit 0;; + --apply-db-migrations) apply_db_migrations; exit 0;; + --check-services) check_services; exit 0;; --patch) apply_patch "$2"; exit 0;; --help) break;; --) break;;