From 3ba6d8fcb2b606ae9a79fa1efd2176a6d4a84541 Mon Sep 17 00:00:00 2001 From: Conor Schaefer Date: Fri, 12 Nov 2021 17:07:02 -0800 Subject: [PATCH] Use Debian for cloud image When Debian 10 was stable, the kernel wasn't new enough to include Wireguard, so I used Ubuntu LTS. That's changed, since Debian 11 now ships with the 5.10 kernel series, which includes Wireguard by default. --- CHANGELOG.md | 3 ++- TODO.md | 2 +- files/cloudinit.cfg | 1 + src/doctor.rs | 9 +++++++-- src/server/mod.rs | 2 +- tools/test-runner | 23 +++++++++++++++++++---- 6 files changed, 31 insertions(+), 9 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0b45bf3..c63cc1a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,7 +1,8 @@ # Innisfree changelog -## 0.2.16 (in progress) +## 0.2.16 +* Use Debian Stable (11 Bullseye), rather than Ubuntu LTS, for cloud image * Bugfix: add all API pubkeys, not just the first * Dev only: don't error out on tests if no API key is present * Dev only: prune unused fields from structs (thanks, clippy!) diff --git a/TODO.md b/TODO.md index f894003..5f3891d 100644 --- a/TODO.md +++ b/TODO.md @@ -75,4 +75,4 @@ * [x] Update cli output for ssh to recommend name flag * [ ] Make IP address pairs deterministic (via ipgen) * [ ] Create wg interfaces early -* [ ] Switch from Ubuntu LTS to Debian Stable (the freest OS <3) +* [x] Switch from Ubuntu LTS to Debian Stable (the freest OS <3) diff --git a/files/cloudinit.cfg b/files/cloudinit.cfg index 25082ed..42c20da 100644 --- a/files/cloudinit.cfg +++ b/files/cloudinit.cfg @@ -70,6 +70,7 @@ write_files: packages: - nginx + - sudo - unattended-upgrades - wireguard - wireguard-tools diff --git a/src/doctor.rs b/src/doctor.rs index b1ada02..1e856f6 100644 --- a/src/doctor.rs +++ b/src/doctor.rs @@ -48,14 +48,19 @@ pub fn distro_support() -> Result { "Debian Stable Buster 10 doesn't ship wireguard by default, but it's available in buster-backports. See for details: https://www.wireguard.com/install/" ); + } else if os_release.contains("ID=debian") && os_release.contains("VERSION_CODENAME=bullseye") { + info!( + "Debian Stable Bullseye 11 supports Wireguard out of the box. \ + Run 'apt-get install wireguard wireguard-tools'." + ); } else if os_release.contains("ID=ubuntu") && os_release.contains("VERSION_CODENAME=focal") { info!( "Ubuntu Focal 20.04 supports Wireguard out of the box. \ Run 'apt-get install wireguard wireguard-tools'." ); - } else if os_release.contains("ID=fedora") && os_release.contains("VERSION_CODENAME=33") { + } else if os_release.contains("ID=fedora") && os_release.contains("VERSION_CODENAME=34") { info!( - "Fedora 33 supports Wireguard out of the box. \ + "Fedora 34 supports Wireguard out of the box. \ Run 'dnf install wireguard wireguard-tools'." ); } else { diff --git a/src/server/mod.rs b/src/server/mod.rs index 9e50382..85760f0 100644 --- a/src/server/mod.rs +++ b/src/server/mod.rs @@ -29,7 +29,7 @@ use crate::wg::WireguardManager; const DO_REGION: &str = "sfo2"; const DO_SIZE: &str = "s-1vcpu-1gb"; -const DO_IMAGE: &str = "ubuntu-20-04-x64"; +const DO_IMAGE: &str = "debian-11-x64"; const DO_API_BASE_URL: &str = "https://api.digitalocean.com/v2/droplets"; // Manager class, wraps a cloudserver VM type, such as Droplet, diff --git a/tools/test-runner b/tools/test-runner index e8342d5..7408137 100755 --- a/tools/test-runner +++ b/tools/test-runner @@ -18,12 +18,27 @@ netstat -lnp | grep -iF "$local_port" | perl -lanE 'say $F[-1]' | grep -oP '^\d+ | xargs -d '\n' -r kill dst_dir="$(mktemp -d)" -echo "Hello, world!" > "${dst_dir}/index.html" +test_string="Hello, world! $(uuid)" +echo "$test_string" > "${dst_dir}/index.html" +trap 'rm -rf "$dst_dir"' EXIT cargo build -cargo run -- up -p "$local_port" +cargo run -- up -p "$local_port" & + +# wait for server to come up +sleep 90s + python3 -m http.server --directory "$dst_dir" "$local_port" & sleep 1 curl "http://localhost:${local_port}" || true -curl --connect-timeout 3 --max-time 5 "http://$(cargo run -- ip):${local_port}" -wait +result_string="$(curl -s --connect-timeout 3 --max-time 5 "http://$(cargo run -- ip):${local_port}")" +if [[ "$test_string" != "$result_string" ]] ; then + echo "ERROR: Failed to find test string: '$test_string'" >&2 + exit 1 +else + echo "SUCCESS: Found test string: '$test_string'" >&2 + echo "Cleaning up..." >&2 + # use SIGINT to kill because I haven't figured out how to catch other signals + jobs -p | xargs -r kill -s SIGINT + exit 0 +fi