adding comfyui sync
This commit is contained in:
8
by-machine/nimo.loc/comfyui-sync.service
Normal file
8
by-machine/nimo.loc/comfyui-sync.service
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
[Unit]
|
||||||
|
Description=Sync new ComfyUI outputs to Samba share, organize, and rename
|
||||||
|
|
||||||
|
[Service]
|
||||||
|
Type=oneshot
|
||||||
|
ExecStart=%h/git/schmeeve-toolz/comfyui-sync
|
||||||
|
StandardOutput=append:%h/.local/state/comfyui-sync.log
|
||||||
|
StandardError=append:%h/.local/state/comfyui-sync.log
|
||||||
9
by-machine/nimo.loc/comfyui-sync.timer
Normal file
9
by-machine/nimo.loc/comfyui-sync.timer
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
[Unit]
|
||||||
|
Description=Run comfyui-sync every 30 minutes
|
||||||
|
|
||||||
|
[Timer]
|
||||||
|
OnCalendar=*:0/30
|
||||||
|
Persistent=true
|
||||||
|
|
||||||
|
[Install]
|
||||||
|
WantedBy=timers.target
|
||||||
64
comfyui-sync
Executable file
64
comfyui-sync
Executable file
@@ -0,0 +1,64 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
set -euo pipefail
|
||||||
|
|
||||||
|
SOURCE="$HOME/ComfyUI/output"
|
||||||
|
SHARE_DIR="/mini.nas/miniShare1/Pictures"
|
||||||
|
STATE_FILE="$HOME/.local/state/comfyui-sync.state"
|
||||||
|
NEATCLI="$(command -v neatcli || true)"
|
||||||
|
RENAME_SCRIPT="$HOME/git/schmeeve-toolz/rename-ai-snaps"
|
||||||
|
|
||||||
|
mkdir -p "$(dirname "$STATE_FILE")"
|
||||||
|
|
||||||
|
if [ ! -d "$SOURCE" ]; then
|
||||||
|
echo "[comfyui-sync] ERROR: Source $SOURCE does not exist"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ ! -d "$SHARE_DIR" ]; then
|
||||||
|
echo "[comfyui-sync] ERROR: Share dir $SHARE_DIR does not exist"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "[comfyui-sync] Starting at $(date)"
|
||||||
|
|
||||||
|
current_files=$(ls "$SOURCE" | sort)
|
||||||
|
|
||||||
|
if [ -f "$STATE_FILE" ]; then
|
||||||
|
new_files=$(comm -13 <(sort "$STATE_FILE") <(echo "$current_files"))
|
||||||
|
else
|
||||||
|
echo "[comfyui-sync] First run — all files considered new."
|
||||||
|
new_files="$current_files"
|
||||||
|
fi
|
||||||
|
|
||||||
|
new_count=$(echo "$new_files" | grep -c '[^[:space:]]' || true)
|
||||||
|
|
||||||
|
if [ "$new_count" -eq 0 ]; then
|
||||||
|
echo "[comfyui-sync] No new files to copy."
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "[comfyui-sync] Copying $new_count new file(s)..."
|
||||||
|
while IFS= read -r f; do
|
||||||
|
[ -z "$f" ] && continue
|
||||||
|
cp "$SOURCE/$f" "$SHARE_DIR/"
|
||||||
|
done <<< "$new_files"
|
||||||
|
|
||||||
|
echo "$current_files" > "$STATE_FILE"
|
||||||
|
echo "[comfyui-sync] State file updated."
|
||||||
|
|
||||||
|
if [ -n "$NEATCLI" ]; then
|
||||||
|
echo "[comfyui-sync] Running neatcli organize --by-type -e $SHARE_DIR"
|
||||||
|
"$NEATCLI" organize --by-type -e "$SHARE_DIR"
|
||||||
|
else
|
||||||
|
echo "[comfyui-sync] WARNING: neatcli not found, skipping organize step"
|
||||||
|
fi
|
||||||
|
|
||||||
|
IMAGES_DIR="$SHARE_DIR/Images"
|
||||||
|
if [ -d "$IMAGES_DIR" ] && [ -x "$RENAME_SCRIPT" ]; then
|
||||||
|
echo "[comfyui-sync] Running rename-ai-snaps on $IMAGES_DIR"
|
||||||
|
cd "$IMAGES_DIR" && "$RENAME_SCRIPT" . --no-interactive
|
||||||
|
elif [ ! -x "$RENAME_SCRIPT" ]; then
|
||||||
|
echo "[comfyui-sync] WARNING: rename-ai-snaps not found, skipping rename step"
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "[comfyui-sync] Done at $(date)"
|
||||||
Reference in New Issue
Block a user