diff --git a/install.sh b/install.sh index e93a4b8451..6a29ffb5aa 100755 --- a/install.sh +++ b/install.sh @@ -30,7 +30,7 @@ if [ -z "$SRC_DIR" -o -z "$DST_DIR" ]; then exit -1 fi -DIRS="/bin /include /etc /etc/im_kvm /etc/im_xen /etc/vmm_kvm /etc/vmm_xen /libexec /lib/ruby /var /share/examples /lib/im_probes /lib/tm_commands/nfs /lib/tm_commands/ssh /lib/tm_commands/dummy /etc/vmm_ec2 /etc/im_ec2 /etc/tm_nfs /etc/tm_ssh" +DIRS="/bin /include /etc /etc/im_kvm /etc/im_xen /etc/vmm_kvm /etc/vmm_xen /libexec /lib/ruby /var /share/examples /share/examples/tm /lib/im_probes /lib/tm_commands/nfs /lib/tm_commands/ssh /lib/tm_commands/dummy /etc/vmm_ec2 /etc/im_ec2 /etc/tm_nfs /etc/tm_ssh" for d in $DIRS; do mkdir -p $DST_DIR$d @@ -153,8 +153,14 @@ inst_ln src/tm_mad/dummy/tm_dummy.sh lib/tm_commands/dummy # --- Examples --- -inst_cp share/examples/vm.template share/examples -inst_cp share/examples/vm.schema share/examples -inst_cp share/examples/private.net share/examples -inst_cp share/examples/public.net share/examples +inst_cp share/examples/vm.template share/examples +inst_cp share/examples/vm.schema share/examples +inst_cp share/examples/private.net share/examples +inst_cp share/examples/public.net share/examples +inst_cp share/examples/tmp/tm_clone.sh share/examples/tm +inst_cp share/examples/tmp/tm_delete.sh share/examples/tm +inst_cp share/examples/tmp/tm_ln.sh share/examples/tm +inst_cp share/examples/tmp/tm_mkimage.sh share/examples/tm +inst_cp share/examples/tmp/tm_mkswap.sh share/examples/tm +inst_cp share/examples/tmp/tm_mv.sh share/examples/tm diff --git a/share/examples/tm/tm_clone.sh b/share/examples/tm/tm_clone.sh new file mode 100755 index 0000000000..ff045eadde --- /dev/null +++ b/share/examples/tm/tm_clone.sh @@ -0,0 +1,34 @@ +#!/bin/bash + +SRC=$1 +DST=$2 + +. $ONE_LOCATION/libexec/tm_common.sh + +SRC_PATH=`arg_path $SRC` +DST_PATH=`arg_path $DST` +DST_HOST=`arg_host $DST` + +log "$1 $2" +log "DST: $DST_PATH" + +DST_DIR=`dirname $DST_PATH` + +log "Creating directory $DST_DIR" +exec_and_log "ssh $DST_HOST mkdir -p $DST_DIR" +exec_and_log "ssh $DST_HOST chmod a+w $DST_DIR" + +case $SRC in +http://*) + log "Downloading $SRC" + exec_and_log "ssh $DST_HOST wget -O $DST_PATH $SRC" + ;; + +*) + log "Cloning $SRC_PATH" + exec_and_log "ssh $DST_HOST cp $SRC_PATH $DST_PATH" + ;; +esac + +exec_and_log "ssh $DST_HOST chmod a+w $DST_PATH" + diff --git a/share/examples/tm/tm_delete.sh b/share/examples/tm/tm_delete.sh new file mode 100755 index 0000000000..801a64321c --- /dev/null +++ b/share/examples/tm/tm_delete.sh @@ -0,0 +1,12 @@ +#!/bin/bash + +SRC=$1 +DST=$2 + +. $ONE_LOCATION/libexec/tm_common.sh + +SRC_PATH=`arg_path $SRC` +SRC_HOST=`arg_host $SRC` + +log "Deleting $SRC_PATH" +exec_and_log "ssh $SRC_HOST rm -rf $SRC_PATH" diff --git a/share/examples/tm/tm_ln.sh b/share/examples/tm/tm_ln.sh new file mode 100755 index 0000000000..acbac67cb2 --- /dev/null +++ b/share/examples/tm/tm_ln.sh @@ -0,0 +1,19 @@ +#!/bin/bash + +SRC=$1 +DST=$2 + +. $ONE_LOCATION/libexec/tm_common.sh + +SRC_PATH=`arg_path $SRC` +DST_PATH=`arg_path $DST` +DST_HOST=`arg_host $DST` + +DST_DIR=`dirname $DST_PATH` + +log "Creating directory $DST_DIR" +exec_and_log "ssh $DST_HOST mkdir -p $DST_DIR" + + +log "Link $SRC_PATH" +exec_and_log "ssh $DST_HOST ln -s $SRC_PATH $DST_PATH" diff --git a/share/examples/tm/tm_mkimage.sh b/share/examples/tm/tm_mkimage.sh new file mode 100755 index 0000000000..5721dd00d5 --- /dev/null +++ b/share/examples/tm/tm_mkimage.sh @@ -0,0 +1,5 @@ +#!/bin/bash + +. $ONE_LOCATION/libexec/tm_common.sh + +log "mkimage placeholder" diff --git a/share/examples/tm/tm_mkswap.sh b/share/examples/tm/tm_mkswap.sh new file mode 100755 index 0000000000..335949d8cd --- /dev/null +++ b/share/examples/tm/tm_mkswap.sh @@ -0,0 +1,18 @@ +#!/bin/bash + +SIZE=$1 +DST=$2 + +. $ONE_LOCATION/libexec/tm_common.sh + +DST_PATH=`arg_path $DST` +DST_HOST=`arg_host $DST` + +log "Creating ${SIZE}Mb image in $DST_PATH" +exec_and_log "ssh $DST_HOST dd if=/dev/zero of=$DST_PATH bs=1 count=1 seek=${SIZE}M" + +log "Initializing swap space" +exec_and_log "ssh $DST_HOST mkswap $DST_PATH" + +exec_and_log "ssh $DST_HOST chmod a+w $DST_PATH" + diff --git a/share/examples/tm/tm_mv.sh b/share/examples/tm/tm_mv.sh new file mode 100755 index 0000000000..0094daafa7 --- /dev/null +++ b/share/examples/tm/tm_mv.sh @@ -0,0 +1,24 @@ +#!/bin/bash + +SRC=$1 +DST=$2 + +. $ONE_LOCATION/libexec/tm_common.sh + +SRC_PATH=`arg_path $SRC` +DST_PATH=`arg_path $DST` +DST_HOST=`arg_host $DST` + +if [ "$SRC_PATH" == "$DST_PATH" ]; then + log "Will not move, source and destination are equal" +else + # Is saving a disk image? + echo "$DST_PATH" | egrep -e "^$ONE_LOCATION/var/.+/disk\..+$" + if [ "x$?" == "x0" ]; then + log "Moving $SRC_PATH" + exec_and_log "ssh $DST_HOST mv $SRC_PATH $DST_PATH" + else + log "Will not move, is not saving image" + fi +fi +