forked from toolshed/abra
		
	fix: --local/--provision works
This commit is contained in:
		@ -135,17 +135,19 @@ func newLocalServer(c *cli.Context, domainName string) error {
 | 
			
		||||
		return err
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if _, err := exec.LookPath("docker"); err != nil {
 | 
			
		||||
		if provision {
 | 
			
		||||
	if provision {
 | 
			
		||||
		if _, err := exec.LookPath("docker"); err != nil {
 | 
			
		||||
			if err := installDockerLocal(c); err != nil {
 | 
			
		||||
				return err
 | 
			
		||||
			}
 | 
			
		||||
			if err := initSwarm(c, cl, domainName); err != nil {
 | 
			
		||||
		}
 | 
			
		||||
		if err := initSwarmLocal(c, cl, domainName); err != nil {
 | 
			
		||||
			if !strings.Contains(err.Error(), "proxy already exists") {
 | 
			
		||||
				logrus.Fatal(err)
 | 
			
		||||
			}
 | 
			
		||||
		} else {
 | 
			
		||||
			logrus.Warn("no docker installation found, use '-p' to provision")
 | 
			
		||||
		}
 | 
			
		||||
	} else {
 | 
			
		||||
		logrus.Warn("no docker installation found, use '-p' to provision")
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if traefik {
 | 
			
		||||
@ -241,6 +243,28 @@ func installDocker(c *cli.Context, cl *dockerClient.Client, sshCl *simplessh.Cli
 | 
			
		||||
	return nil
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func initSwarmLocal(c *cli.Context, cl *dockerClient.Client, domainName string) error {
 | 
			
		||||
	initReq := swarm.InitRequest{ListenAddr: "0.0.0.0:2377"}
 | 
			
		||||
	if _, err := cl.SwarmInit(c.Context, initReq); err != nil {
 | 
			
		||||
		if !strings.Contains(err.Error(), "is already part of a swarm") {
 | 
			
		||||
			return err
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	logrus.Infof("initialised swarm mode on local server")
 | 
			
		||||
 | 
			
		||||
	netOpts := types.NetworkCreate{Driver: "overlay", Scope: "swarm"}
 | 
			
		||||
	if _, err := cl.NetworkCreate(c.Context, "proxy", netOpts); err != nil {
 | 
			
		||||
		if !strings.Contains(err.Error(), "is already part of a swarm") {
 | 
			
		||||
			return err
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	logrus.Infof("swarm overlay network created on local server")
 | 
			
		||||
 | 
			
		||||
	return nil
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func initSwarm(c *cli.Context, cl *dockerClient.Client, domainName string) error {
 | 
			
		||||
	// comrade librehosters DNS resolver -> https://www.privacy-handbuch.de/handbuch_93d.htm
 | 
			
		||||
	freifunkDNS := "5.1.66.255:53"
 | 
			
		||||
@ -283,7 +307,9 @@ func initSwarm(c *cli.Context, cl *dockerClient.Client, domainName string) error
 | 
			
		||||
 | 
			
		||||
	netOpts := types.NetworkCreate{Driver: "overlay", Scope: "swarm"}
 | 
			
		||||
	if _, err := cl.NetworkCreate(c.Context, "proxy", netOpts); err != nil {
 | 
			
		||||
		return err
 | 
			
		||||
		if !strings.Contains(err.Error(), "is already part of a swarm") {
 | 
			
		||||
			return err
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	logrus.Infof("swarm overlay network created on %s", domainName)
 | 
			
		||||
 | 
			
		||||
		Reference in New Issue
	
	Block a user