.DEFAULT_GOAL = test include ../Makefile testuser = testuser SU = $(SUDO) su .PHONY: test useradd cleanuser useradd: $(SUDO) useradd $(testuser) --shell /bin/bash --create-home $(SU) - $(testuser) -c 'ssh-keygen -t ed25519 -f ~/.ssh/id_ed25519 -N ""' $(SU) - $(testuser) -c 'git config --global user.name $(testuser)' $(SU) - $(testuser) -c 'git config --global user.email $(testuser)' test: $(shell getent passwd $(testuser) >/dev/null || echo useradd) $(SUDO) install -t ~$(testuser) tests.sh $(SUDO) machinectl shell --uid=$(testuser) '' /bin/sh -c './tests.sh' ifeq ($(testuser),) $(error testuser not defined) endif cleanuser_command = $(SUDO) rm -I -r ~$(testuser) cleanuser: : Preparing to run destructive command: : : : $(cleanuser_command) : : : Press ctrl-c to abort. : @for n in 5 4 3 2 1; do printf ' %d\r' "$$n"; sleep 1; done $(cleanuser_command) || true $(SUDO) userdel testuser || true