Find file
Fetching contributors…
Cannot retrieve contributors at this time
136 lines (110 sloc) 3.54 KB
package main
import (
func SetupTemplate(w io.Writer, icecast *Icecast, server, master *Server) error {
err := setupTmpl.Execute(w, struct {
Icecast *Icecast
Server, Master *Server
}{icecast, server, master})
if err != nil {
return fmt.Errorf("SetupTemplate: %v", err)
return nil
var setupTmpl *template.Template
func init() {
setupTmpl = template.New("setup")
const setupText = `#!/bin/bash
sudo apt-get -qq -y install icecast2
cat > etc_icecast2_icecast.xml <<EOF
<!-- Sources log in with username 'source' -->
<!-- Relays log in username 'relay' -->
<!-- Admin logs in with the username given below -->
{{if .Master}}
<alias source="/" dest="/status.xsl"/>
<loglevel>3</loglevel> <!-- 4 Debug, 3 Info, 2 Warn, 1 Error -->
<logsize>10000</logsize> <!-- Max size of a logfile -->
cat > etc_default_icecast2 <<EOF
# Defaults for icecast2 initscript
# sourced by /etc/init.d/icecast2
# installed at /etc/default/icecast2 by the maintainer scripts
# This is a POSIX shell fragment
# Full path to the server configuration file
# Name or ID of the user and group the daemon should run under
# Edit /etc/icecast2/icecast.xml and change at least the passwords.
# Change this to true when done to enable the init.d script
sudo cp etc_default_icecast2 /etc/default/icecast2
sudo cp etc_icecast2_icecast.xml /etc/icecast2/icecast.xml
sudo chown icecast2:icecast /etc/icecast2/icecast.xml
sudo chmod 660 /etc/icecast2/icecast.xml
sudo /etc/init.d/icecast2 restart
var m3uTmpl = template.Must(template.New("m3u").Parse(
"{{range .}}{{.}}\n{{end}}"))
var plsTmpl = template.Must(template.New("m3u").Funcs(template.FuncMap{
"idx": func(i int) int { return i + 1 },
{{range $i, $s := .}}
File{{idx $i}}={{$s}}
Title{{idx $i}}=Server {{idx $i}}
Length{{idx $i}}=-1
NumberOfEntries={{len .}}