Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitarchiveinclude
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
ca-certificates.crt
bin/h700/minui-list
bin/h700/minui-presenter
bin/m17/minui-list
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@ bin/*
!bin/.gitkeep
res/fonts/*
!res/fonts/.gitkeep
ca-certificates.crt

!bin/on-boot
6 changes: 5 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,13 @@ clean:
rm -f bin/*/jq* || true
rm -f bin/*/tailscale* || true
rm -f bin/*/tailscaled* || true
rm -f ca-certificates.crt || true

bump-version:
jq '.version = "$(RELEASE_VERSION)"' pak.json > pak.json.tmp
mv pak.json.tmp pak.json

build: $(foreach platform,$(PLATFORMS),bin/$(platform)/minui-list bin/$(platform)/minui-presenter) $(foreach arch,$(ARCHITECTURES),bin/$(arch)/jq bin/$(arch)/tailscale bin/$(arch)/tailscaled)
build: $(foreach platform,$(PLATFORMS),bin/$(platform)/minui-list bin/$(platform)/minui-presenter) $(foreach arch,$(ARCHITECTURES),bin/$(arch)/jq bin/$(arch)/tailscale bin/$(arch)/tailscaled) ca-certificates.crt
@echo "Build complete"

bin/%/minui-list:
Expand Down Expand Up @@ -86,6 +87,9 @@ bin/%/tailscaled:
chmod +x bin/$*/tailscaled
curl -sSL -o bin/$*/tailscaled.LICENSE "https://github.com/tailscale/tailscale/raw/refs/heads/main/LICENSE"

ca-certificates.crt:
curl -f -o ca-certificates.crt -sSL https://curl.se/ca/cacert.pem

release: build
mkdir -p dist
git archive --format=zip --output "dist/$(PAK_NAME).pak.zip" HEAD
Expand Down
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,10 @@ Debug logs are written to the `$SDCARD_PATH/.userdata/$PLATFORM/logs/` folder.
- [NextUI](https://github.com/LoveRetro/NextUI) by [@ro8inmorgan](https://github.com/ro8inmorgan), [@frysee](https://github.com/frysee) and the rest of the NextUI contributors.
- Also, thank you, [Jose Diaz-Gonzalez](https://github.com/josegonzalez), for your pak repositories, which this project is based on.

## Custom login server (Headscale)

If you use a self-hosted Headscale or other custom login server, create a file named `loginserver` containing only the base URL of your login server (for example, `https://headscale.example.com`). Drop the file on the root of your SD card or directly into `$USERDATA_PATH/$PAK_NAME`. On launch, the pak cleans the value, moves it into `$USERDATA_PATH/$PAK_NAME/loginserver`, and automatically passes it to `tailscale up` using `--login-server`.

## License

This project is released under the MIT License. For more information, see the [LICENSE](LICENSE) file.
This project is released under the MIT License. For more information, see the [LICENSE](LICENSE) file.
1 change: 1 addition & 0 deletions bin/on-boot
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ if uname -m | grep -q '64'; then
fi

export PATH="$PAK_DIR/bin/$architecture:$PAK_DIR/bin/$PLATFORM:$PAK_DIR/bin:$PATH"
export SSL_CERT_FILE="$PAK_DIR/ca-certificates.crt"

main() {
"$PAK_DIR/bin/$architecture/tailscaled" --statedir="$USERDATA_PATH/$PAK_NAME/" --no-logs-no-support &
Expand Down
47 changes: 46 additions & 1 deletion launch.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,15 @@ fi

export PATH="$PAK_DIR/bin/$architecture:$PAK_DIR/bin/$PLATFORM:$PAK_DIR/bin:$PATH"

export SSL_CERT_FILE="$PAK_DIR/ca-certificates.crt"

SERVICE_NAME="tailscaled"
HUMAN_READABLE_NAME="Tailscale VPN"
LAUNCHES_SCRIPT="false"

TAILSCALE_AUTHKEY_FILE="$SDCARD_PATH/authkey"
TAILSCALE_LOGIN_SERVER_FILE="$SDCARD_PATH/loginserver"
TAILSCALE_LOGIN_SERVER_STORAGE_FILE="$USERDATA_PATH/$PAK_NAME/loginserver"

service_off() {
killall "$SERVICE_NAME"
Expand Down Expand Up @@ -140,9 +144,50 @@ current_settings() {
tailscale_login() {
authkey="$1"

if ! tailscale up --authkey="$authkey" --hostname="minui" --accept-routes --accept-dns; then
tailscale_args="--authkey=$authkey --hostname=minui --accept-routes --accept-dns"

if login_server="$(tailscale_get_login_server)"; then
tailscale_args="$tailscale_args --login-server=$login_server"
fi

# shellcheck disable=SC2086
if ! tailscale up $tailscale_args; then
return 1
fi
}

tailscale_get_login_server() {
loginserver_file="$TAILSCALE_LOGIN_SERVER_STORAGE_FILE"

tailscale_sync_login_server

if [ ! -f "$loginserver_file" ] || [ ! -s "$loginserver_file" ]; then
return 1
fi

tr -d '\r' <"$loginserver_file" | tr -d '\n'
}

tailscale_sync_login_server() {
source_file="$TAILSCALE_LOGIN_SERVER_FILE"
target_file="$TAILSCALE_LOGIN_SERVER_STORAGE_FILE"

if [ ! -f "$source_file" ] || [ ! -s "$source_file" ]; then
return 1
fi

mkdir -p "$(dirname "$target_file")"
tr -d '\r' <"$source_file" | tr -d '\n' >"$target_file.tmp"

if ! cmp -s "$target_file.tmp" "$target_file"; then
mv "$target_file.tmp" "$target_file"
else
rm -f "$target_file.tmp"
fi

rm -f "$source_file"
sync
return 0
}

tailscale_start() {
Expand Down
Loading