# $Id$ root_password_dialog() { 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 } add_user_dialog() { 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 } 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() { local ROOT_USER_SETUP ROOT_USER_SETUP=($(root_password_dialog)) case $? in -1) die "Error!" ;; 255) die "aborted by user" ;; 1) root_password_dialog ;; 0) # 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() { local USER_SETUP USER_SETUP=($(add_user_dialog)) case $? in -1) die "Error!" ;; 255) die "aborted by user" ;; 1) rundialog_root_password_dialog rundialog_add_user_dialog ;; 0) 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 }