Skip to content

Script Internals

Detailed walkthrough of openvpn-install.sh — what it does and how it works.

The script is ~4,500 lines of Bash organized into clear sections. This page documents every major part so you can understand, debug, and modify the script confidently.

High-Level Flow

graph LR
    A[parse_args] --> B{Command?}

    B -->|install| C[cmd_install]
    C --> C1[initialCheck]
    C1 --> C2[installQuestions]
    C2 --> C3[installOpenVPN]
    C3 --> C4[newClient]

    B -->|interactive| D[cmd_interactive]
    D -->|Not installed| D1[installQuestions]
    D -->|Installed| D2[manageMenu]

    B -->|client| E[cmd_client]
    E -->|add| E1[newClient]
    E -->|list| E2[listClients]
    E -->|revoke| E3[revokeClient]
    E -->|renew| E4[renewClient]

    B -->|server| F[cmd_server]
    F -->|status| F1[listConnectedClients]
    F -->|renew| F2[renewServer]

    B -->|uninstall| G[cmd_uninstall]

Entry Point

The script starts at the very last line:

parse_args "$@"

parse_args() handles global flags (--verbose, --log, --no-color), then dispatches to the appropriate command handler (cmd_install, cmd_client, etc.).

Before any installation or management command runs, initialCheck() verifies:

  1. Running as root
  2. /dev/net/tun is available
  3. OS is supported (via checkOS())
  4. Arch Linux has no pending kernel upgrades