PROJECT_NAME := "Le-Guichet" .PHONY: all test audit clippy build install uninstall help all: test audit clippy build install test: ## Run unittests @cargo test audit: ## Audit code and dependencies @cargo audit clippy: ## Run clippy syntax checker @cargo clippy build: ## Build the binary files @if [ ! -d "bin" ]; then mkdir bin; fi @cargo build --release @cp target/release/leguichet-in bin/ @cp target/release/leguichet-transit bin/ @cp target/release/leguichet-out bin/ @echo "build: Le-Guichet is now compiled in bin directory !" clean: ## Remove previous build @if [ -d "bin" ]; then rm -fr bin; fi install: ## Install Le-Guichet on your GNU/Linux OS, you need to be sudo ! @echo "************************************************************" @echo "You need to be root or a sudo user : type sudo make install" @echo "************************************************************" @if ! getent passwd leguichet-in >/dev/null ; then adduser --quiet --system --disabled-password --home /home/in --group --gecos "leguichet-in user" leguichet-in; fi @if ! getent passwd leguichet-transit >/dev/null ; then adduser --quiet --system --disabled-password --home /home/transit --group --gecos "leguichet-transit user" leguichet-transit; fi @if ! getent passwd leguichet-out >/dev/null ; then adduser --quiet --system --disabled-password --home /home/out --group --gecos "leguichet-out user" leguichet-out; fi @if [ ! -d "/var/log/leguichet-in" ]; then mkdir /var/log/leguichet-in; fi @if [ ! -d "/var/log/leguichet-out" ]; then mkdir /var/log/leguichet-out; fi @if [ ! -d "/var/log/leguichet-transit" ]; then mkdir /var/log/leguichet-transit; fi @chown -R leguichet-in:leguichet-in /var/log/leguichet-in @chown -R leguichet-transit:leguichet-transit /var/log/leguichet-transit @chown -R leguichet-out:leguichet-out /var/log/leguichet-out @chown -R leguichet-in:leguichet-in /home/in @chmod 750 /var/log/leguichet-in @chmod 750 /var/log/leguichet-transit @chmod 750 /var/log/leguichet-out @chmod 775 /home/in @chmod 770 /home/transit @chmod 770 /home/out @if [ ! -d "/run/diode-in" ]; then mkdir /run/diode-in; fi @if [ ! -d "/run/diode-out" ]; then mkdir /run/diode-out; fi @chown leguichet-in:leguichet-transit /run/diode-in @chown leguichet-transit:leguichet-out /run/diode-out @chmod 750 /run/diode-in @chmod 750 /run/diode-out @cp bin/leguichet-in /usr/bin/leguichet-in @cp bin/leguichet-transit /usr/bin/leguichet-transit @cp bin/leguichet-out /usr/bin/leguichet-out @chown leguichet-in:root /usr/bin/leguichet-in @chown leguichet-transit:root /usr/bin/leguichet-transit @chown leguichet-out:root /usr/bin/leguichet-out @cp debian/leguichet-in.service /etc/systemd/system/leguichet-in.service @cp debian/leguichet-transit.service /etc/systemd/system/leguichet-transit.service @cp debian/leguichet-out.service /etc/systemd/system/leguichet-out.service @cp debian/leguichet-in.default /etc/default/leguichet-in @cp debian/leguichet-transit.default /etc/default/leguichet-transit @cp debian/leguichet-out.default /etc/default/leguichet-out @echo "Installation completed !" @echo "Enable Le-Guichet system in systemd..." @sudo systemctl enable leguichet-in.service @sudo systemctl enable leguichet-transit.service @sudo systemctl enable leguichet-out.service @echo "Reloading the systemd daemon" @sudo systemctl daemon-reload @echo "Now, starting the systemd units ! " @sudo systemctl start leguichet-in.service @sudo systemctl start leguichet-transit.service @sudo systemctl start leguichet-out.service @echo "Now, you can create new users belonging to group leguichet-in to be able to deposit files into /home/in/" @echo "sudo adduser --home /home/in --gid LEGUICHET-IN_GID untrusted_user (where LEGUICHET-IN_GID is the ID of the group leguichet-in)" @echo "You also need to create new users belonging to group leguichet-out to be able to retrieve files from /home/out/" @echo "sudo adduser --home /home/out --gid LEGUICHET-OUT_GID trusted_user (where LEGUICHET-OUT_GID is the ID of the group leguichet-out)" uninstall: ## Uninstall Le-Guichet on your GNU/Linux OS, you need to be sudo ! @echo "*************************************************************" @echo "You need to be root or a sudo user : type sudo make uninstall" @echo "*************************************************************" @sudo systemctl stop leguichet-in.service @sudo systemctl stop leguichet-transit.service @sudo systemctl stop leguichet-out.service @sudo systemctl disable leguichet-in.service @sudo systemctl disable leguichet-transit.service @sudo systemctl disable leguichet-out.service @sudo systemctl daemon-reload @if [ -d "/var/log/leguichet-in" ]; then sudo rm -fr /var/log/leguichet-in/; fi @if [ -d "/var/log/leguichet-transit" ]; then sudo rm -fr /var/log/leguichet-transit/; fi @if [ -d "/var/log/leguichet-out" ]; then sudo rm -fr /var/log/leguichet-out/; fi @if [ -f "/etc/systemd/system/leguichet-in.service" ]; then rm /etc/systemd/system/leguichet-in.service; fi @if [ -f "/etc/systemd/system/leguichet-transit.service" ]; then rm /etc/systemd/system/leguichet-transit.service; fi @if [ -f "/etc/systemd/system/leguichet-out.service" ]; then rm /etc/systemd/system/leguichet-out.service; fi @if [ -f "/etc/default/leguichet-in" ]; then rm /etc/default/leguichet-in; fi @if [ -f "/etc/default/leguichet-transit" ]; then rm /etc/default/leguichet-transit; fi @if [ -f "/etc/default/leguichet-out" ]; then rm /etc/default/leguichet-out; fi @rm /usr/bin/leguichet-in @rm /usr/bin/leguichet-transit @rm /usr/bin/leguichet-out @deluser --quiet leguichet-in >/dev/null @deluser --quiet leguichet-transit >/dev/null @deluser --quiet leguichet-out >/dev/null @if [ -d "/home/in" ]; then sudo rm -fr /home/in/; fi @if [ -d "/home/out" ]; then sudo rm -fr /home/out/; fi @if [ -d "/home/transit" ]; then sudo rm -fr /home/transit/; fi @if [ -d "/run/diode-in" ]; then sudo rm -fr /run/diode-in/; fi @if [ -d "/run/diode-out" ]; then sudo rm -fr /run/diode-out/; fi @echo "Le-Guichet should be removed !" help: ## Display this help screen @echo "!!! Cargo and rustc should be installed and configured before compiling !!!" @grep -h -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'