mirror of
				https://github.com/kevinveenbirkenbach/computer-playbook.git
				synced 2025-11-04 04:08:15 +00:00 
			
		
		
		
	Added exit code and regex
This commit is contained in:
		@@ -1,6 +1,11 @@
 | 
				
			|||||||
#!/bin/bash
 | 
					#!/bin/bash
 | 
				
			||||||
# Checks the healt of all btrfs volumes
 | 
					exit_code=0
 | 
				
			||||||
for path in $(btrfs filesystem show | awk '/ path /{print $NF}')
 | 
					for path in $(btrfs filesystem show | awk '/ path /{print $NF}')
 | 
				
			||||||
do
 | 
					do
 | 
				
			||||||
  btrfs device stats $path
 | 
					  echo "Checking healt for $path..."
 | 
				
			||||||
 | 
					  result=$(btrfs device stats $path)
 | 
				
			||||||
 | 
					  echo "$result"
 | 
				
			||||||
 | 
					  regex='\.(.*)_errs(\s*)[1-9]'
 | 
				
			||||||
 | 
					  [[ "$result" =~ $regex ]] && echo "Errors found!" && exit_code=1;
 | 
				
			||||||
done
 | 
					done
 | 
				
			||||||
 | 
					exit $exit_code
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user