2025-01-06 00:45:59 +00:00
|
|
|
#!/bin/bash
|
|
|
|
|
2025-01-06 06:26:15 +00:00
|
|
|
echo "Starting LibMan"
|
|
|
|
|
2025-01-06 00:45:59 +00:00
|
|
|
# Set default destination if FLATPAK_DEST is not set
|
|
|
|
if [ -z "$FLATPAK_DEST" ]; then
|
|
|
|
FLATPAK_DEST="/app"
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Check if source directory is provided
|
|
|
|
if [ -z "$1" ]; then
|
|
|
|
echo "Usage: $0 <source_directory>"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Define target directory
|
|
|
|
target_dir="${FLATPAK_DEST}/retrodeck/lib"
|
|
|
|
|
|
|
|
# Ensure the target directory exists
|
2025-01-06 06:26:15 +00:00
|
|
|
if ! mkdir -p "$target_dir"; then
|
|
|
|
echo "Error: Failed to create target directory $target_dir"
|
|
|
|
exit 0
|
|
|
|
fi
|
2025-01-06 00:45:59 +00:00
|
|
|
|
|
|
|
# Find and copy files
|
2025-01-06 06:26:15 +00:00
|
|
|
find "$1" -type f | while IFS= read -r file; do
|
|
|
|
# Define destination file path
|
|
|
|
dest_file="$target_dir/$(basename "$file")"
|
|
|
|
|
|
|
|
# Skip if the destination file already exists
|
|
|
|
if [ -e "$dest_file" ]; then
|
|
|
|
echo "Skipped $file as $dest_file already exists"
|
|
|
|
continue
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Attempt to copy the file
|
|
|
|
if cp "$file" "$dest_file"; then
|
|
|
|
echo "Copied $file to $dest_file"
|
|
|
|
else
|
|
|
|
echo "Warning: Failed to copy $file. Skipping."
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
|
|
|
|
echo "Terminating LibMan"
|
|
|
|
|