This commit is contained in:
@@ -27,26 +27,50 @@ var initCmd = &cobra.Command{
|
||||
Short: "Initialize BanForge",
|
||||
Run: func(cmd *cobra.Command, args []string) {
|
||||
fmt.Println("Initializing BanForge...")
|
||||
err := os.Mkdir("/var/log/banforge", 0750)
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
os.Exit(1)
|
||||
}
|
||||
err = os.Mkdir("/etc/banforge", 0750)
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
os.Exit(1)
|
||||
}
|
||||
err = config.CreateConf()
|
||||
|
||||
if _, err := os.Stat("/var/log/banforge"); err == nil {
|
||||
fmt.Println("/var/log/banforge already exists, skipping...")
|
||||
} else if os.IsNotExist(err) {
|
||||
err := os.Mkdir("/var/log/banforge", 0750)
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
os.Exit(1)
|
||||
}
|
||||
fmt.Println("Created /var/log/banforge")
|
||||
} else {
|
||||
fmt.Println(err)
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
if _, err := os.Stat("/etc/banforge"); err == nil {
|
||||
fmt.Println("/etc/banforge already exists, skipping...")
|
||||
} else if os.IsNotExist(err) {
|
||||
err := os.Mkdir("/etc/banforge", 0750)
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
os.Exit(1)
|
||||
}
|
||||
fmt.Println("Created /etc/banforge")
|
||||
} else {
|
||||
fmt.Println(err)
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
err := config.CreateConf()
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
os.Exit(1)
|
||||
}
|
||||
fmt.Println("Config created")
|
||||
|
||||
err = config.FindFirewall()
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
os.Exit(1)
|
||||
}
|
||||
fmt.Println("Firewall detected and configured")
|
||||
|
||||
fmt.Println("BanForge initialized successfully!")
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
@@ -20,3 +20,5 @@ log_path = "/var/log/nginx/access.log"
|
||||
enabled = false
|
||||
|
||||
`
|
||||
|
||||
// TODO: fix types for use 1 or any services"
|
||||
|
||||
Reference in New Issue
Block a user