История изменений
Исправление leg0las, (текущая версия) :
#!/bin/bash
# System config
EXCLUDE_PATH="
/boot
/dev
/home
/lib/modules
/lib64/modules
/lost+found
/media
/mnt
/proc
/pub
/root
/run
/sys
/tmp
/usr/local
/usr/portage
/usr/src
/var/db/pkg
/var/tmp
/
"
TMP_DIR="/tmp/garbage"
TMP_PACKAGE_FILES="package_files"
TMP_PACKAGE_FILES_SORT="package_files_sort"
TMP_SYSTEM_FILES="system_files"
TMP_SYSTEM_FILES_SORT="system_files_sort"
TMP_RESULT="garbage.log"
mkdir "${TMP_DIR}" 2> /dev/null
TMP_PACKAGE_FILES="$TMP_DIR/$TMP_PACKAGE_FILES"
TMP_PACKAGE_FILES_SORT="$TMP_DIR/$TMP_PACKAGE_FILES_SORT"
TMP_SYSTEM_FILES="$TMP_DIR/$TMP_SYSTEM_FILES"
TMP_SYSTEM_FILES_SORT="$TMP_DIR/$TMP_SYSTEM_FILES_SORT"
TMP_RESULT="/var/log/$TMP_RESULT"
find /var/db/pkg/ -name CONTENTS -exec cat {} \; >> "$TMP_PACKAGE_FILES"
cat "$TMP_PACKAGE_FILES" | awk '{print $2}' | grep -v "^/usr/src" | sort -u > "$TMP_PACKAGE_FILES_SORT"
FIND_FILES="find / -type f"
for E in $EXCLUDE_PATH ; do
FIND_FILES="$FIND_FILES -prune -o -path $E"
done
FIND_DIRS="find / -type d"
for E in $EXCLUDE_PATH ; do
FIND_DIRS="$FIND_DIRS -prune -o -path $E"
done
$FIND_FILES > $TMP_SYSTEM_FILES
$FIND_DIRS >> $TMP_SYSTEM_FILES
cat $TMP_SYSTEM_FILES | sort -u > $TMP_SYSTEM_FILES_SORT
diff "$TMP_SYSTEM_FILES_SORT" "$TMP_PACKAGE_FILES_SORT" | grep "^<" | sed "s/^< //g" > "$TMP_RESULT"
rm -rf "TMP_DIR"
Сейчас буду писать исключения для /var.
Исправление leg0las, :
#!/bin/bash
# System config
EXCLUDE_PATH="
/boot
/dev
/home
/lib/modules
/lib64/modules
/lost+found
/media
/mnt
/proc
/pub
/root
/run
/sys
/tmp
/usr/local
/usr/portage
/usr/src
/var/db/pkg
/var/tmp
/
"
TMP_DIR="/tmp/garbage"
TMP_PACKAGE_FILES="package_files"
TMP_PACKAGE_FILES_SORT="package_files_sort"
TMP_SYSTEM_FILES="system_files"
TMP_SYSTEM_FILES_SORT="system_files_sort"
TMP_RESULT="garbage.log"
mkdir "${TMP_DIR}" 2> /dev/null
TMP_PACKAGE_FILES="$TMP_DIR/$TMP_PACKAGE_FILES"
TMP_PACKAGE_FILES_SORT="$TMP_DIR/$TMP_PACKAGE_FILES_SORT"
TMP_SYSTEM_FILES="$TMP_DIR/$TMP_SYSTEM_FILES"
TMP_SYSTEM_FILES_SORT="$TMP_DIR/$TMP_SYSTEM_FILES_SORT"
TMP_RESULT="/var/log/$TMP_RESULT"
find /var/db/pkg/ -name CONTENTS -exec cat {} \; >> "$TMP_PACKAGE_FILES"
cat "$TMP_PACKAGE_FILES" | awk '{print $2}' | grep -v "^/usr/src" | sort -u > "$TMP_PACKAGE_FILES_SORT"
FIND_FILES="find / -type f"
for E in $EXCLUDE_PATH ; do
FIND_FILES="$FIND_FILES -prune -o -path $E"
done
FIND_DIRS="find / -type d"
for E in $EXCLUDE_PATH ; do
FIND_DIRS="$FIND_DIRS -prune -o -path $E"
done
$FIND_FILES > $TMP_SYSTEM_FILES
$FIND_DIRS >> $TMP_SYSTEM_FILES
cat $TMP_SYSTEM_FILES | sort -u > $TMP_SYSTEM_FILES_SORT
diff "$TMP_SYSTEM_FILES_SORT" "$TMP_PACKAGE_FILES_SORT" | grep "^<" | sed "s/^< //g" > "$TMP_RESULT"
rm -rf "TMP_DIR"
Исходная версия leg0las, :
Новая версия
#!/bin/bash
# System config
EXCLUDE_PATH="
/boot
/dev
/home
/lib/modules
/lib64/modules
/lost+found
/media
/mnt
/proc
/pub
/root
/run
/sys
/tmp
/usr/local
/usr/portage
/usr/src
/var/db/pkg
/var/tmp
/
"
TMP_DIR="/tmp/garbage"
TMP_PACKAGE_FILES="package_files"
TMP_PACKAGE_FILES_SORT="package_files_sort"
TMP_SYSTEM_FILES="system_files"
TMP_SYSTEM_FILES_SORT="system_files_sort"
TMP_RESULT="garbage.log"
mkdir "${TMP_DIR}" 2> /dev/null
TMP_PACKAGE_FILES="$TMP_DIR/$TMP_PACKAGE_FILES"
TMP_PACKAGE_FILES_SORT="$TMP_DIR/$TMP_PACKAGE_FILES_SORT"
TMP_SYSTEM_FILES="$TMP_DIR/$TMP_SYSTEM_FILES"
TMP_SYSTEM_FILES_SORT="$TMP_DIR/$TMP_SYSTEM_FILES_SORT"
TMP_RESULT="/var/log/$TMP_RESULT"
find /var/db/pkg/ -name CONTENTS -exec cat {} \; >> "$TMP_PACKAGE_FILES"
cat "$TMP_PACKAGE_FILES" | awk '{print $2}' | grep -v "^/usr/src" | sort -u > "$TMP_PACKAGE_FILES_SORT"
FIND_FILES="find / -type f"
for E in $EXCLUDE_PATH ; do
FIND_FILES="$FIND_FILES -prune -o -path $E"
done
FIND_DIRS="find / -type d"
for E in $EXCLUDE_PATH ; do
FIND_DIRS="$FIND_DIRS -prune -o -path $E"
done
$FIND_FILES > $TMP_SYSTEM_FILES
$FIND_DIRS >> $TMP_SYSTEM_FILES
cat $TMP_SYSTEM_FILES | sort -u > $TMP_SYSTEM_FILES_SORT
diff "$TMP_SYSTEM_FILES_SORT" "$TMP_PACKAGE_FILES_SORT" | grep "^<" | sed "s/^< //g" > "$TMP_RESULT"
rm -rf "TMP_DIR"