-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvmctl
More file actions
65 lines (57 loc) · 1.11 KB
/
vmctl
File metadata and controls
65 lines (57 loc) · 1.11 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#!/bin/bash
VMWARE='/Applications/VMware\ Fusion.app/Contents/Library/vmrun'
VMPATH=~/Virtual\ Machines.localized
machine_list=(01 02 03 04)
cmd=$1
machine=$2
log_info() {
echo -e "\033[32m$1\033[0m\n"
}
hardstop() {
log_info "Machine $1 stoping..."
sh -c "$VMWARE -T fusion stop '$VMPATH/$1.vmwarevm' hard"
log_info "Machine $1 stoped"
}
hardstopall() {
for i in "${machine_list[@]}"
do
hardstop k8s$i
done
}
start() {
log_info "Machine $1 starting..."
sh -c "$VMWARE -T fusion start '$VMPATH/$1.vmwarevm' nogui"
log_info "Machine $1 started"
}
startall() {
for i in "${machine_list[@]}"
do
start k8s$i
done
}
case $cmd in
stop)
if [ -n "$machine" ]; then
hardstop $machine
else
hardstopall
fi
;;
start)
if [ -n "$machine" ]; then
start $machine
else
startall
fi
;;
*)
echo '
Usage
vmctl cmd [machine_name]
vmctl start # start all machine
vmctl start k8s01 # start spec machine named k8s01
vmctl stop # stop hard all machine
vmctl stop k8s01 # stop spec machine named k8s01
'
;;
esac