mirror of
				https://github.com/therootcompany/serviceman.git
				synced 2025-10-31 04:42:46 +00:00 
			
		
		
		
	fix #5: only use group when specified in both dry-run and real templates
This commit is contained in:
		
							parent
							
								
									c8453f8d54
								
							
						
					
					
						commit
						c78cd82059
					
				| @ -27,6 +27,8 @@ | ||||
| 	{{if .User -}} | ||||
| 	<key>UserName</key> | ||||
| 	<string>{{ .User }}</string> | ||||
| 	{{end -}} | ||||
| 	{{if .Group -}} | ||||
| 	<key>GroupName</key> | ||||
| 	<string>{{ .Group }}</string> | ||||
| 	<key>InitGroups</key> | ||||
|  | ||||
| @ -159,7 +159,10 @@ func stop(conf *service.Service) error { | ||||
| 	return nil | ||||
| } | ||||
| 
 | ||||
| // Render will create a systemd .service file using a simple the internal template | ||||
| func Render(c *service.Service) ([]byte, error) { | ||||
| 	defaultUserGroup(c) | ||||
| 
 | ||||
| 	// Create service file from template | ||||
| 	b, err := static.ReadFile("dist/etc/systemd/system/_name_.service.tmpl") | ||||
| 	if err != nil { | ||||
| @ -181,15 +184,7 @@ func Render(c *service.Service) ([]byte, error) { | ||||
| } | ||||
| 
 | ||||
| func install(c *service.Service) (string, error) { | ||||
| 	// Linux-specific config options | ||||
| 	if c.System { | ||||
| 		if "" == c.User { | ||||
| 			c.User = "root" | ||||
| 		} | ||||
| 	} | ||||
| 	if "" == c.Group { | ||||
| 		c.Group = c.User | ||||
| 	} | ||||
| 	defaultUserGroup(c) | ||||
| 
 | ||||
| 	// Check paths first | ||||
| 	serviceDir := srvSysPath | ||||
| @ -230,3 +225,15 @@ func install(c *service.Service) (string, error) { | ||||
| 
 | ||||
| 	return "systemd", nil | ||||
| } | ||||
| 
 | ||||
| func defaultUserGroup(c *service.Service) { | ||||
| 	// Linux-specific config options | ||||
| 	if c.System { | ||||
| 		if "" == c.User { | ||||
| 			c.User = "root" | ||||
| 		} | ||||
| 	} | ||||
| 	if "" == c.Group { | ||||
| 		c.Group = c.User | ||||
| 	} | ||||
| } | ||||
|  | ||||
										
											
												File diff suppressed because one or more lines are too long
											
										
									
								
							
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user