diff --git a/share/install_gems/install_gems b/share/install_gems/install_gems index 9b1da6f65d..d0dd30ac98 100755 --- a/share/install_gems/install_gems +++ b/share/install_gems/install_gems @@ -90,6 +90,62 @@ class String end end +def good_gem_version? + v=`gem --version`.strip + version=Gem::Version.new(v) + version>=Gem::Version.new('1.3.6') +end + +def install_rubygems + if !good_gem_version? + puts(<<-EOT.unindent()) + The rubygems version installed is too old to install some required + libraries. We are about to update your rubygems version. If you + want to do this by other means cancel this installation with + CTRL+C now. + + Press ENTER to continue... + +EOT + + STDIN.readline + + `gem install rubygems-update --version '= 1.3.6'` + + if $?.ecxitstatus!=0 + puts "Error updating rubygems" + exit(-1) + end + + update_rubygems_path=[ + '/usr/bin/update_rubygems', + '/var/lib/gems/1.8/bin/update_rubygems', + '/var/lib/gems/1.9/bin/update_rubygems' + ] + + installed=false + + update_rubygems_path.each do |path| + if File.exist?(path) + `#{path}` + + if $?.exitstatus!=0 + puts "Error executing update_rubygems" + exit(-1) + end + + installed=true + break + end + end + + if !installed + puts "Could not find update_rubygems executable" + exit(-1) + end + end +end + def installed_gems text=`gem list --no-versions --no-details` if $?.exitstatus!=0 @@ -331,6 +387,7 @@ try_library :mkmf, <<-EOT.unindent * Install the ruby development package for your distro EOT +install_rubygems command='' params=ARGV diff --git a/src/im_mad/remotes/kvm.d/kvm.rb b/src/im_mad/remotes/kvm.d/kvm.rb index 9fd51c7eb6..9e717c2cd1 100755 --- a/src/im_mad/remotes/kvm.d/kvm.rb +++ b/src/im_mad/remotes/kvm.d/kvm.rb @@ -51,9 +51,9 @@ exit(-1) if $?.exitstatus != 0 top_text.gsub!(/^top.*^top.*?$/m, "") # Strip first top output top_text.split(/\n/).each{|line| - if line.match('^Cpu') + if line.match('^%?Cpu') line[7..-1].split(",").each{|elemento| - temp = elemento.strip.split("%") + temp = elemento.strip.split(/[% ]/) if temp[1]=="id" idle = temp[0] $free_cpu = idle.to_f * $total_cpu.to_f / 100 diff --git a/src/image_mad/remotes/fs/mkfs b/src/image_mad/remotes/fs/mkfs index d4e8c61157..344e669335 100755 --- a/src/image_mad/remotes/fs/mkfs +++ b/src/image_mad/remotes/fs/mkfs @@ -21,7 +21,7 @@ # as (FS) ############################################################################### -# ------------ Set up the environment to source common tools ------------ +# ------------ Set up the environment to source common tools ------------ if [ -z "${ONE_LOCATION}" ]; then LIB_LOCATION=/usr/lib/one @@ -32,37 +32,20 @@ fi . $LIB_LOCATION/sh/scripts_common.sh source $(dirname $0)/fsrc -# ------------ Create the image to the repository ------------ +# ------------ Create the image to the repository ------------ FSTYPE=$1 SIZE=$2 ID=$3 -# Specific options for different FS -case "$FSTYPE" in - "ext2"|"ext3"|"ext4"|"ntfs") - OPTS="-F" - ;; - - "reiserfs") - OPTS="-f -q" - ;; - - "jfs") - OPTS="-q" - ;; - *) - OPTS="" - ;; -esac - DST=`generate_image_path` +MKFS_CMD=`mkfs_command $DST $FSTYPE` + exec_and_log "$DD if=/dev/zero of=$DST bs=1 count=1 seek=${SIZE}M" \ "Could not create image $DST" -exec_and_log "$MKFS -t $FSTYPE $OPTS $DST" \ +exec_and_log "$MKFS_CMD" \ "Unable to create filesystem $FSTYPE in $DST" - exec_and_log "chmod 0660 $DST" # ---------------- Get the size of the image ------------ diff --git a/src/mad/sh/scripts_common.sh b/src/mad/sh/scripts_common.sh index 5730e0b99c..0153c6bff6 100755 --- a/src/mad/sh/scripts_common.sh +++ b/src/mad/sh/scripts_common.sh @@ -148,3 +148,30 @@ function timeout_exec_and_log exit $CMD_CODE fi } + +# This function will return a command that upon execution will format a +# filesystem with its proper parameters based on the filesystem type +function mkfs_command { + DST=$1 + FSTYPE=${2:-ext3} + + # Specific options for different FS + case "$FSTYPE" in + "ext2"|"ext3"|"ext4"|"ntfs") + OPTS="-F" + ;; + + "reiserfs") + OPTS="-f -q" + ;; + + "jfs") + OPTS="-q" + ;; + *) + OPTS="" + ;; + esac + + echo "$MKFS -t $FSTYPE $OPTS $DST" +} diff --git a/src/tm_mad/lvm/tm_mkimage.sh b/src/tm_mad/lvm/tm_mkimage.sh index d092a8b9b2..1410eae120 100755 --- a/src/tm_mad/lvm/tm_mkimage.sh +++ b/src/tm_mad/lvm/tm_mkimage.sh @@ -32,7 +32,9 @@ DST_PATH=`arg_path $DST` DST_HOST=`arg_host $DST` DST_DIR=`dirname $DST_PATH` +MKFS_CMD=`mkfs_command $DST_PATH $FSTYPE` + exec_and_log "$SSH $DST_HOST mkdir -p $DST_DIR" exec_and_log "$SSH $DST_HOST $DD if=/dev/zero of=$DST_PATH bs=1 count=1 seek=${SIZE}M" -exec_and_log "$SSH $DST_HOST $MKFS -t $FSTYPE -F $DST_PATH" +exec_and_log "$SSH $DST_HOST $MKFS_CMD" exec_and_log "$SSH $DST_HOST chmod a+rw $DST_PATH" diff --git a/src/tm_mad/shared/tm_mkimage.sh b/src/tm_mad/shared/tm_mkimage.sh index b30c0ff327..97985c0368 100755 --- a/src/tm_mad/shared/tm_mkimage.sh +++ b/src/tm_mad/shared/tm_mkimage.sh @@ -36,11 +36,13 @@ fix_dst_path DST_DIR=`dirname $DST_PATH` +MKFS_CMD=`mkfs_command $DST_PATH $FSTYPE` + exec_and_log "mkdir -p $DST_DIR" \ "Error creating directory $DST_DIR" exec_and_log "$DD if=/dev/zero of=$DST_PATH bs=1 count=1 seek=${SIZE}M" \ "Could not create image $DST_PATH" -exec_and_log "$MKFS -t $FSTYPE -F $DST_PATH" \ +exec_and_log "$MKFS_CMD" \ "Unable to create filesystem $FSTYPE in $DST_PATH" exec_and_log "chmod a+rw $DST_PATH" diff --git a/src/tm_mad/ssh/tm_mkimage.sh b/src/tm_mad/ssh/tm_mkimage.sh index 81ff20f32c..dec17c3d1e 100755 --- a/src/tm_mad/ssh/tm_mkimage.sh +++ b/src/tm_mad/ssh/tm_mkimage.sh @@ -32,10 +32,12 @@ DST_PATH=`arg_path $DST` DST_HOST=`arg_host $DST` DST_DIR=`dirname $DST_PATH` +MKFS_CMD=`mkfs_command $DST_PATH $FSTYPE` + exec_and_log "$SSH $DST_HOST mkdir -p $DST_DIR" \ "Error creating directory $DST_DIR" exec_and_log "$SSH $DST_HOST $DD if=/dev/zero of=$DST_PATH bs=1 count=1 seek=${SIZE}M" \ "Could not create image $DST_PATH" -exec_and_log "$SSH $DST_HOST $MKFS -t $FSTYPE -F $DST_PATH" \ +exec_and_log "$SSH $DST_HOST $MKFS_CMD" \ "Unable to create filesystem $FSTYPE in $DST_PATH" -exec_and_log "$SSH $DST_HOST chmod a+rw $DST_PATH" \ No newline at end of file +exec_and_log "$SSH $DST_HOST chmod a+rw $DST_PATH" diff --git a/src/tm_mad/vmware/tm_ln.sh b/src/tm_mad/vmware/tm_ln.sh index 87dd227bb0..805e7de61c 100755 --- a/src/tm_mad/vmware/tm_ln.sh +++ b/src/tm_mad/vmware/tm_ln.sh @@ -52,3 +52,4 @@ done #Mark this disk persistent with a symlink for tm_mv and repo mv exec_and_log "ln -sf ${REL_SRC_PATH#../../} $DST_PATH/.disk" + diff --git a/src/tm_mad/vmware/tm_mv.sh b/src/tm_mad/vmware/tm_mv.sh index f52499cd3e..990abfca40 100755 --- a/src/tm_mad/vmware/tm_mv.sh +++ b/src/tm_mad/vmware/tm_mv.sh @@ -43,9 +43,9 @@ SRC_PATH=`fix_dir_slashes "$SRC_PATH"` if [ "$SRC_PATH" = "$DST_PATH" ]; then log "Will not move, source and destination are equal" elif [ -L "$SRC_PATH/.disk" ]; then - exec_and_log "mv $SRC_PATH/.disk $DST_PATH" + exec_and_log "mv $SRC_PATH/.disk $DST_PATH" elif [ "`is_disk $SRC_PATH`" = "0" ] ; then - log "Moving $SRC_PATH" + log "Moving $SRC_PATH"    exec_and_log "mv $SRC_PATH $DST_PATH" elif [ -d $SRC_PATH ]; then log "Will not move, it is not saving a VM disk image"