#!/bin/sh # Assumptions: # - pib (APU) is factory reset OpenWRT # - WAN port is connected with an active upstream (pib has internet connectivity via WAN port) # - You are connected via LAN and you can ssh into it # How it works # if [ $# -lt 2 ]; then echo "$0 ip-address vpn-network [wireguard-private-key]" echo " ip-address: where to find the PIB" echo " network: 2a0a:e5c0:123::/48" echo " private-key: specify if you already have a private key" exit 1 fi my_ip=$1; shift my_network=$1; shift if [ $# -eq 1 ]; then private_key=$1; shift else private_key=$(wg genkey) fi my_prefix=$(echo $my_network | sed 's,::/.*,,') my_hostname=pib-$(echo ${my_prefix} | sed 's/:/-/g') my_wireguard_ip=${my_prefix}::42 my_lan_ip=${my_prefix}:cafe::42 public_key=$(echo $private_key | wg pubkey) vpn_endpoint_host=vpn-2a0ae5c1.ungleich.ch vpn_endpoint_pubkey=hi60lGP+xEUQ+kVnqA7PlJAO1SVqTS1W36g0LhFP0xQ= cat < ${my_hostname}.public_key cat <