Files
ProjectOctopus/agent-go/tmp/Exsi-copy-virtual-host.sh
2024-06-14 10:37:40 +08:00

42 lines
1.2 KiB
Bash
Executable File
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/bin/sh
SourcePath=/vmfs/volumes/HardDrive
DestinationPath=/vmfs/volumes/datastore2
main() {
check_input "$@"
# 继续执行其他操作
echo "输入参数数量为1个继续执行脚本..."
local vmHostname="test-$1"
echo "准备创建 的虚拟机名称为 => ${vmHostname}"
echo ""
echo "开始创建虚拟机目录!"
mkdir -p "$SourcePath/$vmHostname"
echo "开始复制虚拟磁盘 $SourcePath/ubuntu-template => $DestinationPath/$vmHostname"
cp "$SourcePath/ubuntu-template/ubuntu-200406-aliyun-pure.mf" "$DestinationPath/$vmHostname/$vmHostname.mf"
cp "$SourcePath/ubuntu-template/ubuntu-200406-aliyun-pure.ovf" "$DestinationPath/$vmHostname/$vmHostname.ovf"
echo ""
echo "开始复制 $SourcePath/ubuntu-template/ubuntu-200406-aliyun-pure-1.vmdk ..."
cp "$SourcePath/ubuntu-template/ubuntu-200406-aliyun-pure-1.vmdk" "$DestinationPath/$vmHostname/$vmHostname.vmdk"
echo ""
echo "复制完成!"
echo "检查复制结果 ↓↓↓↓↓↓"
ls "$SourcePath/$vmHostname"
}
check_input() {
if [ "$#" -ne 1 ]; then
echo "输入参数数量必须为1个"
exit 1
fi
}
main "$@"