_bindir=/usr/bin
_sysconfdir=/etc

if [ -f ${_bindir}/vmware-guestproxycerttool ]; then
   mkdir -p ${_sysconfdir}/vmware-tools/GuestProxyData/server
   mkdir -p -m 0700 ${_sysconfdir}/vmware-tools/GuestProxyData/trusted
   ${_bindir}/vmware-guestproxycerttool -g &> /dev/null || /bin/true
fi

# Setup mount point for Shared Folders
if [ -f ${_bindir}/vmware-checkvm -a                     \
     -f ${_bindir}/vmhgfs-fuse ] &&                      \
   ${_bindir}/vmware-checkvm &> /dev/null &&             \
   ${_bindir}/vmware-checkvm -p | grep -q Workstation && \
   ${_bindir}/vmhgfs-fuse -e &> /dev/null; then
   mkdir -p /mnt/hgfs
fi

echo -e "Checking whether open-vm-tools units need to be reload..."
if [[ $(systemctl show vgauthd --property=NeedDaemonReload | cut -d= -f2) == "yes" || \
      $(systemctl show vmtoolsd --property=NeedDaemonReload | cut -d= -f2) == "yes" ]]; then
    echo "Reloading systemd units ..."
    systemctl daemon-reload
else
    echo "Nothing needs reloading."
fi

echo -e "Enabling open-vm-tools services ..."
systemctl enable vgauthd.service
systemctl enable vmtoolsd.service
