-
Notifications
You must be signed in to change notification settings - Fork 3
/
vlab
executable file
·53 lines (47 loc) · 1.34 KB
/
vlab
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
#!/bin/sh
set -e
# lib
. ./lib/lab.sh
[ "$(id -u)" != 0 ] && _log_error "This program must be run as root"
_usage() {
prog=$(basename "$0")
echo "Usage:"
echo " $prog [ p | profile ] [ l | list ]"
echo " $prog [ p | profile ] [ sh | show ] PROFILE_NAME"
echo " $prog [ p | profile ] [ u | use ] PROFILE_NAME"
echo " $prog [ i | images ] [ l | list ]"
echo " $prog [ i | images ] [ d | download ] [ RELEASE_NAME | URL ]"
echo " $prog [ i | images ] delete IMAGE_NAME"
echo " $prog [ i | images ] [ u | use ] IMAGE_NAME"
echo " $prog [ e | enter ] [ MODEM_NAME | CLIENT_NAME ]"
echo " $prog [ c | client ] CLIENT_NAME"
echo " $prog [ q | qemu ]"
exit 1
}
_handle_profile() {
shift
case "$1" in
l|list) _profile_list ;;
sh|show) _profile_show "$@" ;;
u|use) _profile_use "$@" ;;
*) _usage ;;
esac
}
_handle_images() {
shift
case "$1" in
l|list) _images_list ;;
d|download) _images_download "$@" ;;
delete) _images_delete "$@" ;;
u|use) _images_use "$@" ;;
*) _usage ;;
esac
}
case $1 in
p|profile) _handle_profile "$@" ;;
e|enter) _namespace_enter "$2" ;;
i|images) _handle_images "$@" ;;
q|qemu) _qemu_start ;;
c|client) _client_start "$@" ;;
*) _usage ;;
esac