-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhoneytrap-agent.rb
74 lines (60 loc) · 2.2 KB
/
honeytrap-agent.rb
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
class HoneytrapAgent < Formula
#git_tag = "RELEASE.2018-01-02T23-07-00Z"
desc "Honeytrap Agent"
homepage "https://github.com/honeytrap/honeytrap-agent"
url "https://github.com/honeytrap/honeytrap-agent.git", :revision => "ff913cf3951bd03fc34abb2a25a1d722fa1ecd87"
#version git_tag.gsub(%r'[^\d]+', '') + 'Z'
#revision 1
bottle :unneeded
depends_on "go" => :build
def install
ENV["GOPATH"] = buildpath
clipath = buildpath/"src/github.com/honeytrap/honeytrap-agent"
clipath.install Dir["*"]
ldflags = "-X github.com/honeytrap/honeytrap-agent/server.Version=2018-03-05T14:52:44Z -X github.com/honeytrap/honeytrap-agent/server.ReleaseTag=DEVELOPMENT.2018-03-05T14-52-44Z -X github.com/honeytrap/honeytrap-agent/server.CommitID=ff913cf3951bd03fc34abb2a25a1d722fa1ecd87 -X github.com/honeytrap/honeytrap-agent/server.ShortCommitID=ff913cf3951b"
cd clipath do
system "go", "build", "-ldflags", ldflags, "-o", buildpath/"honeytrap-agent"
end
bin.install "honeytrap-agent"
(buildpath/"honeytrap-agent.toml").write <<~EOS
server="{server-name-or-ip:1337}"
remote-key="{token}"
EOS
etc.install "honeytrap-agent.toml"
end
def post_install
(var/"log/honeytrap-agent").mkpath
end
plist_options :manual => "honeytrap-agent"
def plist; <<~EOS
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>UserName</key>
<string>root</string>
<key>KeepAlive</key>
<true/>
<key>Label</key>
<string>#{plist_name}</string>
<key>ProgramArguments</key>
<array>
<string>#{bin}/honeytrap-agent</string>
<string>--config=#{etc}/honeytrap-agent/config.toml</string>
</array>
<key>RunAtLoad</key>
<true/>
<key>WorkingDirectory</key>
<string>#{HOMEBREW_PREFIX}</string>
<key>StandardErrorPath</key>
<string>#{var}/log/honeytrap-agent/output.log</string>
<key>StandardOutPath</key>
<string>#{var}/log/honeytrap-agent/output.log</string>
</dict>
</plist>
EOS
end
test do
system "#{bin}/honeytrap-agent"
end
end