/[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 134 - (show annotations)
Fri Sep 24 12:58:07 2010 UTC (13 years, 6 months ago) by sng
File size: 10136 byte(s)
- printable.php - Removing <link> tags
- cust-menu - fixing copying custom boot image and
  adding relative (to /home/partimag) files support

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 local targetPNG=/restorecd/ocswp.png
78 if [ -n "$bootImg" ];then targetPNG="$bootImg";fi
79 SYSLINUX_FILE=`echo $finalCFG | sed 's{isolinux{syslinux{g'`
80 SYS=`dirname $finalCFG`
81 sed 's{noprompt {{g' $finalCFG > $SYSLINUX_FILE
82 cp "$targetPNG" $SYS
83 cp "$targetPNG" `echo $SYS | sed 's{isolinux{syslinux{g'`
84 }
85
86
87 type=ISO
88
89 # 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 -z)
111 type=ZIP
112 shift
113 ;;
114 -o)
115 ORIGINAL_INSERT_MODE=y
116 shift
117 ;;
118 *)
119 break;
120 ;;
121 esac
122 done
123
124
125
126
127
128 # # #
129 # # #
130 # # # the CFG file can be found as
131 # # # /tmp/ocs_isosys*/isolinux/isolinux.cfg
132 # # # or
133 # # # /home/partimag/ocs_isosys*/isolinux/isolinux.cfg
134 # # #
135 # # #
136
137 if [ "$type" = ISO ];then
138 type=ISO
139 # finalCFG=/tmp/ocs_isosys*/isolinux/isolinux.cfg
140 finalCFG=`find /tmp -name isolinux.cfg`
141 else
142 type=ZIP
143 # finalCFG=/home/partimag/ocs_isosys*/isolinux/isolinux.cfg
144 finalCFG=`find /home/partimag -name isolinux.cfg`
145 fi
146
147 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
152 exit 1
153 fi
154
155 # Check if -s has been used (only iso)
156 if [ -n "$ORIGINAL_INSERT_MODE" ];then
157 # When -s is used, do nothing
158 # findCFGfile
159 # import_parameters_to_cfg $templateCFG $finalCFG
160 # copy_PNG_SYSLINUX
161 exit
162 fi
163
164
165 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 CUSTOMIZE=no
171 fi
172
173
174 if [ "$1" = "prog_only" ];then
175 find2RamCFGfile
176 else
177 findCFGfile
178 fi
179
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 # DVD Title
193 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
194 menuTitle=`cat /tmp/answer`
195
196 rm /tmp/answer 2>/dev/null
197
198
199
200 # Item caption
201 whiptail --backtitle Clonezilla-SysRescCD --title ' Menu Items Caption ' --inputbox 'Insert the Caption for each manu item' 8 60 'Clonezilla Live' 2>/tmp/answer
202 itemCaption=`cat /tmp/answer`
203
204 rm /tmp/answer 2>/dev/null
205
206
207 #
208 whiptail --backtitle Clonezilla-SysRescCD --title ' Boot delay ' --inputbox 'Insert the boot delay in seconds' 8 60 30 2>/tmp/answer
209 bootDelay=`cat /tmp/answer`
210 if [ "$bootDelay" = "30" ];then
211 bootDelay=''
212 fi
213 rm /tmp/answer 2>/dev/null
214
215
216
217
218 #
219 # Default boot item
220 #
221
222
223
224 echo "whiptail --backtitle Clonezilla-SysRescCD --title ' Default Boot Item ' --menu 'Select
225 Item 6 - Boot from the first hard disk
226 to maintain current setting
227 ' 0 60 0 \\" > /tmp/q.$$
228
229 grep 'MENU LABEL' "$templateCFG" | sed '/---/d' | sed 's|^.*MENU LABEL *||' | sed "s|^|'|" | sed "s|$|'|" | awk '{print NR " " ""$0"" " "}' | tr -d '\n$' > /tmp/qq.$$
230
231 oldCaption=`sed 's|^1 *.||' /tmp/qq.$$ | sed "s| *-.*||"`
232
233 if [ -n "$itemCaption" ];then
234 sed "s/$oldCaption/$itemCaption/g" /tmp/qq.$$ >> /tmp/q.$$
235 else
236 cat /tmp/qq.$$ >> /tmp/q.$$
237 fi
238
239 echo "2>/tmp/answer" >> /tmp/q.$$
240 rm /tmp/qq.$$
241 . /tmp/q.$$
242 rm /tmp/q.$$
243
244 defItem=`cat /tmp/answer`
245 if [ $defItem -gt 6 ];then ((defItem++));fi
246 ((defItem++))
247 #if [ $defItem -eq 6 ];then defItem='';fi
248 if [ $defItem -eq 7 ];then defItem='';fi
249 rm /tmp/answer 2>/dev/null
250
251
252 # Boot Screen Image
253 whiptail --backtitle Clonezilla-SysRescCD --title ' Boot Screen Image ' --inputbox 'Insert the Image to be displayed on the Boot Screen
254
255 The file must be a 640x480 32-bit png image' 0 60 ocswp.png 2>/tmp/answer
256 bootImage=`cat /tmp/answer`
257 if [ "$bootImage" = "ocswp.png" ];then
258 bootImage=''
259 fi
260 rm /tmp/answer 2>/dev/null
261
262
263
264
265 if [ "$type" = "ISO" ];then
266 # ISO Label
267 whiptail --backtitle Clonezilla-SysRescCD --title ' ISO Label ' --inputbox 'Insert the Volume Label of the ISO file' 0 60 "$isoLabel" 2>/tmp/answer
268 isoLabelTMP=`cat /tmp/answer`
269 if [ -z "$isoLabelTMP" ];then
270 isoLabelTMP="$isoLabel"
271 fi
272 rm /tmp/answer 2>/dev/null
273
274
275
276 # Publisher ID
277 whiptail --backtitle Clonezilla-SysRescCD --title ' Publisher ID ' --inputbox 'Insert the Publisher ID of the ISO file' 0 60 "$isoPublisher" 2>/tmp/answer
278 isoPublisherTMP=`cat /tmp/answer`
279 if [ -z "$isoPublisherTMP" ];then
280 isoPublisherTMP="$isoPublisher"
281 fi
282 rm /tmp/answer 2>/dev/null
283
284 echo "$isoLabelTMP" > /tmp/isodata
285 echo "$isoPublisherTMP" >> /tmp/isodata
286 fi
287
288
289
290
291
292 ############################################################################
293 #
294 # Insert user data to file
295 #
296 ############################################################################
297
298
299
300 if [ -n "$menuTitle" ];then
301 sed "s|^ *MENU TITLE .*|MENU TITLE $menuTitle|" $finalCFG > $finalCFG.$$ && mv $finalCFG.$$ $finalCFG
302 fi
303
304 if [ -n "$itemCaption" ];then
305 sed "s|MENU LABEL *$oldCaption *-|MENU LABEL $itemCaption -|" $finalCFG > $finalCFG.$$ && mv $finalCFG.$$ $finalCFG
306 fi
307
308 if [ -n "$bootDelay" ];then
309 sed "s|[tT][iI][mM][eE][oO][uU][tT] .*| timeout "$bootDelay"0|" $finalCFG > $finalCFG.$$ && mv $finalCFG.$$ $finalCFG
310 fi
311
312 if [ -n "$defItem" ];then
313 sed 's|^ *MENU DEFAULT| # MENU DEFAULT|' $finalCFG > $finalCFG.$$ && mv $finalCFG.$$ $finalCFG
314 addIt=`grep -n 'MENU DEFAULT' $finalCFG | sed 's|:.*||' | sed -n ""$defItem"p"`
315 sed ""$addIt"s|# *MENU *DEFAULT|MENU DEFAULT|" $finalCFG > $finalCFG.$$ && mv $finalCFG.$$ $finalCFG
316 fi
317
318
319 if [ -n "$bootImage" ];then
320 if [ -e "$bootImage" ] || [ -e /home/partimag/"$bootImage" ] ;then
321 bootImg="$bootImage"
322 fi
323 fi
324
325 fi
326
327 copy_PNG_SYSLINUX
328

Properties

Name Value
svn:executable *

webmaster@linux.gr
ViewVC Help
Powered by ViewVC 1.1.26