Added proxysql system user and group management

During the make install phase a proxysql system user and group are created automatically.
As system user this cannot be used for login to the system but just to run the program.

During the make uninstall phase the proxysql user and group are deleted automatically.

Fixed the error with the number of endif statements that prevented the execution of the uninstall rule.
pull/1919/head
Lorenzo Cipriani 7 years ago committed by GitHub
parent e5508179f0
commit 8b772ed397
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -19,6 +19,8 @@ ifeq ($(wildcard /usr/lib/systemd/system), /usr/lib/systemd/system)
else
SYSTEMD=0
endif
USERCHECK := $(shell getent passwd proxysql)
GROUPCHECK := $(shell getent group proxysql)
.PHONY: default
default: build_deps build_lib build_src
@ -346,10 +348,15 @@ cleanbuild:
cd lib && ${MAKE} clean
cd src && ${MAKE} clean
.PHONY: install
install: src/proxysql
install -m 0755 src/proxysql /usr/bin
install -m 0600 etc/proxysql.cnf /etc
if [ ! -d /var/lib/proxysql ]; then mkdir /var/lib/proxysql ; fi
ifeq ($(findstring proxysql,$(USERCHECK)),)
@echo "Creating proxysql user and group"
useradd -r -U -s /bin/false proxysql
endif
ifeq ($(SYSTEMD), 1)
install -m 0644 systemd/system/proxysql.service /usr/lib/systemd/system/
systemctl enable proxysql.service
@ -370,35 +377,44 @@ endif
endif
endif
endif
.PHONY: install
endif
.PHONY: uninstall
uninstall:
rm /etc/proxysql.cnf
rm /usr/bin/proxysql
rmdir /var/lib/proxysql 2>/dev/null || true
if [ -f /etc/proxysql.cnf ]; then rm /etc/proxysql.cnf ; fi
if [ -f /usr/bin/proxysql ]; then rm /usr/bin/proxysql ; fi
if [ -d /var/lib/proxysql ]; then rmdir /var/lib/proxysql 2>/dev/null || true ; fi
ifeq ($(SYSTEMD), 1)
systemctl stop proxysql.service
rm /usr/lib/systemd/system/proxysql.service
if [ -f /usr/lib/systemd/system/proxysql.service ]; then rm /usr/lib/systemd/system/proxysql.service ; fi
find /etc/systemd -name "proxysql.service" -exec rm {} \;
systemctl daemon-reload
else
ifeq ($(DISTRO),"CentOS Linux")
chkconfig --level 0123456 proxysql off
rm /etc/init.d/proxysql
if [ -f /etc/init.d/proxysql ]; then rm /etc/init.d/proxysql ; fi
else
ifeq ($(DISTRO),"Red Hat Enterprise Linux Server")
chkconfig --level 0123456 proxysql off
rm /etc/init.d/proxysql
if [ -f /etc/init.d/proxysql ]; then rm /etc/init.d/proxysql ; fi
else
ifeq ($(DISTRO),"Ubuntu")
rm /etc/init.d/proxysql
if [ -f /etc/init.d/proxysql ]; then rm /etc/init.d/proxysql ; fi
update-rc.d proxysql remove
else
ifeq ($(DISTRO),"Debian GNU/Linux")
rm /etc/init.d/proxysql
if [ -f /etc/init.d/proxysql ]; then rm /etc/init.d/proxysql ; fi
update-rc.d proxysql remove
endif
endif
endif
endif
endif
ifneq ($(findstring proxysql,$(USERCHECK)),)
@echo "Deleting proxysql user"
userdel proxysql
endif
ifneq ($(findstring proxysql,$(GROUPCHECK)),)
@echo "Deleting proxysql group"
groupdel proxysql
endif
.PHONY: uninstall

Loading…
Cancel
Save