/[clonezilla-sysresccd]/trunk/create-clonezilla-sysresccd/files/cust-menu
ViewVC logotype

Annotation of /trunk/create-clonezilla-sysresccd/files/cust-menu

Parent Directory Parent Directory | Revision Log Revision Log


Revision 177 - (hide annotations)
Wed Jun 1 12:33:25 2011 UTC (12 years, 10 months ago) by sng
File size: 11524 byte(s)
- cust-menu update only

Making cust-menu "remembering" previous user input, through
consecutive restore iso/zip creation (as long as the system
is not rebooted). This is especially useful when creating
iso and zip in one go

1 sng 47 #!/bin/bash
2     ##############################################################################
3     # #
4 sng 177 # cust-menu, (C) 2007-2011 S. Georgaras <sng@hellug.gr> #
5 sng 47 # #
6     # This file is part of Clonezilla-SysRescCD. #
7     # #
8     # Clonezilla-SysRescCD is free software: you can redistribute it and/or #
9     # modify it under the terms of the GNU General Public License as published #
10     # by the Free Software Foundation, either version 2 of the License, or #
11     # (at your option) any later version. #
12     # #
13     # Clonezilla-SysRescCD is distributed in the hope that it will be useful, #
14     # but WITHOUT ANY WARRANTY; without even the implied warranty of #
15     # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
16     # GNU General Public License for more details. #
17     # #
18     # You should have received a copy of the GNU General Public License along #
19     # with Clonezilla-SysRescCD. If not, see <http://www.gnu.org/licenses/>. #
20     # #
21     ##############################################################################
22    
23 sng 93 function findCFGfile(){
24 sng 47 if [ -e isolinux-restore-cd.cfg ];then
25 sng 93 templateCFG="./isolinux-restore-cd.cfg"
26 sng 47 elif [ -r /live/image/restorecd/isolinux-restore-cd.cfg ];then
27 sng 93 templateCFG="/live/image/restorecd/isolinux-restore-cd.cfg"
28 sng 47 elif [ -r /tmp/restorecd/isolinux-restore-cd.cfg ];then
29 sng 93 templateCFG="/tmp/restorecd/isolinux-restore-cd.cfg"
30     elif [ -r /restorecd/isolinux-restore-cd.cfg ];then
31     templateCFG="/restorecd/isolinux-restore-cd.cfg"
32 sng 47 else
33     whiptail --backtitle Clonezilla-SysRescCD --title " Execution Error " --msgbox "This is not a stand-alone script and should not be executed by the command line
34    
35     This script will terminate now" 0 0
36     exit 1
37     fi
38     }
39    
40 sng 93 function find2RamCFGfile(){
41 sng 47 if [ -e isolinux-restore-cd-ram.cfg ];then
42 sng 93 templateCFG="./isolinux-restore-cd-ram.cfg"
43 sng 47 elif [ -r /live/image/restorecd/isolinux-restore-cd-ram.cfg ];then
44 sng 93 templateCFG="/live/image/restorecd/isolinux-restore-cd-ram.cfg"
45 sng 47 elif [ -r /tmp/restorecd/isolinux-restore-cd-ram.cfg ];then
46 sng 93 templateCFG="/tmp/restorecd/isolinux-restore-cd-ram.cfg"
47     elif [ -r /restorecd/isolinux-restore-cd-ram.cfg ];then
48     templateCFG="/restorecd/isolinux-restore-cd-ram.cfg"
49 sng 47 else
50     whiptail --backtitle Clonezilla-SysRescCD --title " Execution Error " --msgbox "This is not a stand-alone script and should not be executed by the command line
51    
52     This script will terminate now" 0 0
53     exit 1
54     fi
55     }
56    
57 sng 93 function import_parameters_to_cfg(){
58     # -> $1 - template cfg file
59     # <- $2 - final cfg file
60     local outCFG="$2".tmp
61     # read parameters inserted by the user
62     # they are found in the isolinux.cfg file
63     # created by Clonezilla Live
64     local paramLine=`grep 'append' $2 | sed '2,$d'`
65     local ocs_live_extra_param="$(echo "$paramLine" | sed 's|.*ocs_live_extra_param="\([^"]*\)".*|\1|')"
66     local ocs_live_keymap="$(echo "$paramLine" | sed 's|.*ocs_live_keymap="\([^"]*\)".*|\1|')"
67     local ocs_lang="$(echo "$paramLine" | sed 's|.*ocs_lang="\([^"]*\)".*|\1|')"
68 sng 47
69 sng 93 # replace with current values
70     sed "s|ocs_live_extra_param=\"[^\"]*\"|ocs_live_extra_param=\"$ocs_live_extra_param\"|
71     s|ocs_live_keymap=\"[^\"]*\"|ocs_live_keymap=\"$ocs_live_keymap\"|
72     s|ocs_lang=\"[^\"]*\"|ocs_lang=\"$ocs_lang\"|
73     " $1 > $outCFG && mv $outCFG $2
74     }
75    
76     function copy_PNG_SYSLINUX(){
77 sng 134 local targetPNG=/restorecd/ocswp.png
78     if [ -n "$bootImg" ];then targetPNG="$bootImg";fi
79 sng 93 SYSLINUX_FILE=`echo $finalCFG | sed 's{isolinux{syslinux{g'`
80     SYS=`dirname $finalCFG`
81     sed 's{noprompt {{g' $finalCFG > $SYSLINUX_FILE
82 sng 134 cp "$targetPNG" $SYS
83     cp "$targetPNG" `echo $SYS | sed 's{isolinux{syslinux{g'`
84 sng 93 }
85    
86    
87     type=ISO
88    
89 sng 47 # Parse command-line options
90     while [ $# -gt 0 ]; do
91     case "$1" in
92     -publisher)
93     shift
94     if [ -z "$(echo $1 |grep ^-.)" ]; then
95     # skip the -xx option, in case
96     isoPublisher="$1"
97     shift
98     fi
99     # [ -z "$target_iso_prefix" ] && USAGE && exit 1
100     ;;
101     -V)
102     shift
103     if [ -z "$(echo $1 |grep ^-.)" ]; then
104     # skip the -xx option, in case
105     isoLabel="$1"
106     shift
107     fi
108     # [ -z "$target_iso_prefix" ] && USAGE && exit 1
109     ;;
110 sng 93 -z)
111     type=ZIP
112     shift
113     ;;
114     -o)
115     ORIGINAL_INSERT_MODE=y
116     shift
117     ;;
118 sng 47 *)
119     break;
120     ;;
121     esac
122     done
123    
124    
125    
126    
127    
128     # # #
129     # # #
130     # # # the CFG file can be found as
131 sng 93 # # # /tmp/ocs_isosys*/isolinux/isolinux.cfg
132 sng 47 # # # or
133 sng 93 # # # /home/partimag/ocs_isosys*/isolinux/isolinux.cfg
134 sng 47 # # #
135     # # #
136 sng 84
137 sng 93 if [ "$type" = ISO ];then
138 sng 47 type=ISO
139 sng 95 # finalCFG=/tmp/ocs_isosys*/isolinux/isolinux.cfg
140 sng 93 finalCFG=`find /tmp -name isolinux.cfg`
141 sng 47 else
142     type=ZIP
143 sng 95 # finalCFG=/home/partimag/ocs_isosys*/isolinux/isolinux.cfg
144 sng 93 finalCFG=`find /home/partimag -name isolinux.cfg`
145 sng 47 fi
146    
147 sng 93 if [ ! -e $finalCFG ];then
148     dialog --backtitle Clonezilla-SysRescCD --title " File not found " --msgbox " The original cfg file ($finalCFG) does not exit!!!
149    
150     This script will terminate now" 0 0
151 sng 47
152 sng 93 exit 1
153     fi
154    
155     # Check if -s has been used (only iso)
156     if [ -n "$ORIGINAL_INSERT_MODE" ];then
157 sng 95 # When -s is used, do nothing
158     # findCFGfile
159     # import_parameters_to_cfg $templateCFG $finalCFG
160     # copy_PNG_SYSLINUX
161 sng 93 exit
162     fi
163    
164    
165 sng 47 whiptail --backtitle Clonezilla-SysRescCD --title ' Customization section ' --yesno "Do you want to further customize the $type file?
166    
167     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
168    
169     if [ $? -eq 1 ];then
170 sng 93 CUSTOMIZE=no
171 sng 47 fi
172    
173    
174     if [ "$1" = "prog_only" ];then
175 sng 93 find2RamCFGfile
176 sng 47 else
177 sng 93 findCFGfile
178 sng 47 fi
179 sng 93
180    
181     import_parameters_to_cfg $templateCFG $finalCFG
182    
183    
184     ##############################################################################
185     #
186     # Menu Customization
187     #
188     ##############################################################################
189    
190     if [ -z "$CUSTOMIZE" ];then
191    
192 sng 177 if [ -e $HOME/.last-cust-menu-values ];then
193    
194     whiptail --backtitle Clonezilla-SysRescCD --title ' Config found!!!' --yesno 'You can use the same values you inserted on a previous customization.\n\nDo you want to use these values?' 11 45
195     if [ $? -eq 0 ];then
196     . $HOME/.last-cust-menu-values
197     useOldCustomizationValues=yes
198     fi
199     fi
200 sng 47
201 sng 177 # DVD Title
202     if [ -z "$useOldCustomizationValues" ];then
203     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
204     menuTitle=`cat /tmp/answer`
205     echo "menuTitle=$menuTitle" | sed 's/ /\\ /g' >> $HOME/.last-cust-menu-values
206     rm /tmp/answer 2>/dev/null
207    
208    
209    
210     # Item caption
211     whiptail --backtitle Clonezilla-SysRescCD --title ' Menu Items Caption ' --inputbox 'Insert the Caption for each menu item' 8 60 'Clonezilla Live' 2>/tmp/answer
212     itemCaption=`cat /tmp/answer`
213     echo "itemCaption=$itemCaption" | sed 's/ /\\ /g' >> $HOME/.last-cust-menu-values
214    
215     rm /tmp/answer 2>/dev/null
216 sng 47
217    
218 sng 177 #
219     whiptail --backtitle Clonezilla-SysRescCD --title ' Boot delay ' --inputbox 'Insert the boot delay in seconds' 8 60 30 2>/tmp/answer
220     bootDelay=`cat /tmp/answer`
221     if [ "$bootDelay" = "30" ];then
222     bootDelay=''
223     fi
224     echo "bootDelay=$bootDelay" | sed 's/ /\\ /g' >> $HOME/.last-cust-menu-values
225     rm /tmp/answer 2>/dev/null
226 sng 47
227    
228    
229    
230 sng 177 #
231     # Default boot item
232     #
233    
234    
235    
236     echo "whiptail --backtitle Clonezilla-SysRescCD --title ' Default Boot Item ' --menu 'Select
237 sng 47 Item 6 - Boot from the first hard disk
238     to maintain current setting
239     ' 0 60 0 \\" > /tmp/q.$$
240 sng 177
241     grep 'MENU LABEL' "$templateCFG" | sed '/---/d' | sed 's|^.*MENU LABEL *||' | sed "s|^|'|" | sed "s|$|'|" | awk '{print NR " " ""$0"" " "}' | tr -d '\n$' > /tmp/qq.$$
242    
243     oldCaption=`sed 's|^1 *.||' /tmp/qq.$$ | sed "s| *-.*||"`
244     echo "oldCaption=$oldCaption" | sed 's/ /\\ /g' >> $HOME/.last-cust-menu-values
245    
246     if [ -n "$itemCaption" ];then
247     sed "s/$oldCaption/$itemCaption/g" /tmp/qq.$$ >> /tmp/q.$$
248     else
249     cat /tmp/qq.$$ >> /tmp/q.$$
250     fi
251    
252     echo "2>/tmp/answer" >> /tmp/q.$$
253     rm /tmp/qq.$$
254     . /tmp/q.$$
255     rm /tmp/q.$$
256    
257     defItem=`cat /tmp/answer`
258     if [ $defItem -gt 6 ];then ((defItem++));fi
259     ((defItem++))
260     #if [ $defItem -eq 6 ];then defItem='';fi
261     if [ $defItem -eq 7 ];then defItem='';fi
262     rm /tmp/answer 2>/dev/null
263     echo "defItem=$defItem" | sed 's/ /\\ /g' >> $HOME/.last-cust-menu-values
264 sng 47
265    
266 sng 177 # Boot Screen Image
267     whiptail --backtitle Clonezilla-SysRescCD --title ' Boot Screen Image ' --inputbox 'Insert the Image to be displayed on the Boot Screen
268    
269     The file must be a 640x480 32-bit png image' 0 60 ocswp.png 2>/tmp/answer
270     bootImage=`cat /tmp/answer`
271     if [ "$bootImage" = "ocswp.png" ];then
272     bootImage=''
273     fi
274     echo "bootImage=$bootImage" | sed 's/ /\\ /g' >> $HOME/.last-cust-menu-values
275     rm /tmp/answer 2>/dev/null
276 sng 47
277    
278    
279    
280 sng 177 if [ "$type" = "ISO" ];then
281     # ISO Label
282     whiptail --backtitle Clonezilla-SysRescCD --title ' ISO Label ' --inputbox 'Insert the Volume Label of the ISO file' 0 60 "$isoLabel" 2>/tmp/answer
283     isoLabelTMP=`cat /tmp/answer`
284     if [ -z "$isoLabelTMP" ];then
285     isoLabelTMP="$isoLabel"
286     fi
287     echo "isoLabelTMP=$isoLabelTMP" | sed 's/ /\\ /g' >> $HOME/.last-cust-menu-values
288     rm /tmp/answer 2>/dev/null
289    
290    
291    
292     # Publisher ID
293     whiptail --backtitle Clonezilla-SysRescCD --title ' Publisher ID ' --inputbox 'Insert the Publisher ID of the ISO file' 0 60 "$isoPublisher" 2>/tmp/answer
294     isoPublisherTMP=`cat /tmp/answer`
295     if [ -z "$isoPublisherTMP" ];then
296     isoPublisherTMP="$isoPublisher"
297     fi
298     echo "isoPublisherTMP=$isoPublisherTMP" | sed 's/ /\\ /g' >> $HOME/.last-cust-menu-values
299     rm /tmp/answer 2>/dev/null
300    
301     echo "$isoLabelTMP" > /tmp/isodata
302     echo "$isoPublisherTMP" >> /tmp/isodata
303     fi
304 sng 47
305    
306     fi
307    
308    
309 sng 93 ############################################################################
310     #
311     # Insert user data to file
312     #
313     ############################################################################
314 sng 47
315    
316    
317     if [ -n "$menuTitle" ];then
318 sng 93 sed "s|^ *MENU TITLE .*|MENU TITLE $menuTitle|" $finalCFG > $finalCFG.$$ && mv $finalCFG.$$ $finalCFG
319 sng 47 fi
320    
321     if [ -n "$itemCaption" ];then
322 sng 93 sed "s|MENU LABEL *$oldCaption *-|MENU LABEL $itemCaption -|" $finalCFG > $finalCFG.$$ && mv $finalCFG.$$ $finalCFG
323 sng 47 fi
324    
325     if [ -n "$bootDelay" ];then
326 sng 93 sed "s|[tT][iI][mM][eE][oO][uU][tT] .*| timeout "$bootDelay"0|" $finalCFG > $finalCFG.$$ && mv $finalCFG.$$ $finalCFG
327 sng 47 fi
328    
329     if [ -n "$defItem" ];then
330 sng 93 sed 's|^ *MENU DEFAULT| # MENU DEFAULT|' $finalCFG > $finalCFG.$$ && mv $finalCFG.$$ $finalCFG
331     addIt=`grep -n 'MENU DEFAULT' $finalCFG | sed 's|:.*||' | sed -n ""$defItem"p"`
332     sed ""$addIt"s|# *MENU *DEFAULT|MENU DEFAULT|" $finalCFG > $finalCFG.$$ && mv $finalCFG.$$ $finalCFG
333 sng 47 fi
334    
335    
336 sng 134 if [ -n "$bootImage" ];then
337     if [ -e "$bootImage" ] || [ -e /home/partimag/"$bootImage" ] ;then
338     bootImg="$bootImage"
339     fi
340 sng 47 fi
341    
342 sng 93 fi
343 sng 47
344 sng 93 copy_PNG_SYSLINUX
345 sng 47
346 sng 177

Properties

Name Value
svn:executable *

webmaster@linux.gr
ViewVC Help
Powered by ViewVC 1.1.26