3 # parse *.profile and build a curses menu, so the user can select a profile
5 # (c) 2015 by Thomas Lange, lange@cs.uni-koeln.de
6 # Universitaet zu Koeln
8 if [ X
$FAI_ACTION = Xinstall
-o X
$FAI_ACTION = Xdirinstall
-o X
$FAI_ACTION = X
]; then
14 [ "$flag_menu" ] ||
return 0
17 # save stdout and redirect stdout to tty
21 trap "rm -f $tempfile $tempfile2" EXIT INT QUIT
23 # declare the data structure, use associative arrays
33 # read a profile and add all info to the data structure
42 # disable word splitting when reading a line, this helps reading a keyword without a value
46 while read -r line ||
[[ -n $line ]]; do
48 if [[ $line =~
"Name: " ]]; then
49 if [ -n "$long" ]; then
58 [ $debug ] && echo "XX NAME $name found"
59 list
+=("$name") # add new item to list
63 if [[ $line =~
"Description: " ]]; then
65 desc
=${line##Description: }
66 [ $debug ] && echo "XX $desc found"
71 if [[ $line =~
"Short: " ]]; then
73 short
=${line##Short: }
74 [ $debug ] && echo "XX $short found"
75 arshort
[$name]="$short"
79 if [[ $line =~
"Classes: " ]]; then
81 classes
=${line##Classes: }
82 [ $debug ] && echo "XX classes found"
83 arclasses
[$name]="$classes"
87 if [[ $line =~
"Long: " ]]; then
90 [ $debug ] && echo "XX long found"
92 # else it's another long line
93 elif [ $lflag -eq 1 ]; then
97 if [[ $line =~
"Default: " ]]; then
99 default
=${line##Default: }
105 if [ -n "$long" ]; then
106 arlong
[$name]="$long"
113 # set newclasses which is used by fai-class(1)
114 local res
=$
(<$tempfile)
115 echo "$BASH_SOURCE defined new classes: ${arclasses[$res]}"
116 newclasses
="${arclasses[$res]}"
120 # read all files with name matching *.profile
123 for _f
in *.profile
; do
129 # do nothing if no profile was read
130 if [ $_parsed -eq 0 ]; then
135 # create the argument list containing the menu entries
136 # and the help text file
137 for i
in "${list[@]}"; do
139 par
+=("${ardesc[${i}]}")
140 par
+=("${arshort[${i}]}")
141 echo "Name: ${i}" >> $tempfile2
142 echo -e ${arlong[${i}]} >> $tempfile2
143 echo -e "Classes: " ${arclasses[${i}]} "\n" >> $tempfile2
149 dialog
--clear --item-help --title "FAI - Fully Automatic Installation" --help-button \
150 --default-item "$default" \
151 --menu "\nSelect your FAI profile\n\nThe profile will define a list of classes,\nwhich are used by FAI.\n\n\n"\
152 15 70 0 "${par[@]}" 2> $tempfile
159 echo "No profile selected."
162 dialog
--title "Description of all profiles" --textbox $tempfile2 0 0 ;;
166 unset par ardesc arshort arlong arclasses list tempfile tempfile2 _parsed _retval line
168 exec 1>&4 # restore stdout