Initial commit: ComposeSync - Automated Docker Compose update agent

This commit is contained in:
robojerk 2025-06-18 21:54:06 -07:00
commit f0dba7cc0a
16 changed files with 3019 additions and 0 deletions

73
install.sh Normal file
View file

@ -0,0 +1,73 @@
#!/bin/bash
# Exit on error
set -e
# Check if running as root
if [ "$EUID" -ne 0 ]; then
echo "Please run as root"
exit 1
fi
# Get username
read -p "Enter the username to run ComposeSync (must be in docker group): " USERNAME
# Verify user exists and is in docker group
if ! id "$USERNAME" &>/dev/null; then
echo "Error: User $USERNAME does not exist"
exit 1
fi
if ! groups "$USERNAME" | grep -q docker; then
echo "Error: User $USERNAME is not in the docker group"
echo "Add user to docker group with: sudo usermod -aG docker $USERNAME"
exit 1
fi
# Create necessary directories
mkdir -p /opt/composesync
chown $USERNAME:docker /opt/composesync
# Copy files to installation directory
cp update-agent.sh /opt/composesync/
chmod +x /opt/composesync/update-agent.sh
chown $USERNAME:docker /opt/composesync/update-agent.sh
# Create default .env file if it doesn't exist
if [ ! -f /opt/composesync/.env ]; then
cat > /opt/composesync/.env << EOF
# Base directory for stacks
COMPOSESYNC_BASE_DIR=/opt/composesync/stacks
# Number of versions to keep (default: 10)
KEEP_VERSIONS=10
# Update interval in seconds (default: 3600)
UPDATE_INTERVAL_SECONDS=3600
# Update mode (notify_only or notify_and_apply)
UPDATE_MODE=notify_and_apply
# Optional: Webhook URL for notifications
# NOTIFICATION_WEBHOOK_URL=
EOF
chown $USERNAME:docker /opt/composesync/.env
fi
# Update service file with username
sed "s/YOUR_USERNAME/$USERNAME/" composesync.service > /etc/systemd/system/composesync.service
# Reload systemd
systemctl daemon-reload
# Enable and start the service
systemctl enable composesync
systemctl start composesync
echo "ComposeSync has been installed and started!"
echo "You can check the status with: systemctl status composesync"
echo "View logs with: journalctl -u composesync -f"
echo ""
echo "To manage your stacks, create directories in /opt/composesync/stacks/"
echo "Example: sudo mkdir -p /opt/composesync/stacks/immich"
echo " sudo chown $USERNAME:docker /opt/composesync/stacks/immich"