#!/bin/bash # # vpn-stack # A set of bash scripts for installing and managing a WireGuard VPN server. # https://git.stack-source.com/msb/vpn-stack # Copyright (c) 2022 Matthew Saunders Brown # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) # load include file source $(dirname $0)/wg.sh help() { thisfilename=$(basename -- "$0") echo "Email client config." echo "" echo "usage: $thisfilename -c -e [-h]" echo "" echo " -h Print this help." echo " -c Name of the client configuration." echo " -e Email address to send config to." } wg::getoptions "$@" # check for client config name if [[ -z $client ]]; then echo "client name is required" exit fi # check for email address if [[ -z $email ]]; then echo "email address is required" exit fi # set config file name config=$client.conf # check for existing config if [ -f /etc/wireguard/clients/$config ]; then # check for zip, create if it doesn't already exist if [[ ! -f /var/lib/wireguard/$config.zip ]]; then wg-client-zip-create.sh -c $client fi mail -s "WireGuard config for $client" --attach=/var/lib/wireguard/$config.zip $email <<< "Please find attached the WireGuard config for $client" else echo "config for $client $device does not exist" fi