Skip to content

Commit

Permalink
Install WireGuard if not already installed
Browse files Browse the repository at this point in the history
  • Loading branch information
muzzammilshahid committed Oct 4, 2024
1 parent 19cd8b0 commit d5c7c5d
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions wireguard.go
Original file line number Diff line number Diff line change
Expand Up @@ -278,8 +278,12 @@ func EnsureWireguardInstallation() error {
return fmt.Errorf("failed to get server port: %w", err)
}

if err = runCommand("apt-get", []string{"install", "-y", "wireguard", "iptables"}, ""); err != nil {
return fmt.Errorf("failed to install wireguard: %w", err)
_, err = exec.LookPath("wg")
if err != nil {
_ = runCommand("apt-get", []string{"update"}, "")
if err = runCommand("apt-get", []string{"install", "-y", "wireguard", "iptables"}, ""); err != nil {
return fmt.Errorf("failed to install wireguard: %w", err)
}
}

if err := os.WriteFile(wireguardParamsFile, []byte(fmt.Sprintf(`SERVER_PUB_IP=%s
Expand Down

0 comments on commit d5c7c5d

Please sign in to comment.