@@ -484,10 +484,6 @@ func (d *Driver) Create() error {
484484 return err
485485 }
486486
487- if err := d .setupMounts (); err != nil {
488- return fmt .Errorf ("Error setting up mounts: %v" , err )
489- }
490-
491487 return nil
492488}
493489
@@ -537,6 +533,10 @@ func (d *Driver) Start() error {
537533 return err
538534 }
539535
536+ if err := d .setupMounts (); err != nil {
537+ return err
538+ }
539+
540540 return nil
541541}
542542
@@ -838,6 +838,7 @@ func (d *Driver) setupMounts() error {
838838 err := d .setupNFSShare ()
839839 if err != nil {
840840 log .Errorf ("NFS setup failed: %s" , err .Error ())
841+ return err
841842 }
842843 }
843844 return nil
@@ -992,20 +993,18 @@ func (d *Driver) setupVirt9pShare() error {
992993 if err != nil {
993994 return err
994995 }
995- bootScriptName := "/var/lib/boot2docker/bootlocal.sh"
996996
997- bootScript := fmt .Sprintf ("#/bin/bash\\ n" )
997+ mountCommands := fmt .Sprintf ("#/bin/bash\\ n" )
998998 i := 0
999999 for _ , virtioShare := range d .Virtio9p {
1000- bootScript = fmt .Sprintf ("%s\\ n" , bootScript )
1000+ mountCommands = fmt .Sprintf ("%s\\ n" , mountCommands )
10011001 fullMountPath := path .Clean (d .Virtio9pRoot + "/" + virtioShare )
1002- bootScript += fmt .Sprintf ("sudo mkdir -p %s\\ n" , fullMountPath )
1003- bootScript += fmt .Sprintf ("sudo mount -t 9p -o version=9p2000 -o trans=virtio -o uname=%s -o dfltuid=$(id -u docker) -o dfltgid=50 -o access=any host-%d %s" , user .Username , i , fullMountPath )
1002+ mountCommands += fmt .Sprintf ("sudo mkdir -p %s\\ n" , fullMountPath )
1003+ mountCommands += fmt .Sprintf ("sudo mount -t 9p -o version=9p2000 -o trans=virtio -o uname=%s -o dfltuid=$(id -u docker) -o dfltgid=50 -o access=any host-%d %s" , user .Username , i , fullMountPath )
10041004 i ++
10051005 }
10061006
1007- writeScriptCmd := fmt .Sprintf ("echo -e \" %s\" | sudo tee -a %s && sudo chmod +x %s" ,
1008- bootScript , bootScriptName , bootScriptName )
1007+ writeScriptCmd := fmt .Sprintf ("echo -e \" %s\" | sh" , mountCommands )
10091008
10101009 if _ , err := drivers .RunSSHCommandFromDriver (d , writeScriptCmd ); err != nil {
10111010 return err
@@ -1026,10 +1025,8 @@ func (d *Driver) setupNFSShare() error {
10261025 return err
10271026 }
10281027
1029- bootScriptName := "/var/lib/boot2docker/bootlocal.sh"
1030- bootScript := fmt .Sprintf ("#/bin/bash\\ n" )
1031-
1032- bootScript += "sudo /usr/local/etc/init.d/nfs-client start\\ n"
1028+ mountCommands := fmt .Sprintf ("#/bin/bash\\ n" )
1029+ mountCommands += "sudo /usr/local/etc/init.d/nfs-client start\\ n"
10331030
10341031 for _ , share := range d .NFSShares {
10351032 if ! path .IsAbs (share ) {
@@ -1046,16 +1043,15 @@ func (d *Driver) setupNFSShare() error {
10461043 }
10471044
10481045 root := path .Clean (d .NFSSharesRoot )
1049- bootScript += fmt .Sprintf ("sudo mkdir -p %s/%s\\ n" , root , share )
1050- bootScript += fmt .Sprintf ("sudo mount -t nfs -o noacl,async %s:%s %s/%s\\ n" , hostIP , share , root , share )
1046+ mountCommands += fmt .Sprintf ("sudo mkdir -p %s/%s\\ n" , root , share )
1047+ mountCommands += fmt .Sprintf ("sudo mount -t nfs -o noacl,async %s:%s %s/%s\\ n" , hostIP , share , root , share )
10511048 }
10521049
10531050 if err := nfsexports .ReloadDaemon (); err != nil {
10541051 return err
10551052 }
10561053
1057- writeScriptCmd := fmt .Sprintf ("echo -e \" %s\" | sudo tee -a %s && sudo chmod +x %s" ,
1058- bootScript , bootScriptName , bootScriptName )
1054+ writeScriptCmd := fmt .Sprintf ("echo -e \" %s\" | sh" , mountCommands )
10591055
10601056 if _ , err := drivers .RunSSHCommandFromDriver (d , writeScriptCmd ); err != nil {
10611057 return err
0 commit comments