#
# dcast: Compression root file system for diskfull nodes
# compression("/tftpboot/boot/")

$stdout.sync = true

def compression(pwd)
  print "Creating root file system"
  pre_size = 0
  cmd = "ls -lk "+ pwd + "root.tgz 2> /dev/null"

  Thread.new {
    while 1
      file = IO.popen(cmd)
      while text = file.gets
        size = text.split[4]
        size = size.to_i / 20000
        if pre_size < size
          $stdout.print "."
          pre_size = size
        end
      end
      sleep 1
    end
  }

  system("cd " + pwd + "; tar cfz root.tgz * 2> /dev/null")
end
