Skip to content

Commit

Permalink
Feature/cli clearnet (#2789)
Browse files Browse the repository at this point in the history
* add support for ACME cert acquisition

* add support for modifying hosts for a package

* misc fixes

* more fixes

* use different port for lan clearnet than wan clearnet

* fix chroot-and-upgrade always growing

* bail on failure

* wip

* fix alpn auth

* bump async-acme

* fix cli

* add barebones documentation

* add domain to hostname info
  • Loading branch information
dr-bonez authored Nov 21, 2024
1 parent ed8a7ee commit fefa88f
Show file tree
Hide file tree
Showing 23 changed files with 1,585 additions and 214 deletions.
40 changes: 40 additions & 0 deletions CLEARNET.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# Setting up clearnet for a service interface

NOTE: this guide is for HTTPS only! Other configurations may require a more bespoke setup depending on the service. Please consult the service documentation or the Start9 Community for help with non-HTTPS applications

## Initialize ACME certificate generation

The following command will register your device with an ACME certificate provider, such as letsencrypt

This only needs to be done once.

```
start-cli net acme init --provider=letsencrypt --contact="mailto:me@drbonez.dev"
```

- `provider` can be `letsencrypt`, `letsencrypt-staging` (useful if you're doing a lot of testing and want to avoid being rate limited), or the url of any provider that supports the [RFC8555](https://datatracker.ietf.org/doc/html/rfc8555) ACME api
- `contact` can be any valid contact url, typically `mailto:` urls. it can be specified multiple times to set multiple contacts

## Whitelist a domain for ACME certificate acquisition

The following command will tell the OS to use ACME certificates instead of system signed ones for the provided url. In this example, `testing.drbonez.dev`

This must be done for every domain you wish to host on clearnet.

```
start-cli net acme domain add "testing.drbonez.dev"
```

## Forward clearnet port

Go into your router settings, and map port 443 on your router to port 5443 on your start-os device. This one port should cover most use cases

## Add domain to service host

The following command will tell the OS to route https requests from the WAN to the provided hostname to the specified service. In this example, we are adding `testing.drbonez.dev` to the host `ui-multi` on the package `hello-world`. To see a list of available host IDs for a given package, run `start-cli package host <PACKAGE> list`

This must be done for every domain you wish to host on clearnet.

```
start-cli package host hello-world address ui-multi add testing.drbonez.dev
```
8 changes: 7 additions & 1 deletion build/lib/scripts/chroot-and-upgrade
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ umount /media/startos/next/dev
umount /media/startos/next/sys
umount /media/startos/next/proc
umount /media/startos/next/boot
umount /media/startos/next/media/startos/root

if [ "$CHROOT_RES" -eq 0 ]; then

Expand All @@ -86,7 +87,12 @@ if [ "$CHROOT_RES" -eq 0 ]; then

echo 'Upgrading...'

time mksquashfs /media/startos/next /media/startos/images/next.squashfs -b 4096 -comp gzip
if ! time mksquashfs /media/startos/next /media/startos/images/next.squashfs -b 4096 -comp gzip; then
umount -R /media/startos/next
umount -R /media/startos/upper
rm -rf /media/startos/upper /media/startos/next
exit 1
fi
hash=$(b3sum /media/startos/images/next.squashfs | head -c 32)
mv /media/startos/images/next.squashfs /media/startos/images/${hash}.rootfs
ln -rsf /media/startos/images/${hash}.rootfs /media/startos/config/current.rootfs
Expand Down
3 changes: 2 additions & 1 deletion build/lib/scripts/prune-images
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,11 @@ if [ -h /media/startos/config/current.rootfs ] && [ -e /media/startos/config/cur
echo 'Pruning...'
current="$(readlink -f /media/startos/config/current.rootfs)"
while [[ "$(df -B1 --output=avail --sync /media/startos/images | tail -n1)" -lt "$needed" ]]; do
to_prune="$(ls -t1 /media/startos/images/*.rootfs /media/startos/images/*.squashfs | grep -v "$current" | tail -n1)"
to_prune="$(ls -t1 /media/startos/images/*.rootfs /media/startos/images/*.squashfs 2> /dev/null | grep -v "$current" | tail -n1)"
if [ -e "$to_prune" ]; then
echo " Pruning $to_prune"
rm -rf "$to_prune"
sync
else
>&2 echo "Not enough space and nothing to prune!"
exit 1
Expand Down
Loading

0 comments on commit fefa88f

Please sign in to comment.