-
Notifications
You must be signed in to change notification settings - Fork 22
/
Copy pathrun.go
80 lines (63 loc) · 1.99 KB
/
run.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
package cmd
import (
"fmt"
"log"
"os"
"path"
"strconv"
"time"
)
func run(d *DDConfig) {
// Print the install banner
if !(d.quiet || d.conf.Options.Embd) {
d.dojoBanner()
}
// Setup command logging
d.cmdLogger = setCmdLogging(d)
// Check embedded
embdCk(d)
// Check install OS
osTarget := checkOS(d)
// Bootstrap install
bootstrapInstall(d, &osTarget)
// Validate Python version
validPython(d)
// Download DefectDojo release or source
downloadDojo(d)
// Install OS packges need by DefectDojo
prepOSForDojo(d, &osTarget)
// Install DB if needed
installDBForDojo(d, &osTarget)
// Prepare the DB for DefectDojo
prepDBForDojo(d, &osTarget)
// Prepare for Django - virtenv, etc
// TODO Convert to Commandeer
prepDjango(d, &osTarget)
// Create settings.py
createSettings(d, &osTarget)
// Setup DefectDojo
setupDefectDojo(d, &osTarget)
d.statusMsg(fmt.Sprintf("\nSuccessfully installed DefectDojo using godojo version %+v", d.ver))
}
func setCmdLogging(d *DDConfig) *log.Logger {
// Setup OS command logging
d.traceMsg("Creating log file for OS command output for debugging reasons")
n := time.Now()
when := strconv.Itoa(int(n.UnixNano()))
cmdLog := "cmd-output_" + when + ".log"
cmdPath := path.Join(d.logLocation, cmdLog)
// Create command output log file in the existing logging directory
cmdLogger, err := os.OpenFile(cmdPath, os.O_CREATE|os.O_WRONLY|os.O_APPEND, 0666)
if err != nil {
fmt.Println("")
fmt.Println("##############################################################################")
fmt.Printf(" ERROR: Failed to open OS Command log file %s. Error was:\n %+v\n", cmdPath, err)
fmt.Println("##############################################################################")
fmt.Println("")
fmt.Println("Log files are required for the install, exiting install")
os.Exit(1)
}
//cmdLogger = cmdFile
d.traceMsg(fmt.Sprintf("Successfully created OS Command log file at %+v", cmdPath))
return log.New(cmdLogger, "[godojo] # ", log.Ldate|log.Ltime)
}