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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 41 - (hide annotations)
Mon May 17 23:45:40 2010 UTC (13 years, 10 months ago) by sng
Original Path: trunk/www/working/update-boot-params
File size: 7215 byte(s)
- updating devel site
- rewriting update-boot-params, adding kernels section to 
  auto-update feature

1 sng 39 #!/bin/bash
2     ##########################################################################################################################################
3     #
4 sng 41 # Script to update the boot parameters sections of boor-params.html
5 sng 39 #
6 sng 41 # To be executed BEFORE ../2site script
7 sng 39 #
8     # In order to execute this script, type the following command
9     #
10     # . ./update-boot-params
11     #
12     #
13 sng 41 # ** NOTE **
14 sng 39 # In order to revert to the previous version, execute teh commands:
15     # rm boot-params.html
16 sng 41 # svn up
17 sng 39 #
18    
19     ##########################################################################################################################################
20     # Configuration for SystemRescueCD documentation section
21     #
22     # This will:
23     # a. remove any text between the line starting with
24 sng 41 # <!--SysRescCD-Documentation--> ( = tokenStart[0] )
25     # and the first </div> TAG ( = tokenEnd[0] )
26 sng 39 # b. add the text from the original site after the line starting with
27 sng 41 # <!--SysRescCD-Documentation--> ( = tokenStart[0] )
28 sng 39 #
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 sng 41 # startTAG[0] and endTAG[0] accordingly.
32 sng 39 #
33 sng 41 # Use variables sectionPrepend[0],sectionAppend[0] to prepend,append any text snippet to the section.
34 sng 39 # Example:
35 sng 41 # Assumming the documentation section on the original page ends like this
36 sng 39 # <li>A line of text
37     # </li>
38     # </ul>
39     # </p>
40 sng 41 # 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 sng 39 # and we get them back
45     #
46 sng 41 # Use name[0] to identify the section, and webPage[0] for the URL of the original documentation
47 sng 39 #
48 sng 41 # Finally, set sedScript[0] to any specific sed script
49 sng 39 #
50 sng 41 # ** 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 sng 39 #
54     #
55 sng 41 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 sng 39
71 sng 41 # 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 sng 39 '
83    
84 sng 41 # 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{<{\&lt;{g
95     s{>{\&gt;{g
96     s{&{\&amp;{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 sng 39 }
105 sng 41 '
106 sng 39
107 sng 41 # 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 sng 39 s{<tr>{{g
119     s{<td[^>]*>{{g
120     s{<small>{{g
121     s{<.tr>{{g
122     s{<.td[^>]*>{{g
123 sng 41 s{You can refer to this <a [^>]*>\([^>]*\)</a>{You can refer to this <a href="#live-initramfs">\1</a>{
124 sng 39 1s{^{<div class="otherpage">{
125 sng 41 '
126 sng 39
127    
128    
129     ##########################################################################################################################################
130 sng 41 # funtion to make all happen
131 sng 39 #
132 sng 41 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 sng 39
146 sng 41 echo aaaaaaa
147     read
148 sng 39
149 sng 41 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 sng 39 fi
165 sng 41
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 sng 39 :a
188 sng 41 /"${tokenEnd}"/!{
189 sng 39 N
190     ba
191     }
192 sng 41 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 sng 39 echo 'done'
197 sng 41 set +x
198     }
199 sng 39
200    
201 sng 41 ##########################################################################################################################################
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 sng 39 }
215    
216 sng 41 ##########################################################################################################################################
217     # funtion clean up things when exiting
218     #
219     function cleanUp(){
220     rm /tmp/webPage.$$
221     }
222 sng 39
223    
224 sng 41
225 sng 39 ##########################################################################################################################################
226     #
227     # Script starts here
228     #
229     ##########################################################################################################################################
230    
231 sng 41 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 sng 39
244 sng 41 cleanUp

webmaster@linux.gr
ViewVC Help
Powered by ViewVC 1.1.26