4 # parse *.profile and build a curses menu, so the user can select a profile
6 # (c) 2015 by Thomas Lange, lange@informatik.uni-koeln.de
7 # Universitaet zu Koeln
9 if [ X
$FAI_ACTION = Xinstall
-o X
$FAI_ACTION = Xdirinstall
-o X
$FAI_ACTION = X
]; then
15 [ "$flag_menu" ] ||
return 0
18 tempfile
=`(tempfile) 2>/dev/null`
19 tempfile2
=`(tempfile) 2>/dev/null`
20 trap "rm -f $tempfile $tempfile2" EXIT INT QUIT
22 # declare the data structure, use associative arrays
32 # read a profile and add all info to the data structure
41 # disable word splitting when reading a line, this helps reading a keyword without a value
45 while read -r line ||
[[ -n $line ]]; do
47 if [[ $line =~
"Name: " ]]; then
48 if [ -n "$long" ]; then
57 [ $debug ] && echo "XX NAME $name found"
58 list
+=("$name") # add new item to list
62 if [[ $line =~
"Description: " ]]; then
64 desc
=${line##Description: }
65 [ $debug ] && echo "XX $desc found"
70 if [[ $line =~
"Short: " ]]; then
72 short
=${line##Short: }
73 [ $debug ] && echo "XX $short found"
74 arshort
[$name]="$short"
78 if [[ $line =~
"Classes: " ]]; then
80 classes
=${line##Classes: }
81 [ $debug ] && echo "XX classes found"
82 arclasses
[$name]="$classes"
86 if [[ $line =~
"Long: " ]]; then
89 [ $debug ] && echo "XX long found"
91 # else it's another long line
92 elif [ $lflag -eq 1 ]; then
96 if [[ $line =~
"Default: " ]]; then
98 default
=${line##Default: }
104 if [ -n "$long" ]; then
105 arlong
[$name]="$long"
112 # set newclasses which is used by fai-class(1)
113 local res
=$
(<$tempfile)
114 echo "$BASH_SOURCE defined new classes: ${arclasses[$res]}"
115 newclasses
="${arclasses[$res]}"
119 # read all files with name matching *.profile
122 for _f
in *.profile
; do
128 # do nothing if no profile was read
129 if [ $_parsed -eq 0 ]; then
134 # create the argument list containing the menu entries
135 # and the help text file
136 for i
in "${list[@]}"; do
138 par
+=("${ardesc[${i}]}")
139 par
+=("${arshort[${i}]}")
140 echo "Name: ${i}" >> $tempfile2
141 echo -e ${arlong[${i}]} >> $tempfile2
142 echo -e "Classes: " ${arclasses[${i}]} "\n" >> $tempfile2
148 dialog
--clear --item-help --title "FAI - Fully Automatic Installation" --help-button \
149 --default-item "$default" \
150 --menu "\nSelect your FAI profile\n\nThe profile will define a list of classes,\nwhich are used by FAI.\n\n\n"\
151 15 70 0 "${par[@]}" 2> $tempfile 1> $out
159 echo "No profile selected."
162 dialog
--title "Description of all profiles" --textbox $tempfile2 0 0 1> $out;;
166 unset par ardesc arshort arlong arclasses list tempfile tempfile2 _parsed _retval line