diff --git a/seafile/backup.sh b/seafile/backup.sh index 97993e6..e0ebf72 100755 --- a/seafile/backup.sh +++ b/seafile/backup.sh @@ -17,7 +17,7 @@ echo "Dumping MariaDB database..." docker exec "${CONTAINER_NAME}_db" mariadb-dump -u root -p"${MYSQL_ROOT_PASSWORD}" --all-databases > "${DATA_PATH}/database.sql" || _die "Failed to dump database" # Stop containers for consistent backup -docker compose stop +docker compose -p "${CONTAINER_NAME}" stop # Backup using dropshell's backup system # shellcheck disable=SC2046 @@ -27,6 +27,6 @@ backup_items $(get_seafile_volumes) || _die "Failed to create backup" rm -f "${DATA_PATH}/database.sql" # Restart containers -docker compose start +docker compose -p "${CONTAINER_NAME}" start echo "Backup created successfully" diff --git a/seafile/config/service.env b/seafile/config/service.env index ebf9760..53c5f33 100644 --- a/seafile/config/service.env +++ b/seafile/config/service.env @@ -1,4 +1,6 @@ -# Service settings specific to this server +# Service identification (REQUIRED) +# CONTAINER_NAME must be unique per instance if running multiple Seafile services +# It's used for container names, network name, and project identification CONTAINER_NAME=seafile IMAGE_TAG="12.0-latest" @@ -6,6 +8,7 @@ IMAGE_TAG="12.0-latest" SSH_USER="root" # Data path on host for persistent storage +# Must be unique per instance if running multiple Seafile services DATA_PATH="/home/dropshell/seafile" # Seafile server configuration diff --git a/seafile/destroy.sh b/seafile/destroy.sh index ada8186..4fe5ef7 100755 --- a/seafile/destroy.sh +++ b/seafile/destroy.sh @@ -14,7 +14,7 @@ echo "This includes all files, database, and configuration!" cd "$SCRIPT_DIR" || _die "Failed to change to script directory" # Stop and remove containers -docker compose down -v 2>/dev/null || true +docker compose -p "${CONTAINER_NAME}" down -v 2>/dev/null || true # Remove data directory rm -rf "${DATA_PATH}" diff --git a/seafile/docker-compose.yml b/seafile/docker-compose.yml index 26619ab..b343e0c 100644 --- a/seafile/docker-compose.yml +++ b/seafile/docker-compose.yml @@ -13,12 +13,16 @@ services: interval: 10s timeout: 5s retries: 5 + networks: + - seafile-net memcached: image: memcached:1.6-alpine container_name: ${CONTAINER_NAME}_memcached restart: unless-stopped entrypoint: memcached -m 256 + networks: + - seafile-net seafile: image: ${IMAGE_REGISTRY}/${IMAGE_REPO}:${IMAGE_TAG} @@ -41,3 +45,9 @@ services: SEAFILE_SERVER_HOSTNAME: ${SEAFILE_SERVER_HOSTNAME} SEAFILE_SERVER_LETSENCRYPT: "false" TIME_ZONE: ${TZ} + networks: + - seafile-net + +networks: + seafile-net: + name: ${CONTAINER_NAME}_net diff --git a/seafile/install.sh b/seafile/install.sh index dcb8ac3..d1d9a20 100755 --- a/seafile/install.sh +++ b/seafile/install.sh @@ -16,13 +16,13 @@ export SEAFILE_SERVER_HOSTNAME SEAFILE_SERVER_PROTOCOL TZ cd "$SCRIPT_DIR" || _die "Failed to change to script directory" # Pull images -docker compose pull || _die "Failed to pull images" +docker compose -p "${CONTAINER_NAME}" pull || _die "Failed to pull images" # Stop existing containers -docker compose down 2>/dev/null || true +docker compose -p "${CONTAINER_NAME}" down 2>/dev/null || true # Start containers -docker compose up -d || _die "Failed to start containers" +docker compose -p "${CONTAINER_NAME}" up -d || _die "Failed to start containers" echo "Installation of ${CONTAINER_NAME} complete" echo "Access Seafile at ${SEAFILE_SERVER_PROTOCOL}://${SEAFILE_SERVER_HOSTNAME}:${HTTP_PORT}" diff --git a/seafile/logs.sh b/seafile/logs.sh index 341eceb..d132c80 100755 --- a/seafile/logs.sh +++ b/seafile/logs.sh @@ -12,5 +12,5 @@ cd "$SCRIPT_DIR" || _die "Failed to change to script directory" echo "Container ${CONTAINER_NAME} logs:" _grey_start -docker compose logs "$@" +docker compose -p "${CONTAINER_NAME}" logs "$@" _grey_end diff --git a/seafile/ports.sh b/seafile/ports.sh new file mode 100755 index 0000000..d9bbb50 --- /dev/null +++ b/seafile/ports.sh @@ -0,0 +1,8 @@ +#!/bin/bash +source "${AGENT_PATH}/common.sh" +_check_required_env_vars "HTTP_PORT" + +# PORTS SCRIPT +# Lists the exposed ports + +echo "$HTTP_PORT" diff --git a/seafile/restore.sh b/seafile/restore.sh index 6513852..bf00661 100755 --- a/seafile/restore.sh +++ b/seafile/restore.sh @@ -13,14 +13,14 @@ export SEAFILE_SERVER_HOSTNAME SEAFILE_SERVER_PROTOCOL TZ cd "$SCRIPT_DIR" || _die "Failed to change to script directory" # Stop and remove containers before restore -docker compose down +docker compose -p "${CONTAINER_NAME}" down # Restore files using dropshell's restore system # shellcheck disable=SC2046 restore_items $(get_seafile_volumes) || _die "Failed to restore data from backup file" # Start database container only -docker compose up -d db +docker compose -p "${CONTAINER_NAME}" up -d db echo "Waiting for database to be ready..." sleep 10 @@ -36,6 +36,6 @@ else fi # Start all containers -docker compose up -d +docker compose -p "${CONTAINER_NAME}" up -d echo "Restore complete! Service is running." diff --git a/seafile/start.sh b/seafile/start.sh index f57c7f3..9ca2612 100755 --- a/seafile/start.sh +++ b/seafile/start.sh @@ -9,7 +9,7 @@ export MYSQL_ROOT_PASSWORD DB_PASSWORD SEAFILE_ADMIN_EMAIL SEAFILE_ADMIN_PASSWOR export SEAFILE_SERVER_HOSTNAME SEAFILE_SERVER_PROTOCOL TZ cd "$SCRIPT_DIR" || _die "Failed to change to script directory" -docker compose up -d || _die "Failed to start containers" +docker compose -p "${CONTAINER_NAME}" up -d || _die "Failed to start containers" echo "Container ${CONTAINER_NAME} started" echo "Access Seafile at ${SEAFILE_SERVER_PROTOCOL}://${SEAFILE_SERVER_HOSTNAME}:${HTTP_PORT}" diff --git a/seafile/stop.sh b/seafile/stop.sh index 14a92be..f15e1eb 100755 --- a/seafile/stop.sh +++ b/seafile/stop.sh @@ -9,6 +9,6 @@ export MYSQL_ROOT_PASSWORD DB_PASSWORD SEAFILE_ADMIN_EMAIL SEAFILE_ADMIN_PASSWOR export SEAFILE_SERVER_HOSTNAME SEAFILE_SERVER_PROTOCOL TZ cd "$SCRIPT_DIR" || _die "Failed to change to script directory" -docker compose stop || _die "Failed to stop containers" +docker compose -p "${CONTAINER_NAME}" stop || _die "Failed to stop containers" echo "Container ${CONTAINER_NAME} stopped" diff --git a/seafile/uninstall.sh b/seafile/uninstall.sh index b9f8aee..733822a 100755 --- a/seafile/uninstall.sh +++ b/seafile/uninstall.sh @@ -11,10 +11,10 @@ export SEAFILE_SERVER_HOSTNAME SEAFILE_SERVER_PROTOCOL TZ cd "$SCRIPT_DIR" || _die "Failed to change to script directory" # Stop and remove containers (but preserve volumes/data) -docker compose down || _die "Failed to stop containers" +docker compose -p "${CONTAINER_NAME}" down || _die "Failed to stop containers" # Remove images -docker compose config --images | xargs -r docker rmi 2>/dev/null || true +docker compose -p "${CONTAINER_NAME}" config --images | xargs -r docker rmi 2>/dev/null || true echo "Uninstallation of ${CONTAINER_NAME} complete." echo "Data preserved in ${DATA_PATH}. To remove all data, use destroy.sh"