Esempio n. 1
0
//New returns a new cache, for the resource identified by hash, backed by store.
func New(hash []byte, store Store) Cache {
	return Cache{
		Store: store,
		Hash:  hash,
		log:   logger.New(),
	}
}
Esempio n. 2
0
)

func handleFatal() {
	if err := recover(); err != nil {
		fmt.Println(err)
		os.Exit(1)
	}
}

func check(err error) {
	if err != nil {
		panic(err)
	}
}

var l = logger.New()
var fileStore = cache.FileStore{Dir: "/var/assemblyline/cache/"}

func main() {
	defer handleFatal()

	confFile, err := os.Open("/etc/assemblyline/spanner/" + os.Args[1] + ".toml")
	check(err)
	config, err := config.Read(confFile)
	check(err)

	assemblyFile, err := os.Open("Assemblyfile")
	check(err)
	af, err := assemblyfile.Read(assemblyFile)
	check(err)
Esempio n. 3
0
package step

import (
	"github.com/assemblyline/spanner/cache"
	"github.com/assemblyline/spanner/logger"
	"os/exec"
)

var log = logger.New()

//Step represents a runnable script that updates the contents of a particular directory
//Optionly caches that directory
type Step struct {
	Name   string
	Dir    string
	Cache  cache.Cache
	Script [][]string
}

//Exec runs the script in order to update the filesystem
//If the step is cacheable the cache is restored to the filesystem before the script is run and updated after
func (s Step) Exec() error {
	log.StepTitle(s.Name)
	s.restore()
	for _, command := range s.Script {
		if err := run(command[0], command[1:]...); err != nil {
			return err
		}
	}
	s.save()
	return nil