From ab85cd5e5af0c9a5491124c8d5929e99ebc27274 Mon Sep 17 00:00:00 2001 From: DarkPhoenix2704 Date: Thu, 22 Aug 2024 13:11:12 +0530 Subject: [PATCH] fix: add comments fix: bring back logs --- docker-compose/setup-script/noco.sh | 241 +++++++++++++++++++++++----- 1 file changed, 201 insertions(+), 40 deletions(-) diff --git a/docker-compose/setup-script/noco.sh b/docker-compose/setup-script/noco.sh index 659468ee18..29739ea030 100755 --- a/docker-compose/setup-script/noco.sh +++ b/docker-compose/setup-script/noco.sh @@ -255,7 +255,7 @@ read_number_range() { } check_if_docker_is_running() { - if ! ${CONFIG_DOCKER_COMMAND} ps >/dev/null 2>&1; then + if ! $CONFIG_DOCKER_COMMAND ps >/dev/null 2>&1; then print_warning "Docker is not running. Most of the commands will not work without Docker." print_info "Use the following command to start Docker:" print_color "$BLUE" " sudo systemctl start docker" @@ -264,16 +264,53 @@ check_if_docker_is_running() { # Main functions check_existing_installation() { - if [ -d "$NOCO_HOME" ] || ${CONFIG_DOCKER_COMMAND} ps --format '{{.Names}}' | grep -q "nocodb"; then - if ! confirm "NocoDB is already installed. Do you want to reinstall?"; then - management_menu - exit 0 - fi - ${CONFIG_DOCKER_COMMAND} compose down - rm -rf "$NOCO_HOME" - fi - mkdir -p "$NOCO_HOME" - cd "$NOCO_HOME" || exit 1 + NOCO_FOUND=false + + # Check if $NOCO_HOME exists as directory + if [ -d "$NOCO_HOME" ]; then + NOCO_FOUND=true + elif $CONFIG_DOCKER_COMMAND ps --format '{{.Names}}' | grep -q "nocodb"; then + NOCO_ID=$($CONFIG_DOCKER_COMMAND ps | grep "nocodb/nocodb" | cut -d ' ' -f 1) + CUSTOM_HOME=$($CONFIG_DOCKER_COMMAND inspect --format='{{index .Mounts 0}}' "$NOCO_ID" | cut -d ' ' -f 3) + PARENT_DIR=$(dirname "$CUSTOM_HOME") + + ln -s "$PARENT_DIR" "$NOCO_HOME" + basename "$PARENT_DIR" > "$NOCO_HOME/.COMPOSE_PROJECT_NAME" + + NOCO_FOUND=true + else + mkdir -p "$NOCO_HOME" + fi + + cd "$NOCO_HOME" || exit 1 + + # Check if nocodb is already installed + if [ "$NOCO_FOUND" = true ]; then + echo "NocoDB is already installed. And running." + echo "Do you want to reinstall NocoDB? [Y/N] (default: N): " + read -r REINSTALL + + if [ -f "$NOCO_HOME/.COMPOSE_PROJECT_NAME" ]; then + COMPOSE_PROJECT_NAME=$(cat "$NOCO_HOME/.COMPOSE_PROJECT_NAME") + export COMPOSE_PROJECT_NAME + fi + + if [ "$REINSTALL" != "Y" ] && [ "$REINSTALL" != "y" ]; then + management_menu + exit 0 + else + echo "Reinstalling NocoDB..." + $CONFIG_DOCKER_COMMAND compose down + + unset COMPOSE_PROJECT_NAME + cd /tmp || exit 1 + rm -rf "$NOCO_HOME" + + cd "$CURRENT_PATH" || exit 1 + mkdir -p "$NOCO_HOME" + cd "$NOCO_HOME" || exit 1 + fi + fi } check_system_requirements() { @@ -381,9 +418,23 @@ services: - "com.centurylinklabs.watchtower.enable=true" - "traefik.enable=true" - "traefik.http.routers.nocodb.rule=Host(\`${CONFIG_DOMAIN_NAME}\`)" - - "traefik.http.routers.nocodb.entrypoints=${CONFIG_SSL_ENABLED:+websecure}" - ${CONFIG_SSL_ENABLED:+- "traefik.http.routers.nocodb.tls=true"} - ${CONFIG_SSL_ENABLED:+- "traefik.http.routers.nocodb.tls.certresolver=letsencrypt"} +EOF +# IF SSL is Enabled add the following lines + if [ "$CONFIG_SSL_ENABLED" = "Y" ]; then + cat >> "$compose_file" <> "$compose_file" <> "$compose_file" <> "$compose_file" <> "$compose_file" <> "$compose_file" <> "$compose_file" <> "$compose_file" <> "$compose_file" <> "$compose_file" <> "$compose_file" <> "$compose_file" < ./update.sh <