tm_mkimage.sh

Marco Gomes, 21 Mar 2012 12:36

Download (1.66 KB)

 
1
#!/bin/bash
2

    
3
# -------------------------------------------------------------------------- #
4
# Copyright 2002-2011, 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
if [ -z "${ONE_LOCATION}" ]; then
20
    TMCOMMON=/usr/lib/one/mads/tm_common.sh
21
else
22
    TMCOMMON=$ONE_LOCATION/lib/mads/tm_common.sh
23
fi
24

    
25
. $TMCOMMON
26

    
27
SIZE=$1
28
FSTYPE=$2
29
DST=$3
30

    
31
DST_PATH=`arg_path $DST`
32
DST_HOST=`arg_host $DST`
33
DST_DIR=`dirname $DST_PATH`
34

    
35
exec_and_log "$SSH $DST_HOST mkdir -p $DST_DIR"
36
exec_and_log "$SSH $DST_HOST $DD if=/dev/zero of=$DST_PATH bs=1 count=1 seek=${SIZE}M"
37
exec_and_log "$SSH $DST_HOST $MKFS -t $FSTYPE -F $DST_PATH"
38
exec_and_log "$SSH $DST_HOST chmod a+rw $DST_PATH"