tm-compressed-images-one-1.4.patch
src/tm_mad/tm_common.sh | ||
---|---|---|
145 | 145 |
exit $CMD_CODE |
146 | 146 |
fi |
147 | 147 |
} |
148 | ||
149 |
function download_extract |
|
150 |
{ |
|
151 |
URL=$1 |
|
152 |
ARCHIVE=$2 |
|
153 |
FILENAME=$3 |
|
154 |
HOST=$4 |
|
155 | ||
156 |
if [ "x$HOST" != "x" ]; then |
|
157 |
SSH_CMD="ssh $HOST" |
|
158 |
fi |
|
159 | ||
160 |
$SSH_CMD curl -k -o $ARCHIVE $URL |
|
161 | ||
162 |
extract_tar $ARCHIVE $FILENAME $HOST |
|
163 | ||
164 |
$SSH_CMD rm -rf $ARCHIVE |
|
165 |
} |
|
166 | ||
167 |
function file_ends_with |
|
168 |
{ |
|
169 |
FILE=$1 |
|
170 |
EXTENSION=$2 |
|
171 | ||
172 |
if [ "x$(echo $FILE | grep -E $EXTENSION)" != "x" ]; then |
|
173 |
echo 0 |
|
174 |
else |
|
175 |
echo 1 |
|
176 |
fi |
|
177 |
} |
|
178 | ||
179 |
function extract_tar |
|
180 |
{ |
|
181 |
ARCHIVE=$1 |
|
182 |
OUTPUT=$2 |
|
183 |
HOST=$3 |
|
184 | ||
185 |
if [ $(file_ends_with $ARCHIVE '.tar.gz') = 0 ]; then |
|
186 |
FORMAT=z |
|
187 |
elif [ $(file_ends_with $ARCHIVE '.tar.bz2') = 0 ]; then |
|
188 |
FORMAT=j |
|
189 |
elif [ $(file_ends_with $ARCHIVE '.tar.xz') = 0 ]; then |
|
190 |
FORMAT=J |
|
191 |
fi |
|
192 |
|
|
193 |
TAR_CMD="tar -x${FORMAT}f $ARCHIVE" |
|
194 | ||
195 |
if [ "x$HOST" != "x" ]; then |
|
196 |
SSH_CMD="ssh $HOST" |
|
197 |
fi |
|
198 | ||
199 |
if [ "x$OUTPUT" != "x" ]; then |
|
200 |
if [ "x$HOST" != "x" ]; then |
|
201 |
$SSH_CMD "$TAR_CMD -O > $OUTPUT" |
|
202 |
else |
|
203 |
$TAR_CMD -O > $OUTPUT |
|
204 |
fi |
|
205 |
else |
|
206 |
$SSH_CMD $TAR_CMD |
|
207 |
fi |
|
208 |
} |
|
209 |
src/tm_mad/nfs/tm_clone.sh | ||
---|---|---|
44 | 44 |
exec_and_log "chmod a+w $DST_DIR" |
45 | 45 | |
46 | 46 |
case $SRC in |
47 |
http://*) |
|
47 |
http*.tar.gz|http*.tgz) |
|
48 |
log "Downloading tar.gz archive $SRC" |
|
49 |
exec_and_log "download_extract $SRC $DST_PATH.tar.gz $DST_PATH" |
|
50 |
;; |
|
51 | ||
52 |
http*.bz2) |
|
53 |
log "Downloading tar.bz2 archive $SRC" |
|
54 |
exec_and_log "download_extract $SRC $DST_PATH.tar.bz2 $DST_PATH" |
|
55 |
;; |
|
56 | ||
57 |
http*.xz) |
|
58 |
log "Downloading tar.xz archive $SRC" |
|
59 |
exec_and_log "download_extract $SRC $DST_PATH.tar.xz $DST_PATH" |
|
60 |
;; |
|
61 | ||
62 |
http*) |
|
48 | 63 |
log "Downloading $SRC" |
49 |
exec_and_log "wget -O $DST_PATH $SRC"
|
|
64 |
exec_and_log "curl -k -o $DST_PATH $SRC"
|
|
50 | 65 |
;; |
51 | 66 | |
52 | 67 |
*) |
src/tm_mad/ssh/tm_clone.sh | ||
---|---|---|
43 | 43 |
exec_and_log "ssh $DST_HOST mkdir -p $DST_DIR" |
44 | 44 | |
45 | 45 |
case $SRC in |
46 |
http://*) |
|
46 |
http*.tar.gz|http*.tgz) |
|
47 |
log "Downloading tar.gz archive $SRC" |
|
48 |
exec_and_log "download_extract $SRC $DST_PATH.tar.gz $DST_PATH $DST_HOST" |
|
49 |
;; |
|
50 | ||
51 |
http*.bz2) |
|
52 |
log "Downloading tar.bz2 archive $SRC"/srv/cloud/one/lib/tm_commands/ssh/tm_clone.sh |
|
53 |
exec_and_log "download_extract $SRC $DST_PATH.tar.bz2 $DST_PATH $DST_HOST" |
|
54 |
;; |
|
55 | ||
56 |
http*.xz) |
|
57 |
log "Downloading tar.xz archive $SRC" |
|
58 |
exec_and_log "download_extract $SRC $DST_PATH.tar.xz $DST_PATH $DST_HOST" |
|
59 |
;; |
|
60 | ||
61 |
http*) |
|
47 | 62 |
log "Downloading $SRC" |
48 |
exec_and_log "ssh $DST_HOST wget -O $DST_PATH $SRC"
|
|
63 |
exec_and_log "ssh $DST_HOST curl -k -o $DST_PATH $SRC"
|
|
49 | 64 |
;; |
50 | 65 | |
51 | 66 |
*) |