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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 93 - (show annotations)
Fri Aug 13 08:30:37 2010 UTC (13 years, 7 months ago) by sng
File size: 9972 byte(s)
updating stuff for latest Clonezilla release

1 #!/bin/bash
2 ##############################################################################
3 # #
4 # cust-menu, (C) 2007-2010 S. Georgaras <sng@hellug.gr> #
5 # #
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 function findCFGfile(){
24 if [ -e isolinux-restore-cd.cfg ];then
25 templateCFG="./isolinux-restore-cd.cfg"
26 elif [ -r /live/image/restorecd/isolinux-restore-cd.cfg ];then
27 templateCFG="/live/image/restorecd/isolinux-restore-cd.cfg"
28 elif [ -r /tmp/restorecd/isolinux-restore-cd.cfg ];then
29 templateCFG="/tmp/restorecd/isolinux-restore-cd.cfg"
30 elif [ -r /restorecd/isolinux-restore-cd.cfg ];then
31 templateCFG="/restorecd/isolinux-restore-cd.cfg"
32 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 function find2RamCFGfile(){
41 if [ -e isolinux-restore-cd-ram.cfg ];then
42 templateCFG="./isolinux-restore-cd-ram.cfg"
43 elif [ -r /live/image/restorecd/isolinux-restore-cd-ram.cfg ];then
44 templateCFG="/live/image/restorecd/isolinux-restore-cd-ram.cfg"
45 elif [ -r /tmp/restorecd/isolinux-restore-cd-ram.cfg ];then
46 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 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 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
69 # 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 SYSLINUX_FILE=`echo $finalCFG | sed 's{isolinux{syslinux{g'`
78 SYS=`dirname $finalCFG`
79 sed 's{noprompt {{g' $finalCFG > $SYSLINUX_FILE
80 cp /restorecd/ocswp.png $SYS
81 cp /restorecd/ocswp.png `echo $SYS | sed 's{isolinux{syslinux{g'`
82 }
83
84
85 type=ISO
86
87 # Parse command-line options
88 while [ $# -gt 0 ]; do
89 case "$1" in
90 -publisher)
91 shift
92 if [ -z "$(echo $1 |grep ^-.)" ]; then
93 # skip the -xx option, in case
94 isoPublisher="$1"
95 shift
96 fi
97 # [ -z "$target_iso_prefix" ] && USAGE && exit 1
98 ;;
99 -V)
100 shift
101 if [ -z "$(echo $1 |grep ^-.)" ]; then
102 # skip the -xx option, in case
103 isoLabel="$1"
104 shift
105 fi
106 # [ -z "$target_iso_prefix" ] && USAGE && exit 1
107 ;;
108 -z)
109 type=ZIP
110 shift
111 ;;
112 -o)
113 ORIGINAL_INSERT_MODE=y
114 shift
115 ;;
116 *)
117 break;
118 ;;
119 esac
120 done
121
122
123
124
125
126 # # #
127 # # #
128 # # # the CFG file can be found as
129 # # # /tmp/ocs_isosys*/isolinux/isolinux.cfg
130 # # # or
131 # # # /home/partimag/ocs_isosys*/isolinux/isolinux.cfg
132 # # #
133 # # #
134
135 if [ "$type" = ISO ];then
136 type=ISO
137 finalCFG=/tmp/ocs_isosys*/isolinux/isolinux.cfg
138 finalCFG=`find /tmp -name isolinux.cfg`
139 else
140 type=ZIP
141 finalCFG=/home/partimag/ocs_isosys*/isolinux/isolinux.cfg
142 finalCFG=`find /home/partimag -name isolinux.cfg`
143 fi
144
145 if [ ! -e $finalCFG ];then
146 dialog --backtitle Clonezilla-SysRescCD --title " File not found " --msgbox " The original cfg file ($finalCFG) does not exit!!!
147
148 This script will terminate now" 0 0
149
150 exit 1
151 fi
152
153 # Check if -s has been used (only iso)
154 if [ -n "$ORIGINAL_INSERT_MODE" ];then
155 findCFGfile
156 import_parameters_to_cfg $templateCFG $finalCFG
157 copy_PNG_SYSLINUX
158 exit
159 fi
160
161
162 whiptail --backtitle Clonezilla-SysRescCD --title ' Customization section ' --yesno "Do you want to further customize the $type file?
163
164 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
165
166 if [ $? -eq 1 ];then
167 CUSTOMIZE=no
168 fi
169
170
171 if [ "$1" = "prog_only" ];then
172 find2RamCFGfile
173 else
174 findCFGfile
175 fi
176
177
178 import_parameters_to_cfg $templateCFG $finalCFG
179
180
181 ##############################################################################
182 #
183 # Menu Customization
184 #
185 ##############################################################################
186
187 if [ -z "$CUSTOMIZE" ];then
188
189 # DVD Title
190 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
191 menuTitle=`cat /tmp/answer`
192
193 rm /tmp/answer 2>/dev/null
194
195
196
197 # Item caption
198 whiptail --backtitle Clonezilla-SysRescCD --title ' Menu Items Caption ' --inputbox 'Insert the Caption for each manu item' 8 60 'Clonezilla Live' 2>/tmp/answer
199 itemCaption=`cat /tmp/answer`
200
201 rm /tmp/answer 2>/dev/null
202
203
204 #
205 whiptail --backtitle Clonezilla-SysRescCD --title ' Boot delay ' --inputbox 'Insert the boot delay in seconds' 8 60 30 2>/tmp/answer
206 bootDelay=`cat /tmp/answer`
207 if [ "$bootDelay" = "30" ];then
208 bootDelay=''
209 fi
210 rm /tmp/answer 2>/dev/null
211
212
213
214
215 #
216 # Default boot item
217 #
218
219
220
221 echo "whiptail --backtitle Clonezilla-SysRescCD --title ' Default Boot Item ' --menu 'Select
222 Item 6 - Boot from the first hard disk
223 to maintain current setting
224 ' 0 60 0 \\" > /tmp/q.$$
225
226 grep 'MENU LABEL' "$templateCFG" | sed '/---/d' | sed 's|^.*MENU LABEL *||' | sed "s|^|'|" | sed "s|$|'|" | awk '{print NR " " ""$0"" " "}' | tr -d '\n$' > /tmp/qq.$$
227
228 oldCaption=`sed 's|^1 *.||' /tmp/qq.$$ | sed "s| *-.*||"`
229
230 if [ -n "$itemCaption" ];then
231 sed "s/$oldCaption/$itemCaption/g" /tmp/qq.$$ >> /tmp/q.$$
232 else
233 cat /tmp/qq.$$ >> /tmp/q.$$
234 fi
235
236 echo "2>/tmp/answer" >> /tmp/q.$$
237 rm /tmp/qq.$$
238 . /tmp/q.$$
239 rm /tmp/q.$$
240
241 defItem=`cat /tmp/answer`
242 if [ $defItem -gt 6 ];then ((defItem++));fi
243 ((defItem++))
244 #if [ $defItem -eq 6 ];then defItem='';fi
245 if [ $defItem -eq 7 ];then defItem='';fi
246 rm /tmp/answer 2>/dev/null
247
248
249 # Boot Screen Image
250 whiptail --backtitle Clonezilla-SysRescCD --title ' Boot Screen Image ' --inputbox 'Insert the Image to be displayed on the Boot Screen
251
252 The file must be a 640x480 32-bit png image' 0 60 ocswp.png 2>/tmp/answer
253 bootImage=`cat /tmp/answer`
254 if [ "$bootImage" = "ocswp.png" ];then
255 bootImage=''
256 fi
257 rm /tmp/answer 2>/dev/null
258
259
260
261
262 if [ "$type" = "ISO" ];then
263 # ISO Label
264 whiptail --backtitle Clonezilla-SysRescCD --title ' ISO Label ' --inputbox 'Insert the Volume Label of the ISO file' 0 60 "$isoLabel" 2>/tmp/answer
265 isoLabelTMP=`cat /tmp/answer`
266 if [ -z "$isoLabelTMP" ];then
267 isoLabelTMP="$isoLabel"
268 fi
269 rm /tmp/answer 2>/dev/null
270
271
272
273 # Publisher ID
274 whiptail --backtitle Clonezilla-SysRescCD --title ' Publisher ID ' --inputbox 'Insert the Publisher ID of the ISO file' 0 60 "$isoPublisher" 2>/tmp/answer
275 isoPublisherTMP=`cat /tmp/answer`
276 if [ -z "$isoPublisherTMP" ];then
277 isoPublisherTMP="$isoPublisher"
278 fi
279 rm /tmp/answer 2>/dev/null
280
281 echo "$isoLabelTMP" > /tmp/isodata
282 echo "$isoPublisherTMP" >> /tmp/isodata
283 fi
284
285
286
287
288
289 ############################################################################
290 #
291 # Insert user data to file
292 #
293 ############################################################################
294
295
296
297 if [ -n "$menuTitle" ];then
298 sed "s|^ *MENU TITLE .*|MENU TITLE $menuTitle|" $finalCFG > $finalCFG.$$ && mv $finalCFG.$$ $finalCFG
299 fi
300
301 if [ -n "$itemCaption" ];then
302 sed "s|MENU LABEL *$oldCaption *-|MENU LABEL $itemCaption -|" $finalCFG > $finalCFG.$$ && mv $finalCFG.$$ $finalCFG
303 fi
304
305 if [ -n "$bootDelay" ];then
306 sed "s|[tT][iI][mM][eE][oO][uU][tT] .*| timeout "$bootDelay"0|" $finalCFG > $finalCFG.$$ && mv $finalCFG.$$ $finalCFG
307 fi
308
309 if [ -n "$defItem" ];then
310 sed 's|^ *MENU DEFAULT| # MENU DEFAULT|' $finalCFG > $finalCFG.$$ && mv $finalCFG.$$ $finalCFG
311 addIt=`grep -n 'MENU DEFAULT' $finalCFG | sed 's|:.*||' | sed -n ""$defItem"p"`
312 sed ""$addIt"s|# *MENU *DEFAULT|MENU DEFAULT|" $finalCFG > $finalCFG.$$ && mv $finalCFG.$$ $finalCFG
313 fi
314
315
316 if [ -n "$bootImage" ] && [ -e "$bootImage" ] ;then
317 bootImg="$bootImage"
318 fi
319
320
321 fi
322
323 copy_PNG_SYSLINUX
324

Properties

Name Value
svn:executable *

webmaster@linux.gr
ViewVC Help
Powered by ViewVC 1.1.26