Remove interactive configuration

This commit is contained in:
Paul-Christian Volkmer 2022-12-10 10:27:59 +01:00
parent f85d6dc215
commit 0957eda443
2 changed files with 20 additions and 24 deletions

View File

@ -30,7 +30,7 @@ Customize the file `docker-compose`. You can change the following environment va
* `CLIENTS`: Number of clients for which configurations are to be created. Do not use more than 240 clients. * `CLIENTS`: Number of clients for which configurations are to be created. Do not use more than 240 clients.
* `DISABLE_FORWARD_ALL_TRAFFIC`: Use `true` or `yes` to not add iptables rules and do not forward all traffic. * `DISABLE_FORWARD_ALL_TRAFFIC`: Use `true` or `yes` to not add iptables rules and do not forward all traffic.
If no environment variables are set, config creation script will ask you for settings. If a required environment variable is not set, config creation script will end with an error.
### Create config files ### Create config files

View File

@ -6,39 +6,29 @@ rm *-client_*.png 2>/dev/null
echo "Create configuration files" echo "Create configuration files"
while [[ -z $DEVICE ]]; do if [[ -z $DEVICE ]]; then
echo -n "Device (eg tun0): " DEVICE="tun0"
read DEVICE fi
done
echo " - Writing server config to file $DEVICE.conf" echo " - Writing server config to file $DEVICE.conf"
while [[ -z $SERVER_HOST ]]; do if [[ -z $SERVER_HOST ]]; then
echo -n "Endpoint hostname: " echo " ERROR: No server hostname!"
read SERVER_HOST exit 1
done fi
echo " - Using endpoint hostname $SERVER_HOST" echo " - Using endpoint hostname $SERVER_HOST"
if [[ -z $SERVER_PORT ]]; then if [[ -z $SERVER_PORT ]]; then
echo -n "Endpoint port: " echo " ERROR: No server port!"
read SERVER_PORT exit 1
fi fi
echo " - Using port $SERVER_PORT" echo " - Using port $SERVER_PORT"
if [[ -z $NETWORK ]]; then if [[ -z $NETWORK ]]; then
echo -n "Network (/24): " NETWORK="192.168.42.0"
read NETWORK else
fi
echo " - Using network $NETWORK/24"
NETWORK=$(echo -n $NETWORK | sed -r "s/\.[0-9]+$//") NETWORK=$(echo -n $NETWORK | sed -r "s/\.[0-9]+$//")
while [[ -z $CLIENTS ]]; do
echo -n "Number of clients: "
read CLIENTS
done
if (( $CLIENTS > 240 )); then
CLIENTS=240
fi fi
echo " - Generating $CLIENTS client configs and client QR codes" echo " - Using network $NETWORK.0/24"
if [ "$DISABLE_FORWARD_ALL_TRAFFIC" != "true" ] && [ "$DISABLE_FORWARD_ALL_TRAFFIC" != "yes" ]; then if [ "$DISABLE_FORWARD_ALL_TRAFFIC" != "true" ] && [ "$DISABLE_FORWARD_ALL_TRAFFIC" != "yes" ]; then
echo " - Forward all traffic" echo " - Forward all traffic"
@ -46,6 +36,11 @@ else
echo " - Do not forward all traffic" echo " - Do not forward all traffic"
fi fi
if (( $CLIENTS > 240 )); then
CLIENTS=240
fi
echo " - Generating $CLIENTS client configs and client QR codes"
SERVER_SEC_KEY=$(wg genkey) SERVER_SEC_KEY=$(wg genkey)
SERVER_PUB_KEY=$(echo $SERVER_SEC_KEY | wg pubkey) SERVER_PUB_KEY=$(echo $SERVER_SEC_KEY | wg pubkey)
@ -113,6 +108,7 @@ PublicKey = $SERVER_PUB_KEY
AllowedIPs = 0.0.0.0/0, ::/0 AllowedIPs = 0.0.0.0/0, ::/0
Endpoint = $SERVER_HOST:$SERVER_PORT Endpoint = $SERVER_HOST:$SERVER_PORT
EOF EOF
done done
# Create QR-codes for clients # Create QR-codes for clients