diff --git a/Makefile b/Makefile index d7621dd..e4bea3e 100644 --- a/Makefile +++ b/Makefile @@ -1,20 +1,41 @@ PREFIX ?= /usr/local -MAN_PREFIX ?= ${PREFIX}/man +BINDIR ?= ${PREFIX}/bin +LIBDIR ?= ${PREFIX}/lib +SHAREDIR ?= ${PREFIX}/share +EXAMPLESDIR ?= ${SHAREDIR}/examples + +MANDIR.${PREFIX} = ${PREFIX}/share/man +MANDIR./usr/local = /usr/local/man +MANDIR. = /usr/share/man +MANDIR ?= ${MANDIR.${PREFIX}} + +.PHONY: all install test distrib all: target/release/pizauth target/release/pizauth: cargo build --release +PLATFORM=$(shell uname) + install: target/release/pizauth - install -d ${PREFIX}/bin - install -c -m 555 target/release/pizauth ${PREFIX}/bin/pizauth - install -d ${MAN_PREFIX}/man1 - install -d ${MAN_PREFIX}/man5 - install -c -m 444 pizauth.1 ${MAN_PREFIX}/man1/pizauth.1 - install -c -m 444 pizauth.conf.5 ${MAN_PREFIX}/man5/pizauth.conf.5 - install -d ${PREFIX}/share/examples/pizauth - install -c -m 444 pizauth.conf.example ${PREFIX}/share/examples/pizauth + install -d ${DESTDIR}${BINDIR} + install -c -m 555 target/release/pizauth ${DESTDIR}${BINDIR}/pizauth + install -d ${DESTDIR}${MANDIR}/man1 + install -d ${DESTDIR}${MANDIR}/man5 + install -c -m 444 pizauth.1 ${DESTDIR}${MANDIR}/man1/pizauth.1 + install -c -m 444 pizauth.conf.5 ${DESTDIR}${MANDIR}/man5/pizauth.conf.5 + install -d ${DESTDIR}${EXAMPLESDIR}/pizauth + install -c -m 444 examples/pizauth.conf ${DESTDIR}${EXAMPLESDIR}/pizauth/pizauth.conf + install -d ${DESTDIR}${SHAREDIR}/pizauth/bash + install -c -m 444 share/bash/completion.bash ${DESTDIR}${SHAREDIR}/pizauth/bash/completion.bash +ifeq ($(PLATFORM), Linux) + install -d ${DESTDIR}${LIBDIR}/systemd/user + install -c -m 444 lib/systemd/user/pizauth.service ${DESTDIR}${LIBDIR}/systemd/user/pizauth.service + install -d ${DESTDIR}${EXAMPLESDIR}/pizauth/systemd-dropins + install -c -m 444 examples/systemd-dropins/age.conf ${DESTDIR}${EXAMPLESDIR}/pizauth/systemd-dropins/age.conf + install -c -m 444 examples/systemd-dropins/gpg-dump.conf ${DESTDIR}${EXAMPLESDIR}/pizauth/systemd-dropins/gpg-dump.conf +endif test: cargo test diff --git a/README.Linux.md b/README.Linux.md new file mode 100644 index 0000000..9023eb3 --- /dev/null +++ b/README.Linux.md @@ -0,0 +1,24 @@ +# pizauth on Linux + +Pizauth comes with a systemd unit and example configurations. To start pizauth: + +```sh +$ systemctl --user start pizauth.service +``` + +If you want `pizauth` to start on login, run + +```sh +$ systemctl --user enable pizauth.service +``` + +In `/usr/share/examples/pizauth/systemd-dropins` are templates for saving +pizauth dumps encrypted with `age` and `gpg`. To use them, run + +```sh +$ systemctl --user edit pizauth.service +``` + +and paste whichever of the templates suits you in the file `systemctl` opens. +Make sure to modify the references to private/public keys/IDs in the temalpte +file to point to your keys/IDs. diff --git a/README.md b/README.md index 369d1b0..8ad9aac 100644 --- a/README.md +++ b/README.md @@ -126,30 +126,6 @@ Note that: becoming invalid and pizauth realising that has happened and notifying you to request a new token. -### Systemd unit - -Pizauth ships with a systemd unit and example configurations. -To start `pizauth`, run - -```sh -$ systemctl --user start pizauth.service -``` - -If you want `pizauth` to start on login, run - -```sh -$ systemctl --user enable pizauth.service -``` - -Finally, in `systemd-dropins/` you'll find templates for saving pizauth dumps -encrypted with `age` and `gpg`. To use them, run - -```sh -$ systemctl --user edit pizauth.service -``` - -and paste whichever of these templates suits you in the file `systemctl` opens. -(Modify the references to private/public keys to actually point to your keys!) ## Command-line interface diff --git a/pizauth.conf.example b/examples/pizauth.conf similarity index 100% rename from pizauth.conf.example rename to examples/pizauth.conf diff --git a/systemd-dropins/age.conf b/examples/systemd-dropins/age.conf similarity index 100% rename from systemd-dropins/age.conf rename to examples/systemd-dropins/age.conf diff --git a/systemd-dropins/gpg-dump.conf b/examples/systemd-dropins/gpg-dump.conf similarity index 100% rename from systemd-dropins/gpg-dump.conf rename to examples/systemd-dropins/gpg-dump.conf diff --git a/pizauth.service b/lib/systemd/user/pizauth.service similarity index 100% rename from pizauth.service rename to lib/systemd/user/pizauth.service diff --git a/pizauth.bashcomp b/share/bash/completion.bash similarity index 100% rename from pizauth.bashcomp rename to share/bash/completion.bash