Skip to content

Commit 37df707

Browse files
authored
Merge pull request #109 from SleepyLeslie/nebula
Add Nebula sysext
2 parents b031afe + 221736a commit 37df707

File tree

3 files changed

+127
-0
lines changed

3 files changed

+127
-0
lines changed

create_nebula_sysext.sh

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
#!/usr/bin/env bash
2+
set -euo pipefail
3+
4+
export ARCH="${ARCH-x86-64}"
5+
SCRIPTFOLDER="$(dirname "$(readlink -f "$0")")"
6+
7+
if [ $# -lt 2 ] || [ "$1" = "-h" ] || [ "$1" = "--help" ]; then
8+
echo "Usage: $0 VERSION SYSEXTNAME"
9+
echo "The script will download nebula release binaries and create a sysext squashfs image with the name SYSEXTNAME.raw in the current folder."
10+
echo "A temporary directory named SYSEXTNAME in the current folder will be created and deleted again."
11+
echo "All files in the sysext image will be owned by root."
12+
echo "To use arm64 pass 'ARCH=arm64' as environment variable (current value is '${ARCH}')."
13+
"${SCRIPTFOLDER}"/bake.sh --help
14+
exit 1
15+
fi
16+
17+
VERSION="$1"
18+
SYSEXTNAME="$2"
19+
20+
if [ "${ARCH}" = "x86_64" ] || [ "${ARCH}" = "x86-64" ]; then
21+
ARCH="amd64"
22+
elif [ "${ARCH}" = "aarch64" ]; then
23+
ARCH="arm64"
24+
fi
25+
26+
VERSION="v${VERSION#v}"
27+
28+
TARBALL="nebula-linux-${ARCH}.tar.gz"
29+
SHASUM="SHASUM256.txt"
30+
31+
TARBALL_URL="https://github.com/slackhq/nebula/releases/download/${VERSION}/${TARBALL}"
32+
SHASUM_URL="https://github.com/slackhq/nebula/releases/download/${VERSION}/${SHASUM}"
33+
34+
rm -rf "${SYSEXTNAME}"
35+
36+
TMP_DIR="${SYSEXTNAME}/tmp"
37+
mkdir -p "${TMP_DIR}"
38+
39+
curl --parallel --fail --silent --show-error --location \
40+
--output "${TMP_DIR}/${TARBALL}" "${TARBALL_URL}" \
41+
--output "${TMP_DIR}/${SHASUM}" "${SHASUM_URL}"
42+
43+
pushd "${TMP_DIR}" > /dev/null
44+
grep "${TARBALL}$" "${SHASUM}" | sha256sum -c -
45+
popd > /dev/null
46+
47+
mkdir -p "${SYSEXTNAME}/usr/bin"
48+
49+
tar --force-local -xf "${TMP_DIR}/${TARBALL}" -C "${SYSEXTNAME}/usr/bin"
50+
chmod +x "${SYSEXTNAME}/usr/bin/nebula"
51+
chmod +x "${SYSEXTNAME}/usr/bin/nebula-cert"
52+
53+
mkdir -p "${SYSEXTNAME}/usr/lib/systemd/system"
54+
cat > "${SYSEXTNAME}/usr/lib/systemd/system/nebula.service" <<-'EOF'
55+
[Unit]
56+
Description=Nebula overlay networking tool
57+
Wants=basic.target network-online.target nss-lookup.target time-sync.target
58+
After=basic.target network.target network-online.target
59+
60+
[Service]
61+
Type=notify
62+
NotifyAccess=main
63+
SyslogIdentifier=nebula
64+
ExecReload=/bin/kill -HUP $MAINPID
65+
ExecStart=/usr/bin/nebula -config /etc/nebula/config.yaml
66+
Restart=always
67+
68+
[Install]
69+
WantedBy=multi-user.target
70+
EOF
71+
72+
mkdir -p "${SYSEXTNAME}"/usr/lib/systemd/system/multi-user.target.d
73+
{ echo "[Unit]"; echo "Upholds=nebula.service"; } > "${SYSEXTNAME}"/usr/lib/systemd/system/multi-user.target.d/10-nebula.conf
74+
75+
rm -rf "${TMP_DIR}"
76+
77+
RELOAD=1 "${SCRIPTFOLDER}"/bake.sh "${SYSEXTNAME}"
78+
rm -rf "${SYSEXTNAME}"

docs/nebula.md

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
# Nebula sysext
2+
3+
This sysext ships [Nebula](https://github.com/slackhq/nebula).
4+
5+
## Usage
6+
7+
Refer to the following Butane snippet that enables Nebula v1.9.5 for an x86-64 machine with automated updates using `systemd-sysupdate`.
8+
9+
Note that you will also need to supply a [Nebula config file](https://github.com/slackhq/nebula/blob/master/examples/config.yml) at `/etc/nebula/config.yaml`, as well as necessary key files. You can embed them into the `files` section of your Butane configuration.
10+
11+
```yaml
12+
variant: flatcar
13+
version: 1.0.0
14+
15+
storage:
16+
files:
17+
- path: /opt/extensions/nebula/nebula-v1.9.5-x86-64.raw
18+
mode: 0644
19+
contents:
20+
source: https://github.com/flatcar/sysext-bakery/releases/download/latest/nebula-v1.9.5-x86-64.raw
21+
- path: /etc/sysupdate.nebula.d/nebula.conf
22+
contents:
23+
source: https://github.com/flatcar/sysext-bakery/releases/download/latest/nebula.conf
24+
- path: /etc/sysupdate.d/noop.conf
25+
contents:
26+
source: https://github.com/flatcar/sysext-bakery/releases/download/latest/noop.conf
27+
links:
28+
- path: /etc/systemd/system/multi-user.target.wants/nebula.service
29+
target: /usr/lib/systemd/system/nebula.service
30+
overwrite: true
31+
- target: /opt/extensions/nebula/nebula-v1.9.5-x86-64.raw
32+
path: /etc/extensions/nebula.raw
33+
hard: false
34+
systemd:
35+
units:
36+
- name: systemd-sysupdate.timer
37+
enabled: true
38+
- name: systemd-sysupdate.service
39+
dropins:
40+
- name: nebula.conf
41+
contents: |
42+
[Service]
43+
ExecStartPre=/usr/bin/sh -c "readlink --canonicalize /etc/extensions/nebula.raw > /tmp/nebula"
44+
ExecStartPre=/usr/lib/systemd/systemd-sysupdate -C nebula update
45+
ExecStartPost=/usr/bin/sh -c "readlink --canonicalize /etc/extensions/nebula.raw > /tmp/nebula-new"
46+
ExecStartPost=/usr/bin/sh -c "if ! cmp --silent /tmp/nebula /tmp/nebula-new; then touch /run/reboot-required; fi"
47+
```

release_build_versions.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ wasmcloud-1.2.1
2626

2727
tailscale-1.76.6
2828

29+
nebula-1.9.5
30+
2931
nvidia_runtime-v1.16.2
3032

3133
ollama-0.3.9

0 commit comments

Comments
 (0)