mirror of
				https://github.com/yggdrasil-network/yggdrasil-go.git
				synced 2025-11-04 11:15:07 +03:00 
			
		
		
		
	Systemd: move config generation to a separate unit
- Modular unit composition: different tasks in separate units - Use systemd tool set to run checks - Avoid using inline shell in unit
This commit is contained in:
		
							parent
							
								
									17a711ab8a
								
							
						
					
					
						commit
						7068160b20
					
				
					 2 changed files with 15 additions and 5 deletions
				
			
		
							
								
								
									
										13
									
								
								contrib/systemd/yggdrasil-default-config.service
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										13
									
								
								contrib/systemd/yggdrasil-default-config.service
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
					@ -0,0 +1,13 @@
 | 
				
			||||||
 | 
					[Unit]
 | 
				
			||||||
 | 
					Description=yggdrasil default config generator
 | 
				
			||||||
 | 
					ConditionPathExists=|!/etc/yggdrasil.conf
 | 
				
			||||||
 | 
					ConditionFileNotEmpty=|!/etc/yggdrasil.conf
 | 
				
			||||||
 | 
					Wants=local-fs.target
 | 
				
			||||||
 | 
					After=local-fs.target
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					[Service]
 | 
				
			||||||
 | 
					Type=oneshot
 | 
				
			||||||
 | 
					Group=yggdrasil
 | 
				
			||||||
 | 
					StandardOutput=file:/etc/yggdrasil.conf
 | 
				
			||||||
 | 
					ExecStart=/usr/bin/yggdrasil -genconf
 | 
				
			||||||
 | 
					ExecStartPost=/usr/bin/chmod 0640 /etc/yggdrasil.conf
 | 
				
			||||||
| 
						 | 
					@ -1,7 +1,9 @@
 | 
				
			||||||
[Unit]
 | 
					[Unit]
 | 
				
			||||||
Description=yggdrasil
 | 
					Description=yggdrasil
 | 
				
			||||||
Wants=network.target
 | 
					Wants=network.target
 | 
				
			||||||
 | 
					Wants=yggdrasil-default-config.service
 | 
				
			||||||
After=network.target
 | 
					After=network.target
 | 
				
			||||||
 | 
					After=yggdrasil-default-config.service
 | 
				
			||||||
 | 
					
 | 
				
			||||||
[Service]
 | 
					[Service]
 | 
				
			||||||
Group=yggdrasil
 | 
					Group=yggdrasil
 | 
				
			||||||
| 
						 | 
					@ -10,11 +12,6 @@ ProtectSystem=true
 | 
				
			||||||
SyslogIdentifier=yggdrasil
 | 
					SyslogIdentifier=yggdrasil
 | 
				
			||||||
CapabilityBoundSet=CAP_NET_ADMIN
 | 
					CapabilityBoundSet=CAP_NET_ADMIN
 | 
				
			||||||
ExecStartPre=+-/sbin/modprobe tun
 | 
					ExecStartPre=+-/sbin/modprobe tun
 | 
				
			||||||
ExecStartPre=/bin/sh -ec "if ! test -s /etc/yggdrasil.conf; \
 | 
					 | 
				
			||||||
                then umask 077; \
 | 
					 | 
				
			||||||
                yggdrasil -genconf > /etc/yggdrasil.conf; \
 | 
					 | 
				
			||||||
                echo 'WARNING: A new /etc/yggdrasil.conf file has been generated.'; \
 | 
					 | 
				
			||||||
            fi"
 | 
					 | 
				
			||||||
ExecStart=/usr/bin/yggdrasil -useconffile /etc/yggdrasil.conf
 | 
					ExecStart=/usr/bin/yggdrasil -useconffile /etc/yggdrasil.conf
 | 
				
			||||||
ExecReload=/bin/kill -HUP $MAINPID
 | 
					ExecReload=/bin/kill -HUP $MAINPID
 | 
				
			||||||
Restart=always
 | 
					Restart=always
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue