-
Notifications
You must be signed in to change notification settings - Fork 6
/
config
52 lines (44 loc) · 1.41 KB
/
config
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
#!/bin/bash
# shellcheck disable=SC2034
# vim: set filetype=sh :
# Configuration file for devenv command
# This is sourced after project config,
# so this can depend on it.
# Number of times to retest if container is started and IP assigned
# RETRIES=0 means 1 attempt and 0 retries.
RETRIES=5
DEVENV_USER=${DEVENV_USER:-root}
# SSH certificate to log in to the SSH server inside the container
SSH_KEY_PATH="$HOME/.ssh/id_rsa.pub"
# Generate a MAC address using the 3 Byte Xen prefix reserved for vm's
# (00:16:3e) plus 3 Bytes more generated by hashing the container's name
#
# sha256sum outputs: "<32-byte-hash> -\n"
# > 50d858e0985ecc7f60418aaf0cc5ab587f42c2570a884095a9e8ccacd0f6545c -
# cut takes only the hash, leaving out the space and \n, but adds another \n
# > 50d858e0985ecc7f60418aaf0cc5ab587f42c2570a884095a9e8ccacd0f6545c
# tail takes the last 6 characters plus the \n, hence 7
# > f6545c
# sed captures groups of 2 chars 3 times and splits them with ':'
# > :f6:54:5c
function name_based_mac_addr() {
INPUT="$1"
echo -n "00:16:3e"
echo -n "$INPUT" |
sha256sum |
cut -d ' ' -f 1 |
tail -c 7 |
sed -r 's/([a-z0-9]{2})/:\1/g'
}
MAC_ADDR="$(name_based_mac_addr $NAME)"
LXC_CONFIG_CONTENT="\
# Network
lxc.net.0.type = veth
lxc.net.0.flags = up
lxc.net.0.link = lxcbr0
lxc.net.0.hwaddr = $MAC_ADDR
# For docker
lxc.apparmor.profile = unconfined
lxc.cgroup.devices.allow = a
lxc.cap.drop =
# Volumes"