/[clonezilla-sysresccd]/trunk/www/working/scripts/update-boot-params
ViewVC logotype

Contents of /trunk/www/working/scripts/update-boot-params

Parent Directory Parent Directory | Revision Log Revision Log


Revision 42 - (show annotations)
Tue May 18 14:22:00 2010 UTC (11 years, 2 months ago) by sng
File size: 7824 byte(s)
- Moving the scripts used to create the documentation
under their own directory (trunk/www/working/scripts)
- Deleting onepage.php (replaced by onepage.html)

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

webmaster@linux.gr
ViewVC Help
Powered by ViewVC 1.1.26