20 |
# # |
# # |
21 |
############################################################################## |
############################################################################## |
22 |
|
|
23 |
function copyCFGfile(){ |
function findCFGfile(){ |
24 |
if [ -e isolinux-restore-cd.cfg ];then |
if [ -e isolinux-restore-cd.cfg ];then |
25 |
inFile="./isolinux-restore-cd.cfg" |
templateCFG="./isolinux-restore-cd.cfg" |
26 |
elif [ -r /live/image/restorecd/isolinux-restore-cd.cfg ];then |
elif [ -r /live/image/restorecd/isolinux-restore-cd.cfg ];then |
27 |
inFile="/live/image/restorecd/isolinux-restore-cd.cfg" |
templateCFG="/live/image/restorecd/isolinux-restore-cd.cfg" |
28 |
elif [ -r /tmp/restorecd/isolinux-restore-cd.cfg ];then |
elif [ -r /tmp/restorecd/isolinux-restore-cd.cfg ];then |
29 |
inFile="/tmp/restorecd/isolinux-restore-cd.cfg" |
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 |
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 |
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 |
This script will terminate now" 0 0 |
36 |
exit 1 |
exit 1 |
37 |
fi |
fi |
|
cp "$inFile" /tmp/isolinux-mine.cfg |
|
|
bootImg="$(dirname "$inFile")"/ocswp.png |
|
|
inFile='/tmp/isolinux-mine.cfg' |
|
38 |
} |
} |
39 |
|
|
40 |
function copy2RamCFGfile(){ |
function find2RamCFGfile(){ |
41 |
if [ -e isolinux-restore-cd-ram.cfg ];then |
if [ -e isolinux-restore-cd-ram.cfg ];then |
42 |
inFile="./isolinux-restore-cd-ram.cfg" |
templateCFG="./isolinux-restore-cd-ram.cfg" |
43 |
elif [ -r /live/image/restorecd/isolinux-restore-cd-ram.cfg ];then |
elif [ -r /live/image/restorecd/isolinux-restore-cd-ram.cfg ];then |
44 |
inFile="/live/image/restorecd/isolinux-restore-cd-ram.cfg" |
templateCFG="/live/image/restorecd/isolinux-restore-cd-ram.cfg" |
45 |
elif [ -r /tmp/restorecd/isolinux-restore-cd-ram.cfg ];then |
elif [ -r /tmp/restorecd/isolinux-restore-cd-ram.cfg ];then |
46 |
inFile="/tmp/restorecd/isolinux-restore-cd-ram.cfg" |
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 |
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 |
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 |
This script will terminate now" 0 0 |
53 |
exit 1 |
exit 1 |
54 |
fi |
fi |
|
cp "$inFile" /tmp/isolinux-mine.cfg |
|
|
bootImg="$(dirname "$inFile")"/ocswp.png |
|
|
inFile='/tmp/isolinux-mine.cfg' |
|
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 |
# Parse command-line options |
88 |
while [ $# -gt 0 ]; do |
while [ $# -gt 0 ]; do |
105 |
fi |
fi |
106 |
# [ -z "$target_iso_prefix" ] && USAGE && exit 1 |
# [ -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; |
break; |
118 |
;; |
;; |
126 |
# # # |
# # # |
127 |
# # # |
# # # |
128 |
# # # the CFG file can be found as |
# # # the CFG file can be found as |
129 |
# # # /tmp/*/isolinux/isolinux.cfg |
# # # /tmp/ocs_isosys*/isolinux/isolinux.cfg |
130 |
# # # or |
# # # or |
131 |
# # # /home/partimag/*/isolinux/isolinux.cfg |
# # # /home/partimag/ocs_isosys*/isolinux/isolinux.cfg |
132 |
# # # |
# # # |
133 |
# # # |
# # # |
134 |
|
|
135 |
if [ -e /tmp/*/isolinux/isolinux.cfg ];then |
if [ "$type" = ISO ];then |
136 |
type=ISO |
type=ISO |
137 |
origCFG="/tmp/*/isolinux/isolinux.cfg" |
finalCFG=/tmp/ocs_isosys*/isolinux/isolinux.cfg |
138 |
elif [ -e /home/partimag/*/isolinux/isolinux.cfg ];then |
finalCFG=`find /tmp -name isolinux.cfg` |
|
type=ZIP |
|
|
origCFG="/home/partimag/*/isolinux/isolinux.cfg" |
|
139 |
else |
else |
|
origCFG='' |
|
140 |
type=ZIP |
type=ZIP |
141 |
dialog --backtitle Clonezilla-SysRescCD --title " Execution Error " --msgbox "This is not a stand-alone script and should not be executed by the command line |
finalCFG=/home/partimag/ocs_isosys*/isolinux/isolinux.cfg |
142 |
|
finalCFG=`find /home/partimag -name isolinux.cfg` |
143 |
This script will terminate now" 0 0 |
fi |
144 |
exit 1 |
|
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 |
fi |
160 |
|
|
161 |
|
|
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 |
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 |
if [ $? -eq 1 ];then |
167 |
exit |
CUSTOMIZE=no |
168 |
fi |
fi |
169 |
|
|
170 |
|
|
171 |
if [ "$1" = "prog_only" ];then |
if [ "$1" = "prog_only" ];then |
172 |
copy2RamCFGfile |
find2RamCFGfile |
173 |
else |
else |
174 |
copyCFGfile |
findCFGfile |
175 |
fi |
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 |
# DVD Title |
190 |
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 |
191 |
menuTitle=`cat /tmp/answer` |
menuTitle=`cat /tmp/answer` |
192 |
|
|
193 |
rm /tmp/answer 2>/dev/null |
rm /tmp/answer 2>/dev/null |
223 |
to maintain current setting |
to maintain current setting |
224 |
' 0 60 0 \\" > /tmp/q.$$ |
' 0 60 0 \\" > /tmp/q.$$ |
225 |
|
|
226 |
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.$$ |
227 |
|
|
228 |
oldCaption=`sed 's|^1 *.||' /tmp/qq.$$ | sed "s| *-.*||"` |
oldCaption=`sed 's|^1 *.||' /tmp/qq.$$ | sed "s| *-.*||"` |
229 |
|
|
240 |
|
|
241 |
defItem=`cat /tmp/answer` |
defItem=`cat /tmp/answer` |
242 |
if [ $defItem -gt 6 ];then ((defItem++));fi |
if [ $defItem -gt 6 ];then ((defItem++));fi |
243 |
if [ $defItem -eq 6 ];then defItem='';fi |
((defItem++)) |
244 |
|
#if [ $defItem -eq 6 ];then defItem='';fi |
245 |
|
if [ $defItem -eq 7 ];then defItem='';fi |
246 |
rm /tmp/answer 2>/dev/null |
rm /tmp/answer 2>/dev/null |
247 |
|
|
248 |
|
|
286 |
|
|
287 |
|
|
288 |
|
|
289 |
|
############################################################################ |
290 |
|
# |
291 |
|
# Insert user data to file |
292 |
|
# |
293 |
|
############################################################################ |
294 |
|
|
295 |
|
|
296 |
|
|
297 |
if [ -n "$menuTitle" ];then |
if [ -n "$menuTitle" ];then |
298 |
sed "s|^ *MENU TITLE .*|MENU TITLE $menuTitle|" "$inFile" > "$inFile".$$ && mv "$inFile".$$ "$inFile" |
sed "s|^ *MENU TITLE .*|MENU TITLE $menuTitle|" $finalCFG > $finalCFG.$$ && mv $finalCFG.$$ $finalCFG |
299 |
fi |
fi |
300 |
|
|
301 |
if [ -n "$itemCaption" ];then |
if [ -n "$itemCaption" ];then |
302 |
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 |
303 |
fi |
fi |
304 |
|
|
305 |
if [ -n "$bootDelay" ];then |
if [ -n "$bootDelay" ];then |
306 |
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 |
307 |
fi |
fi |
308 |
|
|
309 |
if [ -n "$defItem" ];then |
if [ -n "$defItem" ];then |
310 |
sed 's|^ *MENU DEFAULT| # MENU DEFAULT|' "$inFile" > "$inFile".$$ |
sed 's|^ *MENU DEFAULT| # MENU DEFAULT|' $finalCFG > $finalCFG.$$ && mv $finalCFG.$$ $finalCFG |
311 |
addIt=`grep -n 'MENU DEFAULT' "$inFile".$$ | sed 's|:.*||' | sed -n ""$defItem"p"` |
addIt=`grep -n 'MENU DEFAULT' $finalCFG | sed 's|:.*||' | sed -n ""$defItem"p"` |
312 |
sed ""$addIt"s|# *MENU *DEFAULT|MENU DEFAULT|" "$inFile".$$ > "$inFile" |
sed ""$addIt"s|# *MENU *DEFAULT|MENU DEFAULT|" $finalCFG > $finalCFG.$$ && mv $finalCFG.$$ $finalCFG |
313 |
fi |
fi |
314 |
|
|
315 |
|
|
318 |
fi |
fi |
319 |
|
|
320 |
|
|
|
# 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"` |
|
321 |
fi |
fi |
322 |
|
|
323 |
rm "$inFile" |
copy_PNG_SYSLINUX |
324 |
|
|