#some constant values used by the dialog screens to make them more legible
BACK="--colors --backtitle"
TITLE="\Z7Pyrenee Conversion Utility"
MSG=--msgbox --yes-label "OK"
SIZE="10 50"
MSG='--yes-label "OK" --msgbox'
SIZE="10 75"
dialog $BACK"$TITLE" --title "WELCOME!"$MSG"Welcome to the Pyrenee Conversion Utility.\n\nThis utility will make a number of (mostly reversible) changes to your system. It should be run directly after installing Alpine Linux 3.15, which will setup the foundation we build upon."$SIZE
dialog $BACK"$TITLE" --form "Please supply the required information:\n(username can only contain small letters)"10503"Full Name:"10""110150"Username:"20""210150 2>input &&FULLNAME=$(sed -n '1p' input)&&USER=$(sed -n '2p' input | sed 's/[A-Z]/\L&/g')&& rm -f input
dialog $BACK"$TITLE" --insecure --title "Password Provider" --passwordbox "Provide a password for $FULLNAME"$SIZE 2>password &&PASSWORD1=$(sed -n '1p' password)&& rm -f password
dialog $BACK"$TITLE" --form "Please supply the required information:\n(username can only contain small letters)"$SIZE3"Full Name:"10""111600" username:"20""211600 2>input &&FULLNAME=$(sed -n '1p' input)&&USER=$(sed -n '2p' input | sed 's/[A-Z]/\L&/g')&& rm -f input
#Return status of non-zero indicates cancel
if["$?" !="0"]||["$USER"=""]||["$FULLNAME"=""]
then
dialog $BACK"$TITLE"$MSG"Pyrenee Conversion was canceled because the provided passwords didn't match or any necessary input was omitted.\n\nPlease restart the Pyrenee Conversion Utility."$SIZE&& clear
dialog $BACK"$TITLE"$MSG"Pyrenee Conversion was canceled at your request or either field was empty.\n\nPlease restart the Pyrenee Conversion Utility."$SIZE&& clear
else
dialog $BACK"$TITLE" --title "Confirmation" --yes-label "Enter" --no-label "Esc" --yesno "This is the last opportunity to cancel the conversion.\n\nPlease press <Enter> to start conversion or <Esc> to cancel."$SIZE
dialog $BACK"$TITLE" --insecure --title "Password Provider" --passwordbox "Provide a password for $FULLNAME"$SIZE 2>password &&PASSWORD1=$(sed -n '1p' password)&& rm -f password
#Return status of non-zero indicates cancel
if["$?" !="0"]
if["$?" !="0"]||["$PASSWORD1"=""]
then
dialog $BACK"$TITLE"$MSG"Pyrenee Conversion was canceled at your request."$SIZE&& clear
dialog $BACK"$TITLE"$MSG"Pyrenee Conversion was canceled at your request or input field was empty.\n\nPlease restart the Pyrenee Conversion Utility."$SIZE&& clear
dialog $BACK"$TITLE"$MSG"Pyrenee Conversion was canceled at your request or input field was empty.\n\nPlease restart the Pyrenee Conversion Utility."$SIZE&& clear
else
if["$PASSWORD1" !="$PASSWORD2"]
then
dialog $BACK"$TITLE"$MSG"Pyrenee Conversion was canceled because the provided passwords didn't match.\n\nPlease restart the Pyrenee Conversion Utility."$SIZE&& clear
else
dialog $BACK"$TITLE" --title "Confirmation" --yes-label "Enter" --no-label "Esc" --yesno "This is the last opportunity to cancel the conversion.\n\nPlease press <Enter> to start conversion or <Esc> to cancel."$SIZE
#Return status of non-zero indicates cancel
if["$?" !="0"]
then
dialog $BACK"$TITLE"$MSG"Pyrenee Conversion was canceled at your request."$SIZE&& clear
else
#backup rc.conf & enable rc_parallel
cp /etc/rc.conf /etc/rc.conf.bak
sed -i s/\#rc\_parallel\=\"NO\"/rc\_parallel\=\"YES\"/g /etc/rc.conf
cp /etc/rc.conf /etc/rc.conf.bak
sed -i s/\#rc\_parallel\=\"NO\"/rc\_parallel\=\"YES\"/g /etc/rc.conf
#backup & switch repositories config file to https connection
dialog $BACK"$TITLE" --title "Finished!" --yes-label "Enter" --no-label "Esc" --yesno "Conversion was completed, it is recommended to reboot to finish your new Desktop experience!\n\nPlease press <Enter> to reboot or <Esc> to continue your current session."$SIZE
dialog $BACK"$TITLE" --title "Finished!" --yes-label "Enter" --no-label "Esc" --yesno "Conversion was completed, it is recommended to reboot to finish your new Desktop experience!\n\nPlease press <Enter> to reboot or <Esc> to continue your current session."$SIZE