mirror of
				https://github.com/materusPL/nixos-config
				synced 2025-11-03 22:10:28 +01:00 
			
		
		
		
	git-crypt: add simple script to unlock repo
This commit is contained in:
		
							parent
							
								
									3e93bbfd82
								
							
						
					
					
						commit
						deaa785e1f
					
				
							
								
								
									
										46
									
								
								crypt.sh
									
									
									
									
									
										Executable file
									
								
							
							
						
						
									
										46
									
								
								crypt.sh
									
									
									
									
									
										Executable file
									
								
							@ -0,0 +1,46 @@
 | 
			
		||||
#!/usr/bin/env bash
 | 
			
		||||
 | 
			
		||||
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
 | 
			
		||||
cd $SCRIPT_DIR
 | 
			
		||||
 | 
			
		||||
if [ $# = 0 ] || ( [ $# = 1 ] && [ $1 = "help" ] ); then
 | 
			
		||||
echo "Use \"unlock\" to unlock with pgp"
 | 
			
		||||
echo "Use \"unlock\" /path/to/key to unlock with symmetric key"
 | 
			
		||||
echo "Use \"lock\": to lock repository"
 | 
			
		||||
exit
 | 
			
		||||
fi
 | 
			
		||||
 | 
			
		||||
if [ "$(git status --porcelain)" ]; then
 | 
			
		||||
echo "Working directory not clean."
 | 
			
		||||
echo "Please commit your changes or 'git stash' them before running this script"
 | 
			
		||||
exit 1
 | 
			
		||||
fi
 | 
			
		||||
 | 
			
		||||
create_decrypt () {
 | 
			
		||||
    touch decrypted
 | 
			
		||||
    git add --intent-to-add decrypted
 | 
			
		||||
    git update-index --assume-unchanged decrypted
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
if [ $# = 1 ]; then
 | 
			
		||||
 | 
			
		||||
    if [ $1 = "unlock" ]; then
 | 
			
		||||
        git-crypt unlock
 | 
			
		||||
        create_decrypt
 | 
			
		||||
        exit
 | 
			
		||||
    fi
 | 
			
		||||
 | 
			
		||||
    if [ $1 = "lock" ]; then
 | 
			
		||||
        rm decrypted
 | 
			
		||||
        git-crypt lock
 | 
			
		||||
        exit
 | 
			
		||||
    fi
 | 
			
		||||
 | 
			
		||||
fi
 | 
			
		||||
 | 
			
		||||
if [ $# = 2 ] && [ $1 = "unlock" ]; then
 | 
			
		||||
    git-crypt unlock $2
 | 
			
		||||
    create_decrypt
 | 
			
		||||
    exit
 | 
			
		||||
fi
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user