Limit clients and add date to configs

This commit is contained in:
Paul-Christian Volkmer 2022-11-29 07:24:22 +01:00
parent e9e9839e64
commit fbbb26f4cb

View File

@ -33,6 +33,9 @@ while [[ -z $CLIENTS ]]; do
echo -n "Number of clients: " echo -n "Number of clients: "
read CLIENTS read CLIENTS
done done
if [[ "240" > "$CLIENTS" ]]; then
CLIENTS=240
fi
echo " - Generating $CLIENTS client configs and client QR codes" echo " - Generating $CLIENTS client configs and client QR codes"
SERVER_SEC_KEY=$(wg genkey) SERVER_SEC_KEY=$(wg genkey)
@ -54,7 +57,6 @@ cat <<EOF >> $DEVICE.conf
############## ##############
# SERVER # SERVER
############## ##############
[Interface] [Interface]
Address = $NETWORK.1/24 Address = $NETWORK.1/24
ListenPort = $SERVER_PORT ListenPort = $SERVER_PORT
@ -62,7 +64,7 @@ PrivateKey = $SERVER_SEC_KEY
PostUp = iptables -A FORWARD -i $DEVICE -j ACCEPT; iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE PostUp = iptables -A FORWARD -i $DEVICE -j ACCEPT; iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
PostDown = iptables -D FORWARD -i $DEVICE -j ACCEPT; iptables -t nat -D POSTROUTING -o eth0 -j MASQUERADE PostDown = iptables -D FORWARD -i $DEVICE -j ACCEPT; iptables -t nat -D POSTROUTING -o eth0 -j MASQUERADE
# <- $(date)
EOF EOF
# Print out client peers # Print out client peers
@ -72,7 +74,7 @@ cat << EOF >> $DEVICE.conf
[Peer] [Peer]
PublicKey = ${CLIENT_PUB_KEYS[$i]} PublicKey = ${CLIENT_PUB_KEYS[$i]}
AllowedIPs = $NETWORK.$(($i+10))/32 AllowedIPs = $NETWORK.$(($i+10))/32
# <- $(date)
EOF EOF
done done
@ -82,8 +84,9 @@ for (( i=1; i<=$CLIENTS; i++ )); do
cat <<EOF >> $DEVICE-client_$i.conf cat <<EOF >> $DEVICE-client_$i.conf
############## ##############
# CLIENT $i # CLIENT $i
#
# <- $(date)
############## ##############
[Interface] [Interface]
Address = $NETWORK.$(($i+10))/24 Address = $NETWORK.$(($i+10))/24
ListenPort = $SERVER_PORT ListenPort = $SERVER_PORT