Skip to content

Refactor: Add architecture detection function#12

Merged
SamNet-dev merged 1 commit intoSamNet-dev:masterfrom
roozbeh-gholami:master
Mar 10, 2026
Merged

Refactor: Add architecture detection function#12
SamNet-dev merged 1 commit intoSamNet-dev:masterfrom
roozbeh-gholami:master

Conversation

@roozbeh-gholami
Copy link
Copy Markdown
Contributor

Summary

Added architecture detection function to support multiple system architectures.

Problem

The original script was hardcoded to download amd64 binaries, breaking installation on ARM64, ARM, and 32-bit x86 systems.

Solution

  • Created detect_architecture() function that detects the system's CPU architecture using uname -m
  • Maps system architectures to supported binary suffixes:
    • x86_64/amd64amd64
    • i386/i686386
    • aarch64/arm64arm64
    • armv7l/armv7armv7
  • Applied to all binary downloads:
    • dnstm binary
    • sshtun-user binary (2 locations)

Testing

Tested on x86_64 systems; should now support ARM64 and ARM systems without code changes.

- Create detect_architecture() function to map uname output to binary suffixes
- Supports: 386, amd64, arm64, armv7
- Replace hardcoded 'amd64' with dynamic detection in:
  - do_manage_users()
  - step_install_dnstm()
  - step_ssh_user()
- Improves compatibility with non-x86_64 systems
@SamNet-dev SamNet-dev merged commit 7521f2a into SamNet-dev:master Mar 10, 2026
@SamNet-dev
Copy link
Copy Markdown
Owner

SamNet-dev commented Mar 10, 2026

Thanks for the contribution @roozbeh-gholami! 🙌

Great catch on the hardcoded amd64 — this was definitely needed for ARM support. Clean implementation with proper fallback.

One small bug we spotted: in the *) fallback case, print_warn writes to stdout, so when called as arch=$(detect_architecture) the warning message gets captured into $arch and breaks the download URL. Will push a fix with >&2 redirect shortly.

Thanks again!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants