Skip to content

Commit

Permalink
Update readme
Browse files Browse the repository at this point in the history
  • Loading branch information
nateinaction committed Jul 17, 2024
1 parent 018a946 commit 318d483
Show file tree
Hide file tree
Showing 6 changed files with 126 additions and 77 deletions.
48 changes: 48 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
name: ci

on:
pull_request:
push:
branches:
- main

jobs:
gomodtidy:
name: tidy
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: stable
- name: go mod tidy
run: go mod tidy
- name: git diff
run: |
git diff --exit-code --quiet
if [ $? -ne 0 ]; then
echo "Please run 'go mod tidy' and commit the changes"
exit 1
fi
golangci:
name: lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: stable
- name: golangci-lint
uses: golangci/golangci-lint-action@v6
with:
version: v1.59
gotest:
name: test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: stable
- name: go test
run: go test -v -race -cover ./...
26 changes: 0 additions & 26 deletions .github/workflows/gomodtidy.yaml

This file was deleted.

22 changes: 0 additions & 22 deletions .github/workflows/lint.yaml

This file was deleted.

19 changes: 0 additions & 19 deletions .github/workflows/test.yaml

This file was deleted.

80 changes: 74 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,80 @@
# PiKVM Tailscale Cert Renewer
# PiKVM Tailscale Certificate Renewer

This is a tool to automatically renew tailscale certs for a PiKVM
[![License](https://img.shields.io/badge/license-MIT-blue.svg)](LICENSE)
<!-- ![CI](https://github.com/nateinaction/pikvm-tailscale-cert-renewer/actions/workflows/ci.yaml/badge.svg) -->

This tool assumes you have setup your PiKVM and the [tailscale integration](https://docs.pikvm.org/tailscale/) using the [official docs](https://docs.pikvm.org/). This tool is designed around the following information from the docs:
>If you have a certificate (making a cert falls outside the scope of PiKVM - please reference OpenSSL documentation or use Let's Encrypt), replace keys in /etc/kvmd/nginx/ssl, edit /etc/kvmd/nginx/ssl.conf if necessary and restart kvmd-nginx service. *[PiKVM Common Questions](https://docs.pikvm.org/faq/#common-questions)*
Automatically renew Tailscale SSL certificates for your PiKVM with ease!

This tool automatically discovers your tailscale domain, creates and renews certs for that domain, sets the cert path in the nginx config, and restarts NGINX.
## 🚀 Features

```
- **Automatic Discovery**: Detects your Tailscale domain without manual configuration
- **Certificate Management**: Creates and renews certificates seamlessly
- **NGINX Integration**: Updates NGINX configuration and restarts the service automatically
- **Zero Maintenance**: Set it and forget it - your certs will always be up-to-date

## 🛠 Prerequisites

This tool assumes you have:
1. Set up your PiKVM
2. Configured the [Tailscale integration](https://docs.pikvm.org/tailscale/) using the [official PiKVM documentation](https://docs.pikvm.org/)

## 📦 Installation

To install, run the following command on your PiKVM:

```bash
curl -L -s "https://raw.githubusercontent.com/nateinaction/pikvm-tailscale-cert-renewer/main/install.sh" | bash
```

## 🔍 Monitoring

After installation, the certificate renewer runs as a system service. You can monitor its status using systemctl:

```bash
systemctl status pikvm-tailscale-cert-renewer
```

For more detailed logs, use journalctl:

```bash
journalctl -u pikvm-tailscale-cert-renewer
```

## 🎬 Covered Scenarios

The certificate renewer primarily operates in an idle state but actively watches for the following scenarios:
- Tailscale domain changes
- Certificate mismatchs between Tailscale and filesystem caused by
- Certificate revocation
- Certificate expiry
- Missing certificate files
- Modified certificate files
- NGINX configuration changes

## 📋 Example Log
Here's an example log output when a Tailscale domain change occurs:

```
Jul 17 04:25:31 pikvm pikvm-tailscale-cert-renewer[11845]: 2024/07/17 04:25:31 WARN cert file does not exist path=/etc/kvmd/nginx/ssl/my-domain.mytailnet.ts.net.crt
Jul 17 04:25:46 pikvm pikvm-tailscale-cert-renewer[11845]: 2024/07/17 04:25:46 INFO filesystem mode changed to read/write
Jul 17 04:25:46 pikvm pikvm-tailscale-cert-renewer[11845]: 2024/07/17 04:25:46 INFO wrote cert file path=/etc/kvmd/nginx/ssl/my-domain.mytailnet.ts.net.crt
Jul 17 04:25:46 pikvm pikvm-tailscale-cert-renewer[11845]: 2024/07/17 04:25:46 INFO wrote key file path=/etc/kvmd/nginx/ssl/my-domain.mytailnet.ts.net.key
Jul 17 04:25:46 pikvm pikvm-tailscale-cert-renewer[11845]: 2024/07/17 04:25:46 INFO filesystem mode changed to read-only
Jul 17 04:25:46 pikvm pikvm-tailscale-cert-renewer[11845]: 2024/07/17 04:25:46 WARN cert or key line not found in nginx config path=/etc/kvmd/nginx/ssl.conf
Jul 17 04:25:46 pikvm pikvm-tailscale-cert-renewer[11845]: 2024/07/17 04:25:46 INFO filesystem mode changed to read/write
Jul 17 04:25:46 pikvm pikvm-tailscale-cert-renewer[11845]: 2024/07/17 04:25:46 INFO wrote to nginx ssl config path=/etc/kvmd/nginx/ssl.conf
Jul 17 04:25:46 pikvm pikvm-tailscale-cert-renewer[11845]: 2024/07/17 04:25:46 INFO filesystem mode changed to read-only
Jul 17 04:25:48 pikvm pikvm-tailscale-cert-renewer[11845]: 2024/07/17 04:25:48 INFO kvmd-nginx restarted
```

## 📝 License
This project is licensed under the MIT License - see the LICENSE file for details.

## 🤝 Contributing
Contributions, issues, and feature requests are welcome! Feel free to check the issues page.

## 🌟 Show your support
Give a ⭐️ if this project helped you!

## 📞 Contact
If you have any questions or feedback, please [open an issue](https://github.com/nateinaction/pikvm-tailscale-cert-renewer/issues) or start a [discussion](https://github.com/nateinaction/pikvm-tailscale-cert-renewer/discussions).
8 changes: 4 additions & 4 deletions install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@ set -e

function cleanup {
# Set FS to read-only
ro 2>&1 1>/dev/null
echo "filesystem mode changed to read-only"
ro
}

trap cleanup EXIT
Expand All @@ -26,8 +25,7 @@ latest_release=$(curl -s "https://api.github.com/repos/${repo}/releases/latest"
echo "Latest release: ${latest_release}"

# Set FS to read/write
rw 2>&1 1>/dev/null
echo "filesystem mode changed to read/write"
rw

# Download binary and move to /usr/local/bin
curl -L -s "https://github.com/${repo}/releases/download/${latest_release}/${tar_name}.tar.gz" -o /tmp/${tar_name}.tar.gz
Expand All @@ -41,3 +39,5 @@ curl -L -s "https://raw.githubusercontent.com/${repo}/${latest_release}/${name}.
systemctl daemon-reload
systemctl enable "${name}"
systemctl start "${name}"

echo "Installed ${name} ${latest_release}"

0 comments on commit 318d483

Please sign in to comment.