mirror of
https://github.com/pcvolkmer/docker-wireguard-boringtun.git
synced 2025-04-19 21:36:49 +00:00
Change configuration creation by adding init command
This commit is contained in:
parent
61dbd439a7
commit
f4d26084a2
13
README.md
13
README.md
@ -36,7 +36,7 @@ If no environment variables are set, config creation script will ask you for set
|
|||||||
Run the service to create required keys and config files in directory `config.d`. It will print out used configuration params.
|
Run the service to create required keys and config files in directory `config.d`. It will print out used configuration params.
|
||||||
|
|
||||||
```
|
```
|
||||||
$ docker-compose run wg
|
$ docker-compose run wg init
|
||||||
|
|
||||||
Starting wireguard_wg_1 ... done
|
Starting wireguard_wg_1 ... done
|
||||||
Attaching to wireguard_wg_1
|
Attaching to wireguard_wg_1
|
||||||
@ -48,13 +48,14 @@ wg_1 | - Generating 5 client configs and client QR codes
|
|||||||
wireguard_wg_1 exited with code 0
|
wireguard_wg_1 exited with code 0
|
||||||
```
|
```
|
||||||
|
|
||||||
### Run the service
|
### Start the service
|
||||||
|
|
||||||
Start the service in detached mode.
|
Start the service in detached mode.
|
||||||
|
|
||||||
```
|
```
|
||||||
$ docker-compose up -d
|
$ docker-compose up -d
|
||||||
```
|
```
|
||||||
|
If creation of config files was skipped, configuration files will be created on first start.
|
||||||
|
|
||||||
### List server and client configs
|
### List server and client configs
|
||||||
|
|
||||||
@ -97,7 +98,13 @@ Stop the service and run the following command to remove existing config files.
|
|||||||
```
|
```
|
||||||
$ docker-compose run wg purge
|
$ docker-compose run wg purge
|
||||||
```
|
```
|
||||||
Run command `docker-compose up` again to generate new config files.
|
Reinitialize configureation
|
||||||
|
|
||||||
|
```
|
||||||
|
$ docker-compose run wg init
|
||||||
|
```
|
||||||
|
|
||||||
|
Restart service.
|
||||||
|
|
||||||
## Client configurations
|
## Client configurations
|
||||||
|
|
||||||
|
@ -4,11 +4,13 @@
|
|||||||
rm *.conf 2>/dev/null
|
rm *.conf 2>/dev/null
|
||||||
rm *-client_*.png 2>/dev/null
|
rm *-client_*.png 2>/dev/null
|
||||||
|
|
||||||
|
echo "Create configuration files"
|
||||||
|
|
||||||
while [[ -z $DEVICE ]]; do
|
while [[ -z $DEVICE ]]; do
|
||||||
echo -n "Device (eg tun0): "
|
echo -n "Device (eg tun0): "
|
||||||
read DEVICE
|
read DEVICE
|
||||||
done
|
done
|
||||||
echo " - Writing config to file $DEVICE.conf"
|
echo " - Writing server config to file $DEVICE.conf"
|
||||||
|
|
||||||
while [[ -z $SERVER_HOST ]]; do
|
while [[ -z $SERVER_HOST ]]; do
|
||||||
echo -n "Endpoint hostname: "
|
echo -n "Endpoint hostname: "
|
||||||
|
@ -6,12 +6,6 @@ if [ -z $DEVICE ]; then
|
|||||||
DEVICE="tun0"
|
DEVICE="tun0"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ ! -f "/etc/wireguard/$DEVICE.conf" ]; then
|
|
||||||
cd /etc/wireguard
|
|
||||||
/scripts/create-config.sh
|
|
||||||
exit 0
|
|
||||||
fi
|
|
||||||
|
|
||||||
case "$1" in
|
case "$1" in
|
||||||
'ls-configs' | 'ls')
|
'ls-configs' | 'ls')
|
||||||
cd /etc/wireguard
|
cd /etc/wireguard
|
||||||
@ -41,6 +35,16 @@ case "$1" in
|
|||||||
/scripts/show-client.sh $2
|
/scripts/show-client.sh $2
|
||||||
exit 0
|
exit 0
|
||||||
;;
|
;;
|
||||||
|
'init')
|
||||||
|
if [ ! -f "/etc/wireguard/$DEVICE.conf" ]; then
|
||||||
|
cd /etc/wireguard
|
||||||
|
/scripts/create-config.sh
|
||||||
|
exit 0
|
||||||
|
else
|
||||||
|
echo "Existing config found: Run command 'purge' first."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
;;
|
||||||
'purge')
|
'purge')
|
||||||
cd /etc/wireguard
|
cd /etc/wireguard
|
||||||
rm *.conf *.png
|
rm *.conf *.png
|
||||||
@ -55,11 +59,16 @@ case "$1" in
|
|||||||
echo "add Add new client"
|
echo "add Add new client"
|
||||||
echo "rm Remove client by ID"
|
echo "rm Remove client by ID"
|
||||||
echo "show Show client config with qrcode"
|
echo "show Show client config with qrcode"
|
||||||
|
echo "init Initialize service by creating config files"
|
||||||
echo "purge Remove server config and all client configs"
|
echo "purge Remove server config and all client configs"
|
||||||
echo "help Show this help message"
|
echo "help Show this help message"
|
||||||
echo
|
echo
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
|
if [ ! -f "/etc/wireguard/$DEVICE.conf" ]; then
|
||||||
|
cd /etc/wireguard
|
||||||
|
/scripts/create-config.sh
|
||||||
|
fi
|
||||||
echo "Starting wg-quick on $DEVICE"
|
echo "Starting wg-quick on $DEVICE"
|
||||||
touch "${WG_LOG_FILE}"
|
touch "${WG_LOG_FILE}"
|
||||||
wg-quick up $DEVICE
|
wg-quick up $DEVICE
|
||||||
|
Loading…
x
Reference in New Issue
Block a user