1 |
############################################################################## |
############################################################################## |
2 |
# # |
# # |
3 |
# create-clonezilla-sysresccd, (C) 2007-2010 S. Georgaras <sng@hellug.gr> # |
# create-clonezilla-sysresccd, (C) 2007-2011 S. Georgaras <sng@hellug.gr> # |
4 |
# # |
# # |
5 |
# This file is part of Clonezilla-SysRescCD. # |
# This file is part of Clonezilla-SysRescCD. # |
6 |
# # |
# # |
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 |
|
if [ -n "$md5sumFound" ];then |
116 |
|
echo "$sysmd5 systemrescuecd-x86-"$sysVersion".iso" > test.md5sum |
117 |
|
echo -n "Checking integrity of " |
118 |
|
md5sum -c test.md5sum 2>/dev/null |
119 |
|
if [ "$?" -eq 1 ];then |
120 |
|
echo "Integrity check on systemrescuecd-x86-"$sysVersion".iso failed!!!" |
121 |
|
echo -n "Do you want to delete this file? ([y]/n): " |
122 |
|
read ans |
123 |
|
if [ "$ans" != "n" ];then |
124 |
|
rm -f systemrescuecd-x86-"$sysVersion".iso 2>/dev/null && echo "File deleted..." || echo "****** Error deleting file!!! ****** |
125 |
|
Please delete systemrescuecd-x86-"$sysVersion".iso manually" |
126 |
|
fi |
127 |
|
fi |
128 |
|
rm -f test.md5sum 2>/dev/null |
129 |
|
fi |
130 |
|
} |
131 |
|
|
132 |
|
function downloadClonezillaLive(){ |
133 |
|
echo " |
134 |
|
****** Downloading Clonezilla Live "$clonVersion" "$clonType" ******" |
135 |
|
unset curlContinue |
136 |
|
if [ -e clonezilla-live-"$clonVersion"-"$clonType".iso ];then |
137 |
|
if [ -n "$md5sumFound" ];then |
138 |
|
if [ "$clonType" = "amd64" ];then |
139 |
|
echo "$amd64md5 clonezilla-live-"$clonVersion"-"$clonType".iso">test.md5sum |
140 |
|
elif [ "$clonType" = "i486" ];then |
141 |
|
echo "$i486md5 clonezilla-live-"$clonVersion"-"$clonType".iso">test.md5sum |
142 |
|
else |
143 |
|
echo "$i686md5 clonezilla-live-"$clonVersion"-"$clonType".iso">test.md5sum |
144 |
|
fi |
145 |
|
unset checkmd5 |
146 |
|
echo -n "File found. Checking integrity of " |
147 |
|
md5sum -c test.md5sum 2>/dev/null && checkmd5=1 |
148 |
|
|
149 |
|
if [ -z "$checkmd5" ];then |
150 |
|
# md5 check failed |
151 |
|
unset checkmd5 |
152 |
|
echo "File clonezilla-live-"$clonVersion"-"$clonType".iso already exists" |
153 |
|
echo "You can continue downloading the file or restart it" |
154 |
|
echo -n "Continue downloading? (y/[n]): " |
155 |
|
read ans |
156 |
|
if [ "$ans" = "y" ];then |
157 |
|
curlContinue=1 |
158 |
|
else |
159 |
|
rm -f test.md5sum 2>/dev/null |
160 |
|
return |
161 |
|
fi |
162 |
|
else |
163 |
|
# file is ok |
164 |
|
return |
165 |
|
fi |
166 |
|
else |
167 |
|
# no md5sum |
168 |
|
echo "File clonezilla-live-"$clonVersion"-"$clonType".iso already exists" |
169 |
|
echo "You can continue downloading the file or restart it" |
170 |
|
echo "If you do continue downloading, and since md5sum was not found," |
171 |
|
echo "make sure you check the file's integrity manually, after the" |
172 |
|
echo "download is complete" |
173 |
|
echo -n "Continue downloading? (y/[n]): " |
174 |
|
read ans |
175 |
|
if [ "$ans" = "y" ];then |
176 |
|
curlContinue=1 |
177 |
|
fi |
178 |
|
fi |
179 |
|
fi |
180 |
|
|
181 |
|
# Check if we have to go to OldFiles |
182 |
|
echo "Checking file availability..." |
183 |
|
oldFiles="$(curl -IL "$clonIso" | grep '301 Moved Permanently')" |
184 |
|
if [ -n "$oldFiles" ];then |
185 |
|
# go to stable |
186 |
|
clonIso="$(echo "$clonIso" | sed 's{OldFiles/{{')" |
187 |
|
echo "This is Clonezilla Live Stable!!!" |
188 |
|
else |
189 |
|
echo "This is an older Clonezilla Live version!!!" |
190 |
|
fi |
191 |
|
|
192 |
|
# Download file |
193 |
|
if [ -z "$curlContinue" ];then |
194 |
|
curl -L "$clonIso" -o clonezilla-live-"$clonVersion"-"$clonType".iso |
195 |
|
else |
196 |
|
curl -L -C - "$clonIso" -o clonezilla-live-"$clonVersion"-"$clonType".iso |
197 |
|
fi |
198 |
|
|
199 |
|
if [ -n "$md5sumFound" ];then |
200 |
|
if [ "$clonType" = "amd64" ];then |
201 |
|
echo "$amd64md5 clonezilla-live-"$clonVersion"-"$clonType".iso">test.md5sum |
202 |
|
elif [ "$clonType" = "i486" ];then |
203 |
|
echo "$i486md5 clonezilla-live-"$clonVersion"-"$clonType".iso">test.md5sum |
204 |
|
else |
205 |
|
echo "$i686md5 clonezilla-live-"$clonVersion"-"$clonType".iso">test.md5sum |
206 |
|
fi |
207 |
|
unset checkmd5 |
208 |
|
echo -n "Checking integrity of " |
209 |
|
md5sum -c test.md5sum 2>/dev/null && checkmd5=1 |
210 |
|
rm -f test.md5sum 2>/dev/null |
211 |
|
if [ -z "$checkmd5" ];then |
212 |
|
echo "Integrity check on clonezilla-live-"$clonVersion"-"$clonType".iso failed!!!" |
213 |
|
echo -n "Do you want to delete this file? ([y]/n): " |
214 |
|
read ans |
215 |
|
if [ "$ans" != "n" ];then |
216 |
|
rm -f clonezilla-live-"$clonVersion"-"$clonType".iso 2>/dev/null && echo "File deleted..." || echo "****** Error deleting file!!! ****** |
217 |
|
Please delete clonezilla-live-"$clonVersion"-"$clonType".iso manually" |
218 |
|
fi |
219 |
|
fi |
220 |
|
fi |
221 |
|
|
222 |
|
|
223 |
|
} |
224 |
|
|
225 |
function noRoot(){ |
function noRoot(){ |
226 |
echo " Error: You must be root to execute this script" |
echo " Error: You must be root to execute this script" |
227 |
exit 1 |
exit 1 |
430 |
instead of $HOME/tmp |
instead of $HOME/tmp |
431 |
x [script] A user defined and written BASH script |
x [script] A user defined and written BASH script |
432 |
to be executed just before mastering the CD |
to be executed just before mastering the CD |
433 |
|
g [arch] Download ISO files and exit. $(basename $0) |
434 |
|
will download the appropriate ISO files in |
435 |
|
order to succesfully build Clonezilla-SysRescCD. |
436 |
|
[arch] refers to Clonezilla Live architecture |
437 |
|
(i686,i486 or amd64 - use all to get them all) |
438 |
v print version and exit |
v print version and exit |
439 |
h print this screen and exit |
h print this screen and exit |
440 |
|
|
537 |
profilesError=0 |
profilesError=0 |
538 |
|
|
539 |
|
|
540 |
while getopts ":asp:bfihvn:x:d:" Option |
while getopts ":asp:bfihvn:x:d:g:" Option |
541 |
do |
do |
542 |
case $Option in |
case $Option in |
543 |
a) |
a) |
544 |
auto=yes |
auto=yes |
545 |
;; |
;; |
546 |
s) |
s) |
547 |
readConfig |
readConfig |
548 |
sourceProfiles |
sourceProfiles |
573 |
if [ $profilesExist -eq 1 ];then |
if [ $profilesExist -eq 1 ];then |
574 |
if $(isnumber "$OPTARG");then |
if $(isnumber "$OPTARG");then |
575 |
applyProfile $OPTARG |
applyProfile $OPTARG |
576 |
usingProfile=yes |
usingProfile=yes |
577 |
else |
else |
578 |
echo " Error in parameter: -p $OPTARG" |
echo " Error in parameter: -p $OPTARG" |
579 |
exit 1 |
exit 1 |
628 |
fi |
fi |
629 |
fi |
fi |
630 |
;; |
;; |
631 |
|
g) |
632 |
|
ARCH="$OPTARG" |
633 |
|
if [ "$ARCH" != "i486" ] && [ "$ARCH" != "i686" ] && [ "$ARCH" != "amd64" ] && [ "$ARCH" != "all" ];then |
634 |
|
echo " Error in parameter -g. Should be -g [i668|i486|amd64|all]" |
635 |
|
exit 1 |
636 |
|
fi |
637 |
|
;; |
638 |
esac |
esac |
639 |
done |
done |
640 |
shift $(($OPTIND - 1)) |
shift $(($OPTIND - 1)) |
641 |
|
|
642 |
test "$(whoami)" = "root" || noRoot |
if [ -z "$ARCH" ];then |
643 |
|
test "$(whoami)" = "root" || noRoot |
644 |
|
else |
645 |
|
evalPrograms |
646 |
|
downloadIsoFiles $ARCH |
647 |
|
exit |
648 |
|
fi |
649 |
# chack auto mode |
# chack auto mode |
650 |
if [ -n "$auto" ];then |
if [ -n "$auto" ];then |
651 |
if [ -z "$usingProfile" ];then |
if [ -z "$usingProfile" ];then |
652 |
echo ' Error: Parameter -a used without -p' |
echo ' Error: Parameter -a used without -p' |
653 |
exit 1 |
exit 1 |
654 |
fi |
fi |
655 |
if [ "$onlyBurnISO" -eq 1 ];then |
if [ "$onlyBurnISO" -eq 1 ];then |
656 |
echo " Error: Conflicting parameters -a and -b used" |
echo " Error: Conflicting parameters -a and -b used" |
657 |
exit 1 |
exit 1 |
658 |
fi |
fi |
659 |
fi |
fi |
660 |
|
|
661 |
# Check input parameters |
# Check input parameters |
719 |
if [ -n "$auto" ]; then |
if [ -n "$auto" ]; then |
720 |
ans=y |
ans=y |
721 |
else |
else |
722 |
clear |
clear |
723 |
echo -n "Current CD info: |
echo -n "Current CD info: |
724 |
Preparer: $preparerID |
Preparer: $preparerID |
725 |
Publisher: $publisher |
Publisher: $publisher |