Skip to content

Instantly share code, notes, and snippets.

@pecord
Last active May 8, 2023 21:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pecord/24a9a3f2f26ac237ab9380934d0471fc to your computer and use it in GitHub Desktop.
Save pecord/24a9a3f2f26ac237ab9380934d0471fc to your computer and use it in GitHub Desktop.
Asked GPT to make a wireguard install script for a non-interactive install
#!/bin/bash
set -eou pipefail
echo "Set the environment variable to non-interactive"
DEBIAN_FRONTEND=noninteractive
USER="$(whoami)"
echo "Update the system"
sudo apt-get update
sudo apt-get upgrade -y
echo "Make directory for pivpn"
sudo mkdir -p /usr/local/src/pivpn
sudo chown -R $USER:$USER /usr/local/src/pivpn
echo "Download the PiVPN non-interactive installation script"
curl -L https://install.pivpn.io -o install_pivpn.sh
chmod +x install_pivpn.sh
echo "Download the specified WireGuard configuration"
curl -L https://raw.githubusercontent.com/pivpn/pivpn/master/examples/unattended_wireguard_example.conf -o unattended_wireguard_example.conf
echo "Run the PiVPN installation script with the specified configuration"
sudo ./install_pivpn.sh --unattended unattended_wireguard_example.conf
echo "Generate WireGuard clients and output their profiles"
num_clients=3
for i in $(seq 1 $num_clients); do
sudo pivpn -a -n "client$i"
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment