哀悼!! 到了 Vmware Workstation 16,這功能就被拿掉了。
這篇原來是想要建議上游,修改 overlay,在 systemd 的檔案中,加入對 server 模式的支援,但沒人理我,只好搬過來,自行修改。
To enable Vmware Workstation Server in systemd, I modified the vmware-workstation-15.0.2.10952284-r2.ebuild. The differences are as follows.
--- vmware-workstation-15.0.2.10952284-r2.ebuild 2018-12-16 10:02:59.220759030 +0800
+++ vmware-workstation-15.0.2.10952284-r3.ebuild 2019-02-13 10:00:15.091008507 +0800
@@ -22,9 +22,8 @@
vmware-tools-darwinPre15? ( https://softwareupdate.vmware.com/cds/vmw-desktop/fusion/${VMWARE_FUSION_VER}/packages/com.vmware.fusion.tools.darwinPre15.zip.tar -> com.vmware.fusion.tools.darwinPre15-${PV}.zip.tar )
vmware-tools-darwin? ( https://softwareupdate.vmware.com/cds/vmw-desktop/fusion/${VMWARE_FUSION_VER}/packages/com.vmware.fusion.tools.darwin.zip.tar -> com.vmware.fusion.tools.darwin-${PV}.zip.tar )
)
- systemd? ( https://github.com/akhuettel/systemd-vmware/archive/${SYSTEMD_UNITS_TAG}.tar.gz -> vmware-systemd-${SYSTEMD_UNITS_TAG}.tgz )
"
-
+
LICENSE="GPL-2 GPL-3 MIT-with-advertising vmware"
SLOT="0"
KEYWORDS="~amd64"
@@ -191,6 +190,7 @@
net-dns/libidn
net-libs/gnutls
cups? ( net-print/cups )
+ server? ( sys-apps/lsb-release )
sys-apps/tcp-wrappers
sys-apps/util-linux
x11-libs/libXxf86vm
@@ -394,14 +394,23 @@
# install binaries
into "${VM_INSTALL_DIR}"/lib/vmware
- dobin "${FILESDIR}"/configure-hostd.sh
+ dobin "${FILESDIR}"/{check-certificates.sh,shutdown-autostart-vm.sh}
+
+ if use systemd; then
+ newbin "${FILESDIR}"/configure-hostd_systemd.sh configure-hostd.sh
+ else
+ dobin "${FILESDIR}"/configure-hostd.sh
+ fi
# install the libraries
insinto "${VM_INSTALL_DIR}"/lib/vmware/lib
doins -r lib/*
+
+ dosym "${VM_INSTALL_DIR}"/lib/vmware/lib/libvmware-hostd.so/libvmware-hostd.so \
+ "${VM_INSTALL_DIR}"/lib/vmware/lib/libvmware-vim-cmd.so/libvmware-vim-cmd.so
into "${VM_INSTALL_DIR}"
- for tool in vmware-hostd wssc-adminTool ; do
+ for tool in vmware-hostd vmware-wssc-adminTool ; do
cat > "${T}/${tool}" <<-EOF
#!/usr/bin/env bash
set -e
@@ -413,6 +422,9 @@
EOF
dobin "${T}/${tool}"
done
+
+ into "${VM_INSTALL_DIR}"
+ dobin vmware-vim-cmd
insinto "${VM_INSTALL_DIR}"/lib/vmware
doins -r hostd
@@ -479,7 +491,7 @@
fperms 0755 "${VM_INSTALL_DIR}"/lib/vmware/lib/libvmware-gksu.so/gksu-run-helper
fperms 4711 "${VM_INSTALL_DIR}"/sbin/vmware-authd
if use server; then
- fperms 0755 "${VM_INSTALL_DIR}"/bin/{vmware-hostd,wssc-adminTool}
+ fperms 0755 "${VM_INSTALL_DIR}"/bin/{vmware-hostd,vmware-vim-cmd,vmware-wssc-adminTool}
fperms 1777 "${VM_DATA_STORE_DIR}"
fi
if use vix; then
@@ -658,8 +670,14 @@
# install systemd unit files
if use systemd; then
- systemd_dounit "${WORKDIR}/systemd-vmware-${SYSTEMD_UNITS_TAG}/"*.{service,target}
- fi
+ systemd_dounit "${FILESDIR}/"vmware-{usb,vmblock,vmci,vmmon,vmnet,vmsock}.service
+ systemd_dounit "${FILESDIR}"/vmware.target
+
+ if use server; then
+ systemd_dounit "${FILESDIR}/"vmware-{authentication,hostd}.service
+ systemd_dounit "${FILESDIR}/"vmware-workstation-server.target
+ fi
+ fi
# enable macOS guests support
if use macos-guests; then
The modified files and new files are listed as follows.
File vmware.target
, vmware-authentication.service
is removed from this file.
[Unit]
Description=VMware Workstation Service(s)
Requires=vmware-vmmon.service
Wants=vmware-vmci.service
Wants=vmware-vmsock.service
Wants=vmware-vmblock.service
Wants=vmware-vmnet.service
Wants=vmware-usb.service
[Install]
WantedBy=multi-user.target
File vmware-workstation-server.target
[Unit]
Description=VMware Workstation server Service(s)
Requires=vmware.target
After=vmware.target
Wants=vmware-authentication.service
Wants=vmware-hostd.service
[Service]
[Install]
WantedBy=multi-user.target
File vmware-authentication.service
, PartOf is modified to vmware-workstation-server.target.
[Unit]
Description=VMware Authentication Daemon
After=vmware.target
PartOf=vmware-workstation-server.target
[Service]
Type=simple
RemainAfterExit=yes
ExecStart=/opt/vmware/sbin/vmware-authdlauncher
File vmware-hostd.service
[Unit]
Description=VMware Workstation Server
After=vmware-authentication.service
PartOf=vmware-workstation-server.target
[Service]
Type=simple
RemainAfterExit=yes
ExecStartPre=sh /opt/vmware/lib/vmware/bin/check-certificates.sh
PIDFile=/var/run/vmware/vmware-hostd.PID
ExecStart=/opt/vmware/bin/vmware-hostd -a -d /etc/vmware/hostd/config.xml
ExecStop=sh /opt/vmware/lib/vmware/bin/shutdown-autostart-vm.sh
File configure-hostd_systemd.sh
, which is installed as /opt/vmware/lib/vmware/bin/configure-hostd.sh
.
#!/bin/bash
action="$1"
case $action in
add)
systemctl -q enable vmware-workstation-server.target
systemctl -q start vmware-workstation-server.target
;;
remove)
systemctl -q disable vmware-workstation-server.target
systemctl -q stop vmware-workstation-server.target
;;
status)
systemctl -q is-active vmware-workstation-server.target && echo on || echo off
;;
*)
exit 1
;;
esac
File check-certificates.sh
#!/bin/bash
# Check if certificates exist. If not, we need to generate them, ala sshd.
if [ ! -e /etc/vmware/ssl/rui.key -o ! -e /etc/vmware/ssl/rui.crt ]; then
chmod 0600 /etc/vmware/ssl
openssl req -x509 -days 365 -newkey rsa:2048 -keyout /etc/vmware/ssl/rui.key -out /etc/vmware/ssl/rui.crt -config /etc/vmware/ssl/hostd.ssl.config
chmod 0600 /etc/vmware/ssl/rui.key /etc/vmware/ssl/rui.crt
fi
File shutdown-autostart-vm.sh
# "Shutdown VMs in the AutoStart Sequence"
HOHO_ADMIN="$(/opt/vmware/bin/vmware-wssc-adminTool "/etc/vmware/hostd/authorization.xml" 2>/dev/null)"
if [ "x" != "x${HOHO_ADMIN}" ]; then
/opt/vmware/bin/vmware-vim-cmd -U "${HOHO_ADMIN}" hostsvc/autostartmanager/autostop
fi
The changes are summarized as follows.
- Put the systemd services in files folder instead of downloading them.
- Create vmware-workstation-server.target, and move vmware-authentication.service from vmware.target to vmware-workstation-server.target.
- Create vmware-hostd.service to start hostd service, and create two scripts, which are invoked by this service, to check certificates and shutdown autostart VMs.
- Use systemctl command instead of rc-service commands In configure-hostd.sh.
- Create libvmware-vim-cmd.so link to libvmware-hostd.so to make vmware-vim-cmd work.
沒有留言:
張貼留言