3 # parse *.profile and build a curses menu, so the user can select a profile
5 # (c) 2015 by Thomas Lange, lange@informatik.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
19 trap "rm -f $tempfile $tempfile2" EXIT INT QUIT
21 # declare the data structure, use associative arrays
31 # read a profile and add all info to the data structure
40 # disable word splitting when reading a line, this helps reading a keyword without a value
44 while read -r line ||
[[ -n $line ]]; do
46 if [[ $line =~
"Name: " ]]; then
47 if [ -n "$long" ]; then
56 [ $debug ] && echo "XX NAME $name found"
57 list
+=("$name") # add new item to list
61 if [[ $line =~
"Description: " ]]; then
63 desc
=${line##Description: }
64 [ $debug ] && echo "XX $desc found"
69 if [[ $line =~
"Short: " ]]; then
71 short
=${line##Short: }
72 [ $debug ] && echo "XX $short found"
73 arshort
[$name]="$short"
77 if [[ $line =~
"Classes: " ]]; then
79 classes
=${line##Classes: }
80 [ $debug ] && echo "XX classes found"
81 arclasses
[$name]="$classes"
85 if [[ $line =~
"Long: " ]]; then
88 [ $debug ] && echo "XX long found"
90 # else it's another long line
91 elif [ $lflag -eq 1 ]; then
95 if [[ $line =~
"Default: " ]]; then
97 default
=${line##Default: }
103 if [ -n "$long" ]; then
104 arlong
[$name]="$long"
111 # set newclasses which is used by fai-class(1)
112 local res
=$
(<$tempfile)
113 echo "$BASH_SOURCE defined new classes: ${arclasses[$res]}"
114 newclasses
="${arclasses[$res]}"
118 # read all files with name matching *.profile
121 for _f
in *.profile
; do
127 # do nothing if no profile was read
128 if [ $_parsed -eq 0 ]; then
133 # create the argument list containing the menu entries
134 # and the help text file
135 for i
in "${list[@]}"; do
137 par
+=("${ardesc[${i}]}")
138 par
+=("${arshort[${i}]}")
139 echo "Name: ${i}" >> $tempfile2
140 echo -e ${arlong[${i}]} >> $tempfile2
141 echo -e "Classes: " ${arclasses[${i}]} "\n" >> $tempfile2
147 dialog
--clear --item-help --title "FAI - Fully Automatic Installation" --help-button \
148 --default-item "$default" \
149 --menu "\nSelect your FAI profile\n\nThe profile will define a list of classes,\nwhich are used by FAI.\n\n\n"\
150 15 70 0 "${par[@]}" 2> $tempfile 1> $out
158 echo "No profile selected."
161 dialog
--title "Description of all profiles" --textbox $tempfile2 0 0 1> $out;;
165 unset par ardesc arshort arlong arclasses list tempfile tempfile2 _parsed _retval line