27 lines
		
	
	
		
			508 B
		
	
	
	
		
			Plaintext
		
	
	
	
	
	
		
		
			
		
	
	
			27 lines
		
	
	
		
			508 B
		
	
	
	
		
			Plaintext
		
	
	
	
	
	
| 
								 | 
							
								#!/bin/bash
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								set -x
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								basedir="/srv/yggdrasil"
							 | 
						||
| 
								 | 
							
								shafile="$basedir""/library.sha256"
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								option="$1"
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								if [ "$option" == "-h" ] || [ "$option" == "--help" ]; then
							 | 
						||
| 
								 | 
							
								    echo Usage: $0 '[verify]'
							 | 
						||
| 
								 | 
							
								    exit 1
							 | 
						||
| 
								 | 
							
								fi
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								if [[ "$option" != "verify" ]]; then
							 | 
						||
| 
								 | 
							
								    chmod u+w "$basedir"
							 | 
						||
| 
								 | 
							
								    touch "$shafile"
							 | 
						||
| 
								 | 
							
								    chmod u+w "$shafile"
							 | 
						||
| 
								 | 
							
								    find "$basedir" -type f -exec sha256sum {} \; > "$shafile"
							 | 
						||
| 
								 | 
							
								    chmod u-w "$basedir" "$shafile"
							 | 
						||
| 
								 | 
							
								    exit 0;
							 | 
						||
| 
								 | 
							
								else
							 | 
						||
| 
								 | 
							
								    echo "These files have problems:"
							 | 
						||
| 
								 | 
							
								    sha256sum -c "$shafile";
							 | 
						||
| 
								 | 
							
								    exit $?;
							 | 
						||
| 
								 | 
							
								fi
							 |