-
Notifications
You must be signed in to change notification settings - Fork 4
/
Makefile
312 lines (238 loc) · 10.1 KB
/
Makefile
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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
DIST ?= development
CLI = ./bin/uhppote-cli
DATETIME = $(shell date "+%Y-%m-%d %H:%M:%S")
CONTROLLER ?= Alpha
SERIALNO ?= 405419896
CARD ?= 10058400
DOOR ?= 3
INTERLOCK ?= 1&2&3
DEVICEIP ?= 192.168.1.125
LISTEN ?= 192.168.1.100:60001
DEBUG ?= --debug
.DEFAULT_GOAL := debug
.PHONY: clean
.PHONY: update
.PHONY: update-release
all: test \
benchmark \
coverage
clean:
go clean
rm -rf bin
update:
go get -u github.com/uhppoted/uhppote-core@main
go get -u github.com/uhppoted/uhppoted-lib@main
go mod tidy
update-release:
go get -u github.com/uhppoted/uhppote-core
go get -u github.com/uhppoted/uhppoted-lib
go mod tidy
format:
go fmt ./...
build: format
mkdir -p bin
go build -trimpath -o bin ./...
test: build
go test ./...
benchmark: build
go test -bench ./...
coverage: build
go test -cover ./...
vet:
go vet ./...
lint:
env GOOS=darwin GOARCH=amd64 staticcheck ./...
env GOOS=linux GOARCH=amd64 staticcheck ./...
env GOOS=windows GOARCH=amd64 staticcheck ./...
vuln:
govulncheck ./...
build-all: build test vet lint
mkdir -p dist/$(DIST)/linux
mkdir -p dist/$(DIST)/arm
mkdir -p dist/$(DIST)/arm7
mkdir -p dist/$(DIST)/arm6
mkdir -p dist/$(DIST)/darwin-x64
mkdir -p dist/$(DIST)/darwin-arm64
mkdir -p dist/$(DIST)/windows
env GOOS=linux GOARCH=amd64 GOWORK=off go build -trimpath -o dist/$(DIST)/linux ./...
env GOOS=linux GOARCH=arm64 GOWORK=off go build -trimpath -o dist/$(DIST)/arm ./...
env GOOS=linux GOARCH=arm GOARM=7 GOWORK=off go build -trimpath -o dist/$(DIST)/arm7 ./...
env GOOS=linux GOARCH=arm GOARM=6 GOWORK=off go build -trimpath -o dist/$(DIST)/arm6 ./...
env GOOS=darwin GOARCH=amd64 GOWORK=off go build -trimpath -o dist/$(DIST)/darwin-x64 ./...
env GOOS=darwin GOARCH=arm64 GOWORK=off go build -trimpath -o dist/$(DIST)/darwin-arm64 ./...
env GOOS=windows GOARCH=amd64 GOWORK=off go build -trimpath -o dist/$(DIST)/windows ./...
release: update-release build-all
find . -name ".DS_Store" -delete
tar --directory=dist/$(DIST)/linux --exclude=".DS_Store" -cvzf dist/$(DIST)-linux-x64.tar.gz .
tar --directory=dist/$(DIST)/arm --exclude=".DS_Store" -cvzf dist/$(DIST)-arm-x64.tar.gz .
tar --directory=dist/$(DIST)/arm7 --exclude=".DS_Store" -cvzf dist/$(DIST)-arm7.tar.gz .
tar --directory=dist/$(DIST)/arm6 --exclude=".DS_Store" -cvzf dist/$(DIST)-arm6.tar.gz .
tar --directory=dist/$(DIST)/darwin-x64 --exclude=".DS_Store" -cvzf dist/$(DIST)-darwin-x64.tar.gz .
tar --directory=dist/$(DIST)/darwin-arm64 --exclude=".DS_Store" -cvzf dist/$(DIST)-darwin-arm64.tar.gz .
cd dist/$(DIST)/windows && zip --recurse-paths ../../$(DIST)-windows-x64.zip . -x ".DS_Store"
publish: release
echo "Releasing version $(VERSION)"
gh release create "$(VERSION)" "./dist/$(DIST)-arm-x64.tar.gz" \
"./dist/$(DIST)-arm7.tar.gz" \
"./dist/$(DIST)-arm6.tar.gz" \
"./dist/$(DIST)-darwin-arm64.tar.gz" \
"./dist/$(DIST)-darwin-x64.tar.gz" \
"./dist/$(DIST)-linux-x64.tar.gz" \
"./dist/$(DIST)-windows-x64.zip" \
--draft --prerelease --title "$(VERSION)-beta" --notes-file release-notes.md
debug: build
$(CLI) $(DEBUG) set-listener 423187757 $(LISTEN)
irl: build
$(CLI) set-time 423187757
$(CLI) clear-time-profiles 423187757
$(CLI) set-time-profile 423187757 29 2023-01-01:2023-12-31 Mon 08:30-17:00
$(CLI) get-time-profiles 423187757
$(CLI) put-card 423187757 6154410 2023-01-01 2023-12-31 3:29
$(CLI) clear-task-list 423187757
$(CLI) add-task 423187757 'disable time profile' 3 2023-01-01:2023-12-31 Mon 08:30
$(CLI) add-task 423187757 'enable time profile' 3 2023-01-01:2023-12-31 Mon 11:30
$(CLI) add-task 423187757 'lock door' 3 2023-01-01:2023-12-31 Mon 11:45
$(CLI) add-task 423187757 'unlock door' 3 2023-01-01:2023-12-31 Mon 12:00
$(CLI) add-task 423187757 'control door' 3 2023-01-01:2023-12-31 Mon 12:05
$(CLI) add-task 423187757 'disable pushbutton' 3 2023-01-01:2023-12-31 Mon 12:10
$(CLI) add-task 423187757 'enable pushbutton' 3 2023-01-01:2023-12-31 Mon 12:15
$(CLI) add-task 423187757 'trigger once' 3 2023-01-01:2023-12-31 Mon 12:05
$(CLI) refresh-task-list 423187757
godoc:
godoc -http=:80 -index_interval=60s
usage: build
$(CLI)
help: build
$(CLI) help
$(CLI) help get-devices
$(CLI) help record-special-events
version: build
$(CLI) version
# DEVICE COMMANDS
get-devices: build
$(CLI) $(DEBUG) get-devices
get-device: build
$(CLI) $(DEBUG) get-device $(SERIALNO)
set-address: build
$(CLI) $(DEBUG) set-address $(SERIALNO) $(DEVICEIP) '255.255.255.0' '0.0.0.0'
get-listener: build
$(CLI) $(DEBUG) get-listener $(SERIALNO)
set-listener: build
$(CLI) $(DEBUG) set-listener $(SERIALNO) $(LISTEN)
$(CLI) $(DEBUG) set-listener $(SERIALNO) $(LISTEN) 7
get-time: build
$(CLI) $(DEBUG) get-time $(SERIALNO)
set-time: build
$(CLI) $(DEBUG) set-time $(SERIALNO)
$(CLI) $(DEBUG) set-time $(SERIALNO) "$(DATETIME)"
get-door-delay: build
$(CLI) $(DEBUG) get-door-delay $(SERIALNO) $(DOOR)
set-door-delay: build
$(CLI) $(DEBUG) set-door-delay $(SERIALNO) $(DOOR) 5
get-door-control: build
$(CLI) $(DEBUG) get-door-control $(SERIALNO) $(DOOR)
set-door-control: build
$(CLI) $(DEBUG) set-door-control $(SERIALNO) $(DOOR) 'normally closed'
set-door-passcodes: build
# $(CLI) $(DEBUG) set-door-passcodes 423187757 1 12345,999999
$(CLI) $(DEBUG) set-door-passcodes $(SERIALNO) 3 12345,0,999999,654321
record-special-events: build
$(CLI) $(DEBUG) record-special-events $(SERIALNO) true
get-status: build
$(CLI) $(DEBUG) get-status $(SERIALNO)
get-cards: build
$(CLI) $(DEBUG) get-cards $(SERIALNO)
get-card: build
$(CLI) $(DEBUG) get-card $(SERIALNO) $(CARD)
put-card: build
$(CLI) $(DEBUG) put-card $(SERIALNO) $(CARD) 2024-01-01 2024-12-31 1,3,4:29 7531 --card-format any
delete-card: build
$(CLI) $(DEBUG) delete-card $(SERIALNO) $(CARD)
delete-cards: build
$(CLI) delete-all $(SERIALNO)
get-time-profile: build
$(CLI) $(DEBUG) get-time-profile $(SERIALNO) 29
set-time-profile: build
$(CLI) $(DEBUG) set-time-profile 405419896 29 2023-04-01:2023-12-31 Mon,Wed,Fri 08:30-11:30,,13:45-17:00
$(CLI) $(DEBUG) set-time-profile 405419896 3 2023-01-01:2023-12-31 Sat,Sun 09:30-16:30,,
$(CLI) $(DEBUG) set-time-profile 405419896 29 2023-04-01:2023-12-31 Mon,Wed,Fri 08:30-11:30,,13:45-17:00 3
clear-time-profiles: build
$(CLI) $(DEBUG) clear-time-profiles $(SERIALNO)
get-time-profiles: build
$(CLI) get-time-profiles $(SERIALNO)
$(CLI) get-time-profiles $(CONTROLLER) ../runtime/$(CONTROLLER).tsv
set-time-profiles: build
$(CLI) clear-time-profiles $(SERIALNO)
$(CLI) set-time-profile $(SERIALNO) 75 2023-04-01:2023-12-31 Mon,Wed,Fri 08:30-11:30,,13:45-17:00
$(CLI) set-time-profile $(SERIALNO) 100 2023-04-01:2023-12-31 Mon,Wed,Fri 08:30-11:30,,13:45-17:00
$(CLI) set-time-profile 303986753 101 2023-01-01:2023-12-31 Sat,Sun 10:30-16:30
$(CLI) set-time-profiles $(SERIALNO) ../runtime/set-time-profiles.tsv
$(CLI) get-time-profiles $(SERIALNO)
clear-task-list: build
$(CLI) --debug clear-task-list $(SERIALNO)
add-task: build
$(CLI) --debug add-task $(SERIALNO) 3 4 2024-01-01:2024-12-31 Mon,Fri 08:30 33
$(CLI) --debug add-task $(SERIALNO) 'enable more cards' 4 2024-01-01:2024-12-31 Mon,Fri 08:30 29
refresh-task-list: build
$(CLI) --debug refresh-task-list $(SERIALNO)
set-task-list: build
$(CLI) set-task-list $(SERIALNO) ../runtime/set-tasks.tsv
get-events: build
$(CLI) $(DEBUG) get-events $(SERIALNO)
get-event: build
$(CLI) get-event $(SERIALNO) 17
$(CLI) get-event $(SERIALNO) first
$(CLI) get-event $(SERIALNO) last
$(CLI) get-event $(SERIALNO) current
$(CLI) get-event $(SERIALNO) next
$(CLI) get-event $(SERIALNO) next:5
$(CLI) get-event $(SERIALNO)
$(CLI) get-event $(SERIALNO) 17263
get-event-index: build
$(CLI) $(DEBUG) get-event-index $(SERIALNO)
set-event-index: build
$(CLI) $(DEBUG) set-event-index $(SERIALNO) 23
open-door: build
$(CLI) $(DEBUG) open $(SERIALNO) 1
set-pc-control: build
$(CLI) $(DEBUG) set-pc-control $(SERIALNO) true
set-interlock: build
$(CLI) $(DEBUG) set-interlock $(SERIALNO) '$(INTERLOCK)'
activate-keypads: build
$(CLI) $(DEBUG) activate-keypads $(SERIALNO) 1,2,4
restore-default-parameters: build
$(CLI) $(DEBUG) restore-default-parameters $(SERIALNO)
listen: build
$(CLI) --listen $(LISTEN) $(DEBUG) listen
# ACL COMMANDS
show: build
$(CLI) show $(CARD)
grant: build
$(CLI) grant $(CARD) 2023-01-01 2023-12-31 "Gryffindor, Slytherin"
$(CLI) grant $(CARD) 2023-01-01 2023-12-31 29 "Dungeon"
grant-all: build
$(CLI) $(DEBUG) grant $(CARD) 2023-01-01 2023-12-31 ALL
revoke: build
$(CLI) $(DEBUG) revoke $(CARD) "Lady's Chamber, D2"
revoke-all: build
$(CLI) $(DEBUG) revoke $(CARD) ALL
get-acl: build
$(CLI) get-acl
get-acl-with-pin: build
$(CLI) get-acl
$(CLI) get-acl --with-pin
$(CLI) get-acl --with-pin ../runtime/uhppote-cli/acl-with-pin.tsv
compare-acl: build
$(CLI) $(DEBUG) compare-acl ../runtime/simulation/simulation.acl
$(CLI) $(DEBUG) --config ../runtime/simulation/$(SERIALNO).conf compare-acl ../runtime/simulation/simulation.acl ../runtime/simulation/$(SERIALNO).rpt
compare-acl-with-pin: build
$(CLI) compare-acl ../runtime/simulation/simulation.acl
$(CLI) compare-acl ../runtime/simulation/simulation.acl ../runtime/uhppote-cli/compare-acl.tsv
$(CLI) compare-acl --with-pin ../runtime/simulation/simulation.acl
$(CLI) compare-acl --with-pin ../runtime/simulation/simulation-with-pin.acl
$(CLI) compare-acl --with-pin ../runtime/simulation/simulation.acl ../runtime/uhppote-cli/compare-acl-with-pin.tsv
load-acl: build
$(CLI) --config ../runtime/simulation/$(SERIALNO).conf load-acl ../runtime/simulation/$(SERIALNO).acl
load-acl-with-pin: build
$(CLI) load-acl ../runtime/simulation/simulation.acl
$(CLI) load-acl --with-pin ../runtime/simulation/simulation-with-pin.acl