Ostatnio aktywny 7 months ago

Rewizja a820b68141b1b78398532964b62c80448ee485ff

install_vmtools.sh Surowy
1#!/bin/bash
2set -e
3
4# Define variables
5ISO_URL="http://172.29.48.5/VMTOOLS/3.2.0/SMTX_VMTOOLS-3.2.0-2501210639.iso"
6ISO_FILE="/tmp/vmtools.iso"
7MOUNT_POINT="/mnt/wuke-vmtools"
8
9# 1. Install required packages
10if command -v yum >/dev/null 2>&1; then
11 echo "Installing dependencies using yum..."
12 yum install -y tar bzip2
13elif command -v apt >/dev/null 2>&1; then
14 echo "Installing dependencies using apt..."
15 apt update
16 apt install -y tar bzip2
17else
18 echo "Unsupported OS: yum or apt not found."
19 exit 1
20fi
21
22# 2. Download the ISO file
23echo "Downloading VMTools ISO..."
24curl -o "$ISO_FILE" "$ISO_URL"
25
26# 3. Check if /mnt/wuke-vmtools exists
27if [ -d "$MOUNT_POINT" ]; then
28 echo "Directory $MOUNT_POINT exists, removing..."
29 umount "$MOUNT_POINT" || true
30 rm -rf "$MOUNT_POINT"
31fi
32
33echo "Creating directory $MOUNT_POINT..."
34mkdir -p "$MOUNT_POINT"
35
36# 4. Mount the ISO
37echo "Mounting ISO file to $MOUNT_POINT..."
38mount -o loop "$ISO_FILE" "$MOUNT_POINT"
39
40# 5. Execute the installation script
41echo "Running VMTools installation script..."
42bash "$MOUNT_POINT/SMTX_VM_TOOLS_INSTALL.sh"
43
44# 6. Cleanup
45echo "Cleaning up temporary files..."
46umount "$MOUNT_POINT" || true
47rm -f "$ISO_FILE"
48rm -rf "$MOUNT_POINT"
49
50echo "Installation and cleanup completed."