#
# $Id$
+# Because we're running from a start-up script, we don't have much
+# of a login environment, so set one up.
export PATH=/usr/sbin:/sbin:/usr/local/bin:/usr/kerberos/bin:/usr/bin:/bin
+export HOME=/root
+export LOGNAME=root
# The defaults here make a generic virt-p2v.sh script, but if you want
# to build a partially-/fully-automatic P2V solution, then you can set
# Use the function read_line instead of the shell built-in read.
# It reads from the console.
function read_line {
- read "$*" </dev/console
+ read "$*"
}
# Launch a bash subshell connected to the console.
function shell {
- PS1='\u@\h:\w\$ ' bash </dev/console >/dev/console 2>&1
+ PS1='\u@\h:\w\$ ' bash
}
#----------------------------------------------------------------------
echo "(Hint: if not sure, there is a shell on console [ALT] [F2])"
echo -n " (y/n) "
local line
- read_line line </dev/console
+ read_line line
if [ "$line" = "y" -o "$line" = "yes" ]; then return 0; fi
return 1
fi
#----------------------------------------------------------------------
# General script setup.
+log
+log virt-p2v starting up at `date`
+
+# The first and only parameter must be the tty. Connect
+# stdin/stdout/stderr to this device.
+if [ -n "$1" ]; then
+ log connecting to /dev/$1
+ exec </dev/$1 &>/dev/$1
+fi
+
# We can safely write files into /tmp without modifying anything.
cd /tmp
#----------------------------------------------------------------------
# Dialog with the user.
-log
-log virt-p2v starting up at `date`
-
if [ "$greeting" != "no" ]; then
dialog \
--title "virt-p2v" \
;;
tcp)
echo "p2v $name $sectors" > header
- cat header - | nc "$remote_host" "$remote_port"
+ echo > newline
+ cat header - newline | nc "$remote_host" "$remote_port"
;;
esac
done