Skip to content

Commit

Permalink
fix ssh problem
Browse files Browse the repository at this point in the history
  • Loading branch information
bketelsen committed Sep 23, 2021
1 parent 235dc86 commit 88ae4ea
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 9 deletions.
16 changes: 7 additions & 9 deletions cmd/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ package cmd

import (
"bytes"
"fmt"
"net"
"os"

Expand All @@ -21,8 +20,7 @@ import (
)

var (
name string
template string
name string
)

// createCmd represents the create command
Expand Down Expand Up @@ -91,20 +89,20 @@ var createCmd = &cobra.Command{
log.Error("unable to connect:" + err.Error())
}
defer client.Close()
session, err := client.NewSession()
newSession, err := client.NewSession()
if err != nil {
log.Error("unable to connect:" + err.Error())
}
defer session.Close()

var b bytes.Buffer
session.Stdout = &b
if err := session.Run("ps -eaf"); err != nil {
newSession.Stdout = &b
defer newSession.Close()
//lxc config device add $container dlxbind disk source=$HOME/projects/$container path=/home/`whoami`/projects/$container
if err := newSession.Run("devices " + name); err != nil {
log.Error("unable to run command:" + err.Error())
}
fmt.Println(b.String())

log.Success("Provisioned container " + name)
newSession.Close()
},
}

Expand Down
8 changes: 8 additions & 0 deletions scripts/devices
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/bin/bash

# arguments
# $1: container name

mkdir -p $HOME/projects/$1
lxc exec $1 -- sh -c "mkdir -p /home/`whoami`/projects && chown -R `whoami`:`whoami` /home/`whoami`/projects"
lxc config device add $1 dlxbind disk source=$HOME/projects/$1 path=/home/`whoami`/projects/$1

0 comments on commit 88ae4ea

Please sign in to comment.