mirror of
				https://github.com/pcvolkmer/docker-wireguard-boringtun.git
				synced 2025-10-31 20:46:13 +00:00 
			
		
		
		
	Add script to remove client
This commit is contained in:
		
							
								
								
									
										10
									
								
								README.md
									
									
									
									
									
								
							
							
						
						
									
										10
									
								
								README.md
									
									
									
									
									
								
							| @@ -66,6 +66,16 @@ $ docker-compose run wg add-client | |||||||
|  |  | ||||||
| This will create new client configuration and adds peer configuration to server config file. | This will create new client configuration and adds peer configuration to server config file. | ||||||
|  |  | ||||||
|  | ### Remove client | ||||||
|  |  | ||||||
|  | Stop the service and run | ||||||
|  |  | ||||||
|  | ``` | ||||||
|  | $ docker-compose run wg rm-client 1 | ||||||
|  | ``` | ||||||
|  |  | ||||||
|  | This will remove client with id '1' (or any other client for different id) configuration. | ||||||
|  |  | ||||||
| ### Remove configuration and create new one from scratch | ### Remove configuration and create new one from scratch | ||||||
|  |  | ||||||
| Remove existing config files or rename device in `docker-compose.yml`. Run command `docker-compose up` again. | Remove existing config files or rename device in `docker-compose.yml`. Run command `docker-compose up` again. | ||||||
|   | |||||||
| @@ -8,19 +8,30 @@ fi | |||||||
|  |  | ||||||
| if [ ! -f "/etc/wireguard/$DEVICE.conf" ]; then | if [ ! -f "/etc/wireguard/$DEVICE.conf" ]; then | ||||||
|   cd /etc/wireguard |   cd /etc/wireguard | ||||||
|   /create-config.sh |   /scripts/create-config.sh | ||||||
|   exit 0 |   exit 0 | ||||||
| fi | fi | ||||||
|  |  | ||||||
| if [ "add-client" == "$1" ]; then | case "$1" in | ||||||
|   cd /etc/wireguard |   'add-client') | ||||||
|   /add-client.sh |     cd /etc/wireguard | ||||||
|   exit 0 |     /scripts/add-client.sh | ||||||
| fi |     exit 0 | ||||||
|  |     ;; | ||||||
| echo "Starting wg-quick on $DEVICE" |   'rm-client') | ||||||
| touch "${WG_LOG_FILE}" |     if [ -z $2 ]; then | ||||||
| wg-quick up $DEVICE |       echo "Usage: rm-client <client id>" | ||||||
| echo "done!" |       exit 1 | ||||||
|  |     fi | ||||||
| tail -f "${WG_LOG_FILE}" |     cd /etc/wireguard | ||||||
|  |     /scripts/rm-client.sh $2 | ||||||
|  |     exit 0 | ||||||
|  |     ;; | ||||||
|  |   *) | ||||||
|  |     echo "Starting wg-quick on $DEVICE" | ||||||
|  |     touch "${WG_LOG_FILE}" | ||||||
|  |     wg-quick up $DEVICE | ||||||
|  |     echo "done!" | ||||||
|  |     tail -f "${WG_LOG_FILE}" | ||||||
|  |     ;; | ||||||
|  | esac | ||||||
|   | |||||||
							
								
								
									
										10
									
								
								scripts/rm-client.sh
									
									
									
									
									
										Executable file
									
								
							
							
						
						
									
										10
									
								
								scripts/rm-client.sh
									
									
									
									
									
										Executable file
									
								
							| @@ -0,0 +1,10 @@ | |||||||
|  | #!/bin/bash | ||||||
|  |  | ||||||
|  | CONFIG=$(cat "$DEVICE.conf" | sed "/^\# Client $1/{N;N;N;N;d}") | ||||||
|  |  | ||||||
|  | echo "$CONFIG" > "$DEVICE.conf" | ||||||
|  |  | ||||||
|  | rm "$DEVICE-client_$1.conf" 2>/dev/null | ||||||
|  | rm "$DEVICE-client_$1.png" 2>/dev/null | ||||||
|  |  | ||||||
|  | echo "Client # $1 removed" | ||||||
		Reference in New Issue
	
	Block a user