Skip to content

Commit 88fec4c

Browse files
committed
update scripts and make note about BTRFS
1 parent ebb3940 commit 88fec4c

23 files changed

+1013
-41
lines changed

src/core-switch/scripts/build-sme-kernel.sh

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,21 +8,17 @@ sudo apt-get -y build-dep linux
88
mkdir -p ~/kernel
99
cd ~/kernel
1010

11-
rm -rf linux-${LINUX_VERSION}
11+
rm -rf linux-* linux_*
1212
apt source linux
13-
cd linux-${LINUX_VERSION}
13+
cd linux-*
1414

1515
cat > debian/config/amd64/config.sme << EOF
1616
CONFIG_AMD_MEM_ENCRYPT=y
1717
CONFIG_MODULE_ALLOW_MISSING_NAMESPACE_IMPORTS=n
1818
CONFIG_MODULE_COMPRESS_ZSTD=y
1919
CONFIG_MODULE_SIG=y
20-
CONFIG_MODULE_SIG_ALL=y
20+
CONFIG_MODULE_SIG_ALL=n
2121
CONFIG_MODULE_SIG_FORCE=n
22-
CONFIG_MODULE_SIG_HASH="sha256"
23-
CONFIG_MODULE_SIG_KEY="/var/lib/shim-signed/mok/MOK.bundle.pem"
24-
CONFIG_MODULE_SIG_KEY_TYPE_RSA=y
25-
CONFIG_MODULE_SIG_SHA256=y
2622
CONFIG_SYSTEM_TRUSTED_KEYS="/var/lib/shim-signed/mok/MOK.pem"
2723
EOF
2824

@@ -51,8 +47,13 @@ configs:
5147
amd64/config.sme
5248
5349
[sme-amd64_build]
54-
signed-code: true
50+
signed-code: false
5551
EOF
5652

5753
debian/bin/gencontrol.py
5854
fakeroot make -f debian/rules.gen binary-arch_amd64_none_sme-amd64 -j$(nproc)
55+
56+
cd ~
57+
rm kernel/*dbg*.deb
58+
59+
tar czvf kernel.tgz kernel/linux-image-*-sme-amd64_*_amd64.deb kernel/linux-headers-*-sme-amd64_*_amd64.deb

src/core-switch/scripts/collect.sh

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ sudo tar czvf ~/install.bundle/configuration.tgz \
1919
etc/network/interfaces \
2020
etc/ssh/sshd_config.d/10-no-passwords.conf \
2121
etc/sysctl.d/10-disable-ipv6.conf \
22+
opt/nomad/docker.json
2223

2324
sudo tar czvf ~/install.bundle/mok.tgz \
2425
var/lib/shim-signed/mok
@@ -31,7 +32,8 @@ tar czvf ~/install.bundle/$USER.tgz \
3132
.zshenv \
3233
.p10k.zsh \
3334

34-
cp -v ~/install{,.bundle}/linux-5.10.0-15-sme-amd64.tgz
35+
cp -v ~{,/install.bundle}/secrets.tgz
36+
cp -v ~{,/install.bundle}/kernel.tgz
3537
cp -v ~/install{,.bundle}/ldap.tgz
3638
cp -vR ~/install{,.bundle}/patch
3739
cp -vR ~/install{,.bundle}/scripts
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#!/usr/bin/bash
2+
3+
if [[ "$DEBUG" == "1" ]]
4+
then
5+
set -euxo pipefail
6+
else
7+
set -euo pipefail
8+
fi
9+
10+
echo $(vault kv get -mount=secret -field=value dockerhub_read_token) | \
11+
docker login \
12+
--username $(vault kv get -mount=secret -field=value dockerhub_username) \
13+
--password-stdin
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
#!/usr/bin/bash
2+
3+
set -euo pipefail
4+
5+
sudo apt-get -y install sbsigntool
6+
7+
cd ~
8+
tar xzvf kernel.tgz
9+
10+
cd ~/kernel
11+
sudo apt-get -y install ./linux-image-*-sme-amd64_*_amd64.deb
12+
sudo apt-get -y install ./linux-headers-*-sme-amd64_*_amd64.deb
13+
14+
VERSION=$(echo linux-image-*-sme-amd64_*_amd64.deb | sed -E 's/linux-image-(.+-sme-amd64)_.+_amd64\.deb/\1/')
15+
SHORT_VERSION=$(echo $VERSION | cut -d'.' -f1-2)
16+
MODULES_DIR=/lib/modules/${VERSION}
17+
18+
PATH_VERSION=$(echo linux-image-*-sme-amd64_*_amd64.deb | sed -E 's/linux-image-.+-sme-amd64_(.+)-.+_amd64\.deb/\1/')
19+
20+
echo -n "Enter MOK passphrase: "
21+
read -s KBUILD_SIGN_PIN
22+
export KBUILD_SIGN_PIN
23+
24+
for MODULE in $(find ${MODULES_DIR} -type f -name '*.ko*'); do
25+
(modinfo "${MODULE}" | rg "signer:\s+core") || \
26+
(echo "signing ${MODULE}"; sudo --preserve-env=KBUILD_SIGN_PIN ${MODULES_DIR}/build/scripts/sign-file sha256 /var/lib/shim-signed/mok/MOK.priv /var/lib/shim-signed/mok/MOK.der "${MODULE}")
27+
done
28+
29+
sudo grub-set-default "Advanced options for Debian GNU/Linux>Debian GNU/Linux, with Linux ${VERSION}"
30+
sudo update-grub
31+
32+
cd /var/lib/shim-signed/mok
33+
sudo sbsign --key MOK.priv --cert MOK.pem "/boot/vmlinuz-${VERSION}" --output "/boot/vmlinuz-${VERSION}.tmp"
34+
cd ~
35+
sudo mv "/boot/vmlinuz-${VERSION}.tmp" "/boot/vmlinuz-${VERSION}"
36+
sudo dracut -f --regenerate-all -v
37+
38+
echo "now you'll need to reboot and configure/update clevis/luks, after typing your passwords"
39+
echo "for example,"
40+
echo " sudo clevis luks bind -d /dev/sda3 tpm2 '{\"pcr_bank\":\"sha256\",\"pcr_ids\":\"0,1,2,3,4,5,6,7\"}'"
41+
echo " sudo clevis luks bind -d /dev/sda4 tpm2 '{\"pcr_bank\":\"sha256\",\"pcr_ids\":\"0,1,2,3,4,5,6,7\"}'"
42+
echo " sudo clevis luks bind -d /dev/md0 tpm2 '{\"pcr_bank\":\"sha256\",\"pcr_ids\":\"0,1,2,3,4,5,6,7\"}'"
43+
echo "or"
44+
echo " sudo clevis luks unbind -d /dev/sda3 -s 1"
45+
echo " sudo clevis luks unbind -d /dev/sda4 -s 1"
46+
echo " sudo clevis luks unbind -d /dev/md0 -s 1"
47+
echo " sudo clevis luks bind -d /dev/sda3 tpm2 '{\"pcr_bank\":\"sha256\",\"pcr_ids\":\"0,1,2,3,4,5,6,7\"}'"
48+
echo " sudo clevis luks bind -d /dev/sda4 tpm2 '{\"pcr_bank\":\"sha256\",\"pcr_ids\":\"0,1,2,3,4,5,6,7\"}'"
49+
echo " sudo clevis luks bind -d /dev/md0 tpm2 '{\"pcr_bank\":\"sha256\",\"pcr_ids\":\"0,1,2,3,4,5,6,7\"}'"
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
#!/usr/bin/bash
2+
3+
if [[ "$DEBUG" == "1" ]]
4+
then
5+
set -euxo pipefail
6+
else
7+
set -euo pipefail
8+
fi
9+
10+
sudo apt-get update
11+
sudo apt-get -y install \
12+
ca-certificates \
13+
curl \
14+
gnupg \
15+
lsb-release
16+
17+
sudo mkdir -p /etc/apt/keyrings
18+
if [[ ! -f /etc/apt/keyrings/docker.gpg ]]
19+
then
20+
curl -fsSL https://download.docker.com/linux/debian/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg
21+
echo \
22+
"deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/debian $(lsb_release -cs) stable" | \
23+
sudo tee /etc/apt/sources.list.d/docker.list
24+
fi
25+
26+
sudo mkdir -p /etc/docker
27+
sudo tee /etc/docker/daemon.json << EOF
28+
{
29+
"bip": "10.1.0.1/16"
30+
}
31+
EOF
32+
33+
sudo apt-get update
34+
sudo apt-get -y install docker-ce docker-ce-cli containerd.io docker-compose-plugin
35+
36+
sudo iptables -I DOCKER-USER -j ACCEPT
37+
38+
sudo tee /etc/iptables.up.rules << EOF
39+
*filter
40+
:DOCKER-USER - [0:0]
41+
-A DOCKER-USER -j ACCEPT
42+
COMMIT
43+
EOF
44+
45+
sudo tee /etc/network/if-pre-up.d/iptables << EOF
46+
#!/bin/sh
47+
/sbin/iptables-restore < /etc/iptables.up.rules
48+
EOF
49+
sudo chmod +x /etc/network/if-pre-up.d/iptables
50+
51+
sudo sysctl fs.inotify.max_user_watches=65536
52+
sudo sysctl fs.inotify.max_user_instances=512
53+
54+
sudo tee /etc/sysctl.d/25-inotify.conf << EOF
55+
fs.inotify.max_user_watches = 65536
56+
fs.inotify.max_user_instances = 512
57+
EOF
Lines changed: 142 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,142 @@
1+
#!/usr/bin/bash
2+
3+
if [[ "$DEBUG" == "1" ]]
4+
then
5+
set -euxo pipefail
6+
else
7+
set -euo pipefail
8+
fi
9+
10+
sudo apt-get -y install consul
11+
12+
sudo tee /etc/sysctl.d/20-bridge-iptables.conf << EOF
13+
net.bridge.bridge-nf-call-arptables = 1
14+
net.bridge.bridge-nf-call-iptables = 1
15+
EOF
16+
17+
sudo sysctl net.bridge.bridge-nf-call-arptables=1
18+
sudo sysctl net.bridge.bridge-nf-call-iptables=1
19+
20+
cd ~/src
21+
go install github.com/containernetworking/cni/cnitool@latest
22+
curl -L -o cni-plugins.tgz "https://github.com/containernetworking/plugins/releases/download/v1.0.0/cni-plugins-linux-$( [ $(uname -m) = aarch64 ] && echo arm64 || echo amd64)"-v1.0.0.tgz
23+
sudo mkdir -p /opt/cni/bin
24+
sudo tar -C /opt/cni/bin -xzf cni-plugins.tgz
25+
26+
sudo tee /etc/consul.d/consul.hcl << EOF
27+
# Full configuration options can be found at https://www.consul.io/docs/agent/config
28+
29+
# datacenter
30+
# This flag controls the datacenter in which the agent is running. If not provided,
31+
# it defaults to "dc1". Consul has first-class support for multiple datacenters, but
32+
# it relies on proper configuration. Nodes in the same datacenter should be on a
33+
# single LAN.
34+
datacenter = "dc1"
35+
36+
# data_dir
37+
# This flag provides a data directory for the agent to store state. This is required
38+
# for all agents. The directory should be durable across reboots. This is especially
39+
# critical for agents that are running in server mode as they must be able to persist
40+
# cluster state. Additionally, the directory must support the use of filesystem
41+
# locking, meaning some types of mounted folders (e.g. VirtualBox shared folders) may
42+
# not be suitable.
43+
data_dir = "/opt/consul"
44+
45+
# client_addr
46+
# The address to which Consul will bind client interfaces, including the HTTP and DNS
47+
# servers. By default, this is "127.0.0.1", allowing only loopback connections. In
48+
# Consul 1.0 and later this can be set to a space-separated list of addresses to bind
49+
# to, or a go-sockaddr template that can potentially resolve to multiple addresses.
50+
client_addr = "127.0.0.1"
51+
52+
# ui
53+
# Enables the built-in web UI server and the required HTTP routes. This eliminates
54+
# the need to maintain the Consul web UI files separately from the binary.
55+
# Version 1.10 deprecated ui=true in favor of ui_config.enabled=true
56+
ui_config{
57+
enabled = false
58+
}
59+
60+
# server
61+
# This flag is used to control if an agent is in server or client mode. When provided,
62+
# an agent will act as a Consul server. Each Consul cluster must have at least one
63+
# server and ideally no more than 5 per datacenter. All servers participate in the Raft
64+
# consensus algorithm to ensure that transactions occur in a consistent, linearizable
65+
# manner. Transactions modify cluster state, which is maintained on all server nodes to
66+
# ensure availability in the case of node failure. Server nodes also participate in a
67+
# WAN gossip pool with server nodes in other datacenters. Servers act as gateways to
68+
# other datacenters and forward traffic as appropriate.
69+
server = true
70+
71+
# Bind addr
72+
# You may use IPv4 or IPv6 but if you have multiple interfaces you must be explicit.
73+
#bind_addr = "[::]" # Listen on all IPv6
74+
#bind_addr = "0.0.0.0" # Listen on all IPv4
75+
bind_addr = "127.0.0.1"
76+
#
77+
# Advertise addr - if you want to point clients to a different address than bind or LB.
78+
advertise_addr = "127.0.0.1"
79+
80+
# Enterprise License
81+
# As of 1.10, Enterprise requires a license_path and does not have a short trial.
82+
#license_path = "/etc/consul.d/consul.hclic"
83+
84+
# bootstrap_expect
85+
# This flag provides the number of expected servers in the datacenter. Either this value
86+
# should not be provided or the value must agree with other servers in the cluster. When
87+
# provided, Consul waits until the specified number of servers are available and then
88+
# bootstraps the cluster. This allows an initial leader to be elected automatically.
89+
# This cannot be used in conjunction with the legacy -bootstrap flag. This flag requires
90+
# -server mode.
91+
#bootstrap_expect=1
92+
93+
# encrypt
94+
# Specifies the secret key to use for encryption of Consul network traffic. This key must
95+
# be 32-bytes that are Base64-encoded. The easiest way to create an encryption key is to
96+
# use consul keygen. All nodes within a cluster must share the same encryption key to
97+
# communicate. The provided key is automatically persisted to the data directory and loaded
98+
# automatically whenever the agent is restarted. This means that to encrypt Consul's gossip
99+
# protocol, this option only needs to be provided once on each agent's initial startup
100+
# sequence. If it is provided after Consul has been initialized with an encryption key,
101+
# then the provided key is ignored and a warning will be displayed.
102+
#encrypt = "..."
103+
104+
# retry_join
105+
# Similar to -join but allows retrying a join until it is successful. Once it joins
106+
# successfully to a member in a list of members it will never attempt to join again.
107+
# Agents will then solely maintain their membership via gossip. This is useful for
108+
# cases where you know the address will eventually be available. This option can be
109+
# specified multiple times to specify multiple agents to join. The value can contain
110+
# IPv4, IPv6, or DNS addresses. In Consul 1.1.0 and later this can be set to a go-sockaddr
111+
# template. If Consul is running on the non-default Serf LAN port, this must be specified
112+
# as well. IPv6 must use the "bracketed" syntax. If multiple values are given, they are
113+
# tried and retried in the order listed until the first succeeds. Here are some examples:
114+
#retry_join = ["consul.domain.internal"]
115+
#retry_join = ["10.0.4.67"]
116+
#retry_join = ["[::1]:8301"]
117+
#retry_join = ["consul.domain.internal", "10.0.4.67"]
118+
# Cloud Auto-join examples:
119+
# More details - https://www.consul.io/docs/agent/cloud-auto-join
120+
#retry_join = ["provider=aws tag_key=... tag_value=..."]
121+
#retry_join = ["provider=azure tag_name=... tag_value=... tenant_id=... client_id=... subscription_id=... secret_access_key=..."]
122+
#retry_join = ["provider=gce project_name=... tag_value=..."]
123+
124+
ports {
125+
grpc = 8502
126+
}
127+
128+
connect {
129+
enabled = true
130+
}
131+
EOF
132+
133+
sudo tee /etc/consul.d/consul-acl.hcl << EOF
134+
acl {
135+
enabled = true
136+
default_policy = "deny"
137+
down_policy = "extend-cache"
138+
tokens {
139+
agent = "AGENT_TOKEN"
140+
}
141+
}
142+
EOF
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
node_prefix "" {
2+
policy = "write"
3+
}
4+
service_prefix "" {
5+
policy = "read"
6+
}
7+
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
agent_prefix "" {
2+
policy = "read"
3+
}
4+
5+
node_prefix "" {
6+
policy = "read"
7+
}
8+
9+
service_prefix "" {
10+
policy = "write"
11+
}
12+
13+
key_prefix "" {
14+
policy = "read"
15+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
agent_prefix "" {
2+
policy = "read"
3+
}
4+
5+
node_prefix "" {
6+
policy = "read"
7+
}
8+
9+
service_prefix "" {
10+
policy = "write"
11+
}
12+
13+
acl = "write"
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
service "vault" { policy = "write" }
2+
key_prefix "vault/" { policy = "write" }
3+
agent_prefix "" { policy = "read" }
4+
session_prefix "" { policy = "write" }

0 commit comments

Comments
 (0)