1 |
#!/bin/bash |
2 |
########################################################################################################################################## |
3 |
# |
4 |
# Script to update the boot parameters sections of boor-params.html |
5 |
# |
6 |
# To be executed BEFORE ../2site script |
7 |
# |
8 |
# In order to execute this script, type the following command |
9 |
# |
10 |
# . ./update-boot-params |
11 |
# |
12 |
# |
13 |
# ** NOTE ** |
14 |
# In order to revert to the previous version, execute teh commands: |
15 |
# rm boot-params.html |
16 |
# svn up |
17 |
# |
18 |
|
19 |
########################################################################################################################################## |
20 |
# Configuration for SystemRescueCD documentation section |
21 |
# |
22 |
# This will: |
23 |
# a. remove any text between the line starting with |
24 |
# <!--SysRescCD-Documentation--> ( = tokenStart[0] ) |
25 |
# and the first </div> TAG ( = tokenEnd[0] ) |
26 |
# b. add the text from the original site after the line starting with |
27 |
# <!--SysRescCD-Documentation--> ( = tokenStart[0] ) |
28 |
# |
29 |
# In order for this to work, inspect the HTML code on page http://www.sysresccd.org/Sysresccd-manual-en_Booting_the_CD-ROM |
30 |
# select the starting and ending line of code you want to include in boot-params.html and initialize the variables |
31 |
# startTAG[0] and endTAG[0] accordingly. |
32 |
# |
33 |
# Use variables sectionPrepend[0],sectionAppend[0] to prepend,append any text snippet to the section. |
34 |
# Example: |
35 |
# Assumming the documentation section on the original page ends like this |
36 |
# <li>A line of text |
37 |
# </li> |
38 |
# </ul> |
39 |
# </p> |
40 |
# We set startTAG[0]='<li>A line of text', but this way we also delete the closing TAGS |
41 |
# So we set sectionAppend[0]='</li> |
42 |
# </ul> |
43 |
# </p>' |
44 |
# and we get them back |
45 |
# |
46 |
# Use name[0] to identify the section, and webPage[0] for the URL of the original documentation |
47 |
# |
48 |
# Finally, set sedScript[0] to any specific sed script |
49 |
# |
50 |
# ** NOTE ** |
51 |
# The above scheme can be used for any other documentation section, i.e. SystemRescueCD (profile 1), |
52 |
# initramfs manual )profile 2), etc. |
53 |
# |
54 |
# |
55 |
name[0]=SystemRescueCD |
56 |
webPage[0]='http://www.sysresccd.org/Sysresccd-manual-en_Booting_the_CD-ROM' |
57 |
startTAG[0]='<a name="General_boot_options"' |
58 |
endTAG[0]='<.li><li><b>ar_nowait<.b>: do not wait for a keypress after the autorun script have been executed.' |
59 |
sectionPrepend[0]='' |
60 |
sectionAppend[0]='</li></ul> |
61 |
</p>' |
62 |
tokenStart[0]='<!--SysRescCD-Documentation-->' |
63 |
tokenEnd[0]='</div>' |
64 |
sedScript[0]=' |
65 |
s{<h[23]>{<p><b><br>{g |
66 |
s{<\/h[23]>{</b></p>{g |
67 |
1s{<p><b><br>{<p><b>{ |
68 |
s{href="/{href="http://www.sysresccd.org/{g |
69 |
' |
70 |
|
71 |
# Configuration for kernels documentation section |
72 |
name[1]=kernels |
73 |
webPage[1]='' |
74 |
startTAG[1]='Default for 32bit systems,' |
75 |
endTAG[1]='an alternative kernel for 64bit systems.' |
76 |
sectionPrepend[1]='<ul class="otherpage" style="padding: 0px 10px 20px 40px">' |
77 |
sectionAppend[1]='</li></ul>' |
78 |
tokenStart[1]='<!--kernels-Documentation-->' |
79 |
tokenEnd[1]='</ul>' |
80 |
sedScript[1]=' |
81 |
s{^<ul>{{ |
82 |
' |
83 |
|
84 |
# Configuration for initramfs documentation section |
85 |
name[2]=initramfs |
86 |
webPage[2]='http://clonezilla.org/clonezilla-live/live-initramfs.en.7.txt' |
87 |
startTAG[2]='' |
88 |
endTAG[2]='' |
89 |
sectionPrepend[2]='<a name="live-initramfs"></a><div class="otherpage"><pre>' |
90 |
sectionAppend[2]='' |
91 |
tokenStart[2]='<!--initramfs-Documentation-->' |
92 |
tokenEnd[2]='</pre>' |
93 |
sedScript[2]=' |
94 |
s{<{\<{g |
95 |
s{>{\>{g |
96 |
s{&{\&{g |
97 |
s{\[HOSTNAME\]:\[DEVICE\]:{\[HOSTNAME\]:\n \[DEVICE\]:{g |
98 |
s!\*\*LAYOUT\*\*, \(.\)kvariant!\*\*LAYOUT\*\*,\n \1kvariant! |
99 |
s{modelcode}=\*\*CODE\*\*{modelcode}=\n \*\*CODE\*\*{ |
100 |
/link:/{ |
101 |
s{\[{+{g |
102 |
s{\]{_{g |
103 |
s{link:\([^+]*\)+\([^_]*\)_{<a href="\1" target="_blank">\2</a>{g |
104 |
} |
105 |
' |
106 |
|
107 |
# Configuration for Clonezilla documentation section |
108 |
name[3]=Clonezilla |
109 |
webPage[3]='http://clonezilla.org/clonezilla-live/doc/fine-print.php?path=./99_Misc/00_live-initramfs-manual.doc' |
110 |
startTAG[3]='Clonezilla live is based on' |
111 |
endTAG[3]='root file system filesystem.squashfs.' |
112 |
sectionPrepend[3]='' |
113 |
sectionAppend[3]='</ul> |
114 |
</ol>' |
115 |
tokenStart[3]='<!--Clonezilla-Documentation-->' |
116 |
tokenEnd[3]='<hr>' |
117 |
sedScript[3]=' |
118 |
s{<tr>{{g |
119 |
s{<td[^>]*>{{g |
120 |
s{<small>{{g |
121 |
s{<.tr>{{g |
122 |
s{<.td[^>]*>{{g |
123 |
s{You can refer to this <a [^>]*>\([^>]*\)</a>{You can refer to this <a href="#live-initramfs">\1</a>{ |
124 |
1s{^{<div class="otherpage">{ |
125 |
' |
126 |
|
127 |
|
128 |
|
129 |
########################################################################################################################################## |
130 |
# funtion to make all happen |
131 |
# |
132 |
function updateContent(){ |
133 |
#set -x |
134 |
echo "Updating ${name[$1]} documentation" |
135 |
rm /tmp/webPage.$$ 2>/dev/null |
136 |
tokenEndReplace=`echo "${tokenEnd[$1]}" | sed 's|/|\\/|'` |
137 |
tokenEnd=`echo "${tokenEnd[$1]}" | sed 's|/|\.|'` |
138 |
if [ -n "${webPage[$1]}" ];then |
139 |
downloadFile $1 |
140 |
else |
141 |
if [ ! -e /tmp/webPage.$$ ];then |
142 |
downloadFile $1 |
143 |
fi |
144 |
fi |
145 |
|
146 |
echo aaaaaaa |
147 |
read |
148 |
|
149 |
set -x |
150 |
echo -n " Adding web content to file... " |
151 |
if [ -n "${startTAG[$1]}" ];then |
152 |
sed -n "/${startTAG[$1]}/ , /${endTAG[$1]}/ p" /tmp/webPage.$$ > /tmp/tmp.$$ |
153 |
|
154 |
# |
155 |
# | sed ' |
156 |
# s{/[tT][aA][rR][gG][eE][tT]="[^"]"{{g |
157 |
# s{[aA] [hH][rR][eE][fF]={a target="_blank" href={g |
158 |
# s{/[tT][aA][rR][gG][eE][tT]="[^"]"{{g |
159 |
# s{target=_blank{{g |
160 |
# s{[aA] [hH][rR][eE][fF]={a target="_blank" href={g |
161 |
# ' > /tmp/tmp.$$ |
162 |
else |
163 |
cp /tmp/webPage.$$ /tmp/tmp.$$ |
164 |
fi |
165 |
|
166 |
|
167 |
echo bbbbbbb |
168 |
read |
169 |
|
170 |
|
171 |
|
172 |
if [ -n "${sedScript[$1]}" ];then |
173 |
echo "${sedScript[$1]}" > /tmp/sedScript.$$ |
174 |
sed -f /tmp/sedScript.$$ /tmp/tmp.$$ > /tmp/tmp-new.$$ && mv /tmp/tmp-new.$$ /tmp/tmp.$$ |
175 |
rm /tmp/sedScript.$$ |
176 |
fi |
177 |
|
178 |
if [ -n "${sectionPrepend[$1]}" ];then |
179 |
echo "${sectionPrepend[$1]}" > /tmp/tmp-new.$$ |
180 |
cat /tmp/tmp.$$ >> /tmp/tmp-new.$$ |
181 |
mv /tmp/tmp-new.$$ /tmp/tmp.$$ |
182 |
fi |
183 |
if [ -n "${sectionAppend[$1]}" ];then |
184 |
echo "${sectionAppend[$1]}" >> /tmp/tmp.$$ |
185 |
fi |
186 |
sed "/${tokenStart[$1]}/!b |
187 |
:a |
188 |
/"${tokenEnd}"/!{ |
189 |
N |
190 |
ba |
191 |
} |
192 |
s[${tokenStart[$1]}.*${tokenEnd}[${tokenStart[$1]}\n${tokenEndReplace}[" boot-params.html > /tmp/page.$$ |
193 |
sed "/${tokenStart[$1]}/r /tmp/tmp.$$" < /tmp/page.$$ > boot-params.html |
194 |
read |
195 |
rm /tmp/page.$$ /tmp/tmp.$$ /tmp/tmp-new.$$ 2>/dev/null |
196 |
echo 'done' |
197 |
set +x |
198 |
} |
199 |
|
200 |
|
201 |
########################################################################################################################################## |
202 |
# funtion to download the original web page |
203 |
# |
204 |
function downloadFile(){ |
205 |
set -x |
206 |
echo -n " Downloading web page... " |
207 |
wget -q "${webPage[$1]}" -O /tmp/webPage.$$ && echo 'done' || { |
208 |
|
209 |
echo " |
210 |
Error downloading original web page" |
211 |
return 1 |
212 |
} |
213 |
set +x |
214 |
} |
215 |
|
216 |
########################################################################################################################################## |
217 |
# funtion clean up things when exiting |
218 |
# |
219 |
function cleanUp(){ |
220 |
rm /tmp/webPage.$$ |
221 |
} |
222 |
|
223 |
|
224 |
|
225 |
########################################################################################################################################## |
226 |
# |
227 |
# Script starts here |
228 |
# |
229 |
########################################################################################################################################## |
230 |
|
231 |
updateContent 0 || { |
232 |
cleanUp;return 1 |
233 |
} |
234 |
updateContent 1 || { |
235 |
cleanUp;return 2 |
236 |
} |
237 |
updateContent 2 || { |
238 |
cleanUp;return 3 |
239 |
} |
240 |
updateContent 3 || { |
241 |
cleanUp;return 4 |
242 |
} |
243 |
|
244 |
cleanUp |