Skip to content

Commit

Permalink
config: make sftp could be configured dynamically
Browse files Browse the repository at this point in the history
    - add `harvester.install.enableSftp` to config `sftp` dynamically

Signed-off-by: Vicente Cheng <vicente.cheng@suse.com>
  • Loading branch information
Vicente-Cheng committed Sep 4, 2023
1 parent a94331a commit 0afdf3f
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 10 deletions.
21 changes: 11 additions & 10 deletions pkg/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -135,16 +135,17 @@ type Install struct {
VipHwAddr string `json:"vipHwAddr,omitempty"`
VipMode string `json:"vipMode,omitempty"`

ForceEFI bool `json:"forceEfi,omitempty"`
Device string `json:"device,omitempty"`
ConfigURL string `json:"configUrl,omitempty"`
Silent bool `json:"silent,omitempty"`
ISOURL string `json:"isoUrl,omitempty"`
PowerOff bool `json:"powerOff,omitempty"`
NoFormat bool `json:"noFormat,omitempty"`
Debug bool `json:"debug,omitempty"`
TTY string `json:"tty,omitempty"`
ForceGPT bool `json:"forceGpt,omitempty"`
ForceEFI bool `json:"forceEfi,omitempty"`
Device string `json:"device,omitempty"`
ConfigURL string `json:"configUrl,omitempty"`
Silent bool `json:"silent,omitempty"`
ISOURL string `json:"isoUrl,omitempty"`
PowerOff bool `json:"powerOff,omitempty"`
NoFormat bool `json:"noFormat,omitempty"`
Debug bool `json:"debug,omitempty"`
TTY string `json:"tty,omitempty"`
ForceGPT bool `json:"forceGpt,omitempty"`
EnableSFTP bool `json:"enableSftp,omitempty"`

// Following options are not cOS installer flag
ForceMBR bool `json:"forceMbr,omitempty"`
Expand Down
6 changes: 6 additions & 0 deletions pkg/config/cos.go
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,12 @@ func ConvertToCOS(config *HarvesterConfig) (*yipSchema.YipConfig, error) {
},
}

// Add SFTP related config to after install stage
if config.Install.EnableSFTP {
config.OS.AfterInstallChrootCommands = append(config.OS.AfterInstallChrootCommands, "mkdir -p /etc/ssh/sshd_config.d")
config.OS.AfterInstallChrootCommands = append(config.OS.AfterInstallChrootCommands, "echo 'Subsystem sftp /usr/lib/ssh/sftp-server' > /etc/ssh/sshd_config.d/sftp.conf")
}

// Add after-install-chroot stage
if len(config.OS.AfterInstallChrootCommands) > 0 {
afterInstallChroot := yipSchema.Stage{}
Expand Down

0 comments on commit 0afdf3f

Please sign in to comment.