mirror of
				https://github.com/apache/cloudstack.git
				synced 2025-10-26 08:42:29 +01:00 
			
		
		
		
	
		
			
				
	
	
		
			35 lines
		
	
	
		
			512 B
		
	
	
	
		
			Bash
		
	
	
		
			Executable File
		
	
	
	
	
			
		
		
	
	
			35 lines
		
	
	
		
			512 B
		
	
	
	
		
			Bash
		
	
	
		
			Executable File
		
	
	
	
	
| #!/bin/bash
 | |
| # Usage
 | |
| #	save_password -v <user VM IP> -p <password>
 | |
| #
 | |
| 
 | |
| while getopts 'v:p:' OPTION
 | |
| do
 | |
|   case $OPTION in
 | |
|   v)	VM_IP="$OPTARG"
 | |
| 		;;
 | |
|   p)	
 | |
| 		ENCODEDPASSWORD="$OPTARG"
 | |
| 		PASSWORD=$(echo $ENCODEDPASSWORD | tr '[a-m][n-z][A-M][N-Z]' '[n-z][a-m][N-Z][A-M]')
 | |
| 		;;
 | |
|   ?)	echo "Incorrect usage"
 | |
| 		exit 1
 | |
| 		;;
 | |
|   esac
 | |
| done
 | |
| 
 | |
| if [ ! -f /root/passwords ]; 
 | |
|   then 
 | |
|     touch /root/passwords; 
 | |
| fi
 | |
| 
 | |
| sed -i /$VM_IP/d /root/passwords
 | |
| echo "$VM_IP=$PASSWORD" >> /root/passwords
 | |
| 
 | |
| if [ $? -ne 0 ]
 | |
| then
 | |
| 	exit 1
 | |
| fi
 | |
| 
 | |
| exit 0
 |