/[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

revision 40 by sng, Thu May 13 13:55:12 2010 UTC revision 41 by sng, Mon May 17 23:45:40 2010 UTC
# Line 1  Line 1 
1  #!/bin/bash  #!/bin/bash
2  ##########################################################################################################################################  ##########################################################################################################################################
3  #  #
4  # Script to update the boot parameters section of boor-params.html  # Script to update the boot parameters sections of boor-params.html
5  #  #
6  # To be executed BEFORE 2site script  # To be executed BEFORE ../2site script
7  #  #
8  # In order to execute this script, type the following command  # In order to execute this script, type the following command
9  #  #
10  #   . ./update-boot-params  #   . ./update-boot-params
11  #  #
12  #  #
13  #    NOTE  #  ** NOTE **
14  #      In order to revert to the previous version, execute teh commands:  #      In order to revert to the previous version, execute teh commands:
15  #            rm boot-params.html  #            rm boot-params.html
16  #            svn up boot-params.html  #            svn up
17  #  #
18    
19  ##########################################################################################################################################  ##########################################################################################################################################
# Line 21  Line 21 
21  #  #
22  # This will:  # This will:
23  #    a. remove any text between the line starting with  #    a. remove any text between the line starting with
24  #           <!--SysRescCD-Documentation-->  #           <!--SysRescCD-Documentation--> ( = tokenStart[0] )
25  #       and the first </div> TAG  #       and the first </div> TAG  ( = tokenEnd[0] )
26  #    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
27  #           <!--SysRescCD-Documentation-->  #           <!--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  # 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  # select the starting and ending line of code you want to include in boot-params.html and initialize the variables
31  # sysStartTAG and sysEndTAG accordingly.  **NOTE** : In case the variables' value (text/html code) contains a '/'  # startTAG[0] and endTAG[0] accordingly.
 # 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>"  
32  #  #
33  # Use variable sysCloseTAG to add any text snippet to the section.  # Use variables sectionPrepend[0],sectionAppend[0] to prepend,append any text snippet to the section.
34  #    Example:  #    Example:
35  #       The documentation section on the original page ends like this  #       Assumming the documentation section on the original page ends like this
36  #       <li>A line of text  #       <li>A line of text
37  #       </li>  #       </li>
38  #       </ul>  #       </ul>
39  #       </p>  #       </p>
40  #       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 the closing TAGS
41  #       So we set sysCloseTAG='</li> #                              </ul>  #       So we set sectionAppend[0]='</li>
42  #                              </p>'  #                                   </ul>
43    #                                   </p>'
44  #       and we get them back  #       and we get them back
45  #  #
46    # Use name[0] to identify the section, and webPage[0] for the URL of the original documentation
 sysStartTAG='<a name="General_boot_options"'  
 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  
47  #  #
48  # This will:  # Finally, set sedScript[0] to any specific sed script
 #    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-->  
49  #  #
50  # In order for this to work, inspect the HTML code on page  # ** NOTE **
51  #        http://clonezilla.org/clonezilla-live/doc/fine-print.php?path=./99_Misc/00_live-initramfs-manual.doc  # The above scheme can be used for any other documentation section, i.e. SystemRescueCD (profile 1),
52  # select the starting and ending line of code you want to include in boot-params.html and initialize the variables  # initramfs manual )profile 2), etc.
 # 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>"  
53  #  #
 # Use variable sysCloseTAG to add any text snippet to the section.  
 #    Example:  
 #       The documentation section on the original page ends like this  
 #       <li>A line of text  
 #       </li>  
 #       </ul>  
 #       </p>  
 #       We set lonStartTAG='<li>A line of text', but this way we also delete the closing TAGS  
 #       So we set lonCloseTAG='</li> #                              </ul>  
 #                              </p>'  
 #       and we get them back  
54  #  #
55    name[0]=SystemRescueCD
56  clonStartTAG='Clonezilla live is based on'  webPage[0]='http://www.sysresccd.org/Sysresccd-manual-en_Booting_the_CD-ROM'
57  clonEndTAG='root file system filesystem.squashfs.'  startTAG[0]='<a name="General_boot_options"'
58  clonCloseTAG='</ul>  endTAG[0]='<.li><li><b>ar_nowait<.b>: do not wait for a keypress after the autorun script have been executed.'
59  </ol>  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  #   Clonezilla documentation section  name[2]=initramfs
86  #  webPage[2]='http://clonezilla.org/clonezilla-live/live-initramfs.en.7.txt'
87  function updateClonezillaDocumentation(){  startTAG[2]=''
88    endTAG[2]=''
89  echo -n "Updating Clonezilla documentation...   "  sectionPrepend[2]='<a name="live-initramfs"></a><div class="otherpage"><pre>'
90  rm 00_live-initramfs-manual.doc 2>/dev/null  sectionAppend[2]=''
91  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-->'
92  echo "  tokenEnd[2]='</pre>'
93    Error downloading 00_live-initramfs-manual.doc"  sedScript[2]='
94  return 1  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  }  }
105    '
106    
107  sed -n "/$clonStartTAG/ , /$clonEndTAG/ p" 00_live-initramfs-manual.doc | sed '  # 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  s{<tr>{{g
119  s{<td[^>]*>{{g  s{<td[^>]*>{{g
120  s{<small>{{g  s{<small>{{g
121  s{<.tr>{{g  s{<.tr>{{g
122  s{<.td[^>]*>{{g  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">{  1s{^{<div class="otherpage">{
125  ' > 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  
   
126    
 rm tmp.$$ boot-params-new.html 00_live-initramfs-manual.doc 2>/dev/null  
 echo 'done'  
127    
 }  
128    
129  ##########################################################################################################################################  ##########################################################################################################################################
130  #   SystemRescueCD documentation section  #   funtion to make all happen
131  #  #
132  function updateSysRescCDDocumentation(){  function updateContent(){
133  echo -n "Updating SysRescCD documentation...   "  #set -x
134  rm Sysresccd-manual-en_Booting_the_CD-ROM 2>/dev/null  echo "Updating ${name[$1]} documentation"
135  wget -q http://www.sysresccd.org/Sysresccd-manual-en_Booting_the_CD-ROM || {  rm /tmp/webPage.$$ 2>/dev/null
136    tokenEndReplace=`echo "${tokenEnd[$1]}" | sed 's|/|\\/|'`
137  echo "  tokenEnd=`echo "${tokenEnd[$1]}" | sed 's|/|\.|'`
138    Error downloading Sysresccd-manual-en_Booting_the_CD-ROM"  if [ -n "${webPage[$1]}" ];then
139  return 1    downloadFile $1
140  }  else
141  sed -n "/$sysStartTAG/ , /$sysEndTAG/ p" Sysresccd-manual-en_Booting_the_CD-ROM | sed '          if [ ! -e /tmp/webPage.$$ ];then
142  s{<h[23]>{<p><b><br>{g      downloadFile $1
143  s{<\/h[23]>{</b></p>{g          fi
144  1s{<p><b><br>{<p><b>{  fi
145  s{href="/{href="http://www.sysresccd.org/{g  
146  ' > tmp.$$  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  if [ -n "$sysCloseTAG" ];then  echo bbbbbbb
168    echo "$sysCloseTAG" >> tmp.$$  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  fi
186  sed '/<!--SysRescCD-Documentation-->/!b  sed "/${tokenStart[$1]}/!b
187  :a  :a
188  /<.div>/!{  /"${tokenEnd}"/!{
189          N          N
190          ba          ba
191  }  }
192  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.$$  
193  sed "/<!--SysRescCD-Documentation-->/r tmp.$$" < boot-params-new.html > boot-params.html  sed "/${tokenStart[$1]}/r /tmp/tmp.$$" < /tmp/page.$$ > boot-params.html
194    read
195  rm Sysresccd-manual-en_Booting_the_CD-en_Booting_the_CD-ROM tmp.$$ 2>/dev/null  rm /tmp/page.$$ /tmp/tmp.$$ /tmp/tmp-new.$$ 2>/dev/null
196  echo 'done'  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    
# Line 172  echo 'done' Line 228  echo 'done'
228  #  #
229  ##########################################################################################################################################  ##########################################################################################################################################
230    
231  updateSysRescCDDocumentation || return  updateContent 0 || {
232  updateClonezillaDocumentation || return          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

Legend:
Removed from v.40  
changed lines
  Added in v.41

webmaster@linux.gr
ViewVC Help
Powered by ViewVC 1.1.26