#!/bin/bash ############################################################################## # # # update-boot-params, (C) 2007-2010 S. Georgaras # # # # This file is part of Clonezilla-SysRescCD. # # # # Clonezilla-SysRescCD is free software: you can redistribute it and/or # # modify it under the terms of the GNU General Public License as published # # by the Free Software Foundation, either version 2 of the License, or # # (at your option) any later version. # # # # Clonezilla-SysRescCD is distributed in the hope that it will be useful, # # but WITHOUT ANY WARRANTY; without even the implied warranty of # # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # # GNU General Public License for more details. # # # # You should have received a copy of the GNU General Public License along # # with Clonezilla-SysRescCD. If not, see . # # # ############################################################################## ############################################################################## # # Script to update the boot parameters sections of boor-params.html # # To be executed BEFORE 2site script # # In order to execute this script, type the following command # # ./update-boot-params # # # ** NOTE ** # In order to revert to the previous (svn) version, (in case something # goes wrong with this script), execute the commands: # rm boot-params.html # svn up # ############################################################################## # Configuration for SystemRescueCD documentation section # # This will: # a. remove any text between the line starting with # ( = tokenStart[0] ) # and the first TAG ( = tokenEnd[0] ) # b. add the text from the original site after the line starting with # ( = tokenStart[0] ) # # In order for this to work, inspect the HTML code on page # http://www.sysresccd.org/Sysresccd-manual-en_Booting_the_CD-ROM # select the starting and ending line of code you want to include in # boot-params.html and initialize the variables startTAG[0] and endTAG[0] # accordingly. # # Use variables sectionPrepend[0],sectionAppend[0] to prepend,append any text # snippet to the section. # Example: # Assumming the documentation section on the original page ends like this #
  • A line of text #
  • # #

    # We set startTAG[0]='
  • A line of text', but this way we also delete # the closing TAGS # So we set sectionAppend[0]='
  • # #

    ' # and we get them back # # Use name[0] to identify the section, and webPage[0] for the URL of the # original documentation # # Finally, set sedScript[0] to any specific sed script # # ** NOTE ** # The above scheme can be used for any other documentation section, i.e. # kernels (profile 1), initramfs manual (profile 2), Clonezilla (profile # 3), etc. # # name[0]=SystemRescueCD webPage[0]='http://www.sysresccd.org/Sysresccd-manual-en_Booting_the_CD-ROM' startTAG[0]=' /tmp/tmp.$$ else cp /tmp/webPage.$$ /tmp/tmp.$$ fi # Apply page specific sed script to new content if [ -n "${sedScript[$1]}" ];then echo "${sedScript[$1]}" > /tmp/sedScript.$$ sed -f /tmp/sedScript.$$ /tmp/tmp.$$ > /tmp/tmp-new.$$ && mv /tmp/tmp-new.$$ /tmp/tmp.$$ rm /tmp/sedScript.$$ fi # Apply prepend text to new content if [ -n "${sectionPrepend[$1]}" ];then echo "${sectionPrepend[$1]}" > /tmp/tmp-new.$$ cat /tmp/tmp.$$ >> /tmp/tmp-new.$$ mv /tmp/tmp-new.$$ /tmp/tmp.$$ fi # Applly append text to new content if [ -n "${sectionAppend[$1]}" ];then echo "${sectionAppend[$1]}" >> /tmp/tmp.$$ fi # remove old content form current page sed "/${tokenStart[$1]}/!b :a /"${tokenEnd}"/!{ N ba } s[${tokenStart[$1]}.*${tokenEnd}[${tokenStart[$1]}\n${tokenEndReplace}[" boot-params.html > /tmp/page.$$ # insert new content to current page if [ -n "$createTamplatePage" ];then cp /tmp/page.$$ boot-params.html else sed "/${tokenStart[$1]}/r /tmp/tmp.$$" < /tmp/page.$$ > boot-params.html fi # clean up rm /tmp/page.$$ /tmp/tmp.$$ /tmp/tmp-new.$$ 2>/dev/null echo 'done' } ############################################################################## # funtion to download the original web page # function downloadFile(){ echo -n " Downloading web page... " rm /tmp/webPage.$$ 2>/dev/null wget -q "${webPage[$1]}" -O /tmp/webPage.$$ && echo 'done' || { echo " Error downloading original web page" exit 1 } } ############################################################################## # funtion clean up things when exiting # function cleanUp(){ rm /tmp/webPage.$$ } ############################################################################## # # Script starts here # ############################################################################## # Go to working/ directory cd .. updateContent 0 || { cleanUp;exit 1 } updateContent 1 || { cleanUp;exit 2 } updateContent 2 || { cleanUp;exit 3 } updateContent 3 || { cleanUp;exit 4 } cleanUp