-
Notifications
You must be signed in to change notification settings - Fork 1
/
vcamp.sh
executable file
·190 lines (182 loc) · 4.82 KB
/
vcamp.sh
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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
#!/bin/bash
base=$(dirname $0)
dest=$base
vm_name="VCamp"
part_name="BOOTCAMP"
guest_toggle=0
efi_toggle=0
bit_mode=_64
icns=$base/applet.icns
create=0
remove=0
restore=0
valid=0
if [ $# -eq 0 ]; then
/bin/bash $base/bin/usage.sh
exit 0
else
case $1 in
create)
create=1
# check if there is an 2 argument
if [ -z $2 ]; then
echo ""
echo "create:"
echo -e "\t create\t default \t\t runs default options"
echo ""
echo -e "\t create\t [-n|--name <string>] \t give your VM a name \t default name is 'VCamp"
echo -e "\t create\t [-p|--dest=<dest>] \t set a dest for vdmk \t default is in VirtualCamp/machines/"
echo -e "\t create\t [-g|--guest <bool>] \t use'Guest Additions' \t default: true"
exit 0
elif [[ $2 = "default" ]]; then
/bin/bash $base/bin/create.sh $base $dest $vm_name $part_name \
1 1 $bit_mode $icns # efi and guest on
exit 0
else
while [[ $# -gt 0 ]]
do
key="$1"
case $key in
-n|--name)
valid=1
if [ -z $2 ]; then
echo "Please provide name for your VM"
exit 0
else
vm_name=$2
fi
shift
;;
-d|--dest)
valid=1
if [ ! -d $2 ]; then
echo "Please provide a proper destination for VM"
exit 0
else
valid=1
dest=$2
fi
shift
;;
-e|--efi)
valid=1
efi_toggle=1
shift
;;
-g|--guest)
valid=1
guest_toggle=1
shift
;;
-b|--bit32)
valid=1
bit_mode=""
shift
;;
-i|--icns)
valid=1
if [[ -f $2 && "$2" == *"icns"* ]]; then
icns=$2
else
echo "Please provide a proper ICNS file"
exit 0
fi
shift
;;
esac
shift
done
fi
;;
remove)
remove=1
if [ -z $2 ]; then
echo ""
echo "remove:"
echo -e "\tremove\t default \t\t runs default options"
echo ""
echo -e "\tremove\t [-n|--name <string>] \t select your VM to delete \t default VM is 'VCamp'"
echo -e "\tremove\t [-p|--dest=<dest>] \t set a dest for vdmk \t\t default is in VirtualCamp/machines/"
exit 0
elif [[ $2 = "default" ]]; then
/bin/bash $base/bin/remove.sh $dest $vm_name $part_name
exit 0
else
while [[ $# -gt 0 ]]
do
key="$1"
case $key in
-n|--name)
if [ -z $2 ]; then
echo "Please provide name of VM to erase | default VCamp"
exit 0
else
valid=1
vm_name=$2
fi
shift
;;
-d|--dest)
if [ ! -d $2 ]; then
echo "Please provide dest of VM to erase | default search dest $base/machines/"
exit 0
else
valid=1
dest=$2
fi
shift
;;
esac
shift
done
fi
;;
restore)
if [ -z $2 ]; then
echo ""
echo "restore:"
echo -e "\trestore\t default \t\t runs default options"
echo -e "\trestore\t [-p|--part <string>] \t select the partition you wish to restore\t default partition is 'VCamp'"
exit 0
else
while [[ $# -gt 0 ]]
do
key="$1"
case $key in
default)
echo "Restoring "$part_name" permissions"
/bin/bash $base/bin/restore.sh $part_name
shift
;;
-p|--part)
if [ -z $2 ]; then
echo "Please enter partition permissions you which to restore"
exit 0
else
part_name=$2
echo "Restoring "$part_name" permissions"
/bin/bash $base/bin/restore.sh $part_name
fi
shift
;;
esac
shift
done
fi
exit 0
;;
esac
fi
if [ $valid -gt 0 ]; then
if [ $create -gt 0 ]; then
/bin/bash $base/bin/create.sh $base $dest $vm_name $part_name \
$efi_toggle $guest_toggle $bit_mode $icns
fi
if [ $remove -gt 0 ]; then
/bin/bash $base/bin/remove.sh $dest $vm_name $part_name
fi
else
echo "Invalid usage. Read usage details below"
/bin/bash $base/bin/usage.sh
exit 0
fi