nmbd=vmware-nmbd
vmware_etc_dir=/etc/vmware
-vmware_db="$vmware_etc_dir"/locations
-if [ ! -r "$vmware_db" ]; then
+vmnet_cfg="$vmware_etc_dir"/vmnet.conf
+if [ -r "$vmnet_cfg" ]; then
+ . "$vmnet_cfg"
+else
echo "Warning: Unable to find VMware Workstation's main database"
- echo "($vmware_db)."
+ echo "($vmnet_cfg)."
echo
exit 1
fi
eval "$dirname"'="$tmp"'"'"'/'"'"'"$prefix$serial"'
}
-#
-# Manage an installer database
-#
-
-# Add an answer to a database in memory
-db_answer_add() {
- local dbvar="$1" # IN/OUT
- local id="$2" # IN
- local value="$3" # IN
- local answers
- local i
-
- eval "$dbvar"'_answer_'"$id"'="$value"'
- eval 'answers="$'"$dbvar"'_answers"'
- # There is no double quote around $answers on purpose
- for i in $answers; do
- if [ "$i" = "$id" ]; then
- return
- fi
- done
- answers="$answers"' '"$id"
- eval "$dbvar"'_answers="$answers"'
-}
-
-# Remove an answer from a database in memory
-db_answer_remove() {
- local dbvar="$1" # IN/OUT
- local id="$2" # IN
- local new_answers
- local answers
- local i
-
- eval 'unset '"$dbvar"'_answer_'"$id"
- new_answers=''
- eval 'answers="$'"$dbvar"'_answers"'
- # There is no double quote around $answers on purpose
- for i in $answers; do
- if [ "$i" != "$id" ]; then
- new_answers="$new_answers"' '"$i"
- fi
- done
- eval "$dbvar"'_answers="$new_answers"'
-}
-
-# Load all answers from a database on stdin to memory (<dbvar>_answer_*
-# variables)
-db_load_from_stdin() {
- local dbvar="$1" # OUT
-
- eval "$dbvar"'_answers=""'
- # read doesn't support -r on FreeBSD 3.x.
- # For this reason, the folowing line is patched to remove the -r in case of
- # Free BSD tools build. Please look at
- # bora-vmsoft/install/FreeBSD/tools-tar.make before making drastic changes to
- # the folowing line.
- # -- Jeremy Bar
- while read -r action p1 p2; do
- if [ "$action" = 'answer' ]; then
- db_answer_add "$dbvar" "$p1" "$p2"
- elif [ "$action" = 'remove_answer' ]; then
- db_answer_remove "$dbvar" "$p1"
- fi
- done
-}
-
-#
-# Load database
-#
-
-db_load_from_stdin "vmdb" < "$vmware_db"
-
#
# Utilities
#
# XXX ping takes 10 seconds to timeout if nobody answers
# that slows boot too much so we do this bit in the
# background.
- if "$vmdb_answer_BINDIR"/"$ping" -q "$ifIp"; then
+ if "$VMNET_BINDIR"/"$ping" -q "$ifIp"; then
echo 'Host-only networking disabled because '"$ifIp"
echo 'appears to be a real, physical, existing address.'
echo 'Please modify your host-only network configuration.'
exit 1
fi
- cd "$vmdb_answer_BINDIR" && "$vmdb_answer_BINDIR"/"$netifup" \
+ cd "$VMNET_BINDIR" && "$VMNET_BINDIR"/"$netifup" \
-d /var/run/"$netifup"-"$vHostIf".pid /dev/vmnet"$vHubNr" "$vHostIf"
[ "$?" -eq 0 ] || exit 1
# Configure the virtual host ethernet interface and define the private IP
# Start a DHCP server on a private IP network
# The daemon already logs its output in the system log, so we can safely
# trash it
- cd "$vmdb_answer_BINDIR" && "$vmdb_answer_BINDIR"/"$dhcpd" \
+ cd "$VMNET_BINDIR" && "$VMNET_BINDIR"/"$dhcpd" \
-cf "$vmware_etc_dir"/"$vHostIf"/dhcpd/dhcpd.conf \
-lf "$vmware_etc_dir"/"$vHostIf"/dhcpd/dhcpd.leases \
-pf /var/run/"$dhcpd"-"$vHostIf".pid "$vHostIf" >/dev/null 2>&1 || exit 1
if [ "$run_samba" = 'yes' ]; then
# Start a SMB name server on a private IP network
# Disable logging to avoid the uncontrolled creation of unmanaged files
- cd "$vmdb_answer_BINDIR" && "$vmdb_answer_BINDIR"/"$nmbd" -D -l /dev/null \
+ cd "$VMNET_BINDIR" && "$VMNET_BINDIR"/"$nmbd" -D -l /dev/null \
-s "$vmware_etc_dir"/"$vHostIf"/smb/smb.conf \
-f /var/run/"$nmbd"-"$vHostIf".pid || exit 1
# Start a SMB share server on a private IP network
# Disable logging to avoid the uncontrolled creation of unmanaged files
- cd "$vmdb_answer_BINDIR" && "$vmdb_answer_BINDIR"/"$smbd" -D -l /dev/null \
+ cd "$VMNET_BINDIR" && "$VMNET_BINDIR"/"$smbd" -D -l /dev/null \
-s "$vmware_etc_dir"/"$vHostIf"/smb/smb.conf \
-f /var/run/"$smbd"-"$vHostIf".pid || exit 1
fi
# See how we were called.
case "$1" in
start)
+ if [ -f /var/lock/subsys/"$subsys" ]; then
+ msg_already_running "VMware Workstation networking"
+ exit 1
+ fi
exitcode='0'
# Try to load parport_pc. Failure is allowed as it does not exist
# on kernels 2.0
/sbin/modprobe parport_pc >/dev/null 2>&1
- if [ "$vmdb_answer_NETWORKING" = 'yes' ]; then
+ if [ "$VM_NETWORKING" = 'yes' ]; then
msg_starting 'Virtual ethernet'
busy
/sbin/modprobe $vnet
exitcode=`expr "$exitcode" + "$?"`
vHubNr=0
while [ $vHubNr -lt 256 ]; do
- eval 'interface="$vmdb_answer_VNET_'"$vHubNr"'_INTERFACE"'
- eval 'hostaddr="$vmdb_answer_VNET_'"$vHubNr"'_HOSTONLY_HOSTADDR"'
- eval 'netmask="$vmdb_answer_VNET_'"$vHubNr"'_HOSTONLY_NETMASK"'
+ eval 'interface="$VNET_'"$vHubNr"'_INTERFACE"'
+ eval 'hostaddr="$VNET_'"$vHubNr"'_HOSTONLY_HOSTADDR"'
+ eval 'netmask="$VNET_'"$vHubNr"'_HOSTONLY_NETMASK"'
if [ -n "$interface" ]; then
# Connect a physical host ethernet interface to a virtual ethernet hub
msg_starting 'Bridged networking on /dev/vmnet'"$vHubNr"
busy
- cd "$vmdb_answer_BINDIR" && "$vmdb_answer_BINDIR"/"$bridge" \
+ cd "$VMNET_BINDIR" && "$VMNET_BINDIR"/"$bridge" \
-d /var/run/"$bridge"-"$vHubNr".pid /dev/vmnet"$vHubNr" "$interface"
[ "$?" -eq 0 ] && ok || fail
exitcode=`expr "$exitcode" + "$?"`
elif [ -n "$hostaddr" -a -n "$netmask" ]; then
- eval 'samba="$vmdb_answer_VNET_'"$vHubNr"'_SAMBA"'
+ eval 'samba="$VNET_'"$vHubNr"'_SAMBA"'
msg_starting 'Host-only networking on /dev/vmnet'"$vHubNr"
busy
- daemon vmware_start_hostonly "$vHubNr" 'vmnet'"$vHubNr" "$hostaddr" "$netmask" 'yes' "$samba"
+ daemon vmware_start_hostonly "$vHubNr" 'vmnet'"$vHubNr" "$hostaddr" \
+ "$netmask" 'yes' "$samba"
[ "$?" -eq 0 ] && ok || fail
exitcode=`expr "$exitcode" + "$?"`
- eval 'nat="$vmdb_answer_VNET_'"$vHubNr"'_NAT"'
+ eval 'nat="$VNET_'"$vHubNr"'_NAT"'
if [ "$nat" = 'yes' ]; then
# Start the NAT network user service
msg_starting 'NAT networking on /dev/vmnet'"$vHubNr"
busy
- cd "$vmdb_answer_BINDIR" && "$vmdb_answer_BINDIR"/"$natd" \
+ cd "$VMNET_BINDIR" && "$VMNET_BINDIR"/"$natd" \
-d /var/run/"$natd"-"$vHubNr".pid \
-m /var/run/"$natd"-"$vHubNr".mac \
-c "$vmware_etc_dir"/vmnet"$vHubNr"/nat/nat.conf
echo 'At least one instance of VMware Workstation is still running.'
echo 'Please stop all running instances of VMware Workstation first.'
echo
- # The unconfigurator handle this exit code differently
- exit 2
+ exit 1
fi
+ if [ ! -f /var/lock/subsys/"$subsys" ]; then
+ msg_not_running "VMware Workstation networking"
+ exit 1
+ fi
exitcode='0'
# Try to unload parport_pc. Failure is allowed as it does not exist
# on kernels 2.0, and some other process could be using it.
/sbin/modprobe -r parport_pc >/dev/null 2>&1
- if [ "$vmdb_answer_NETWORKING" = "yes" ]; then
+ if [ "$VM_NETWORKING" = "yes" ]; then
# NB: must kill off processes using vmnet before
# unloading module
vHubNr=0
while [ $vHubNr -lt 256 ]; do
- eval 'interface="$vmdb_answer_VNET_'"$vHubNr"'_INTERFACE"'
- eval 'hostaddr="$vmdb_answer_VNET_'"$vHubNr"'_HOSTONLY_HOSTADDR"'
- eval 'netmask="$vmdb_answer_VNET_'"$vHubNr"'_HOSTONLY_NETMASK"'
+ eval 'interface="$VNET_'"$vHubNr"'_INTERFACE"'
+ eval 'hostaddr="$VNET_'"$vHubNr"'_HOSTONLY_HOSTADDR"'
+ eval 'netmask="$VNET_'"$vHubNr"'_HOSTONLY_NETMASK"'
if [ -n "$interface" ]; then
# Disconnect a physical host ethernet interface from a virtual ethernet hub
msg_stopping "Bridged networking on /dev/vmnet$vHubNr"
vmware_stop_pidfile /var/run/"$dhcpd"-"vmnet$vHubNr".pid
[ "$?" -eq 0 ] && ok || fail
exitcode=`expr "$exitcode" + "$?"`
- eval 'samba="$vmdb_answer_VNET_'"$vHubNr"'_SAMBA"'
+ eval 'samba="$VNET_'"$vHubNr"'_SAMBA"'
if [ "$samba" = "yes" ]; then
# Stop a SMB share server on a private IP network
msg_stopping 'SMB share server on /dev/vmnet'"$vHubNr"
[ "$?" -eq 0 ] && ok || fail
exitcode=`expr "$exitcode" + "$?"`
fi
- eval 'nat="$vmdb_answer_VNET_'"$vHubNr"'_NAT"'
+ eval 'nat="$VNET_'"$vHubNr"'_NAT"'
if [ "$nat" = "yes" ]; then
# Stop the NAT network user service
msg_stopping 'NAT networking on /dev/vmnet'"$vHubNr"
echo 'At least one instance of VMware Workstation is still running.'
echo
fi
- if [ "$vmdb_answer_NETWORKING" = "yes" ]; then
+ if [ "$VM_NETWORKING" = "yes" ]; then
status "$bridge"
status "$dhcpd"
status "$netifup"
fi
- if [ "$vmdb_answer_NETWORKING" = "yes" ]; then
+ if [ "$VM_NETWORKING" = "yes" ]; then
echo -n "Module $vnet "
/sbin/modprobe "$vnet" >/dev/null 2>&1 && echo installed || echo "not installed"
fi