/[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 41 by sng, Mon May 17 23:45:40 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 sections 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  #            svn up
40  #  #
41    
42  ##########################################################################################################################################  ##############################################################################
43  # Configuration for SystemRescueCD documentation section  # Configuration for SystemRescueCD documentation section
44  #  #
45  # This will:  # This will:
# Line 26  Line 49 
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-->  ( = tokenStart[0] )  #           <!--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  # startTAG[0] and endTAG[0] accordingly.  # 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 snippet to the section.  # Use variables sectionPrepend[0],sectionAppend[0] to prepend,append any text
59    # snippet to the section.
60  #    Example:  #    Example:
61  #       Assumming 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 startTAG[0]='<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    #       the closing TAGS
68  #       So we set sectionAppend[0]='</li>  #       So we set sectionAppend[0]='</li>
69  #                                   </ul>  #                                   </ul>
70  #                                   </p>'  #                                   </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 original documentation  # 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  # Finally, set sedScript[0] to any specific sed script
77  #  #
78  # ** NOTE **  # ** NOTE **
79  # The above scheme can be used for any other documentation section, i.e. SystemRescueCD (profile 1),  # The above scheme can be used for any other documentation section, i.e.
80  # initramfs manual )profile 2), etc.  # kernels (profile 1), initramfs manual (profile 2), Clonezilla (profile
81    # 3), etc.
82  #  #
83  #  #
84  name[0]=SystemRescueCD  name[0]=SystemRescueCD
# Line 66  s{<h[23]>{<p><b><br>{g Line 95  s{<h[23]>{<p><b><br>{g
95  s{<\/h[23]>{</b></p>{g  s{<\/h[23]>{</b></p>{g
96  1s{<p><b><br>{<p><b>{  1s{<p><b><br>{<p><b>{
97  s{href="/{href="http://www.sysresccd.org/{g  s{href="/{href="http://www.sysresccd.org/{g
98    s{<span[^>]*>{{
99    s{<.span>{{
100  '  '
101    
102  # Configuration for kernels documentation section  # Configuration for kernels documentation section
# Line 73  name[1]=kernels Line 104  name[1]=kernels
104  webPage[1]=''  webPage[1]=''
105  startTAG[1]='Default for 32bit systems,'  startTAG[1]='Default for 32bit systems,'
106  endTAG[1]='an alternative kernel for 64bit systems.'  endTAG[1]='an alternative kernel for 64bit systems.'
107  sectionPrepend[1]='<ul class="otherpage" style="padding: 0px 10px 20px 40px">'  sectionPrepend[1]=''
108  sectionAppend[1]='</li></ul>'  sectionAppend[1]='</li>'
109  tokenStart[1]='<!--kernels-Documentation-->'  tokenStart[1]='<!--kernels-Documentation-->'
110  tokenEnd[1]='</ul>'  tokenEnd[1]='</ul>'
111  sedScript[1]='  sedScript[1]='
112  s{^<ul>{{  s{^<ul>{{
113    s{^</ul>{{
114  '  '
115    
116  # Configuration for initramfs documentation section  # Configuration for initramfs documentation section
# Line 86  name[2]=initramfs Line 118  name[2]=initramfs
118  webPage[2]='http://clonezilla.org/clonezilla-live/live-initramfs.en.7.txt'  webPage[2]='http://clonezilla.org/clonezilla-live/live-initramfs.en.7.txt'
119  startTAG[2]=''  startTAG[2]=''
120  endTAG[2]=''  endTAG[2]=''
121  sectionPrepend[2]='<a name="live-initramfs"></a><div class="otherpage"><pre>'  sectionPrepend[2]='<a name="live-initramfs"></a><div class="otherpage" style="overflow: auto;"><pre>'
122  sectionAppend[2]=''  sectionAppend[2]=''
123  tokenStart[2]='<!--initramfs-Documentation-->'  tokenStart[2]='<!--initramfs-Documentation-->'
124  tokenEnd[2]='</pre>'  tokenEnd[2]='</pre>'
# Line 126  s{You can refer to this <a [^>]*>\([^>]* Line 158  s{You can refer to this <a [^>]*>\([^>]*
158    
159    
160    
161  ##########################################################################################################################################  ##############################################################################
162  #   funtion to make all happen  #   funtion to make all happen
163  #  #
164  function updateContent(){  function updateContent(){
 #set -x  
165  echo "Updating ${name[$1]} documentation"  echo "Updating ${name[$1]} documentation"
166  rm /tmp/webPage.$$ 2>/dev/null  # Fix varaibles for sed (sed syntax)
167  tokenEndReplace=`echo "${tokenEnd[$1]}" | sed 's|/|\\/|'`  tokenEndReplace=`echo "${tokenEnd[$1]}" | sed 's|/|\\/|'`
168  tokenEnd=`echo "${tokenEnd[$1]}" | sed 's|/|\.|'`  tokenEnd=`echo "${tokenEnd[$1]}" | sed 's|/|\.|'`
169    
170    # Download original web page/file
171  if [ -n "${webPage[$1]}" ];then  if [ -n "${webPage[$1]}" ];then
172    downloadFile $1    downloadFile $1
173  else  else
# Line 143  else Line 176  else
176          fi          fi
177  fi  fi
178    
 echo aaaaaaa  
 read  
   
 set -x  
179  echo -n "  Adding web content to file...   "  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  if [ -n "${startTAG[$1]}" ];then
184    sed -n "/${startTAG[$1]}/ , /${endTAG[$1]}/ p" /tmp/webPage.$$  > /tmp/tmp.$$    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  #       | sed '  s{/[tT][aA][rR][gG][eE][tT]="[^"]"{{g
188  # s{/[tT][aA][rR][gG][eE][tT]="[^"]"{{g  s{target=_blank{{g
189  # s{[aA] [hH][rR][eE][fF]={a target="_blank" href={g  s{[aA] [hH][rR][eE][fF]={a target="_blank" href={g
190  # s{/[tT][aA][rR][gG][eE][tT]="[^"]"{{g  ' > /tmp/tmp.$$
 # s{target=_blank{{g  
 # s{[aA] [hH][rR][eE][fF]={a target="_blank" href={g  
 # ' > /tmp/tmp.$$  
191  else  else
192    cp /tmp/webPage.$$ /tmp/tmp.$$    cp /tmp/webPage.$$ /tmp/tmp.$$
193  fi  fi
194    
195    # Apply page specific sed script to new content
 echo bbbbbbb  
 read  
   
   
   
196  if [ -n "${sedScript[$1]}" ];then  if [ -n "${sedScript[$1]}" ];then
197          echo "${sedScript[$1]}" > /tmp/sedScript.$$          echo "${sedScript[$1]}" > /tmp/sedScript.$$
198    sed -f /tmp/sedScript.$$ /tmp/tmp.$$ > /tmp/tmp-new.$$ && mv /tmp/tmp-new.$$ /tmp/tmp.$$    sed -f /tmp/sedScript.$$ /tmp/tmp.$$ > /tmp/tmp-new.$$ && mv /tmp/tmp-new.$$ /tmp/tmp.$$
199          rm /tmp/sedScript.$$          rm /tmp/sedScript.$$
200  fi  fi
201    
202    # Apply prepend text to new content
203  if [ -n "${sectionPrepend[$1]}" ];then  if [ -n "${sectionPrepend[$1]}" ];then
204    echo "${sectionPrepend[$1]}" > /tmp/tmp-new.$$    echo "${sectionPrepend[$1]}" > /tmp/tmp-new.$$
205          cat /tmp/tmp.$$ >> /tmp/tmp-new.$$          cat /tmp/tmp.$$ >> /tmp/tmp-new.$$
206          mv /tmp/tmp-new.$$ /tmp/tmp.$$          mv /tmp/tmp-new.$$ /tmp/tmp.$$
207  fi  fi
208    
209    # Applly append text to new content
210  if [ -n "${sectionAppend[$1]}" ];then  if [ -n "${sectionAppend[$1]}" ];then
211    echo "${sectionAppend[$1]}" >> /tmp/tmp.$$    echo "${sectionAppend[$1]}" >> /tmp/tmp.$$
212  fi  fi
213    
214    
215    # remove old content form current page
216  sed "/${tokenStart[$1]}/!b  sed "/${tokenStart[$1]}/!b
217  :a  :a
218  /"${tokenEnd}"/!{  /"${tokenEnd}"/!{
# Line 190  sed "/${tokenStart[$1]}/!b Line 220  sed "/${tokenStart[$1]}/!b
220          ba          ba
221  }  }
222  s[${tokenStart[$1]}.*${tokenEnd}[${tokenStart[$1]}\n${tokenEndReplace}[" boot-params.html > /tmp/page.$$    s[${tokenStart[$1]}.*${tokenEnd}[${tokenStart[$1]}\n${tokenEndReplace}[" boot-params.html > /tmp/page.$$  
223  sed "/${tokenStart[$1]}/r /tmp/tmp.$$" < /tmp/page.$$ > boot-params.html  
224  read  # 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    # clean up
232  rm /tmp/page.$$ /tmp/tmp.$$ /tmp/tmp-new.$$ 2>/dev/null  rm /tmp/page.$$ /tmp/tmp.$$ /tmp/tmp-new.$$ 2>/dev/null
233  echo 'done'  echo 'done'
 set +x  
234  }  }
235    
236    
237  ##########################################################################################################################################  ##############################################################################
238  #   funtion to download the original web page  #   funtion to download the original web page
239  #  #
240  function downloadFile(){  function downloadFile(){
 set -x  
241    echo -n "  Downloading web page...   "    echo -n "  Downloading web page...   "
242      rm /tmp/webPage.$$ 2>/dev/null
243    wget -q "${webPage[$1]}" -O /tmp/webPage.$$ && echo 'done' || {    wget -q "${webPage[$1]}" -O /tmp/webPage.$$ && echo 'done' || {
     
244    echo "    echo "
245    Error downloading original web page"    Error downloading original web page"
246    return 1    exit 1
247    }    }
 set +x  
248  }  }
249    
250  ##########################################################################################################################################  ##############################################################################
251  #   funtion clean up things when exiting  #   funtion clean up things when exiting
252  #  #
253  function cleanUp(){  function cleanUp(){
# Line 222  function cleanUp(){ Line 256  function cleanUp(){
256    
257    
258    
259  ##########################################################################################################################################  ##############################################################################
260  #  #
261  #                      Script starts here  #                              Script starts here
262  #  #
263  ##########################################################################################################################################  ##############################################################################
264    
265    # Go to working/ directory
266    cd ..
267  updateContent 0 || {  updateContent 0 || {
268          cleanUp;return 1          cleanUp;exit 1
269  }  }
270  updateContent 1 || {  updateContent 1 || {
271    cleanUp;return 2    cleanUp;exit 2
272  }  }
273    
274  updateContent 2 || {  updateContent 2 || {
275    cleanUp;return 3    cleanUp;exit 3
276  }  }
277  updateContent 3 || {  updateContent 3 || {
278    cleanUp;return 4    cleanUp;exit 4
279  }    }  
280    
281  cleanUp  cleanUp

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

webmaster@linux.gr
ViewVC Help
Powered by ViewVC 1.1.26