1 |
sng |
47 |
#!/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 copyCFGfile(){ |
24 |
|
|
if [ -e isolinux-restore-cd.cfg ];then |
25 |
|
|
inFile="./isolinux-restore-cd.cfg" |
26 |
|
|
elif [ -r /live/image/restorecd/isolinux-restore-cd.cfg ];then |
27 |
|
|
inFile="/live/image/restorecd/isolinux-restore-cd.cfg" |
28 |
|
|
elif [ -r /tmp/restorecd/isolinux-restore-cd.cfg ];then |
29 |
|
|
inFile="/tmp/restorecd/isolinux-restore-cd.cfg" |
30 |
|
|
else |
31 |
|
|
whiptail --backtitle Clonezilla-SysRescCD --title " Execution Error " --msgbox "This is not a stand-alone script and should not be executed by the command line |
32 |
|
|
|
33 |
|
|
This script will terminate now" 0 0 |
34 |
|
|
exit 1 |
35 |
|
|
fi |
36 |
|
|
cp "$inFile" /tmp/isolinux-mine.cfg |
37 |
|
|
bootImg="$(dirname "$inFile")"/ocswp.png |
38 |
|
|
inFile='/tmp/isolinux-mine.cfg' |
39 |
|
|
} |
40 |
|
|
|
41 |
|
|
function copy2RamCFGfile(){ |
42 |
|
|
if [ -e isolinux-restore-cd-ram.cfg ];then |
43 |
|
|
inFile="./isolinux-restore-cd-ram.cfg" |
44 |
|
|
elif [ -r /live/image/restorecd/isolinux-restore-cd-ram.cfg ];then |
45 |
|
|
inFile="/live/image/restorecd/isolinux-restore-cd-ram.cfg" |
46 |
|
|
elif [ -r /tmp/restorecd/isolinux-restore-cd-ram.cfg ];then |
47 |
|
|
inFile="/tmp/restorecd/isolinux-restore-cd-ram.cfg" |
48 |
|
|
else |
49 |
|
|
whiptail --backtitle Clonezilla-SysRescCD --title " Execution Error " --msgbox "This is not a stand-alone script and should not be executed by the command line |
50 |
|
|
|
51 |
|
|
This script will terminate now" 0 0 |
52 |
|
|
exit 1 |
53 |
|
|
fi |
54 |
|
|
cp "$inFile" /tmp/isolinux-mine.cfg |
55 |
|
|
bootImg="$(dirname "$inFile")"/ocswp.png |
56 |
|
|
inFile='/tmp/isolinux-mine.cfg' |
57 |
|
|
} |
58 |
|
|
|
59 |
|
|
|
60 |
|
|
# Parse command-line options |
61 |
|
|
while [ $# -gt 0 ]; do |
62 |
|
|
case "$1" in |
63 |
|
|
-publisher) |
64 |
|
|
shift |
65 |
|
|
if [ -z "$(echo $1 |grep ^-.)" ]; then |
66 |
|
|
# skip the -xx option, in case |
67 |
|
|
isoPublisher="$1" |
68 |
|
|
shift |
69 |
|
|
fi |
70 |
|
|
# [ -z "$target_iso_prefix" ] && USAGE && exit 1 |
71 |
|
|
;; |
72 |
|
|
-V) |
73 |
|
|
shift |
74 |
|
|
if [ -z "$(echo $1 |grep ^-.)" ]; then |
75 |
|
|
# skip the -xx option, in case |
76 |
|
|
isoLabel="$1" |
77 |
|
|
shift |
78 |
|
|
fi |
79 |
|
|
# [ -z "$target_iso_prefix" ] && USAGE && exit 1 |
80 |
|
|
;; |
81 |
|
|
*) |
82 |
|
|
break; |
83 |
|
|
;; |
84 |
|
|
esac |
85 |
|
|
done |
86 |
|
|
|
87 |
|
|
|
88 |
|
|
|
89 |
|
|
|
90 |
|
|
|
91 |
|
|
# # # |
92 |
|
|
# # # |
93 |
|
|
# # # the CFG file can be found as |
94 |
sng |
84 |
# # # /tmp/*/isolinux/isolinux.cfg |
95 |
sng |
47 |
# # # or |
96 |
sng |
84 |
# # # /home/partimag/*/isolinux/isolinux.cfg |
97 |
sng |
47 |
# # # |
98 |
|
|
# # # |
99 |
sng |
84 |
|
100 |
|
|
if [ -e /tmp/*/isolinux/isolinux.cfg ];then |
101 |
sng |
47 |
type=ISO |
102 |
sng |
84 |
origCFG="/tmp/*/isolinux/isolinux.cfg" |
103 |
|
|
elif [ -e /home/partimag/*/isolinux/isolinux.cfg ];then |
104 |
sng |
47 |
type=ZIP |
105 |
sng |
84 |
origCFG="/home/partimag/*/isolinux/isolinux.cfg" |
106 |
sng |
47 |
else |
107 |
|
|
origCFG='' |
108 |
|
|
type=ZIP |
109 |
sng |
84 |
dialog --backtitle Clonezilla-SysRescCD --title " Execution Error " --msgbox "This is not a stand-alone script and should not be executed by the command line |
110 |
|
|
|
111 |
|
|
This script will terminate now" 0 0 |
112 |
|
|
exit 1 |
113 |
sng |
47 |
fi |
114 |
|
|
|
115 |
|
|
|
116 |
|
|
whiptail --backtitle Clonezilla-SysRescCD --title ' Customization section ' --yesno "Do you want to further customize the $type file? |
117 |
|
|
|
118 |
|
|
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 |
119 |
|
|
|
120 |
|
|
if [ $? -eq 1 ];then |
121 |
|
|
exit |
122 |
|
|
fi |
123 |
|
|
|
124 |
|
|
|
125 |
|
|
if [ "$1" = "prog_only" ];then |
126 |
|
|
copy2RamCFGfile |
127 |
|
|
else |
128 |
|
|
copyCFGfile |
129 |
|
|
fi |
130 |
|
|
# DVD Title |
131 |
|
|
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 |
132 |
|
|
menuTitle=`cat /tmp/answer` |
133 |
|
|
|
134 |
|
|
rm /tmp/answer 2>/dev/null |
135 |
|
|
|
136 |
|
|
|
137 |
|
|
|
138 |
|
|
# Item caption |
139 |
|
|
whiptail --backtitle Clonezilla-SysRescCD --title ' Menu Items Caption ' --inputbox 'Insert the Caption for each manu item' 8 60 'Clonezilla Live' 2>/tmp/answer |
140 |
|
|
itemCaption=`cat /tmp/answer` |
141 |
|
|
|
142 |
|
|
rm /tmp/answer 2>/dev/null |
143 |
|
|
|
144 |
|
|
|
145 |
|
|
# |
146 |
|
|
whiptail --backtitle Clonezilla-SysRescCD --title ' Boot delay ' --inputbox 'Insert the boot delay in seconds' 8 60 30 2>/tmp/answer |
147 |
|
|
bootDelay=`cat /tmp/answer` |
148 |
|
|
if [ "$bootDelay" = "30" ];then |
149 |
|
|
bootDelay='' |
150 |
|
|
fi |
151 |
|
|
rm /tmp/answer 2>/dev/null |
152 |
|
|
|
153 |
|
|
|
154 |
|
|
|
155 |
|
|
|
156 |
|
|
# |
157 |
|
|
# Default boot item |
158 |
|
|
# |
159 |
|
|
|
160 |
|
|
|
161 |
|
|
|
162 |
|
|
echo "whiptail --backtitle Clonezilla-SysRescCD --title ' Default Boot Item ' --menu 'Select |
163 |
|
|
Item 6 - Boot from the first hard disk |
164 |
|
|
to maintain current setting |
165 |
|
|
' 0 60 0 \\" > /tmp/q.$$ |
166 |
|
|
|
167 |
|
|
grep 'MENU LABEL' "$inFile" | sed '/---/d' | sed 's|^.*MENU LABEL *||' | sed "s|^|'|" | sed "s|$|'|" | awk '{print NR " " ""$0"" " "}' | tr -d '\n$' > /tmp/qq.$$ |
168 |
|
|
|
169 |
|
|
oldCaption=`sed 's|^1 *.||' /tmp/qq.$$ | sed "s| *-.*||"` |
170 |
|
|
|
171 |
|
|
if [ -n "$itemCaption" ];then |
172 |
|
|
sed "s/$oldCaption/$itemCaption/g" /tmp/qq.$$ >> /tmp/q.$$ |
173 |
|
|
else |
174 |
|
|
cat /tmp/qq.$$ >> /tmp/q.$$ |
175 |
|
|
fi |
176 |
|
|
|
177 |
|
|
echo "2>/tmp/answer" >> /tmp/q.$$ |
178 |
|
|
rm /tmp/qq.$$ |
179 |
|
|
. /tmp/q.$$ |
180 |
|
|
rm /tmp/q.$$ |
181 |
|
|
|
182 |
|
|
defItem=`cat /tmp/answer` |
183 |
|
|
if [ $defItem -gt 6 ];then ((defItem++));fi |
184 |
|
|
if [ $defItem -eq 6 ];then defItem='';fi |
185 |
|
|
rm /tmp/answer 2>/dev/null |
186 |
|
|
|
187 |
|
|
|
188 |
|
|
# Boot Screen Image |
189 |
|
|
whiptail --backtitle Clonezilla-SysRescCD --title ' Boot Screen Image ' --inputbox 'Insert the Image to be displayed on the Boot Screen |
190 |
|
|
|
191 |
|
|
The file must be a 640x480 32-bit png image' 0 60 ocswp.png 2>/tmp/answer |
192 |
|
|
bootImage=`cat /tmp/answer` |
193 |
|
|
if [ "$bootImage" = "ocswp.png" ];then |
194 |
|
|
bootImage='' |
195 |
|
|
fi |
196 |
|
|
rm /tmp/answer 2>/dev/null |
197 |
|
|
|
198 |
|
|
|
199 |
|
|
|
200 |
|
|
|
201 |
|
|
if [ "$type" = "ISO" ];then |
202 |
|
|
# ISO Label |
203 |
|
|
whiptail --backtitle Clonezilla-SysRescCD --title ' ISO Label ' --inputbox 'Insert the Volume Label of the ISO file' 0 60 "$isoLabel" 2>/tmp/answer |
204 |
|
|
isoLabelTMP=`cat /tmp/answer` |
205 |
|
|
if [ -z "$isoLabelTMP" ];then |
206 |
|
|
isoLabelTMP="$isoLabel" |
207 |
|
|
fi |
208 |
|
|
rm /tmp/answer 2>/dev/null |
209 |
|
|
|
210 |
|
|
|
211 |
|
|
|
212 |
|
|
# Publisher ID |
213 |
|
|
whiptail --backtitle Clonezilla-SysRescCD --title ' Publisher ID ' --inputbox 'Insert the Publisher ID of the ISO file' 0 60 "$isoPublisher" 2>/tmp/answer |
214 |
|
|
isoPublisherTMP=`cat /tmp/answer` |
215 |
|
|
if [ -z "$isoPublisherTMP" ];then |
216 |
|
|
isoPublisherTMP="$isoPublisher" |
217 |
|
|
fi |
218 |
|
|
rm /tmp/answer 2>/dev/null |
219 |
|
|
|
220 |
|
|
echo "$isoLabelTMP" > /tmp/isodata |
221 |
|
|
echo "$isoPublisherTMP" >> /tmp/isodata |
222 |
|
|
fi |
223 |
|
|
|
224 |
|
|
|
225 |
|
|
|
226 |
|
|
|
227 |
|
|
|
228 |
|
|
|
229 |
|
|
|
230 |
|
|
|
231 |
|
|
|
232 |
sng |
84 |
|
233 |
sng |
47 |
if [ -n "$menuTitle" ];then |
234 |
|
|
sed "s|^ *MENU TITLE .*|MENU TITLE $menuTitle|" "$inFile" > "$inFile".$$ && mv "$inFile".$$ "$inFile" |
235 |
|
|
fi |
236 |
|
|
|
237 |
|
|
if [ -n "$itemCaption" ];then |
238 |
|
|
sed "s|MENU LABEL *$oldCaption *-|MENU LABEL $itemCaption -|" "$inFile" > "$inFile".$$ && mv "$inFile".$$ "$inFile" |
239 |
|
|
fi |
240 |
|
|
|
241 |
|
|
if [ -n "$bootDelay" ];then |
242 |
|
|
sed "s|[tT][iI][mM][eE][oO][uU][tT] .*| timeout "$bootDelay"0|" "$inFile" > "$inFile".$$ && mv "$inFile".$$ "$inFile" |
243 |
|
|
fi |
244 |
|
|
|
245 |
|
|
if [ -n "$defItem" ];then |
246 |
|
|
sed 's|^ *MENU DEFAULT| # MENU DEFAULT|' "$inFile" > "$inFile".$$ |
247 |
|
|
addIt=`grep -n 'MENU DEFAULT' "$inFile".$$ | sed 's|:.*||' | sed -n ""$defItem"p"` |
248 |
|
|
sed ""$addIt"s|# *MENU *DEFAULT|MENU DEFAULT|" "$inFile".$$ > "$inFile" |
249 |
|
|
fi |
250 |
|
|
|
251 |
|
|
|
252 |
|
|
if [ -n "$bootImage" ] && [ -e "$bootImage" ] ;then |
253 |
|
|
bootImg="$bootImage" |
254 |
|
|
fi |
255 |
|
|
|
256 |
|
|
|
257 |
|
|
# read parameters inserted by the user |
258 |
|
|
# they are found in the isolinux.cfg file |
259 |
|
|
# created by Clonezilla Live |
260 |
|
|
paramLine=`grep 'append' $origCFG | sed '2,$d'` |
261 |
|
|
ocs_live_extra_param="$(echo "$paramLine" | sed 's|.*ocs_live_extra_param="\([^"]*\)".*|\1|')" |
262 |
|
|
ocs_live_keymap="$(echo "$paramLine" | sed 's|.*ocs_live_keymap="\([^"]*\)".*|\1|')" |
263 |
|
|
ocs_lang="$(echo "$paramLine" | sed 's|.*ocs_lang="\([^"]*\)".*|\1|')" |
264 |
|
|
|
265 |
|
|
|
266 |
|
|
# replace with current values |
267 |
|
|
sed "s|ocs_live_extra_param=\"[^\"]*\"|ocs_live_extra_param=\"$ocs_live_extra_param\"| |
268 |
|
|
s|ocs_live_keymap=\"[^\"]*\"|ocs_live_keymap=\"$ocs_live_keymap\"| |
269 |
|
|
s|ocs_lang=\"[^\"]*\"|ocs_lang=\"$ocs_lang\"| |
270 |
|
|
" "$inFile" > "$inFile".$$ && mv "$inFile".$$ "$inFile" |
271 |
|
|
|
272 |
|
|
|
273 |
|
|
|
274 |
|
|
|
275 |
|
|
if [ "$type" = "ISO" ];then |
276 |
sng |
84 |
cp "$inFile" /tmp/*/isolinux/isolinux.cfg |
277 |
|
|
cp "$bootImg" /tmp/*/isolinux |
278 |
sng |
47 |
else |
279 |
sng |
84 |
# cp "$inFile" /home/partimag/*/syslinux/syslinux.cfg |
280 |
|
|
# cp "$bootImg" /home/partimag/usb-dev.* |
281 |
|
|
#fi |
282 |
|
|
# |
283 |
|
|
#if [ "$type" = "ZIP" ];then |
284 |
|
|
SYSLINUX_FILE=`echo "$origCFG" | sed 's{isolinux{syslinux{g'` |
285 |
|
|
sed "$inFile" | sed '{noprompt {{g' > "$SYSLINUX_FILE" |
286 |
|
|
cp "$bootImg" `dirname "$SYSLINUX_FILE"` |
287 |
sng |
47 |
fi |
288 |
|
|
|
289 |
|
|
rm "$inFile" |