phi/openldap/Makefile

59 lines
1.1 KiB
Makefile
Raw Permalink Normal View History

2019-04-12 16:22:36 +02:00
CONTAINER := phi_slapd
2017-12-16 23:03:03 +01:00
.PHONY: all
all: build run
.PHONY: build
build: gen-cert
docker build --no-cache -t unit/slapd .
.PHONY: gen-cert
gen-cert:
openssl req \
-x509 -nodes -days 365 -sha256 \
-subj '/C=IT/ST=Lombardia/L=Milano/CN=localhost' \
2017-12-16 23:03:03 +01:00
-newkey rsa:2048 -keyout key.pem -out cert.pem
.PHONY: clean
clean:
2020-08-23 21:32:20 +02:00
docker rm $(CONTAINER) || true
docker rmi unit/slapd
2017-12-16 23:03:03 +01:00
rm -f key.pem cert.pem
.PHONY: run
2019-04-12 16:22:36 +02:00
run: prepare
docker attach phi_slapd
2017-12-16 23:03:03 +01:00
2019-04-12 16:22:36 +02:00
.PHONY: prepare
prepare:
docker run -p 389:389 -d --name="$(CONTAINER)" --rm unit/slapd
sleep 2
LDAPTLS_REQCERT=never \
ldapmodify -ZZ -H ldap://127.0.0.1:389 \
2017-12-16 23:03:03 +01:00
-x -D "cn=root,dc=unit,dc=macaomilano,dc=org" -w root \
-a -f init.ldif
2019-04-12 16:22:36 +02:00
.PHONY: run-bg
run-bg:
make prepare
2020-11-11 22:24:11 +01:00
.PHONY: logs
logs:
docker logs -f phi_slapd
2019-04-12 16:22:36 +02:00
.PHONY: stop
stop: is-running
docker stop $(CONTAINER)
.PHONY: is-running
is-running:
@[[ $$(docker ps -qf=name=$(CONTAINER)|wc -l) -eq 1 ]]
2017-12-16 23:03:03 +01:00
.PHONY: inspect
2019-04-12 16:22:36 +02:00
inspect: is-running
LDAPTLS_REQCERT=never \
ldapsearch -ZZ -H ldap://127.0.0.1 \
2017-12-16 23:03:03 +01:00
-x -D "cn=root,dc=unit,dc=macaomilano,dc=org" -w root \
-b "dc=unit,dc=macaomilano,dc=org" \
'(objectclass=*)'