Skip to content

Commit

Permalink
upgrade 171
Browse files Browse the repository at this point in the history
  • Loading branch information
idroz committed Mar 21, 2024
1 parent 54b6aff commit 5a10512
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 3 deletions.
4 changes: 2 additions & 2 deletions cmd/launch.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ func includeLaunchFlags(cmd *cobra.Command) {
func CorrectArguments(imageVersion string, machineArch string, machineCPU string,
machineMemory string, machineDisk string, sshPort string, machinePort string) error {

if !utils.StringSliceContains([]string{"alpine_3.16.0", "alpine_3.16.0_lxd", "debian_11.3.0"}, imageVersion) {
return errors.New("unsupported image. only -i alpine_3.16.0 | debian_11.3.0 are currently available")
if !utils.StringSliceContains([]string{"alpine_3.16.0", "alpine_3.19.1", "alpine_3.16.0_lxd", "debian_11.3.0"}, imageVersion) {
return errors.New("unsupported image. only -i alpine_3.16.0 | alpine_3.19.1 | debian_11.3.0 are currently available")
}

if machineArch != "" {
Expand Down
34 changes: 33 additions & 1 deletion qemu/ops.go
Original file line number Diff line number Diff line change
Expand Up @@ -394,8 +394,8 @@ func (c *MachineConfig) Start() error {
"-smp", "cpus=" + c.CPU + ",sockets=1,cores=" + c.CPU + ",threads=1",
"-drive", "if=virtio,file=" + filepath.Join(c.Location, c.Image),
"-nographic",
"-netdev", exposedPorts,
"-device", "e1000,netdev=net0,mac=" + c.MACAddress,
"-netdev", exposedPorts,
"-pidfile", filepath.Join(c.Location, "alpine.pid"),
"-chardev", "socket,id=char-serial,path=" + filepath.Join(c.Location,
"alpine.sock") + ",server=on,wait=off,logfile=" + filepath.Join(c.Location, "alpine.log"),
Expand Down Expand Up @@ -541,6 +541,38 @@ func (c *MachineConfig) Launch() error {
return errors.New("unable launch a new machine. " + err.Error())
}

// Make sure DNS is set up correctly
err = c.Exec("echo 'nameserver 8.8.8.8' > /etc/resolv.conf", true)
if err != nil {
return errors.New("unable to set up DNS: " + err.Error())
}

err = c.Exec("apk update && apk add --no-cache dhclient", true)
if err != nil {
return errors.New("unable to install dhclient: " + err.Error())
}

err = c.Exec(`cat >/etc/dhcp/dhclient.conf <<EOL
option rfc3442-classless-static-routes code 121 = array of unsigned integer 8;
send host-name = gethostname();
request subnet-mask, broadcast-address, time-offset, routers,
domain-name, domain-name-servers, domain-search, host-name,
dhcp6.name-servers, dhcp6.domain-search, dhcp6.fqdn, dhcp6.sntp-servers,
netbios-name-servers, netbios-scope, interface-mtu,
rfc3442-classless-static-routes, ntp-servers;
prepend domain-name-servers 8.8.8.8, 8.8.4.4;
EOL`, true)
if err != nil {
return errors.New("unable to configure dhclient: " + err.Error())
}

err = c.Exec("rc-service networking restart", true)
if err != nil {
return errors.New("unable to restart networking services: " + err.Error())
}

// Resize disk on an alpine guest
if strings.Split(c.Image, "_")[0] == "alpine" {
//TODO add these dependencies into pre-baked macpine image
Expand Down

0 comments on commit 5a10512

Please sign in to comment.