--- trunk/create-clonezilla-sysresccd/files/cust-menu 2010/07/15 20:54:27 84 +++ trunk/create-clonezilla-sysresccd/files/cust-menu 2010/08/13 08:30:37 93 @@ -20,42 +20,69 @@ # # ############################################################################## -function copyCFGfile(){ +function findCFGfile(){ if [ -e isolinux-restore-cd.cfg ];then - inFile="./isolinux-restore-cd.cfg" + templateCFG="./isolinux-restore-cd.cfg" elif [ -r /live/image/restorecd/isolinux-restore-cd.cfg ];then - inFile="/live/image/restorecd/isolinux-restore-cd.cfg" + templateCFG="/live/image/restorecd/isolinux-restore-cd.cfg" elif [ -r /tmp/restorecd/isolinux-restore-cd.cfg ];then - inFile="/tmp/restorecd/isolinux-restore-cd.cfg" + templateCFG="/tmp/restorecd/isolinux-restore-cd.cfg" +elif [ -r /restorecd/isolinux-restore-cd.cfg ];then + templateCFG="/restorecd/isolinux-restore-cd.cfg" else whiptail --backtitle Clonezilla-SysRescCD --title " Execution Error " --msgbox "This is not a stand-alone script and should not be executed by the command line This script will terminate now" 0 0 exit 1 fi -cp "$inFile" /tmp/isolinux-mine.cfg -bootImg="$(dirname "$inFile")"/ocswp.png -inFile='/tmp/isolinux-mine.cfg' } -function copy2RamCFGfile(){ +function find2RamCFGfile(){ if [ -e isolinux-restore-cd-ram.cfg ];then - inFile="./isolinux-restore-cd-ram.cfg" + templateCFG="./isolinux-restore-cd-ram.cfg" elif [ -r /live/image/restorecd/isolinux-restore-cd-ram.cfg ];then - inFile="/live/image/restorecd/isolinux-restore-cd-ram.cfg" + templateCFG="/live/image/restorecd/isolinux-restore-cd-ram.cfg" elif [ -r /tmp/restorecd/isolinux-restore-cd-ram.cfg ];then - inFile="/tmp/restorecd/isolinux-restore-cd-ram.cfg" + templateCFG="/tmp/restorecd/isolinux-restore-cd-ram.cfg" +elif [ -r /restorecd/isolinux-restore-cd-ram.cfg ];then + templateCFG="/restorecd/isolinux-restore-cd-ram.cfg" else whiptail --backtitle Clonezilla-SysRescCD --title " Execution Error " --msgbox "This is not a stand-alone script and should not be executed by the command line This script will terminate now" 0 0 exit 1 fi -cp "$inFile" /tmp/isolinux-mine.cfg -bootImg="$(dirname "$inFile")"/ocswp.png -inFile='/tmp/isolinux-mine.cfg' } +function import_parameters_to_cfg(){ +# -> $1 - template cfg file +# <- $2 - final cfg file +local outCFG="$2".tmp +# read parameters inserted by the user +# they are found in the isolinux.cfg file +# created by Clonezilla Live +local paramLine=`grep 'append' $2 | sed '2,$d'` +local ocs_live_extra_param="$(echo "$paramLine" | sed 's|.*ocs_live_extra_param="\([^"]*\)".*|\1|')" +local ocs_live_keymap="$(echo "$paramLine" | sed 's|.*ocs_live_keymap="\([^"]*\)".*|\1|')" +local ocs_lang="$(echo "$paramLine" | sed 's|.*ocs_lang="\([^"]*\)".*|\1|')" + +# replace with current values +sed "s|ocs_live_extra_param=\"[^\"]*\"|ocs_live_extra_param=\"$ocs_live_extra_param\"| +s|ocs_live_keymap=\"[^\"]*\"|ocs_live_keymap=\"$ocs_live_keymap\"| +s|ocs_lang=\"[^\"]*\"|ocs_lang=\"$ocs_lang\"| +" $1 > $outCFG && mv $outCFG $2 +} + +function copy_PNG_SYSLINUX(){ + SYSLINUX_FILE=`echo $finalCFG | sed 's{isolinux{syslinux{g'` + SYS=`dirname $finalCFG` + sed 's{noprompt {{g' $finalCFG > $SYSLINUX_FILE + cp /restorecd/ocswp.png $SYS + cp /restorecd/ocswp.png `echo $SYS | sed 's{isolinux{syslinux{g'` +} + + +type=ISO # Parse command-line options while [ $# -gt 0 ]; do @@ -78,6 +105,14 @@ fi # [ -z "$target_iso_prefix" ] && USAGE && exit 1 ;; + -z) + type=ZIP + shift + ;; + -o) + ORIGINAL_INSERT_MODE=y + shift + ;; *) break; ;; @@ -91,25 +126,36 @@ # # # # # # # # # the CFG file can be found as -# # # /tmp/*/isolinux/isolinux.cfg +# # # /tmp/ocs_isosys*/isolinux/isolinux.cfg # # # or -# # # /home/partimag/*/isolinux/isolinux.cfg +# # # /home/partimag/ocs_isosys*/isolinux/isolinux.cfg # # # # # # -if [ -e /tmp/*/isolinux/isolinux.cfg ];then +if [ "$type" = ISO ];then type=ISO - origCFG="/tmp/*/isolinux/isolinux.cfg" -elif [ -e /home/partimag/*/isolinux/isolinux.cfg ];then - type=ZIP - origCFG="/home/partimag/*/isolinux/isolinux.cfg" + finalCFG=/tmp/ocs_isosys*/isolinux/isolinux.cfg + finalCFG=`find /tmp -name isolinux.cfg` else - origCFG='' type=ZIP - dialog --backtitle Clonezilla-SysRescCD --title " Execution Error " --msgbox "This is not a stand-alone script and should not be executed by the command line - - This script will terminate now" 0 0 - exit 1 + finalCFG=/home/partimag/ocs_isosys*/isolinux/isolinux.cfg + finalCFG=`find /home/partimag -name isolinux.cfg` +fi + +if [ ! -e $finalCFG ];then + dialog --backtitle Clonezilla-SysRescCD --title " File not found " --msgbox " The original cfg file ($finalCFG) does not exit!!! + + This script will terminate now" 0 0 + + exit 1 +fi + +# Check if -s has been used (only iso) +if [ -n "$ORIGINAL_INSERT_MODE" ];then + findCFGfile + import_parameters_to_cfg $templateCFG $finalCFG + copy_PNG_SYSLINUX + exit fi @@ -118,17 +164,30 @@ You will have the chance to change the Title and Text of the Boot Screen, and set the Default menu item and Boot Delay" 11 60 if [ $? -eq 1 ];then - exit + CUSTOMIZE=no fi if [ "$1" = "prog_only" ];then - copy2RamCFGfile + find2RamCFGfile else - copyCFGfile + findCFGfile fi + + +import_parameters_to_cfg $templateCFG $finalCFG + + +############################################################################## +# +# Menu Customization +# +############################################################################## + +if [ -z "$CUSTOMIZE" ];then + # DVD Title -whiptail --backtitle Clonezilla-SysRescCD --title ' DVD Title ' --inputbox 'Insert the Title for the menu' 8 60 "$(grep 'MENU TITLE' "$inFile" | sed 's|^ *MENU TITLE *||' | sed 's| *||g')" 2>/tmp/answer +whiptail --backtitle Clonezilla-SysRescCD --title ' Menu Title ' --inputbox 'Insert the Title for the menu' 8 60 "$(grep 'MENU TITLE' $finalCFG | sed 's|^ *MENU TITLE *||' | sed 's| *||g')" 2>/tmp/answer menuTitle=`cat /tmp/answer` rm /tmp/answer 2>/dev/null @@ -164,7 +223,7 @@ to maintain current setting ' 0 60 0 \\" > /tmp/q.$$ -grep 'MENU LABEL' "$inFile" | sed '/---/d' | sed 's|^.*MENU LABEL *||' | sed "s|^|'|" | sed "s|$|'|" | awk '{print NR " " ""$0"" " "}' | tr -d '\n$' > /tmp/qq.$$ +grep 'MENU LABEL' "$templateCFG" | sed '/---/d' | sed 's|^.*MENU LABEL *||' | sed "s|^|'|" | sed "s|$|'|" | awk '{print NR " " ""$0"" " "}' | tr -d '\n$' > /tmp/qq.$$ oldCaption=`sed 's|^1 *.||' /tmp/qq.$$ | sed "s| *-.*||"` @@ -181,7 +240,9 @@ defItem=`cat /tmp/answer` if [ $defItem -gt 6 ];then ((defItem++));fi -if [ $defItem -eq 6 ];then defItem='';fi +((defItem++)) +#if [ $defItem -eq 6 ];then defItem='';fi +if [ $defItem -eq 7 ];then defItem='';fi rm /tmp/answer 2>/dev/null @@ -225,27 +286,30 @@ - - +############################################################################ +# +# Insert user data to file +# +############################################################################ if [ -n "$menuTitle" ];then - sed "s|^ *MENU TITLE .*|MENU TITLE $menuTitle|" "$inFile" > "$inFile".$$ && mv "$inFile".$$ "$inFile" + sed "s|^ *MENU TITLE .*|MENU TITLE $menuTitle|" $finalCFG > $finalCFG.$$ && mv $finalCFG.$$ $finalCFG fi if [ -n "$itemCaption" ];then - sed "s|MENU LABEL *$oldCaption *-|MENU LABEL $itemCaption -|" "$inFile" > "$inFile".$$ && mv "$inFile".$$ "$inFile" + sed "s|MENU LABEL *$oldCaption *-|MENU LABEL $itemCaption -|" $finalCFG > $finalCFG.$$ && mv $finalCFG.$$ $finalCFG fi if [ -n "$bootDelay" ];then - sed "s|[tT][iI][mM][eE][oO][uU][tT] .*| timeout "$bootDelay"0|" "$inFile" > "$inFile".$$ && mv "$inFile".$$ "$inFile" + sed "s|[tT][iI][mM][eE][oO][uU][tT] .*| timeout "$bootDelay"0|" $finalCFG > $finalCFG.$$ && mv $finalCFG.$$ $finalCFG fi if [ -n "$defItem" ];then - sed 's|^ *MENU DEFAULT| # MENU DEFAULT|' "$inFile" > "$inFile".$$ - addIt=`grep -n 'MENU DEFAULT' "$inFile".$$ | sed 's|:.*||' | sed -n ""$defItem"p"` - sed ""$addIt"s|# *MENU *DEFAULT|MENU DEFAULT|" "$inFile".$$ > "$inFile" + sed 's|^ *MENU DEFAULT| # MENU DEFAULT|' $finalCFG > $finalCFG.$$ && mv $finalCFG.$$ $finalCFG + addIt=`grep -n 'MENU DEFAULT' $finalCFG | sed 's|:.*||' | sed -n ""$defItem"p"` + sed ""$addIt"s|# *MENU *DEFAULT|MENU DEFAULT|" $finalCFG > $finalCFG.$$ && mv $finalCFG.$$ $finalCFG fi @@ -254,36 +318,7 @@ fi -# read parameters inserted by the user -# they are found in the isolinux.cfg file -# created by Clonezilla Live -paramLine=`grep 'append' $origCFG | sed '2,$d'` -ocs_live_extra_param="$(echo "$paramLine" | sed 's|.*ocs_live_extra_param="\([^"]*\)".*|\1|')" -ocs_live_keymap="$(echo "$paramLine" | sed 's|.*ocs_live_keymap="\([^"]*\)".*|\1|')" -ocs_lang="$(echo "$paramLine" | sed 's|.*ocs_lang="\([^"]*\)".*|\1|')" - - -# replace with current values -sed "s|ocs_live_extra_param=\"[^\"]*\"|ocs_live_extra_param=\"$ocs_live_extra_param\"| -s|ocs_live_keymap=\"[^\"]*\"|ocs_live_keymap=\"$ocs_live_keymap\"| -s|ocs_lang=\"[^\"]*\"|ocs_lang=\"$ocs_lang\"| -" "$inFile" > "$inFile".$$ && mv "$inFile".$$ "$inFile" - - - - -if [ "$type" = "ISO" ];then - cp "$inFile" /tmp/*/isolinux/isolinux.cfg - cp "$bootImg" /tmp/*/isolinux -else -# cp "$inFile" /home/partimag/*/syslinux/syslinux.cfg -# cp "$bootImg" /home/partimag/usb-dev.* -#fi -# -#if [ "$type" = "ZIP" ];then - SYSLINUX_FILE=`echo "$origCFG" | sed 's{isolinux{syslinux{g'` - sed "$inFile" | sed '{noprompt {{g' > "$SYSLINUX_FILE" - cp "$bootImg" `dirname "$SYSLINUX_FILE"` fi -rm "$inFile" +copy_PNG_SYSLINUX +