[Ovirt-devel] [PATCH node] Password configuration script for the root password and sasl users

Bryan Kearney bkearney at redhat.com
Mon Nov 10 19:22:13 UTC 2008


---
 scripts/ovirt-config-password |   92 +++++++++++++++++++++++++++++++++++++++++
 1 files changed, 92 insertions(+), 0 deletions(-)

diff --git a/scripts/ovirt-config-password b/scripts/ovirt-config-password
index 8b13789..af99915 100755
--- a/scripts/ovirt-config-password
+++ b/scripts/ovirt-config-password
@@ -1 +1,93 @@
+#!/bin/bash
+#
+# Set the root password and others
+
+ROOT_PASSWORD=""
+
+function sasl_password {
+	printf "adding user $1 to the sasl list for libvirt\n"
+	echo $2 | saslpasswd2 -a libvirt -p $1
+}
+
+function set_root_password {
+	while true; do
+		printf "\nPlease enter the new root password (hit return to skip) "
+		read -s	
+		if [[ $REPLY == "" ]]; then
+			return 1
+		fi
+		ROOT_PASSWORD=$REPLY
+		printf "\nPlease enter again to confirm "				
+		read -s 
+		ROOT_PASSWORD_CONFIRM=$REPLY
+		if [[ $ROOT_PASSWORD == $ROOT_PASSWORD_CONFIRM ]]; then
+			echo $ROOT_PASSWORD | passwd --stdin root
+			sasl_password root $ROOT_PASSWORD
+			break 
+		else
+			printf "\nPaswords did not match. Please try again"
+		fi
+	done
+	return 0
+}
+
+# Prompts the user for a single username, password combo
+function prompt_sasl_user {
+	while true; do	
+		printf "\nPlease enter a new user (hit return to skip) "
+		read
+		if [[ $REPLY == "" ]]; then
+			break
+		fi	
+		SASL_USER=$REPLY	
+		printf "\nPlease enter the password for $SASL_USER (hit return to skip) "
+		read -s	
+		if [[ $REPLY == "" ]]; then
+			return 1
+		fi
+		SASL_PASSWORD=$REPLY
+		printf "\nPlease enter again to confirm "				
+		read -s 
+		SASL_PASSWORD_CONFIRM=$REPLY
+		if [[ $SASL_PASSWORD == $SASL_PASSWORD_CONFIRM ]]; then
+			sasl_password $SASL_USER $SASL_PASSWORD
+			break 
+		else
+			printf "\nPaswords did not match. Please try again"
+		fi	
+	done
+	
+}
+
+#Check for the root user first
+while true ; do 
+	printf "\nWould you like to set the root password (Y|N) "
+	read
+	case $REPLY in
+	Y|y) 
+		set_root_password
+		if [[ $? == 0 ]] ; then
+			break ;
+		fi
+		;;
+	N|n)
+		break ;
+		;;
+	esac
+done
+
+#Check for any sasl users
+while true ; do 
+	printf "\nWould you like to add a new sasl user for libvirt (Y|N) "
+	read
+	case $REPLY in
+	Y|y) 
+		prompt_sasl_user
+		;;
+	N|n)
+		break ;
+		;;
+	esac
+done
+
 
-- 
1.5.6.5




More information about the ovirt-devel mailing list