add seafile
All checks were successful
Test and Publish Templates / test-and-publish (push) Successful in 7s

This commit is contained in:
j
2025-12-29 12:53:02 +13:00
parent 53e34ad6f3
commit 2053e78ee0
14 changed files with 352 additions and 0 deletions

61
seafile/README.txt Normal file
View File

@@ -0,0 +1,61 @@
Template: seafile
Seafile is an open source file sync and share solution designed for high reliability,
performance, and productivity. It enables you to easily host your own cloud storage
service with clients for Windows, Mac, Linux, iOS, and Android.
QUICK START
-----------
1. Edit config/service.env to customize your deployment:
- Set SEAFILE_SERVER_HOSTNAME to your domain/IP
- Change SEAFILE_ADMIN_EMAIL and SEAFILE_ADMIN_PASSWORD
- Change MYSQL_ROOT_PASSWORD and DB_PASSWORD
- Set DATA_PATH to your desired storage location
- Adjust HTTP_PORT if needed (default: 8080)
2. Run 'dropshell validate seafile' to check for issues
3. Deploy with 'dropshell install <server> seafile'
ARCHITECTURE
------------
This template deploys three containers using docker-compose:
- seafile: Main Seafile server (seafileltd/seafile-mc)
- db: MariaDB database (mariadb:10.11)
- memcached: Caching layer (memcached:1.6-alpine)
DATA STORAGE
------------
All data is stored in the host directory specified by DATA_PATH:
- ${DATA_PATH}/seafile-data/ : Seafile files, configs, and logs
- ${DATA_PATH}/mariadb/ : MariaDB database files
DEFAULT PORTS
-------------
- HTTP_PORT (default 8080): Web interface and file sync
CONFIGURATION
-------------
Key variables in service.env:
- CONTAINER_NAME : Base name for containers
- DATA_PATH : Host directory for persistent data
- HTTP_PORT : Web interface port
- SEAFILE_SERVER_HOSTNAME : Your server's hostname/domain
- SEAFILE_SERVER_PROTOCOL : http or https
- SEAFILE_ADMIN_EMAIL : Admin account email
- SEAFILE_ADMIN_PASSWORD : Admin account password
- MYSQL_ROOT_PASSWORD : MariaDB root password
- TZ : Timezone (e.g., UTC, Europe/London)
FIRST STARTUP
-------------
The first startup takes several minutes as Seafile initializes the database.
Check progress with: dropshell logs <server> seafile
ACCESS
------
After installation, access Seafile at:
${SEAFILE_SERVER_PROTOCOL}://${SEAFILE_SERVER_HOSTNAME}:${HTTP_PORT}
Login with the admin credentials you configured in service.env.
For full documentation, see: https://manual.seafile.com/

7
seafile/_volumes.sh Executable file
View File

@@ -0,0 +1,7 @@
#!/bin/bash
# Define volume items for seafile container
# These are used across backup, restore, create, and destroy operations
get_seafile_volumes() {
echo "path:data:${DATA_PATH}"
}

32
seafile/backup.sh Executable file
View File

@@ -0,0 +1,32 @@
#!/bin/bash
# shellcheck disable=SC1091
source "${AGENT_PATH}/common.sh"
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
source "${SCRIPT_DIR}/_volumes.sh"
_check_required_env_vars "CONTAINER_NAME" "DATA_PATH"
# Export variables for docker compose
export CONTAINER_NAME DATA_PATH HTTP_PORT IMAGE_REGISTRY IMAGE_REPO IMAGE_TAG
export MYSQL_ROOT_PASSWORD DB_PASSWORD SEAFILE_ADMIN_EMAIL SEAFILE_ADMIN_PASSWORD
export SEAFILE_SERVER_HOSTNAME SEAFILE_SERVER_PROTOCOL TZ
cd "$SCRIPT_DIR" || _die "Failed to change to script directory"
# Dump MariaDB database before backup
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
# Backup using dropshell's backup system
# shellcheck disable=SC2046
backup_items $(get_seafile_volumes) || _die "Failed to create backup"
# Clean up database dump (it's now in the backup)
rm -f "${DATA_PATH}/database.sql"
# Restart containers
docker compose start
echo "Backup created successfully"

View File

@@ -0,0 +1,13 @@
# DO NOT EDIT THIS FILE FOR YOUR SERVICE!
# This file is replaced from the template whenever there is an update.
# Edit the service.env file to make changes.
# Template to use - always required!
TEMPLATE=seafile
REQUIRES_HOST_ROOT=false
REQUIRES_DOCKER=true
REQUIRES_DOCKER_ROOT=false
# Image settings (used by docker-compose.yml)
IMAGE_REGISTRY="docker.io"
IMAGE_REPO="seafileltd/seafile-mc"

View File

@@ -0,0 +1,25 @@
# Service settings specific to this server
CONTAINER_NAME=seafile
IMAGE_TAG="12.0-latest"
# Server Settings
SSH_USER="root"
# Data path on host for persistent storage
DATA_PATH="/home/dropshell/seafile"
# Seafile server configuration
SEAFILE_SERVER_HOSTNAME="seafile.example.com"
SEAFILE_SERVER_PROTOCOL="http"
HTTP_PORT=8080
# Admin credentials (change these!)
SEAFILE_ADMIN_EMAIL="admin@example.com"
SEAFILE_ADMIN_PASSWORD="changeme"
# Database settings (change the password!)
MYSQL_ROOT_PASSWORD="db_root_changeme"
DB_PASSWORD="db_seafile_changeme"
# Timezone
TZ="UTC"

22
seafile/destroy.sh Executable file
View File

@@ -0,0 +1,22 @@
#!/bin/bash
source "${AGENT_PATH}/common.sh"
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
_check_required_env_vars "CONTAINER_NAME" "DATA_PATH"
# Export variables for docker compose
export CONTAINER_NAME DATA_PATH HTTP_PORT IMAGE_REGISTRY IMAGE_REPO IMAGE_TAG
export MYSQL_ROOT_PASSWORD DB_PASSWORD SEAFILE_ADMIN_EMAIL SEAFILE_ADMIN_PASSWORD
export SEAFILE_SERVER_HOSTNAME SEAFILE_SERVER_PROTOCOL TZ
echo "WARNING: This will PERMANENTLY DELETE all data for ${CONTAINER_NAME}"
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
# Remove data directory
rm -rf "${DATA_PATH}"
echo "Destroyed ${CONTAINER_NAME} and all data."

View File

@@ -0,0 +1,43 @@
services:
db:
image: mariadb:10.11
container_name: ${CONTAINER_NAME}_db
restart: unless-stopped
environment:
MYSQL_ROOT_PASSWORD: ${MYSQL_ROOT_PASSWORD}
MYSQL_LOG_CONSOLE: "true"
volumes:
- ${DATA_PATH}/mariadb:/var/lib/mysql
healthcheck:
test: ["CMD", "healthcheck.sh", "--connect", "--innodb_initialized"]
interval: 10s
timeout: 5s
retries: 5
memcached:
image: memcached:1.6-alpine
container_name: ${CONTAINER_NAME}_memcached
restart: unless-stopped
entrypoint: memcached -m 256
seafile:
image: ${IMAGE_REGISTRY}/${IMAGE_REPO}:${IMAGE_TAG}
container_name: ${CONTAINER_NAME}
restart: unless-stopped
depends_on:
db:
condition: service_healthy
memcached:
condition: service_started
ports:
- "${HTTP_PORT}:80"
volumes:
- ${DATA_PATH}/seafile-data:/shared
environment:
DB_HOST: ${CONTAINER_NAME}_db
DB_ROOT_PASSWD: ${MYSQL_ROOT_PASSWORD}
SEAFILE_ADMIN_EMAIL: ${SEAFILE_ADMIN_EMAIL}
SEAFILE_ADMIN_PASSWORD: ${SEAFILE_ADMIN_PASSWORD}
SEAFILE_SERVER_HOSTNAME: ${SEAFILE_SERVER_HOSTNAME}
SEAFILE_SERVER_LETSENCRYPT: "false"
TIME_ZONE: ${TZ}

29
seafile/install.sh Executable file
View File

@@ -0,0 +1,29 @@
#!/bin/bash
source "${AGENT_PATH}/common.sh"
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
_check_required_env_vars "CONTAINER_NAME" "DATA_PATH" "MYSQL_ROOT_PASSWORD" "SEAFILE_ADMIN_EMAIL" "SEAFILE_ADMIN_PASSWORD" "SEAFILE_SERVER_HOSTNAME"
_check_docker_installed || _die "Docker test failed, aborting installation..."
# Create data directories
mkdir -p "${DATA_PATH}/mariadb" "${DATA_PATH}/seafile-data"
# Export variables for docker compose
export CONTAINER_NAME DATA_PATH HTTP_PORT IMAGE_REGISTRY IMAGE_REPO IMAGE_TAG
export MYSQL_ROOT_PASSWORD DB_PASSWORD SEAFILE_ADMIN_EMAIL SEAFILE_ADMIN_PASSWORD
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"
# Stop existing containers
docker compose down 2>/dev/null || true
# Start containers
docker compose 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}"
echo "Note: First startup may take a few minutes while Seafile initializes the database."

16
seafile/logs.sh Executable file
View File

@@ -0,0 +1,16 @@
#!/bin/bash
source "${AGENT_PATH}/common.sh"
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
_check_required_env_vars "CONTAINER_NAME"
# Export variables for docker compose
export CONTAINER_NAME DATA_PATH HTTP_PORT IMAGE_REGISTRY IMAGE_REPO IMAGE_TAG
export MYSQL_ROOT_PASSWORD DB_PASSWORD SEAFILE_ADMIN_EMAIL SEAFILE_ADMIN_PASSWORD
export SEAFILE_SERVER_HOSTNAME SEAFILE_SERVER_PROTOCOL TZ
cd "$SCRIPT_DIR" || _die "Failed to change to script directory"
echo "Container ${CONTAINER_NAME} logs:"
_grey_start
docker compose logs "$@"
_grey_end

41
seafile/restore.sh Executable file
View File

@@ -0,0 +1,41 @@
#!/bin/bash
# shellcheck disable=SC1091
source "${AGENT_PATH}/common.sh"
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
source "${SCRIPT_DIR}/_volumes.sh"
_check_required_env_vars "CONTAINER_NAME" "DATA_PATH"
# Export variables for docker compose
export CONTAINER_NAME DATA_PATH HTTP_PORT IMAGE_REGISTRY IMAGE_REPO IMAGE_TAG
export MYSQL_ROOT_PASSWORD DB_PASSWORD SEAFILE_ADMIN_EMAIL SEAFILE_ADMIN_PASSWORD
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
# 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
echo "Waiting for database to be ready..."
sleep 10
# Restore database if dump exists
if [ -f "${DATA_PATH}/database.sql" ]; then
echo "Restoring MariaDB database..."
docker exec -i "${CONTAINER_NAME}_db" mariadb -u root -p"${MYSQL_ROOT_PASSWORD}" < "${DATA_PATH}/database.sql" || _die "Failed to restore database"
# Clean up dump file
rm -f "${DATA_PATH}/database.sql"
echo "Database restored successfully"
else
echo "Warning: No database dump found in backup"
fi
# Start all containers
docker compose up -d
echo "Restore complete! Service is running."

15
seafile/start.sh Executable file
View File

@@ -0,0 +1,15 @@
#!/bin/bash
source "${AGENT_PATH}/common.sh"
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
_check_required_env_vars "CONTAINER_NAME" "DATA_PATH"
# Export variables for docker compose
export CONTAINER_NAME DATA_PATH HTTP_PORT IMAGE_REGISTRY IMAGE_REPO IMAGE_TAG
export MYSQL_ROOT_PASSWORD DB_PASSWORD SEAFILE_ADMIN_EMAIL SEAFILE_ADMIN_PASSWORD
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"
echo "Container ${CONTAINER_NAME} started"
echo "Access Seafile at ${SEAFILE_SERVER_PROTOCOL}://${SEAFILE_SERVER_HOSTNAME}:${HTTP_PORT}"

14
seafile/status.sh Executable file
View File

@@ -0,0 +1,14 @@
#!/bin/bash
source "${AGENT_PATH}/common.sh"
_check_required_env_vars "CONTAINER_NAME"
# Check if main seafile container is running
if docker ps --format "{{.Names}}" | grep -q "^${CONTAINER_NAME}$"; then
echo "Running"
else
if docker ps -a --format "{{.Names}}" | grep -q "^${CONTAINER_NAME}$"; then
echo "Stopped"
else
echo "Unknown"
fi
fi

14
seafile/stop.sh Executable file
View File

@@ -0,0 +1,14 @@
#!/bin/bash
source "${AGENT_PATH}/common.sh"
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
_check_required_env_vars "CONTAINER_NAME"
# Export variables for docker compose
export CONTAINER_NAME DATA_PATH HTTP_PORT IMAGE_REGISTRY IMAGE_REPO IMAGE_TAG
export MYSQL_ROOT_PASSWORD DB_PASSWORD SEAFILE_ADMIN_EMAIL SEAFILE_ADMIN_PASSWORD
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"
echo "Container ${CONTAINER_NAME} stopped"

20
seafile/uninstall.sh Executable file
View File

@@ -0,0 +1,20 @@
#!/bin/bash
source "${AGENT_PATH}/common.sh"
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
_check_required_env_vars "CONTAINER_NAME" "DATA_PATH"
# Export variables for docker compose
export CONTAINER_NAME DATA_PATH HTTP_PORT IMAGE_REGISTRY IMAGE_REPO IMAGE_TAG
export MYSQL_ROOT_PASSWORD DB_PASSWORD SEAFILE_ADMIN_EMAIL SEAFILE_ADMIN_PASSWORD
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"
# Remove images
docker compose 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"