您现在的位置是:首页 >技术杂谈 >Linux Shell 实现一键部署VMware Workstation网站首页技术杂谈

Linux Shell 实现一键部署VMware Workstation

CIAS 2024-06-17 10:29:49
简介Linux Shell 实现一键部署VMware Workstation

VMware Workstation  前言

VMware Workstation Pro 是业界标准的桌面 Hypervisor,用于在 Linux 或 Windows PC 上运行虚拟机

download VMware_Workstation

VMware_Workstation WindowsVMware_Workstation linux文档
downloaddownload参考

Linux 各系统下载使用参考

Red HatRocky Linux Oracle Linux

AlmaLinux 

ubuntususelinuxesxiRHEL标准安装系统安装参考YUM参考

MobaXterm 远程连接工具

Red Hat Enterprise 9.0 文档Kickstart 生成器
downloaddownloaddownloaddownloaddownloaddownloaddownload参考参考配置参考download参考Kickstart 
版本兼容性

创建一键部署VMware_Workstation

  • 安装时间较长耐心等待预计一小时,原因基础依赖环境安装较多,也可在安装操作系统的时候把这些基础环境包全部安装了这样节省很多时间,我的环境是迷你版环境。
  • 最中实现在线下载VMware_Workstation,安装VMware_Workstation,授权,安装基础环境依赖,配置VMware_Workstation,初始化VMware Workstation,安装完成后需要重启服务器必须要重启,重复安装操作系统之前安装了依赖环境那就不需要重启系统。
  • vmware-installer -u vmware-workstation #卸载使用此命令
  • systemctl set-default graphical.target #将系统引导方式改为图形化引导
  • systemctl set-default multi-user.target #将系统引导方式改为命令行引导
vi /install_vmware-workstation.sh
#!/bin/bash
# -*- coding: utf-8 -*-
# Author: CIASM
# update 2023/05/16

directory=/root
vmware_workstation_url=https://download3.vmware.com/software/WKST-1702-LX/
vmware_workstation_bundle=VMware-Workstation-Full-17.0.2-21581411.x86_64.bundle
vmware_workstation_directory_check=/usr/lib/vmware
vmware_workstation_key=JU090-6039P-08409-8J0QH-2YR7F

install_vmware_workstation (){
if [ ! -d ${vmware_workstation_directory_check} ];then
echo "install vmware_workstation"
if [ $? -eq 0 ];then 

echo "Close selinux"
sed -i 's/SELINUX=enforcing/SELINUX=disabled/' /etc/selinux/config 
setenforce 0

echo "install Dependent environment"
yum install -y http://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm
yum install -y kernel-devel kernel-headers perl 
yum install -y libXtst-devel libXrender-devel xinetd bison libgcrypt
yum install -y gcc gcc-c++ make cmake vim wget net-tools
yum install -y kernel* elfutils-libelf-devel pcsc-lite-libs 
yum install -y mesa-libGL -y
dnf groupinstall "Server with GUI" -y

echo "gtk modules config"
cat >>/etc/ld.so.conf.d/gtk-2.0.conf<<EOF
/usr/lib64/gtk-2.0/modules
EOF
ldconfig

echo "downlod vmware_workstation"
wget -N -P $directory $vmware_workstation_url/$vmware_workstation_bundle
chmod +x $directory/$vmware_workstation_bundle

echo "install vmware_workstation"
sh $directory/$vmware_workstation_bundle --console --eulas-agreed --required --set-setting vmware-workstation serialNumber $vmware_workstation_key

echo "proxy server"
mkdir -p /etc/vmware/hostd/
cat >>/etc/vmware/hostd/proxy.xml<<EOF
   <HttpProxyConfig>
     <Enabled>false</Enabled>
     <ServerName>proxy.example.com</ServerName>
     <ServerPort>8080</ServerPort>
   </HttpProxyConfig>
EOF

echo "Deleting an installation package"
rm -f $directory/$vmware_workstation_bundle

echo "vmware_workstation version check"
vmware --version | awk '{print $3}'

echo "reboot system"
reboot

   echo -e "33[32mThe vmware workstation Install Sussess...33[0m" 
  else
   echo -e "33[33mThe vmware workstation Install Failed...33[0m" 
    exit 1
   fi
  else
   echo -e "33[31mThe vmware workstation Install already...33[0m"
fi
}

main (){
install_vmware_workstation
}

main

执行一键部署

sh /install_vmware-workstation.sh

系统重启完成后在执行初始化vmware-workstation

  • 执行初始化vmware-workstation
cat >>/initialize_vmware-workstation.sh<<EOF
#!/bin/bash
# -*- coding: utf-8 -*-
# Author: CIASM
# update 2023/05/16

echo "Manually compile VMware kernel modules"
vmware-modconfig --console --install-all

echo "start vmware-workstation "
systemctl start vmware
EOF

sh /initialize_vmware-workstation.sh

打开vmware,远程连接软件使用Xmanager Power Suite 7,shell终端输入以下命令打开vmware_workstation

  • 依赖库 yum install -y elfutils-libelf-devel  pcsc-lite-libs 
vmware

打开vmware,远程连接软件使用MobaXterm,shell终端输入以下命令打开vmware_workstation

  •  yum install -y mesa-libGL 打开需要的依赖库
vmware

风语者!平时喜欢研究各种技术,目前在从事后端开发工作,热爱生活、热爱工作。