mirror of
https://github.com/MinecraftServerControl/mscs.git
synced 2024-11-14 22:38:18 -07:00
86bde27736
Added a safety check to see if the user exists when running make install. It was dying on me because the user already existed. Now if the user exists, it reports back the user exists and skips it.
52 lines
1.4 KiB
Makefile
52 lines
1.4 KiB
Makefile
MSCS_USER := minecraft
|
|
MSCS_HOME := /opt/mscs
|
|
|
|
MSCTL := /usr/local/bin/msctl
|
|
MSCS := /usr/local/bin/mscs
|
|
MSCS_INIT_D := /etc/init.d/mscs
|
|
MSCS_SERVICE := /etc/systemd/system/mscs.service
|
|
MSCS_SERVICE_TEMPLATE := /etc/systemd/system/mscs@.service
|
|
MSCS_COMPLETION := /etc/bash_completion.d/mscs
|
|
|
|
UPDATE_D := $(wildcard update.d/*)
|
|
|
|
.PHONY: install adduser update clean
|
|
|
|
install: adduser update
|
|
if which systemctl; then \
|
|
systemctl -f enable mscs.service; \
|
|
else \
|
|
ln -s $(MSCS) $(MSCS_INIT_D); \
|
|
update-rc.d mscs defaults; \
|
|
fi
|
|
|
|
adduser:
|
|
# safety check to see if user exists before trying to create it
|
|
if id $(MSCS_USER); then \
|
|
echo "Minecraft user $(MSCS_USER) exists so not creating it"; \
|
|
else \
|
|
useradd --system --user-group --create-home -K UMASK=0022 --home $(MSCS_HOME) $(MSCS_USER); \
|
|
fi
|
|
|
|
update:
|
|
install -m 0755 msctl $(MSCTL)
|
|
install -m 0755 mscs $(MSCS)
|
|
install -m 0644 mscs.completion $(MSCS_COMPLETION)
|
|
if which systemctl; then \
|
|
install -m 0644 mscs.service $(MSCS_SERVICE); \
|
|
install -m 0644 mscs@.service $(MSCS_SERVICE_TEMPLATE); \
|
|
fi
|
|
@for script in $(UPDATE_D); do \
|
|
sh $$script; \
|
|
done; true;
|
|
|
|
clean:
|
|
if which systemctl; then \
|
|
systemctl -f disable mscs.service; \
|
|
rm -f $(MSCS_SERVICE) $(MSCS_SERVICE_TEMPLATE); \
|
|
else \
|
|
update-rc.d mscs remove; \
|
|
rm -f $(MSCS_INIT_D); \
|
|
fi
|
|
rm -f $(MSCTL) $(MSCS) $(MSCS_COMPLETION)
|