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

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

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

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

Legend:
Removed from v.39  
changed lines
  Added in v.52

webmaster@linux.gr
ViewVC Help
Powered by ViewVC 1.1.26