Switched to OS version of write file
This commit is contained in:
		
							parent
							
								
									70c024b387
								
							
						
					
					
						commit
						e872bcccae
					
				
							
								
								
									
										23
									
								
								services.go
									
									
									
									
									
								
							
							
						
						
									
										23
									
								
								services.go
									
									
									
									
									
								
							|  | @ -24,18 +24,14 @@ func (s *Services) AddPrivateKey() error { | |||
| 		return err | ||||
| 	} | ||||
| 
 | ||||
| 	if err := writeFile(`${HOME}/.ssh/id_rsa`, s.cfg.PrivateKey, 0400); err != nil { | ||||
| 		return err | ||||
| 	} | ||||
| 
 | ||||
| 	if err := runCmd(`chmod 700 $HOME/.ssh`); err != nil { | ||||
| 		return err | ||||
| 	} | ||||
| 
 | ||||
| 	if err := writeFile(`${HOME}/.ssh/id_rsa`, s.cfg.PrivateKey); err != nil { | ||||
| 		return err | ||||
| 	} | ||||
| 
 | ||||
| 	if err := runCmd(`chmod -R 400 $HOME/.ssh/.`); err != nil { | ||||
| 		return err | ||||
| 	} | ||||
| 
 | ||||
| 	return nil | ||||
| } | ||||
| 
 | ||||
|  | @ -53,11 +49,7 @@ func (s *Services) ConfigureSSH() error { | |||
| 		return err | ||||
| 	} | ||||
| 
 | ||||
| 	if err := writeFile(`${HOME}/.ssh/config`, bfr.String()); err != nil { | ||||
| 		return err | ||||
| 	} | ||||
| 
 | ||||
| 	if err := runCmd(`chmod 400 $HOME/.ssh/config`); err != nil { | ||||
| 	if err := writeFile(`${HOME}/.ssh/config`, bfr.String(), 0400); err != nil { | ||||
| 		return err | ||||
| 	} | ||||
| 
 | ||||
|  | @ -91,12 +83,11 @@ func runCmd(cmd string) error { | |||
| 	return script.Exec(fullCmd).Error() | ||||
| } | ||||
| 
 | ||||
| func writeFile(path string, content string) error { | ||||
| func writeFile(path string, content string, mode os.FileMode) error { | ||||
| 	fullPath := os.ExpandEnv(path) | ||||
| 	log.Printf(" .. [file] %v", fullPath) | ||||
| 
 | ||||
| 	_, err := script.Echo(content).WriteFile(fullPath) | ||||
| 	return err | ||||
| 	return os.WriteFile(fullPath, []byte(content), mode) | ||||
| } | ||||
| 
 | ||||
| var ( | ||||
|  |  | |||
		Loading…
	
		Reference in a new issue