#!/bin/bash label_regexp(){ echo "^label[[:blank:]]\+${1}\|^LABEL[[:blank:]]\+${1}" } label_locale(){ echo "[[:blank:]]locale=${1}" } generate_label(){ LNUM=$1 echo -e "\nLABEL ${ISOLINUX_OPT[$LNUM]}" sed -e "s%$(label_locale '[^[:blank:]]\+')% locale=${ISOLINUX_LANG[$LNUM]}%" $TMP_FILE } ISOLINUX_CFG="binary/isolinux/isolinux.cfg" ISOLINUX_OPT=(1 2 lliurex lliurex-de lliurex-ar lliurex-fr lliurex-en lliurex-ro lliurex-ru lliurex-an lliurex-ca lliurex-eu lliurex-gl) ISOLINUX_LANG=(qcv_ES es_ES qcv_ES de_DE ar_MA fr_FR en_GB ro_RO ru_RU an_ES ca_ES eu_ES gl_ES) APPEND_LOCALE="locale=${ISOLINUX_LANG[0]}" LABEL_APPEND="^[[:blank:]]*append[[:blank:]]\+\|^[[:blank:]]*APPEND[[:blank:]]\+" TMP_OPTIONS_LIST="$(tempfile)" FINAL_OPTIONS_LIST="binary/casper/boot-options.standard" [ -f "$ISOLINUX_CFG" ] || exit 0 grep -q "$(label_regexp live)" "$ISOLINUX_CFG" || exit 0 TMP_FILE="$(tempfile)" # extract "default label" to TMP_FILE sed -ne "/$(label_regexp live)/,/$(label_regexp)/{/$(label_regexp)/d;p}" "$ISOLINUX_CFG" > "$TMP_FILE" # check locale if ! grep -q "$(label_locale '[^[:blank:]]\+')" $TMP_FILE ; then # fix temp sed -i -e "/${LABEL_APPEND}/s%$% $APPEND_LOCALE%" $TMP_FILE # fix isolinux.cfg sed -i -e "/$(label_regexp live)/,/$(label_regexp)/{/${LABEL_APPEND}/s%$% $APPEND_LOCALE%}" "$ISOLINUX_CFG" fi # generate isolinux labels and temporary list of 'ignorable options' i=0 while [ $i -lt ${#ISOLINUX_OPT[@]} ] ; do generate_label $i |tee -a "$ISOLINUX_CFG" |sed -ne "/${LABEL_APPEND}/{s%${LABEL_APPEND}%%;s%[[:blank:]]\+%\n%gp}" >> "$TMP_OPTIONS_LIST" i=$(( $i+1 )) done # generate final list sort -u "$TMP_OPTIONS_LIST" > "$FINAL_OPTIONS_LIST" #Added options for failsafe mode ISOLINUX_OPT=(3 4) grep -q "$(label_regexp livefailsafe)" "$ISOLINUX_CFG" || exit 0 # extract "default label" to TMP_FILE sed -ne "/$(label_regexp livefailsafe)/,/$(label_regexp)/{/$(label_regexp)/d;p}" "$ISOLINUX_CFG" > "$TMP_FILE" # check locale if ! grep -q "$(label_locale '[^[:blank:]]\+')" $TMP_FILE ; then # fix temp sed -i -e "/${LABEL_APPEND}/s%$% $APPEND_LOCALE%" $TMP_FILE # fix isolinux.cfg sed -i -e "/$(label_regexp livefailsafe)/,/$(label_regexp)/{/${LABEL_APPEND}/s%$% $APPEND_LOCALE%}" "$ISOLINUX_CFG" fi i=0 while [ $i -lt ${#ISOLINUX_OPT[@]} ] ; do generate_label $i >> "$ISOLINUX_CFG" i=$(( $i+1 )) done #remove splash and quiet options for failsafe mode sed -i -e "/LABEL 3/,$ s%splash quiet\|quiet splash%%" "$ISOLINUX_CFG" # generate final list sort -u "$TMP_OPTIONS_LIST" > "$FINAL_OPTIONS_LIST" rm -f "$TMP_FILE" rm -f "$TMP_OPTIONS_LIST" exit 0