Created
October 26, 2025 18:23
-
-
Save fathonix/e6380d0f197a245408f4a66fcb8b4297 to your computer and use it in GitHub Desktop.
Check duplicate files on OpenWrt's overlay filesystem
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/sh | |
| # ovldups.sh - Check duplicate files on OpenWrt's overlay filesystem | |
| # I am not responsible for any damages caused by this script. | |
| # Run this script at your own risk. | |
| # Licensed under MIT. (c) 2025 Aldo Fathoni | |
| set -e | |
| case "$1" in | |
| -v) | |
| VERBOSE=1 | |
| ;; | |
| -d) | |
| RUNDELETE=1 | |
| ;; | |
| -h|--help|-?) | |
| echo -e \ | |
| "ovldups.sh - Check duplicate files on OpenWrt's overlay filesystem\n\n" \ | |
| "\010I am not responsible for any damages caused by this script.\n" \ | |
| "\010Run this script at your own risk.\n" \ | |
| "\010Licensed under MIT. (c) 2025 Aldo Fathoni\n\n" \ | |
| "\010\t-d\tDelete duplicate files\n" \ | |
| "\010\t-v\tBe verbose\n" \ | |
| "\010\t-h\tShow this help" | |
| exit 0 | |
| ;; | |
| esac | |
| TMPSCPT=/tmp/ovldups.$$ | |
| DUPCMD='echo "$@"' | |
| if [ -n "$VERBOSE" ]; then | |
| DUPCMD='echo "Duplicate: ${@}"' | |
| elif [ -n "$RUNDELETE" ]; then | |
| DUPCMD='rm "/rom/overlay/upper${@}" && echo "Deleted ${@}"' | |
| fi | |
| cat > $TMPSCPT <<EOF | |
| #!/bin/sh | |
| if [ -e "/rom\${@}" ]; then | |
| if cmp "/rom\${@}" "\$@"; then | |
| $DUPCMD | |
| fi | |
| fi | |
| EOF | |
| chmod 755 $TMPSCPT | |
| find /rom/overlay/upper -type f \ | |
| | sed 's|/rom/overlay/upper||g' \ | |
| | xargs -n 1 $TMPSCPT | |
| if [ -n "$RUNDELETE" ]; then | |
| mount -o remount / | |
| fi | |
| rm $TMPSCPT |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment