Example #1
0
func (ngx *Nginx) Render(pkg urknall.Package) {
	syslogPatchPath := "/tmp/nginx_syslog_patch"
	fileName := "syslog_{{ .SyslogPatchVersion }}.patch"
	pkg.AddCommands("packages",
		InstallPackages("build-essential", "curl", "libpcre3", "libpcre3-dev", "libssl-dev", "libpcrecpp0", "zlib1g-dev", "libgd2-xpm-dev"),
	)
	pkg.AddCommands("download",
		DownloadAndExtract("{{ .Url }}", "/opt/src/"),
	)
	pkg.AddCommands("syslog_patch",
		Mkdir(syslogPatchPath, "root", 0755),
		Download("https://raw.github.com/yaoweibin/nginx_syslog_patch/master/config", syslogPatchPath+"/config", "root", 0644),
		Download("https://raw.github.com/yaoweibin/nginx_syslog_patch/master/"+fileName, syslogPatchPath+"/"+fileName, "root", 0644),
		And(
			"cd /opt/src/nginx-{{ .Version }}",
			"patch -p1 < "+syslogPatchPath+"/"+fileName,
		),
	)
	pkg.AddCommands("more_clear_headers",
		DownloadAndExtract("https://github.com/agentzh/headers-more-nginx-module/archive/v{{ .HeadersMoreVersion }}.tar.gz", "/opt/src/"),
	)
	pkg.AddCommands("build",
		And(
			"cd /opt/src/nginx-{{ .Version }}",
			"./configure --with-http_ssl_module --with-http_gzip_static_module --with-http_stub_status_module --with-http_spdy_module --add-module=/tmp/nginx_syslog_patch --add-module=/opt/src/headers-more-nginx-module-{{ .HeadersMoreVersion }} --prefix={{ .InstallDir }}",
			"make",
			"make install",
		),
	)
	pkg.AddCommands("upstart",
		WriteFile("/etc/init/nginx.conf", utils.MustRenderTemplate(nginxUpstartScript, ngx), "root", 0644),
	)
}
Example #2
0
func (pkg *packageImpl) AddTemplate(name string, tpl Template) {
	if pkg.cacheKeyPrefix != "" {
		name = pkg.cacheKeyPrefix + "." + name
	}
	name = utils.MustRenderTemplate(name, pkg.reference)
	e := validateTemplate(tpl)
	if e != nil {
		panic(e)
	}
	if pkg.reference != nil {
		name = utils.MustRenderTemplate(name, pkg.reference)
	}
	pkg.validateTaskName(name)
	child := &packageImpl{cacheKeyPrefix: name, reference: tpl}
	tpl.Render(child)
	for _, task := range child.tasks {
		pkg.addTask(task)
	}
}
Example #3
0
func (pkg *packageImpl) AddCommands(name string, cmds ...cmd.Command) {
	if pkg.cacheKeyPrefix != "" {
		name = pkg.cacheKeyPrefix + "." + name
	}
	name = utils.MustRenderTemplate(name, pkg.reference)
	t := &task{name: name}
	for _, c := range cmds {
		if r, ok := c.(cmd.Renderer); ok {
			r.Render(pkg.reference)
		}
		t.Add(c)
	}
	pkg.addTask(t)
}
Example #4
0
func (pkg *packageImpl) AddTask(name string, tsk Task) {
	if pkg.cacheKeyPrefix != "" {
		name = pkg.cacheKeyPrefix + "." + name
	}
	name = utils.MustRenderTemplate(name, pkg.reference)
	t := &task{name: name}
	cmds, e := tsk.Commands()
	if e != nil {
		panic(e)
	}
	for _, c := range cmds {
		t.Add(c)
	}
	pkg.addTask(t)
}
Example #5
0
func (c *testCommand) Render(i interface{}) {
	c.cmd = utils.MustRenderTemplate(c.cmd, i)
}
Example #6
0
func (cmd *ShellCommand) Render(i interface{}) {
	cmd.Command = utils.MustRenderTemplate(cmd.Command, i)
}
Example #7
0
func (cmd *FileCommand) Render(i interface{}) {
	cmd.Path = utils.MustRenderTemplate(cmd.Path, i)
	cmd.Content = utils.MustRenderTemplate(cmd.Content, i)
}
Example #8
0
func (fsc *FileSendCommand) Render(i interface{}) {
	fsc.Source = utils.MustRenderTemplate(fsc.Source, i)
	fsc.Target = utils.MustRenderTemplate(fsc.Target, i)
}
Example #9
0
func (sc *stringCommand) Render(i interface{}) {
	sc.cmd = utils.MustRenderTemplate(sc.cmd, i)
}
Example #10
0
func (cmd *ShellCommand) Render(i interface{}) {
	cmd.Command = utils.MustRenderTemplate(cmd.Command, i)
	if cmd.user != "" {
		cmd.user = utils.MustRenderTemplate(cmd.user, i)
	}
}
Example #11
0
func (cmd *DownloadCommand) Render(i interface{}) {
	cmd.Url = utils.MustRenderTemplate(cmd.Url, i)
	cmd.Destination = utils.MustRenderTemplate(cmd.Destination, i)
}
Example #12
0
func (ngx *Nginx) ReloadCommand() string {
	return utils.MustRenderTemplate("{{ . }} -t && {{ . }} -s reload", ngx.BinPath())
}