mirror of
https://github.com/bettercap/bettercap
synced 2025-07-05 20:42:09 -07:00
new: new -caplets-path argument to specify an alternative caplets base path (closes #850)
This commit is contained in:
parent
161124a3f4
commit
d63122bab3
3 changed files with 27 additions and 6 deletions
|
@ -15,7 +15,7 @@ const (
|
||||||
InstallArchive = "https://github.com/bettercap/caplets/archive/master.zip"
|
InstallArchive = "https://github.com/bettercap/caplets/archive/master.zip"
|
||||||
)
|
)
|
||||||
|
|
||||||
func getInstallBase() string {
|
func getDefaultInstallBase() string {
|
||||||
if runtime.GOOS == "windows" {
|
if runtime.GOOS == "windows" {
|
||||||
return filepath.Join(os.Getenv("ALLUSERSPROFILE"), "bettercap")
|
return filepath.Join(os.Getenv("ALLUSERSPROFILE"), "bettercap")
|
||||||
}
|
}
|
||||||
|
@ -28,10 +28,18 @@ func getUserHomeDir() string {
|
||||||
}
|
}
|
||||||
|
|
||||||
var (
|
var (
|
||||||
InstallBase = getInstallBase()
|
InstallBase = ""
|
||||||
|
InstallPathArchive = ""
|
||||||
|
InstallPath = ""
|
||||||
|
ArchivePath = ""
|
||||||
|
LoadPaths = []string(nil)
|
||||||
|
)
|
||||||
|
|
||||||
|
func Setup(base string) error {
|
||||||
|
InstallBase = base
|
||||||
InstallPathArchive = filepath.Join(InstallBase, "caplets-master")
|
InstallPathArchive = filepath.Join(InstallBase, "caplets-master")
|
||||||
InstallPath = filepath.Join(InstallBase, "caplets")
|
InstallPath = filepath.Join(InstallBase, "caplets")
|
||||||
ArchivePath = filepath.Join(os.TempDir(), "caplets.zip")
|
ArchivePath = filepath.Join(os.TempDir(), "caplets.zip")
|
||||||
|
|
||||||
LoadPaths = []string{
|
LoadPaths = []string{
|
||||||
"./",
|
"./",
|
||||||
|
@ -39,9 +47,7 @@ var (
|
||||||
InstallPath,
|
InstallPath,
|
||||||
filepath.Join(getUserHomeDir(), "caplets"),
|
filepath.Join(getUserHomeDir(), "caplets"),
|
||||||
}
|
}
|
||||||
)
|
|
||||||
|
|
||||||
func init() {
|
|
||||||
for _, path := range str.SplitBy(str.Trim(os.Getenv(EnvVarName)), string(os.PathListSeparator)) {
|
for _, path := range str.SplitBy(str.Trim(os.Getenv(EnvVarName)), string(os.PathListSeparator)) {
|
||||||
if path = str.Trim(path); len(path) > 0 {
|
if path = str.Trim(path); len(path) > 0 {
|
||||||
LoadPaths = append(LoadPaths, path)
|
LoadPaths = append(LoadPaths, path)
|
||||||
|
@ -51,4 +57,11 @@ func init() {
|
||||||
for i, path := range LoadPaths {
|
for i, path := range LoadPaths {
|
||||||
LoadPaths[i], _ = filepath.Abs(path)
|
LoadPaths[i], _ = filepath.Abs(path)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
// init with defaults
|
||||||
|
Setup(getDefaultInstallBase())
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,6 +16,7 @@ type Options struct {
|
||||||
Commands *string
|
Commands *string
|
||||||
CpuProfile *string
|
CpuProfile *string
|
||||||
MemProfile *string
|
MemProfile *string
|
||||||
|
CapletsPath *string
|
||||||
}
|
}
|
||||||
|
|
||||||
func ParseOptions() (Options, error) {
|
func ParseOptions() (Options, error) {
|
||||||
|
@ -33,6 +34,7 @@ func ParseOptions() (Options, error) {
|
||||||
Commands: flag.String("eval", "", "Run one or more commands separated by ; in the interactive session, used to set variables via command line."),
|
Commands: flag.String("eval", "", "Run one or more commands separated by ; in the interactive session, used to set variables via command line."),
|
||||||
CpuProfile: flag.String("cpu-profile", "", "Write cpu profile `file`."),
|
CpuProfile: flag.String("cpu-profile", "", "Write cpu profile `file`."),
|
||||||
MemProfile: flag.String("mem-profile", "", "Write memory profile to `file`."),
|
MemProfile: flag.String("mem-profile", "", "Write memory profile to `file`."),
|
||||||
|
CapletsPath: flag.String("caplets-path", "", "Specify an alternative base path for caplets."),
|
||||||
}
|
}
|
||||||
|
|
||||||
flag.Parse()
|
flag.Parse()
|
||||||
|
|
|
@ -224,6 +224,12 @@ func (s *Session) Start() error {
|
||||||
return s.Modules[i].Name() < s.Modules[j].Name()
|
return s.Modules[i].Name() < s.Modules[j].Name()
|
||||||
})
|
})
|
||||||
|
|
||||||
|
if *s.Options.CapletsPath != "" {
|
||||||
|
if err = caplets.Setup(*s.Options.CapletsPath); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if s.Interface, err = network.FindInterface(*s.Options.InterfaceName); err != nil {
|
if s.Interface, err = network.FindInterface(*s.Options.InterfaceName); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue