mirror of
				https://github.com/Telecominfraproject/wlan-lanforge-scripts.git
				synced 2025-10-31 18:58:01 +00:00 
			
		
		
		
	check_large_files.bash: WIP
This commit is contained in:
		| @@ -2,12 +2,24 @@ | |||||||
| # ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- # | # ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- # | ||||||
| #  Check for large files and purge many of the most inconsequencial       # | #  Check for large files and purge many of the most inconsequencial       # | ||||||
| # ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- # | # ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- # | ||||||
| set -x | # set -x | ||||||
| set -e | # set -e | ||||||
| HR=" ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- -----" |  | ||||||
| function hr() { | USAGE="$0 # Check for large files and purge many of the most inconsequencial | ||||||
|   echo "$HR" |  -a   # automatic: disable menu and clean automatically | ||||||
| } |  -b   # remove extra kernels and modules | ||||||
|  |  -c   # remove all core files | ||||||
|  |  -d   # remove old LANforge downloads | ||||||
|  |  -h   # help | ||||||
|  |  -k   # remove ath10k crash files | ||||||
|  |  -l   # remove old files from /var/log, truncate /var/log/messages | ||||||
|  |  -m   # remove orphaned fileio items in /mnt/lf | ||||||
|  |  -q   # quiet | ||||||
|  |  -r   # compress .csv data in /home/lanforge | ||||||
|  |  -t   # remove /var/tmp files | ||||||
|  |  -v   # verbose | ||||||
|  |  | ||||||
|  | " | ||||||
|  |  | ||||||
| eyedee=`id -u` | eyedee=`id -u` | ||||||
| if (( eyedee != 0 )); then | if (( eyedee != 0 )); then | ||||||
| @@ -15,12 +27,83 @@ if (( eyedee != 0 )); then | |||||||
|     exit 1 |     exit 1 | ||||||
| fi | fi | ||||||
|  |  | ||||||
|  | # these are default selections | ||||||
|  | selections=() | ||||||
|  | deletion_targets=() | ||||||
|  | show_menu=1 | ||||||
|  | verbose=0 | ||||||
|  | quiet=0 | ||||||
|  | #opts="" | ||||||
|  | opts="abcdhklmqrtv" | ||||||
|  | while getopts $opts opt; do | ||||||
|  |   case "$opt" in | ||||||
|  |     a) | ||||||
|  |       verbose=0 | ||||||
|  |       quiet=1 | ||||||
|  |       selections+=($opt) | ||||||
|  |       show_menu=0 | ||||||
|  |       ;; | ||||||
|  |     b) | ||||||
|  |       selections+=($opt) | ||||||
|  |       ;; | ||||||
|  |     c) | ||||||
|  |       selections+=($opt) | ||||||
|  |       ;; | ||||||
|  |     d) | ||||||
|  |       selections+=($opt) | ||||||
|  |       ;; | ||||||
|  |     h) | ||||||
|  |       echo "$USAGE" | ||||||
|  |       exit 0 | ||||||
|  |       ;; | ||||||
|  |     k) | ||||||
|  |       selections+=($opt) | ||||||
|  |       ;; | ||||||
|  |     l) | ||||||
|  |       selections+=($opt) | ||||||
|  |       ;; | ||||||
|  |     m) | ||||||
|  |       selections+=($opt) | ||||||
|  |       ;; | ||||||
|  |     r) | ||||||
|  |       selections+=($opt) | ||||||
|  |       ;; | ||||||
|  |     q) | ||||||
|  |       quiet=1 | ||||||
|  |       verbose=0 | ||||||
|  |       selections+=($opt) | ||||||
|  |       ;; | ||||||
|  |     t) | ||||||
|  |       selections+=($opt) | ||||||
|  |       ;; | ||||||
|  |     v) | ||||||
|  |       quiet=0 | ||||||
|  |       verbose=1 | ||||||
|  |       selections+=($opt) | ||||||
|  |       ;; | ||||||
|  |     *) | ||||||
|  |       echo "unknown option: $opt" | ||||||
|  |       echo "$USAGE" | ||||||
|  |       exit 1 | ||||||
|  |       ;; | ||||||
|  |   esac | ||||||
|  | done | ||||||
|  |  | ||||||
|  | if (( ${#selections} < 1 )); then | ||||||
|  |   echo "$USAGE" | ||||||
|  |   exit 0 | ||||||
|  | fi | ||||||
|  |  | ||||||
|  | HR=" ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- -----" | ||||||
|  | function hr() { | ||||||
|  |   echo "$HR" | ||||||
|  | } | ||||||
|  |  | ||||||
| # Find core files | # Find core files | ||||||
| core_files=() | core_files=() | ||||||
| cd / | cd / | ||||||
| mapfile -t core_files < <(ls /core* /home/lanforge/core* 2>/dev/null) | mapfile -t core_files < <(ls /core* /home/lanforge/core* 2>/dev/null) | ||||||
|  |  | ||||||
|  |  | ||||||
| # Find ath10k crash residue | # Find ath10k crash residue | ||||||
| ath10_files=() | ath10_files=() | ||||||
| mapfile -t ath10_files < <(ls /home/lanforge/ath10* 2>/dev/null) | mapfile -t ath10_files < <(ls /home/lanforge/ath10* 2>/dev/null) | ||||||
| @@ -53,7 +136,7 @@ echo "Usage of /mnt: $usage_mnt" | |||||||
| echo "Usage of /lib/modules: $usage_libmod" | echo "Usage of /lib/modules: $usage_libmod" | ||||||
| echo "Boot usage: $boot_usage" | echo "Boot usage: $boot_usage" | ||||||
|  |  | ||||||
| if (( ${#boot_kernels[@]} > 4 )); then | if (( ${#boot_kernels[@]} > 1 )); then | ||||||
|     echo "Boot ramdisks:" |     echo "Boot ramdisks:" | ||||||
|     hr |     hr | ||||||
|     printf '     %s\n' "${boot_kernels[@]}" |     printf '     %s\n' "${boot_kernels[@]}" | ||||||
| @@ -63,8 +146,21 @@ fi | |||||||
| # ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- # | # ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- # | ||||||
| #   delete extra things now                                               # | #   delete extra things now                                               # | ||||||
| # ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- # | # ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- # | ||||||
|  | echo "Automatic deletion will include: " | ||||||
|  | echo " journalctl space" | ||||||
|  | sleep 1 | ||||||
| # ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- # | # ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- # | ||||||
| #   ask to remove if we are interactive                                   # | #   ask to remove if we are interactive                                   # | ||||||
| # ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- # | # ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- # | ||||||
|  | if | ||||||
|  | item="" | ||||||
|  | while [[ $item != q ]]; do | ||||||
|  |   hr | ||||||
|  |   echo "Would you like to delete? " | ||||||
|  |   echo "  1) core crash files" | ||||||
|  |   echo "  2) ath10k crash files" | ||||||
|  |   echo "  3) old var/www downloads" | ||||||
|  |   echo "  4) old lanforge downloads" | ||||||
|  |   echo "  5) orphaned /mnt/lf files" | ||||||
|  |   read -p "[1-5] or q ? " item | ||||||
|  | done | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 Jed Reynolds
					Jed Reynolds