From Fedora Project Wiki

< Anaconda

Revision as of 16:26, 24 May 2008 by Ravidiip (talk | contribs) (1 revision(s))
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

The printable version is no longer supported and may have rendering errors. Please update your browser bookmarks and please use the default browser print function instead.

An example for customized user interaction in the %post section:

In order to allow user interaction in the %post section a switch of the virtual terminal has to occur. This is done with the following lines right after the *%post%* line and before any other script starts.

_exec < /dev/tty3 > /dev/tty3_ _chvt 3_

Once the script is finished the virtual terminal needs to be switched back to where the original Anaconda process runs. This is accomplished by adding a _chvt 3_ line to the end of the *%post%* section.

The following is an example of a *%post%* script that will first ask to enter a new root password, then it will ask to verify the new root password. If the two entries match it asks to enter a user name, then a "real user name" and finally the script asks for a user password and a verification entry. If the two passwords match the script is finished and is returned to the Anaconda process where the installaion process continues.

---
*Example %post section*
---
%post
exec < /dev/tty3 > /dev/tty3
chvt 3

<!--##################################################################################################################################################################
-->
<!--##################################################################################################################################################################
-->

PASSWORD="&*UY^&^YI"
PASSWORD_CHECK=1

until [ "$PASSWORD" = "$PASSWORD_CHECK" ] 
do
if [ $PASSWORD = "&*UY^&^YI" ]  ; then

dialog --title "Enter root (Administrator) Password" --backtitle "MyDistro (C) 2003 MyDistro" --no-cancel --passwordbox "Enter a root (Administrator) password between 6 and 8 characters" 8 60 2>/tmp/passwd.$$

SEL=$?

NA5=<code>cat /tmp/passwd.$$</code>
case $SEL in
0)  PASSWORD=$NA5;;
1) echo "Cancel is Pressed" ;;
255) echo "[ESCAPE]  key pressed" ;;
esac

rm -f /tmp/passwd.$$

else

dialog --title "Passwords do not match" --backtitle "MyDistro (C) 2003 MyDistro" --msgbox "The passwords you entered do not match. Please re-enter passwords" 6 50

dialog --title "Enter root (Administrator) Password" --backtitle "MyDistro (C) 2003 MyDistro" --no-cancel --passwordbox "Enter a root (Administrator) password between 6 and 8 characters" 8 60 2>/tmp/passwd.$$

SEL=$?

NA5=<code>cat /tmp/passwd.$$</code>
case $SEL in
0) PASSWORD=$NA5;;
1) echo "Cancel is Pressed" ;;
255) echo "[ESCAPE]  key pressed" ;;
esac

rm -f /tmp/passwd.$$

fi

dialog --title "Re-enter root (Administrator) Password" --backtitle "MyDistro (C) 2003 MyDistro" --no-cancel --passwordbox "Please re-enter the root (Administrator) password" 8 60 2>/tmp/passwd.$$

SEL=$?

NA4=<code>cat /tmp/passwd.$$</code>
case $SEL in
0)  PASSWORD_CHECK=$NA4;;
1) echo "Cancel is Pressed" ;;
255) echo "[ESCAPE]  key pressed" ;;
esac

rm -f /tmp/passwd.$$

done

echo $NA4 | passwd --stdin root >/dev/null 2>&1

<!--##################################################################################################################################################################
-->

<!--##################################################################################################################################################################
-->
<!--##################################################################################################################################################################
-->

dialog --title "Add Username" --backtitle "MyDistro (C) 2003 MyDistro" --no-cancel --inputbox "Enter an easy to remember Username please" 8 60 2>/tmp/usrname.$$

SEL=$?

NA=<code>cat /tmp/usrname.$$</code>
case $SEL in
0) useradd $NA >/dev/null 2>&1 ;;
1) echo "Cancel is Pressed" ;;
255) echo "[ESCAPE]  key pressed" ;;
esac

rm -f /tmp/usrname.$$

<!--##################################################################################################################################################################
-->

<!--##################################################################################################################################################################
-->
<!--##################################################################################################################################################################
-->

dialog --title "Enter Name" --backtitle "MyDistro (C) 2003 MyDistro" --no-cancel --inputbox "Please enter your real name(first and last)" 8 60 2>/tmp/name.$$

SEL=$?

NA2=<code>cat /tmp/name.$$</code>
case $SEL in
0) chfn -f "$NA2" $NA >/dev/null 2>&1 ;;
1) echo "Cancel is Pressed" ;;
255) echo "[ESCAPE]  key pressed" ;;
esac

rm -f /tmp/name.$$

<!--##################################################################################################################################################################
-->

<!--##################################################################################################################################################################
-->
<!--##################################################################################################################################################################
-->

PASSWORD="&*UY^&^YY"
PASSWORD_CHECK=1
until [ "$PASSWORD" = "$PASSWORD_CHECK" ] 
do
if [ $PASSWORD = "&*UY^&^YY" ]  ; then

dialog --title "Enter Password" --backtitle "MyDistro (C) 2003 MyDistro" --no-cancel --passwordbox "Enter a password between 6 and 8 characters" 8 60 2>/tmp/passwd.$$

SEL=$?

NA1=<code>cat /tmp/passwd.$$</code>
case $SEL in
0) PASSWORD=$NA1;;
1) echo "Cancel is Pressed" ;;
255) echo "[ESCAPE]  key pressed" ;;
esac

rm -f /tmp/passwd.$$

else

dialog --title "Password's do not match" --backtitle "MyDistro (C) 2003 MyDistro" --msgbox "The passwords you entered do not match. Please re-enter passwords" 6 50

dialog --title "Enter Password" --backtitle "MyDistro (C) 2003 MyDistro" --no-cancel --passwordbox "Enter a password between 6 and 8 characters" 8 60 2>/tmp/passwd.$$

SEL=$?

NA1=<code>cat /tmp/passwd.$$</code>
case $SEL in
0) PASSWORD=$NA1;;
1) echo "Cancel is Pressed" ;;
255) echo "[ESCAPE]  key pressed" ;;
esac

rm -f /tmp/passwd.$$

fi

dialog --title "Re-enter Password" --backtitle "MyDistro (C) 2003 MyDistro" --no-cancel --passwordbox "Please re-enter your password" 8 60 2>/tmp/passwd.$$

SEL=$?

NA3=<code>cat /tmp/passwd.$$</code>
case $SEL in
0)  PASSWORD_CHECK=$NA3;;
1) echo "Cancel is Pressed" ;;
255) echo "[ESCAPE]  key pressed" ;;
esac

rm -f /tmp/passwd.$$

done

echo $NA3 | passwd --stdin $NA >/dev/null 2>&1

<!--##################################################################################################################################################################
-->

<!--##################################################################################################################################################################
-->
<!--##################################################################################################################################################################
-->

dialog --title "Thank you" --backtitle "MyDistro (C) 2003 MyDistro" --msgbox "Thank you for choosing and installing MyDistro. Please press <ENTER> to reboot system and start MyDistro. Please remove any floppy disks and/or CD-ROMS from their respective drives." 9 50

<!--##################################################################################################################################################################
-->

chvt 3