-
Notifications
You must be signed in to change notification settings - Fork 3
/
lxc.bash
43 lines (36 loc) · 1.06 KB
/
lxc.bash
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
function lxc_list_all() {
lxc image list
lxc network list
lxc list
}
function lxc_image_import() {
: ${2?"Usage: ${FUNCNAME[0]} <image.tar.gz> <alias>"}
lxc image import "$1" --alias $2
}
function lxc_profile_assign() {
: ${2?"Usage: ${FUNCNAME[0]} <image_name> <profile_name,...>"}
local image_name=$1
shift
lxc assign $image_name "$@"
}
function lxc_launch() {
: ${2?"Usage: ${FUNCNAME[0]} <image_name> <lxc_name>"}
lxc launch "$1" $2
}
function lxc_pull_file() {
: ${2?"Usage: ${FUNCNAME[0]} <lxc_name> <lxc_file>"}
lxc file pull $1/$2 .
}
function lxc_share_dir_home_to_home() {
: ${2?"Usage: ${FUNCNAME[0]} <lxc_name> <lxc_dir> <local_dir>"}
lxc config device add "$1" dev disk source=/home/$2 path=/home/ubuntu/$3
lxc image import "$1" --alias $2
}
function lxc_share_dir_remove() {
: ${2?"Usage: ${FUNCNAME[0]} <lxc_name> <lxc_dir>"}
lxc config device remove "$1" $2
}
function lxc_login_as_ubuntu_user() {
: ${2?"Usage: ${FUNCNAME[0]} <lxc_name>"}
lxc exec "$1" -- sudo --user ubuntu --login
}