#!/bin/bash # # Wireguard / VPN Service PATH=$HOME/.docker/cli-plugins:/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin config_wireguard() { echo -ne "\n* Configuring /federated/apps/wireguard container.." spin & SPINPID=$! if [ ! -d "/federated/apps/wireguard" ]; then mkdir -p /federated/apps/wireguard/data/config fi cat > /federated/apps/wireguard/docker-compose.yml < /federated/apps/wireguard/.env < /dev/null echo -ne "done." } start_wireguard() { # Grab the container IP from docker-compose above SERVICE_IP=`grep ipv4_address /federated/apps/wireguard/docker-compose.yml | awk '{ print $2 }'` # Start service with command to make sure it's up before proceeding start_service "wireguard" "nc -uvz $SERVICE_IP 51820 &> /dev/null" kill -9 $SPINPID &> /dev/null echo -ne "done." }