- Create entrypoint.sh to handle SMB mount on container startup - Read credentials from settings.json and mount //172.18.210.5/ame - Bind-mount subdirectories (watch, output, logs) to container paths - Update Dockerfile with cifs-utils and entrypoint script - Update docker-compose.yml with SYS_ADMIN capability for mounting - Add comprehensive SMB configuration section to README - Include troubleshooting guide and alternative approaches - Maintain backward compatibility with local volumes - Never expose passwords to browser (server-side storage only) Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
78 lines
2.5 KiB
Bash
Executable file
78 lines
2.5 KiB
Bash
Executable file
#!/bin/bash
|
|
set -e
|
|
|
|
echo "=== AME Remote Job Manager — Entrypoint ==="
|
|
|
|
# Create mount directories
|
|
mkdir -p /watch /output /ame-logs /mnt/smb-share
|
|
|
|
# Settings file path
|
|
SETTINGS_FILE="/data/settings.json"
|
|
SMB_SHARE_PATH="//172.18.210.5/ame"
|
|
|
|
# Function to get setting value from JSON
|
|
get_setting() {
|
|
local key=$1
|
|
local default=$2
|
|
if [ -f "$SETTINGS_FILE" ]; then
|
|
value=$(grep -o "\"$key\":\"[^\"]*\"" "$SETTINGS_FILE" 2>/dev/null | cut -d'"' -f4)
|
|
if [ -n "$value" ]; then
|
|
echo "$value"
|
|
return
|
|
fi
|
|
fi
|
|
echo "$default"
|
|
}
|
|
|
|
# Read SMB credentials from settings.json (or use env vars as fallback)
|
|
SMB_USERNAME=$(get_setting 'smbUsername' "${SMB_USERNAME:-}")
|
|
SMB_PASSWORD=$(get_setting 'smbPassword' "${SMB_PASSWORD:-}")
|
|
SMB_DOMAIN=$(get_setting 'smbDomain' "${SMB_DOMAIN:-}")
|
|
|
|
# Try to mount SMB share only if credentials are provided
|
|
if [ -n "$SMB_USERNAME" ] && [ -n "$SMB_PASSWORD" ]; then
|
|
echo "Mounting SMB share with credentials..."
|
|
|
|
# Build mount options
|
|
MOUNT_OPTS="username=$SMB_USERNAME,password=$SMB_PASSWORD"
|
|
|
|
if [ -n "$SMB_DOMAIN" ]; then
|
|
MOUNT_OPTS="$MOUNT_OPTS,domain=$SMB_DOMAIN"
|
|
fi
|
|
|
|
# Add standard options for Linux mounts
|
|
MOUNT_OPTS="$MOUNT_OPTS,uid=1000,gid=1000,file_mode=0755,dir_mode=0755,vers=3.0"
|
|
|
|
if mount -t cifs "$SMB_SHARE_PATH" /mnt/smb-share -o "$MOUNT_OPTS" 2>&1; then
|
|
echo "✓ SMB share mounted at /mnt/smb-share"
|
|
else
|
|
echo "⚠ Failed to mount SMB share. Check credentials and network connectivity."
|
|
echo " Will continue with local volumes. Mount SMB and restart container to use network share."
|
|
fi
|
|
else
|
|
echo "⚠ No SMB credentials found in settings. Skipping SMB mount."
|
|
echo " Configure SMB credentials in the settings GUI and restart the container."
|
|
fi
|
|
|
|
# Bind mount the SMB directories to container paths (if mount succeeded)
|
|
if mountpoint -q /mnt/smb-share; then
|
|
echo "Binding SMB subdirectories..."
|
|
mkdir -p /mnt/smb-share/watch /mnt/smb-share/output /mnt/smb-share/logs
|
|
|
|
mount --bind /mnt/smb-share/watch /watch 2>/dev/null || echo "⚠ Could not bind watch folder"
|
|
mount --bind /mnt/smb-share/output /output 2>/dev/null || echo "⚠ Could not bind output folder"
|
|
mount --bind /mnt/smb-share/logs /ame-logs 2>/dev/null || echo "⚠ Could not bind logs folder"
|
|
|
|
echo "✓ Mount points configured"
|
|
else
|
|
echo "⚠ SMB share not mounted. Using local docker volumes as fallback."
|
|
fi
|
|
|
|
# Verify watch folder exists
|
|
if [ ! -d "/watch" ]; then
|
|
mkdir -p /watch
|
|
echo "Created /watch directory"
|
|
fi
|
|
|
|
echo "Starting Node.js application..."
|
|
exec node server.js
|