tm_context.sh

my fix - Gian Uberto Lauri, 02/14/2011 07:35 PM

Download (1.83 KB)

 
1
#!/bin/bash
2

    
3
# -------------------------------------------------------------------------- #
4
# Copyright 2002-2010, OpenNebula Project Leads (OpenNebula.org)             #
5
#                                                                            #
6
# Licensed under the Apache License, Version 2.0 (the "License"); you may    #
7
# not use this file except in compliance with the License. You may obtain    #
8
# a copy of the License at                                                   #
9
#                                                                            #
10
# http://www.apache.org/licenses/LICENSE-2.0                                 #
11
#                                                                            #
12
# Unless required by applicable law or agreed to in writing, software        #
13
# distributed under the License is distributed on an "AS IS" BASIS,          #
14
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.   #
15
# See the License for the specific language governing permissions and        #
16
# limitations under the License.                                             #
17
#--------------------------------------------------------------------------- #
18

    
19
while (( "$#" )); do
20
    if [ "$#" == "1" ]; then
21
        DST=$1
22
    else
23
        SRC="$SRC $1"
24
    fi
25
    shift
26
done
27

    
28

    
29
if [ -z "${ONE_LOCATION}" ]; then
30
    TMCOMMON=/usr/lib/one/mads/tm_common.sh
31
else
32
    TMCOMMON=$ONE_LOCATION/lib/mads/tm_common.sh
33
fi
34

    
35
. $TMCOMMON
36

    
37
get_vmdir
38

    
39
DST_PATH=`arg_path $DST`
40

    
41
#fix_dst_path
42

    
43
DST_DIR=`dirname $DST_PATH`
44
ISO_DIR=$DST_DIR/isofiles
45

    
46
exec_and_log "mkdir -p $ISO_DIR"
47

    
48
for f in $SRC; do
49
    case $f in
50
    http://*)
51
        exec_and_log "$WGET -O $ISO_DIR $f"
52
        ;;
53

    
54
    *)
55
        exec_and_log "cp -R $f $ISO_DIR"
56
        ;;
57
    esac
58
done
59

    
60
exec_and_log "$MKISOFS -o $DST_PATH -J -R $ISO_DIR"
61

    
62
exec_and_log "rm -rf $ISO_DIR"
63

    
64