# $Id$ root_password_dialog() { #ROOT_PASSWORD=$(passwordbox "root" "Enter a password for root:" 10 50) #ROOT_PASSWORD_RETYPE=$(passwordbox "root" "Re-enter the password:" 10 50) ROOT_USER_SETUP=($(dialog \ --stdout \ --colors \ --title "root" \ --backtitle "${TITLE}" \ --insecure \ --mixedform "Enter a password for root:" 10 60 0 \ " Username:" 1 1 "root" 1 18 36 0 2 \ " Password:" 2 1 "${ROOT_PASSWORD}" 2 18 36 0 1 \ "Retype Password:" 3 1 "${ROOT_PASSWORD_RETYPE}" 3 18 36 0 1)) debug "ARRAY_LEN='${#ROOT_USER_SETUP[*]}'" debug "ROOT_USER_SETUP='${ROOT_USER_SETUP[*]}'" } add_user_dialog() { #USER_NAME=$(inputbox "Create a user" "Please enter a username for daily use:" 10 50) #if [[ ! -z ${USER_NAME} ]] #then # USER_PASSWORD=$(passwordbox "${USER_NAME}" "Enter a password for '${USER_NAME}':" 10 50) # USER_PASSWORD_RETYPE=$(passwordbox "${USER_NAME}" "Enter a password for '${USER_NAME}':" 10 50) #fi USER_SETUP=($(dialog \ --stdout \ --colors \ --title "User-Setup" \ --backtitle "${TITLE}" \ --insecure \ --mixedform "Please enter a username and password for daily use:" 10 60 0 \ " Username:" 1 1 "${USER_NAME}" 1 18 36 0 0 \ " Password:" 2 1 "${USER_PASSWORD}" 2 18 36 0 1 \ "Retype Password:" 3 1 "${USER_PASSWORD_RETYPE}" 3 18 36 0 1)) debug "ARRAY_LEN='${#USER_SETUP[*]}'" debug "USER_SETUP='${USER_SETUP[*]}'" } check_password() { local pass1="$1" local pass2="$2" if [[ -z ${pass1} ]] then messagebox "Warning" "Empty password given!" 10 40 return 1 fi if [[ ${pass1} = ${pass2} ]] then return 0 else messagebox "Warning" "Passwords did not match!" 10 40 return 1 fi } rundialog_root_password_dialog() { # root_password_dialog # case $? in # -1) die "Error!" ;; # 255) die "aborted by user" ;; # # 1) # root_password_dialog # ;; # # 0) # export ROOT_PASSWORD # if ! check_password "${ROOT_PASSWORD}" "${ROOT_PASSWORD_RETYPE}" # then # rundialog_root_password_dialog # fi # ;; # esac root_password_dialog case $? in -1) die "Error!" ;; 255) die "aborted by user" ;; 1) root_password_dialog ;; 0) #export ROOT_PASSWORD #if ! check_password "${ROOT_PASSWORD}" "${ROOT_PASSWORD_RETYPE}" #then # rundialog_root_password_dialog #fi # root username is array item 0! ROOT_PASSWORD="${ROOT_USER_SETUP[1]}" ROOT_PASSWORD_RETYPE="${ROOT_USER_SETUP[2]}" # check array len if [ ${#ROOT_USER_SETUP[*]} -ne 3 ] then messagebox "Warning" "You must re-type the password!" 10 40 rundialog_root_password_dialog fi if ! check_password "${ROOT_PASSWORD}" "${ROOT_PASSWORD_RETYPE}" then rundialog_root_password_dialog fi export ROOT_PASSWORD ;; esac debug "ROOT_PASSWORD='${ROOT_PASSWORD}'" } rundialog_add_user_dialog() { # add_user_dialog # case $? in # -1) die "Error!" ;; # 255) die "aborted by user" ;; # # 1) # rundialog_root_password_dialog # rundialog_add_user_dialog # ;; # # 0) # export USER_NAME # export USER_PASSWORD # if [[ -z ${USER_NAME} ]] # then # messagebox "Warning" "No username given!" 10 40 # rundialog_add_user_dialog # fi # if ! check_password "${USER_PASSWORD}" "${USER_PASSWORD_RETYPE}" # then # rundialog_add_user_dialog # fi # ;; # esac add_user_dialog case $? in -1) die "Error!" ;; 255) die "aborted by user" ;; 1) rundialog_root_password_dialog rundialog_add_user_dialog ;; 0) # export USER_NAME # export USER_PASSWORD # if [[ -z ${USER_NAME} ]] # then # messagebox "Warning" "No username given!" 10 40 # rundialog_add_user_dialog # fi # if ! check_password "${USER_PASSWORD}" "${USER_PASSWORD_RETYPE}" # then # rundialog_add_user_dialog # fi USER_NAME="${USER_SETUP[0]}" USER_PASSWORD="${USER_SETUP[1]}" USER_PASSWORD_RETYPE="${USER_SETUP[2]}" # check array len if [ ${#USER_SETUP[*]} -ne 3 ] then if [[ -z ${USER_SETUP[0]} ]] then messagebox "Warning" "No username given!" 10 40 else messagebox "Warning" "You must re-type the password!" 10 40 fi rundialog_add_user_dialog fi if ! check_password "${USER_PASSWORD}" "${USER_PASSWORD_RETYPE}" then rundialog_add_user_dialog fi export USER_NAME export USER_PASSWORD ;; esac debug "USER_NAME='${USER_NAME}'" debug "USER_PASSWORD='${USER_PASSWORD}'" debug "USER_PASSWORD_RETYPE='${USER_PASSWORD_RETYPE}'" } main_usermanagement() { rundialog_root_password_dialog rundialog_add_user_dialog }