/[clonezilla-sysresccd]/trunk/create-clonezilla-sysresccd/create-clonezilla-sysresccd.sh
ViewVC logotype

Diff of /trunk/create-clonezilla-sysresccd/create-clonezilla-sysresccd.sh

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

revision 140 by sng, Mon Sep 27 17:02:51 2010 UTC revision 162 by sng, Tue Mar 29 16:53:17 2011 UTC
# Line 18  Line 18 
18  # with Clonezilla-SysRescCD. If not, see <http://www.gnu.org/licenses/>.     #  # with Clonezilla-SysRescCD. If not, see <http://www.gnu.org/licenses/>.     #
19  #                                                                            #  #                                                                            #
20  ##############################################################################  ##############################################################################
21    function evalPrograms(){
22    local ans
23    
24    echo -n "Looking for curl...   "
25    if [ -z "$(curl -V 2>/dev/null)" ];then
26      echo failed
27      unset curlFound
28      echo
29      echo "curl was not found on your system, so the ISO files cannot be download"
30      echo "Please install curl and try again"
31      exit 1
32    else
33      echo found
34      curlFound=1
35    fi
36    
37    echo -n "Looking for md5sum...   "
38    if [ -z "$(md5sum --version 2>/dev/null)" ];then
39      echo failed
40      unset md5sumFound
41      echo
42      echo "  Info: md5sum was not found on your system"
43      echo "        The ISO files will not be validated."
44      echo
45      echo -n "     Do you want to continue? (y/[n]) "
46      read ans
47      if [ "$ans" != "y" ];then
48        exit
49      fi
50    else
51      echo found
52      md5sumFound=1
53    fi
54    }
55    
56    function downloadIsoFiles(){
57    local clonIso
58    local sysIso="http://sourceforge.net/projects/systemrescuecd/files/sysresccd-x86/"$sysVersion"/systemrescuecd-x86-"$sysVersion".iso/download"
59    
60    # Start with Clonezilla Live
61    if [ "$1" = "all" ] || [ -z "$1" ];then
62      # Download all files
63      for clonType in i686 i486 amd64;do
64        clonIso="http://sourceforge.net/projects/clonezilla/files/clonezilla_live_stable/OldFiles/"$clonVersion"/clonezilla-live-"$clonVersion"-"$clonType".iso/download"
65        downloadClonezillaLive
66      done
67    else
68      clonType="$1"
69      clonIso="http://sourceforge.net/projects/clonezilla/files/clonezilla_live_stable/OldFiles/"$clonVersion"/clonezilla-live-"$clonVersion"-"$clonType".iso/download"
70      downloadClonezillaLive
71    fi
72    
73    # Download System Rescue CD
74    echo "
75    ******  Downloading System Rescue CD "$sysVersion" ******"
76    unset curlContinue
77    if [ -e systemrescuecd-x86-"$sysVersion".iso ];then
78      if [ -n "$md5sumFound" ];then
79        echo "$sysmd5  systemrescuecd-x86-"$sysVersion".iso" > test.md5sum
80        echo -n "File found. Checking integrity of "
81        md5sum -c test.md5sum 2>/dev/null
82        if [ "$?" -eq 0 ];then
83          rm -f test.md5sum 2>/dev/null
84          return
85        else
86          echo "File systemrescuecd-x86-"$sysVersion".iso already exists"
87          echo "You can continue downloading the file or restart it"
88          echo -n "Continue downloading? (y/[n]): "
89          read ans
90          if [ "$ans" = "y" ];then
91            curlContinue=1
92          else
93            rm -f test.md5sum 2>/dev/null
94          fi
95        fi
96      else
97        echo "File systemrescuecd-x86-"$sysVersion".iso already exists"
98        echo "You can continue downloading the file or restart it"
99        echo "If you do continue downloading, and since md5sum was not found,"
100        echo "make sure you check the file's integrity manually, after the"
101        echo "download is complete"
102        echo -n "Continue downloading? (y/[n]): "
103        read ans
104        if [ "$ans" = "y" ];then
105          curlContinue=1
106        fi
107      fi
108    fi
109    if [ -z "$curlContinue" ];then
110      curl -L "$sysIso" -o systemrescuecd-x86-"$sysVersion".iso
111    else
112      curl -L -C - "$sysIso" -o systemrescuecd-x86-"$sysVersion".iso
113    fi
114    # Check integrity
115    echo "$sysmd5  systemrescuecd-x86-"$sysVersion".iso" > test.md5sum
116    echo -n "Checking integrity of "
117    md5sum -c test.md5sum 2>/dev/null
118    if [ "$?" -eq 1 ];then
119      echo "Integrity check on systemrescuecd-x86-"$sysVersion".iso failed!!!"
120      echo -n "Do you want to delete this file? ([y]/n): "
121      read ans
122      if [ "$ans" != "y" ];then
123        rm -f systemrescuecd-x86-"$sysVersion".iso 2>/dev/null && echo "File deleted..." || echo "******  Error deleting file!!!  ******
124    Please delete systemrescuecd-x86-"$sysVersion".iso manually"
125      fi
126      rm -f test.md5sum 2>/dev/null
127    fi
128    }
129    
130    function downloadClonezillaLive(){
131    echo "
132    ******  Downloading Clonezilla Live "$clonVersion" "$clonType"  ******"
133    unset curlContinue
134    if [ -e clonezilla-live-"$clonVersion"-"$clonType".iso ];then
135      if [ -n "$md5sumFound" ];then
136        if [ "$clonType" = "amd64" ];then
137          echo "$amd64md5  clonezilla-live-"$clonVersion"-"$clonType".iso">test.md5sum
138        elif [ "$clonType" = "i486" ];then
139          echo "$i486md5  clonezilla-live-"$clonVersion"-"$clonType".iso">test.md5sum
140        else
141          echo "$i686md5  clonezilla-live-"$clonVersion"-"$clonType".iso">test.md5sum
142        fi
143        unset checkmd5
144        echo -n "File found. Checking integrity of "
145        md5sum -c test.md5sum 2>/dev/null && checkmd5=1
146      
147        if [ -z "$checkmd5" ];then
148          # md5 check failed
149          unset checkmd5
150          echo "File clonezilla-live-"$clonVersion"-"$clonType".iso already exists"
151          echo "You can continue downloading the file or restart it"
152          echo -n "Continue downloading? (y/[n]): "
153          read ans
154          if [ "$ans" = "y" ];then
155            curlContinue=1
156          else
157            rm -f test.md5sum 2>/dev/null
158            return
159          fi
160        else
161          # file is ok
162          return
163        fi
164      else
165        # no md5sum
166        echo "File clonezilla-live-"$clonVersion"-"$clonType".iso already exists"
167        echo "You can continue downloading the file or restart it"
168        echo "If you do continue downloading, and since md5sum was not found,"
169        echo "make sure you check the file's integrity manually, after the"
170        echo "download is complete"
171        echo -n "Continue downloading? (y/[n]): "
172        read ans
173        if [ "$ans" = "y" ];then
174          curlContinue=1
175        fi
176      fi
177    fi
178    
179    # Check if we have to go to OldFiles
180    echo "Checking file availability..."
181    oldFiles="$(curl -IL "$clonIso" | grep '301 Moved Permanently')"
182    if [ -n "$oldFiles" ];then
183      # go to stable
184      clonIso="$(echo "$clonIso" | sed 's{OldFiles/{{')"
185      echo "This is Clonezilla Live Stable!!!"
186    else
187      echo "This is an older Clonezilla Live version!!!"
188    fi
189    
190    # Download file
191    if [ -z "$curlContinue" ];then
192      curl -L "$clonIso" -o clonezilla-live-"$clonVersion"-"$clonType".iso
193    else
194      curl -L -C - "$clonIso" -o clonezilla-live-"$clonVersion"-"$clonType".iso
195    fi  
196    
197    if [ -n "$md5sumFound" ];then
198      if [ "$clonType" = "amd64" ];then
199        echo "$amd64md5  clonezilla-live-"$clonVersion"-"$clonType".iso">test.md5sum
200      elif [ "$clonType" = "i486" ];then
201        echo "$i486md5  clonezilla-live-"$clonVersion"-"$clonType".iso">test.md5sum
202      else
203        echo "$i686md5  clonezilla-live-"$clonVersion"-"$clonType".iso">test.md5sum
204      fi
205      unset checkmd5
206      echo -n "Checking integrity of "
207      md5sum -c test.md5sum 2>/dev/null && checkmd5=1
208      rm -f test.md5sum 2>/dev/null
209      if [ -z "$checkmd5" ];then
210        echo "Integrity check on clonezilla-live-"$clonVersion"-"$clonType".iso failed!!!"
211        echo -n "Do you want to delete this file? ([y]/n): "
212        read ans
213        if [ "$ans" != "y" ];then
214          rm -f clonezilla-live-"$clonVersion"-"$clonType".iso 2>/dev/null && echo "File deleted..." || echo "******  Error deleting file!!!  ******
215    Please delete clonezilla-live-"$clonVersion"-"$clonType".iso manually"
216        fi
217      fi
218    fi
219    
220    
221    }
222    
223  function noRoot(){  function noRoot(){
224  echo "    Error: You must be root to execute this script"  echo "    Error: You must be root to execute this script"
225  exit 1  exit 1
# Line 226  Available options are: Line 428  Available options are:
428                instead of $HOME/tmp                instead of $HOME/tmp
429    x [script]  A user defined and written BASH script    x [script]  A user defined and written BASH script
430                to be executed just before mastering the CD                to be executed just before mastering the CD
431      g [arch]    Download ISO files and exit. $(basename $0)
432                  will download the appropriate ISO files in
433                  order to succesfully build Clonezilla-SysRescCD.
434                  [arch] refers to Clonezilla Live architecture
435                  (i686,i486 or amd64 - use all to get them all)
436    v           print version and exit    v           print version and exit
437    h           print this screen and exit    h           print this screen and exit
438    
# Line 328  profilesExist=0 Line 535  profilesExist=0
535  profilesError=0  profilesError=0
536    
537    
538  while getopts ":asp:bfihvn:x:d:" Option  while getopts ":asp:bfihvn:x:d:g:" Option
539  do  do
540   case $Option in   case $Option in
541   a)   a)
542    auto=yes    auto=yes
543          ;;    ;;
544   s)   s)
545    readConfig    readConfig
546    sourceProfiles    sourceProfiles
# Line 364  do Line 571  do
571    if [ $profilesExist -eq 1 ];then    if [ $profilesExist -eq 1 ];then
572     if $(isnumber "$OPTARG");then     if $(isnumber "$OPTARG");then
573      applyProfile $OPTARG      applyProfile $OPTARG
574                  usingProfile=yes      usingProfile=yes
575     else     else
576      echo "    Error in parameter: -p $OPTARG"      echo "    Error in parameter: -p $OPTARG"
577      exit 1      exit 1
# Line 419  do Line 626  do
626      fi      fi
627    fi    fi
628    ;;    ;;
629     g)
630      ARCH="$OPTARG"
631      if [ "$ARCH" != "i486" ]  && [ "$ARCH" != "i686" ]  && [ "$ARCH" != "amd64" ] && [ "$ARCH" != "all" ];then
632        echo "    Error in parameter -g. Should be -g [i668|i486|amd64|all]"
633        exit 1
634      fi
635      ;;
636   esac   esac
637  done  done
638  shift $(($OPTIND - 1))  shift $(($OPTIND - 1))
639    
640  test "$(whoami)" = "root" || noRoot  if [ -z "$ARCH" ];then
641      test "$(whoami)" = "root" || noRoot
642    else
643      evalPrograms
644      downloadIsoFiles $ARCH
645      exit
646    fi
647  # chack auto mode  # chack auto mode
648  if [ -n "$auto" ];then  if [ -n "$auto" ];then
649    if [ -z "$usingProfile" ];then    if [ -z "$usingProfile" ];then
650      echo '  Error: Parameter -a used without -p'      echo '  Error: Parameter -a used without -p'
651                  exit 1      exit 1
652          fi    fi
653    if [ "$onlyBurnISO" -eq 1 ];then    if [ "$onlyBurnISO" -eq 1 ];then
654      echo "  Error: Conflicting parameters -a and -b used"      echo "  Error: Conflicting parameters -a and -b used"
655                  exit 1      exit 1
656          fi    fi
657  fi  fi
658    
659  # Check input parameters  # Check input parameters
# Line 499  Is this correct? (y/[n]): " Line 717  Is this correct? (y/[n]): "
717      if [ -n "$auto" ]; then      if [ -n "$auto" ]; then
718        ans=y        ans=y
719      else      else
720                  clear      clear
721    echo -n "Current CD info:    echo -n "Current CD info:
722       Preparer: $preparerID       Preparer: $preparerID
723       Publisher: $publisher       Publisher: $publisher

Legend:
Removed from v.140  
changed lines
  Added in v.162

webmaster@linux.gr
ViewVC Help
Powered by ViewVC 1.1.26