当前位置: 首页 > article >正文

VMware Tools工具安装脚本(CentOS Ubuntu)

1、VMware Tools(CentOS版)

#!/bin/bash

log_info() {
echo "[INFO] $1"
echo "[INFO] $1" >> "$LOGFILE"
}

log_error() {
echo "[ERROR] $1"
echo "[ERROR] $1" >> "$LOGFILE"
exit 1
}

# log to record install process
LOGFILE="/var/log/env-script.log"

mkdir -p /mnt/cdrom || log_error "Failed to create mount point"

chmod 777 /dev/sr0 || log_error "Failed to set CD-ROM permissions"

mount -t iso9660 /dev/sr0 /mnt/cdrom || log_error "Failed to mount ISO image"

cp /mnt/cdrom/VMwareTools-10.3.25-20206839.tar.gz /usr/local/src || log_error "Failed to copy VMware Tools package"

cd /usr/local/src || log_error "Cannot enter extraction directory"
tar -xf VMwareTools-10.3.25-20206839.tar.gz || log_error "Failed to extract VMware Tools package"

cd vmware-tools-distrib || log_error "Cannot enter vmware-tools-distrib directory"

yum install -y perl || log_error "Failed to install Perl dependency"

echo -e "y\n" | ./vmware-install.pl || log_error "Failed to execute VMware Tools installation script"

chmod 660 /dev/sr0 || log_error "Failed to reset CD-ROM permissions"

# recoard success information
log_info "All steps completed."
echo "All steps completed." >> "$LOGFILE"

2、VMware Tools(Ubuntu版)

#!/bin/bash

log_info() {
echo "[INFO] $1"
echo "[INFO] $1" >> "$LOGFILE"
}

log_error() {
echo "[ERROR] $1"
echo "[ERROR] $1" >> "$LOGFILE"
exit 1
}

# Log file to record install process
LOGFILE="/var/log/env-script.log"

# Create mount point if it doesn't exist
mkdir -p /mnt/cdrom || log_error "Failed to create mount point"

# Set CD-ROM permissions
chmod 777 /dev/cdrom || log_error "Failed to set CD-ROM permissions"

# Mount the ISO image
mount -t iso9660 /dev/cdrom /mnt/cdrom || log_error "Failed to mount ISO image"

# Copy VMware Tools package
cp /mnt/cdrom/VMwareTools-10.3.25-20206839.tar.gz /usr/local/src || log_error "Failed to copy VMware Tools package"

# Change to the extraction directory
cd /usr/local/src || log_error "Cannot enter extraction directory"

# Extract VMware Tools package
tar -xf VMwareTools-10.3.25-20206839.tar.gz || log_error "Failed to extract VMware Tools package"

# Change to the extracted directory
cd vmware-tools-distrib || log_error "Cannot enter vmware-tools-distrib directory"

# Install Perl dependency
apt-get update || log_error "Failed to update package list"
apt-get install -y perl || log_error "Failed to install Perl dependency"

# Execute VMware Tools installation script
echo -e "y\n" | ./vmware-install.pl || log_error "Failed to execute VMware Tools installation script"

# Reset CD-ROM permissions
chmod 660 /dev/cdrom || log_error "Failed to reset CD-ROM permissions"

# Record success information
log_info "All steps completed."
echo "All steps completed." >> "$LOGFILE"

http://www.kler.cn/a/398144.html

相关文章:

  • 【Linux庖丁解牛】—Linux基本指令(下)!
  • 什么是Spring Boot Actuator
  • 【C++】构造函数
  • v-html 富文本中图片使用element-ui image-viewer组件实现预览,并且阻止滚动条
  • java 数组 拼接 详解
  • Excel使用-弹窗“此工作簿包含到一个或多个可能不安全的外部源的链接”的发生与处理
  • 【微信小程序】用户房屋管理
  • 软硬互联——革新机器人非标产线智能制造
  • CSS Float(浮动)
  • 快速搭建Android开发环境:Docker部署docker-android并实现远程连接
  • 【大数据学习 | HBASE高级】hive操作hbase
  • pytorch中的ImageFolder 用法
  • ASUS/华硕灵耀14 2024款 UX3405MA 原厂Win11-23H2系统 工厂文件 带ASUS Recovery恢复
  • 【Java Web】Ajax 介绍及 jQuery 实现
  • ranger-kms安装
  • 串口DMA接收不定长数据
  • AndroidStudio-Activity的生命周期
  • 权限系统:权限应用服务设计
  • LeetCode 18. 四数之和 Java题解
  • JVM双亲委派机制详解
  • GPT-5 要来了:抢先了解其创新突破
  • web与网络编程
  • scoop安装ffmpeg转换视频为语音文件
  • 前端Javascript、Vue、CSS等场景面试题目(二)
  • 7.2 图像复原之空间滤波
  • Docker 组添加用户,设置允许普通用户操作 docker