Skip to content

OS Detection and System Checks

OS Detection — checkOS()

The script sources /etc/os-release and identifies the distribution. It sets the OS variable used throughout the script to select the correct package manager and paths.

For the full list of supported distributions and minimum versions, see Compatibility.

The OS variable is set to the distribution identifier used internally by the script:

OS Variable Distribution
debian Debian, Raspbian
ubuntu Ubuntu
fedora Fedora
centos CentOS Stream
rocky Rocky Linux
almalinux AlmaLinux
oracle Oracle Linux
amzn Amazon Linux
arch Arch Linux
opensuse-leap openSUSE Leap
opensuse-tumbleweed openSUSE Tumbleweed

If the version is below the minimum, the script warns the user and asks for confirmation to continue.

Pre-Flight Checks — initialCheck()

Before any installation, four checks run in sequence:

1. Root Check — isRoot()

Verifies EUID == 0. The script must run as root or via sudo.

2. TUN Device — tunAvailable()

Checks that /dev/net/tun exists. The TUN kernel module is required for OpenVPN. If missing, the script exits with a fatal error.

3. OS Detection — checkOS()

Described above. Identifies the distribution and validates version support.

4. Arch Kernel Check — checkArchPendingKernelUpgrade()

Arch Linux specific. If the kernel was upgraded but the system hasn't rebooted:

  • Running kernel modules may be deleted
  • TUN module won't load after reboot
  • OpenVPN will fail

The function:

  1. Skips if not Arch or running in a container
  2. Checks if running kernel modules are available on disk
  3. Syncs the pacman database
  4. Checks for pending kernel package upgrades
  5. Fatally exits if a reboot is needed

Version Checks

openvpnVersionAtLeast(version)

Checks the installed OpenVPN version:

if openvpnVersionAtLeast "2.6"; then
    # Use OpenVPN 2.6+ features
fi

Uses sort -V for semantic version comparison.

kernelVersionAtLeast(version)

Checks the running kernel version from uname -r:

if kernelVersionAtLeast "6.16"; then
    # DCO is natively supported
fi

isDCOAvailable()

Data Channel Offload requires both:

  • OpenVPN 2.6+
  • Kernel 6.16+ or the ovpn-dco kernel module loaded
if isDCOAvailable; then
    log_info "DCO (Data Channel Offload) is available"
fi