Skip to content

Commit

Permalink
Move vm network setup into build-vm
Browse files Browse the repository at this point in the history
  • Loading branch information
mlschroe committed Sep 19, 2016
1 parent ff206ef commit 619d2aa
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 38 deletions.
39 changes: 1 addition & 38 deletions build
Original file line number Diff line number Diff line change
Expand Up @@ -1278,44 +1278,7 @@ for RECIPEFILE in "${RECIPEFILES[@]}" ; do
mount -n -ttmpfs none $BUILD_ROOT/dev/shm 2> /dev/null

if test -n "$RUNNING_IN_VM" ; then
if test -x /sbin/ip ; then
ip addr add 127.0.0.1/8 dev lo
ip addr add ::1/128 dev lo
ip link set lo up
else
ifconfig lo 127.0.0.1 up
ifconfig lo add ::1/128
fi
if test -n "$VM_TELNET"; then
VM_TELNET_DEVICE=$( cd /sys/class/net/; echo * )
VM_TELNET_DEVICE=${VM_TELNET_DEVICE#lo }
VM_TELNET_DEVICE=${VM_TELNET_DEVICE%% *}
if test -z "$VM_TELNET_DEVICE"; then
cleanup_and_exit 1 "ERROR: no network device found for telnet server"
fi
if test -x /sbin/ip ; then
ip addr add 10.0.2.15/8 dev ${VM_TELNET_DEVICE}
ip addr add ::1/24 dev ${VM_TELNET_DEVICE}
ip link set ${VM_TELNET_DEVICE} up
else
if ! test -x /sbin/ifconfig ; then
cleanup_and_exit 1 "ERROR: /usr/sbin/in.telnetd is not running, please specify correct package via -x option"
fi
ifconfig ${VM_TELNET_DEVICE} 10.0.2.15 up
ifconfig ${VM_TELNET_DEVICE} add ::1/24
fi
fi
if test -n "$MYHOSTNAME" ; then
hostname "$MYHOSTNAME"
fi
if test -n "$VM_TELNET"; then
echo WARNING: telnet option used, setting up telnet server ${VM_TELNET_DEVICE}
if test -x /usr/sbin/in.telnetd; then
( /usr/sbin/in.telnetd -L /.build/telnet_login_wrapper -debug 23 & )
else
cleanup_and_exit 1 "ERROR: /usr/sbin/in.telnetd is not running, please specify right package via -x option"
fi
fi
vm_setup_network
fi

setupicecream
Expand Down
40 changes: 40 additions & 0 deletions build-vm
Original file line number Diff line number Diff line change
Expand Up @@ -915,3 +915,43 @@ vm_wrapup_build() {
popd >/dev/null
fi
}

vm_setup_network() {
if test -x /sbin/ip ; then
ip addr add 127.0.0.1/8 dev lo
ip addr add ::1/128 dev lo
ip link set lo up
else
ifconfig lo 127.0.0.1 up
ifconfig lo add ::1/128
fi
if test -n "$VM_TELNET"; then
VM_TELNET_DEVICE=$( cd /sys/class/net/; echo * )
VM_TELNET_DEVICE=${VM_TELNET_DEVICE#lo }
VM_TELNET_DEVICE=${VM_TELNET_DEVICE%% *}
if test -z "$VM_TELNET_DEVICE" ; then
cleanup_and_exit 1 "ERROR: no network device found for telnet server"
fi
if test -x /sbin/ip ; then
ip addr add 10.0.2.15/8 dev ${VM_TELNET_DEVICE}
ip addr add ::1/24 dev ${VM_TELNET_DEVICE}
ip link set ${VM_TELNET_DEVICE} up
elif test -x /sbin/ifconfig ; then
ifconfig ${VM_TELNET_DEVICE} 10.0.2.15 up
ifconfig ${VM_TELNET_DEVICE} add ::1/24
else
cleanup_and_exit 1 "ERROR: neither /sbin/ifconfig nor /sbin/ip is installed, please specify correct package via -x option"
fi
fi
if test -n "$MYHOSTNAME" ; then
hostname "$MYHOSTNAME"
fi
if test -n "$VM_TELNET"; then
echo WARNING: telnet option used, setting up telnet server ${VM_TELNET_DEVICE}
if test -x /usr/sbin/in.telnetd; then
( /usr/sbin/in.telnetd -L /.build/telnet_login_wrapper -debug 23 & )
else
cleanup_and_exit 1 "ERROR: /usr/sbin/in.telnetd is not installed, please specify correct package via -x option"
fi
fi
}

0 comments on commit 619d2aa

Please sign in to comment.