-
Notifications
You must be signed in to change notification settings - Fork 67
/
Makefile
103 lines (97 loc) · 2.88 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
IMGNAME = sdelrio/rpi-hostap
VERSION = $(shell grep "ENV VERSION" Dockerfile| awk 'NF>1{print $$NF}')
SUBNET = 192.168.254.0
APADDR = 192.168.254.1
PLATFORM ?= linux/amd64,linux/arm/v7,linux/arm64
.PHONY: all build test taglatest
all: build test
build:
@docker build -t $(IMGNAME):$(VERSION) --rm . && echo Buildname: $(IMGNAME):$(VERSION)
build-multiarch:
$(info Make: Building container images: $(IMGNAME):${VERSION})
docker buildx build \
--platform $(PLATFORM) \
--progress=plain \
--tag $(IMGNAME):$(VERSION) \
.
build-multiarch-push:
$(info Make: Building container images: $(IMGNAME):${VERSION})
docker buildx build \
--platform $(PLATFORM) \
--progress=plain \
--tag $(IMGNAME):$(VERSION) \
--push \
.
build-multiarch-push-latest:
$(info Make: Building container images: $(IMGNAME):latest)
docker buildx build \
--platform $(PLATFORM) \
--progress=plain \
--tag $(IMGNAME):latest \
--push \
.
test:
@sudo /sbin/ifconfig wlan0 $(APADDR)/24 down
@sudo /sbin/ifconfig wlan0 $(APADDR)/24 up
sudo docker run -t \
--name $(IMGNAME)_test \
-e INTERFACE=wlan0 \
-e SSID=testssid \
-e AP_ADDR=$(APADDR) \
-e SUBNET=$(SUBNET) \
-e SSID=testssid \
-e CHANNEL=6 \
-e WPA_PASSPHRASE=passw0rd \
-e OUTGOINGS=eth0 \
--entrypoint=/bin/test.sh \
--privileged \
--net host \
--rm \
$(IMGNAME):$(VERSION) \
/bin/test.sh || sudo docker stop $(IMGNAME)_test && docker rm $(IMGNAME)_test
run:
@sudo /sbin/ifconfig wlan0 $(APADDR)/24 down
@sudo /sbin/ifconfig wlan0 $(APADDR)/24 up
sudo docker run -d -t \
--name $(IMGNAME)_run \
-e INTERFACE=wlan0 \
-e CHANNEL=6 \
-e SSID=runssid \
-e AP_ADDR=$(APADDR) \
-e SUBNET=$(SUBNET) \
-e WPA_PASSPHRASE=passw0rd \
-e OUTGOINGS=eth0 \
--privileged \
--net host \
$(IMGNAME):$(VERSION)
stop:
@docker stop $(IMGNAME)_test || docker stop $(IMGNAME)_run || docker stop $(IMGNAME)_shell
@docker rm $(IMGNAME)_test || docker rm $(IMGNAME)_run || docker rm $(IMGNAME)_shell
shell:
@sudo /sbin/ifconfig wlan0 $(APADDR)/24 down
@sudo /sbin/ifconfig wlan0 $(APADDR)/24 up
@sudo docker run -t \
--name $(IMGNAME)_shell \
-e INTERFACE=wlan0 \
-e SSID=shellssid \
-e AP_ADDR=$(APADDR) \
-e SUBNET=$(SUBNET) \
-e WPA_PASSPHRASE=passw0rd \
-e OUTGOINGS=eth0 \
--privileged \
--net host \
-ti --entrypoint=/bin/sh \
--rm \
$(IMGNAME):$(VERSION) || sudo docker stop $(IMGNAME)_shell && docker rm $(IMGNAME)_shell
clean:
@docker ps -a |grep rpi-hostap |cut -f 1 -d' '|xargs -P1 -i docker stop {}
@docker ps -a |grep rpi-hostap |cut -f 1 -d' '|xargs -P1 -i docker rm {}
@docker rmi $(IMGNAME):$(VERSION)
taglatest:
docker tag -f $(IMGNAME):$(VERSION) $(IMGNAME):lastest
docker tag -f $(IMGNAME):$(VERSION) sdelrio/$(IMGNAME):$(VERSION)
docker tag -f $(IMGNAME):$(VERSION) sdelrio/$(IMGNAME):latest
push:
docker push sdelrio/$(IMGNAME)
docker push sdelrio/$(IMGNAME):$(VERSION)
release: taglatest push