open-vm-tools: add sysvinit script to start vmtoolsd daemon at boot time

It adds support to start vmtoolsd daemon during system startup,
when init manager is SysVinit.

Patch V2 adds option to store pid file in /var/run/vmtoolsd.pid file,
which is helpful to stop/restart vmtoolsd daemon.

Signed-off-by: Jagadeesh Krishnanjanappa <jkrishnanjanappa@mvista.com>
Signed-off-by: Armin Kuster <akuster808@gmail.com>
This commit is contained in:
Jagadeesh Krishnanjanappa 2018-01-10 00:01:06 +05:30 committed by Armin Kuster
parent 7919c886cd
commit bb1465863d
2 changed files with 80 additions and 3 deletions

View File

@ -0,0 +1,66 @@
#!/bin/sh
#
# vmtoolsd Start/stop the vmware tools daemon
#
# chkconfig: 2345 90 60
# description: vmtoolsd is a daemon that starts up. for some reason, it
# doesn't include a sysv init startup file in the latest release.
# so i have to write this
#
### BEGIN INIT INFO
# Provides: vmtoolsd
# Required-Start: $local_fs $syslog
# Required-Stop: $local_fs $syslog
# Default-Start: 2345
# Default-Stop: 90
# Short-Description: Run vmware tools daemon
### END INIT INFO
PATH=/sbin:/bin:/usr/sbin:/usr/bin
DAEMON=/usr/bin/vmtoolsd
NAME=vmtoolsd
DESC="vmware tools daemon"
VMTOOLSDARGS=" -b /var/run/vmtoolsd.pid "
RETVAL="1"
# source function library
. /etc/init.d/functions
test -f $DAEMON || exit 0
case "$1" in
start)
echo -n "Starting vmware tools daemon: "
start-stop-daemon --start --quiet --exec $DAEMON -- $VMTOOLSDARGS
RETVAL=$?
if [ $RETVAL -eq 0 ] ; then
echo "OK"
else
echo "FAIL"
fi
;;
stop)
echo -n "Stopping vmware tools daemon: "
start-stop-daemon --stop --quiet --pidfile /var/run/vmtoolsd.pid
RETVAL=$?
if [ $RETVAL -eq 0 ] ; then
echo "OK"
else
echo "FAIL"
fi
;;
status)
status vmtoolsd
exit $?
;;
restart)
$0 stop && sleep 1 && $0 start
;;
*)
echo "Usage: /etc/init.d/vmtoolsd {start|stop|status|restart}"
exit 1
esac
exit $RETVAL

View File

@ -24,6 +24,7 @@ LICENSE_modules/solaris = "CDDL-1.0"
SRC_URI = "git://github.com/vmware/open-vm-tools.git;protocol=https \
file://tools.conf \
file://vmtoolsd.service \
file://vmtoolsd.init \
file://0001-configure.ac-don-t-use-dnet-config.patch \
file://0002-add-include-sys-sysmacros.h.patch \
file://0001-Remove-assumptions-about-glibc-being-only-libc-imple.patch \
@ -50,7 +51,7 @@ DEPENDS_append_libc-musl = " libtirpc"
# open-vm-tools is supported only on x86.
COMPATIBLE_HOST = '(x86_64.*|i.86.*)-linux'
inherit autotools pkgconfig systemd
inherit autotools pkgconfig systemd update-rc.d
SYSTEMD_SERVICE_${PN} = "vmtoolsd.service"
@ -85,8 +86,14 @@ RDEPENDS_${PN} = "util-linux libdnet fuse"
do_install_append() {
ln -sf ${sbindir}/mount.vmhgfs ${D}/sbin/mount.vmhgfs
install -d ${D}${systemd_unitdir}/system ${D}${sysconfdir}/vmware-tools
install -m 644 ${WORKDIR}/*.service ${D}${systemd_unitdir}/system
install -d ${D}${sysconfdir}/vmware-tools
if ${@bb.utils.contains('DISTRO_FEATURES', 'systemd', 'true', 'false', d)}; then
install -d ${D}${systemd_unitdir}/system
install -m 644 ${WORKDIR}/*.service ${D}${systemd_unitdir}/system
else
install -d ${D}${sysconfdir}/init.d
install -m 0755 ${WORKDIR}/vmtoolsd.init ${D}${sysconfdir}/init.d/vmtoolsd
fi
install -m 0644 ${WORKDIR}/tools.conf ${D}${sysconfdir}/vmware-tools/tools.conf
}
@ -95,6 +102,10 @@ do_configure_prepend() {
export CUSTOM_DNET_LIBS=-L${STAGING_LIBDIR}/libdnet.so
}
INITSCRIPT_PACKAGES = "${PN}"
INITSCRIPT_NAME_${PN} = "vmtoolsd"
INITSCRIPT_PARAMS_${PN} = "start 90 2 3 4 5 . stop 60 0 1 6 ."
python() {
if 'networking-layer' not in d.getVar('BBFILE_COLLECTIONS').split() or \
'filesystems-layer' not in d.getVar('BBFILE_COLLECTIONS').split():