mirror of
				https://github.com/flynx/proxmox-utils.git
				synced 2025-11-03 21:50:10 +00:00 
			
		
		
		
	
		
			
	
	
		
			25 lines
		
	
	
		
			496 B
		
	
	
	
		
			Plaintext
		
	
	
	
	
	
		
		
			
		
	
	
			25 lines
		
	
	
		
			496 B
		
	
	
	
		
			Plaintext
		
	
	
	
	
	
| 
								 | 
							
								#!/usr/bin/bash
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								SERVER_TEMPLATE=${SERVER_TEMPLATE:=templates/wg0.conf}
							 | 
						||
| 
								 | 
							
								SERVER_CONF=/etc/wireguard/wg0.conf
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								PUBLIC_KEY=/etc/wireguard/server_id
							 | 
						||
| 
								 | 
							
								PRIVATE_KEY=/etc/wireguard/server_id.pub
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								if ! [ -e "$PRIVATE_KEY" ] ; then
							 | 
						||
| 
								 | 
							
									wg genkey > "$PRIVATE_KEY" 
							 | 
						||
| 
								 | 
							
								fi
							 | 
						||
| 
								 | 
							
								if ! [ -e "$PUBLIC_KEY" ] ; then
							 | 
						||
| 
								 | 
							
									cat "$PRIVATE_KEY" | wg pubkey > "$PUBLIC_KEY"
							 | 
						||
| 
								 | 
							
								fi
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								PRIVATE_KEY=$(cat "$PRIVATE_KEY")
							 | 
						||
| 
								 | 
							
								cat ${SERVER_TEMPLATE} \
							 | 
						||
| 
								 | 
							
									| sed \
							 | 
						||
| 
								 | 
							
										-q 's/\${SERVER_PRIVATE_KEY}/'${PRIVATE_KEY}'/g' \
							 | 
						||
| 
								 | 
							
									> "${SERVER_CONF}"
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								./make-client
							 | 
						||
| 
								 | 
							
								
							 |