/[clonezilla-sysresccd]/trunk/create-clonezilla-sysresccd/continue-multi-cd
ViewVC logotype

Contents of /trunk/create-clonezilla-sysresccd/continue-multi-cd

Parent Directory Parent Directory | Revision Log Revision Log


Revision 47 - (show annotations)
Thu May 20 12:12:53 2010 UTC (13 years, 10 months ago) by sng
File size: 5034 byte(s)
adding release scripts

1 #!/bin/bash
2 ###########################################################################
3 # Copyright (C) 2007 by Spiros Georgaras <sng@hellug.gr> #
4 # continue-multi-cd: Continue a multi session CD #
5 # #
6 # This program is free software; you can redistribute it and/or modify #
7 # it under the terms of the GNU General Public License as published by #
8 # the Free Software Foundation; either version 2 of the License, or #
9 # (at your option) any later version. #
10 # #
11 # This program is distributed in the hope that it will be useful, #
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of #
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
14 # GNU General Public License for more details. #
15 # #
16 # You should have received a copy of the GNU General Public License #
17 # along with this program; if not, write to the #
18 # Free Software Foundation, Inc., #
19 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. #
20 ###########################################################################
21 myVers=2.0.0
22
23 function printVersion(){
24 echo "$(basename "$0") - v $myVers - S. Georgaras <sng@hellug.gr>"
25 }
26
27 function usage(){
28 printVersion
29 echo
30 echo "Usage: $(basename "$0") [options] <path to be added to CD>"
31 echo
32 echo "Available options are:
33 d Specify write device (in case auto detection does not work)
34 c Close the CD. No more burning will be possible
35 Default is to leave it open
36 l Don't burn the CD after image creation
37 o <image name> Save the image file as <image name>
38 r Remove the image file after burning
39 f On the fly burning of the CD. No image file will be created
40 v Print version info and exit
41 h Print this screen and exit
42 "
43
44 }
45
46 function findCDRECORD(){
47 [ -z $(which cdrecord 2>/dev/null) ] && {
48 echo "Error: cdrecord not found!!!"
49 exit 1
50 }
51 }
52
53 function findMKISOFS(){
54 [ -z $(which mkisofs 2>/dev/null) ] && {
55 echo "Error: mkisofs not found!!!"
56 exit 1
57 }
58 }
59
60 function longHelp(){
61 echo longHelp
62 }
63
64
65 # while [ ! -z "$1" ];do
66 # case "$1" in
67 # --long-help) longHelp
68 # shift
69 # exit;;
70 # esac
71 # done
72
73 BURN_CD=1
74 REMOVE_IMAGE=0
75 SAVE_MULTI='-multi'
76
77 while getopts fcrd:lo:hv name
78 do
79 case "$name" in
80 f) output_mode=cdwriter;;
81 d) dev="$OPTARG";;
82 r) REMOVE_IMAGE=1;;
83 c) SAVE_MULTI='';;
84 l) BURN_CD=0;;
85 o) img="$OPTARG"
86 ;;
87 h) usage
88 exit;;
89 v) printVersion
90 exit;;
91 *) exit;;
92 esac
93 done
94 shift $(($OPTIND - 1))
95
96
97
98 [ -z "$1" ] && {
99 usage
100 echo "Error: <path to be added to CD> not specified!!!"
101 exit 1
102 }
103 [ ! -d "$1" ]&& {
104 usage
105 echo "Error: <path to be added to CD> is not a directory!!!"
106 exit 1
107 }
108
109 pathToAdd="$1"
110
111 [ -d "$img" ] && {
112 usage
113 echo "Error: <image name> is a directory!!!"
114 exit 1
115 }
116 [ -e "$img" ] && {
117 usage
118 echo "Error: <image name> already exists!!!"
119 exit 1
120 }
121
122 [ ! -w $(dirname "$img") ] && {
123 usage
124 echo "Error: No write permission for <image name>!!!"
125 exit 1
126 }
127
128 [ -z $(echo "$img" | grep "$pathToAdd") ] || {
129 usage
130 echo "Error: <image name> cannot be under <path to be added to CD>!!!"
131 exit 1
132 }
133
134 findMKISOFS
135 if [ $BURN_CD -eq 1 ];then findCDRECORD;fi
136
137
138 if [ -z "$dev" ];then
139 theCD=$(what-cd -wb 2>/dev/null)
140 # theCD=/dev/hda
141 else
142 theCD="$dev"
143 fi
144
145
146 [ -z "$theCD" ] && {
147 echo " Error: Cannot determine your CD writer!!!"
148 exit 1
149 }
150
151
152 [ -z "$(mount |grep "$theCD")" ] || {
153 umount "$theCD" || {
154 echo
155 echo
156 echo " Error: Your CD writer cannot be unmounted!!!"
157 exit 1
158 }
159 }
160
161 cont=$(cdrecord -msinfo dev="$theCD" 2>/dev/null)
162 [ -z "$cont" ] && {
163 echo " Error: The media in $theCD is not a CD/RW!!!"
164 exit 1
165 }
166
167 [ -z "$img" ] && img="/tmp/multi-session-cd-$$.iso"
168
169 mkisofs -r -J -l -f -M "$theCD" -C "$cont" "$pathToAdd" | \
170 {
171 case "$output_mode" in
172 "cdwriter")
173 cdrecord -v "$SAVE_MULTI" driveropts=burnfree -data -eject dev="$theCD" -
174 exit
175 ;;
176 *)
177 # use /dev/stdout as the bridge
178 cat - > "$img" && {
179 # set -x
180 if [ "$BURN_CD" -eq 1 ];then
181 cdrecord -v "$SAVE_MULTI" driveropts=burnfree -data -eject dev="$theCD" "$img" && {
182 if [ "$REMOVE_IMAGE" -eq 0 ];then
183 echo
184 echo
185 echo " The image file has been saved as: $img"
186 else
187 rm -r "$img"
188 fi
189 }
190 else
191 echo
192 echo
193 echo " The image file has been saved as: $img"
194 fi
195 } || {
196 printVersion
197 echo
198 echo " Error: Image file creation failed!!!"
199 exit 1
200 }
201 ;;
202 esac
203 }
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218 # echo "Data to continue: $cont"
219 # echo "img=$img"

Properties

Name Value
svn:executable *

webmaster@linux.gr
ViewVC Help
Powered by ViewVC 1.1.26