diff --git a/deploy/packages/deb/debian/rules b/deploy/packages/deb/debian/rules index 9ca6c8e17..7d28be282 100755 --- a/deploy/packages/deb/debian/rules +++ b/deploy/packages/deb/debian/rules @@ -33,23 +33,16 @@ install: build mkdir -p debian/emqx/var/lib/emqx mkdir -p debian/emqx/var/run/emqx mkdir -p debian/emqx/var/log/emqx - mkdir -p debian/emqx/usr/lib/emqx/bin - mkdir -p debian/emqx/etc/emqx - mkdir -p debian/emqx/etc/init.d - cp bin/* debian/emqx/usr/lib/emqx/bin - cp -R lib debian/emqx/usr/lib/emqx cp -R erts* debian/emqx/usr/lib/emqx cp -R releases debian/emqx/usr/lib/emqx cp -R etc/* debian/emqx/etc/emqx cp -R data/* debian/emqx/var/lib/emqx - install -d debian/emqx/lib/systemd/system install -p -m0644 debian/emqx.service debian/emqx/lib/systemd/system/emqx.service - dh_shlibdeps # We have nothing to do by default. diff --git a/deploy/packages/rpm/Makefile b/deploy/packages/rpm/Makefile index 72170dc4a..15de40627 100644 --- a/deploy/packages/rpm/Makefile +++ b/deploy/packages/rpm/Makefile @@ -20,9 +20,6 @@ SYSTEMD := $(shell if command -v systemctl >/dev/null 2>&1; then echo yes; fi) # Not $(PWD) as it does not work for make -C CURDIR := $(shell pwd) -SERVICE_SRC := $(if $(SYSTEMD),$(CURDIR)/emqx.service,$(CURDIR)/init.script) -SERVICE_DST := $(if $(SYSTEMD),%{_unitdir}/emqx.service,%{_initddir}/emqx) - POST_ADDITION := $(if $(SYSTEMD),%systemd_post %{_name}.service,echo post) PREUN_ADDITION := $(if $(SYSTEMD),%systemd_preun %{_name}.service,echo preun) @@ -36,8 +33,6 @@ all: | $(BUILT) --define "_version $(RPM_VSN)" \ --define "_reldir $(SRCDIR)" \ --define "_release $(RPM_REL)" \ - --define "_service_src $(SERVICE_SRC)" \ - --define "_service_dst $(SERVICE_DST)" \ --define "_post_addition $(POST_ADDITION)" \ --define "_preun_addition $(PREUN_ADDITION)" \ --define "_sharedstatedir /var/lib" \ diff --git a/deploy/packages/rpm/emqx.spec b/deploy/packages/rpm/emqx.spec index 461c3024c..99d236736 100644 --- a/deploy/packages/rpm/emqx.spec +++ b/deploy/packages/rpm/emqx.spec @@ -39,7 +39,6 @@ mkdir -p %{buildroot}%{_unitdir} mkdir -p %{buildroot}%{_conf_dir} mkdir -p %{buildroot}%{_bindir} mkdir -p %{buildroot}%{_var_home} -mkdir -p %{buildroot}%{_initddir} cp -R %{_reldir}/lib %{buildroot}%{_lib_home}/ cp -R %{_reldir}/erts-* %{buildroot}%{_lib_home}/ @@ -47,7 +46,6 @@ cp -R %{_reldir}/releases %{buildroot}%{_lib_home}/ cp -R %{_reldir}/bin %{buildroot}%{_lib_home}/ cp -R %{_reldir}/etc/* %{buildroot}%{_conf_dir}/ cp -R %{_reldir}/data/* %{buildroot}%{_var_home}/ -install -m644 %{_service_src} %{buildroot}%{_service_dst} %pre if [ $1 = 1 ]; then @@ -64,23 +62,14 @@ if [ $1 = 1 ]; then ln -s %{_lib_home}/bin/emqx_ctl %{_bindir}/emqx_ctl fi %{_post_addition} -if [ -e %{_initddir}/%{_name} ] ; then - /sbin/chkconfig --add %{_name} -else - systemctl enable %{_name}.service -fi +systemctl enable %{_name}.service chown -R %{_user}:%{_group} %{_lib_home} %preun %{_preun_addition} # Only on uninstall, not upgrades if [ $1 = 0 ]; then - if [ -e %{_initddir}/%{_name} ] ; then - /sbin/service %{_name} stop > /dev/null 2>&1 - /sbin/chkconfig --del %{_name} - else - systemctl disable %{_name}.service - fi + systemctl disable %{_name}.service rm -f %{_bindir}/emqx rm -f %{_bindir}/emqx_ctl fi @@ -94,7 +83,6 @@ exit 0 %files %defattr(-,root,root) -%{_service_dst} %attr(-,%{_user},%{_group}) %{_lib_home}/* %attr(-,%{_user},%{_group}) %dir %{_var_home} %attr(-,%{_user},%{_group}) %config(noreplace) %{_var_home}/* @@ -105,4 +93,3 @@ exit 0 rm -rf %{buildroot} %changelog - diff --git a/deploy/packages/rpm/init.script b/deploy/packages/rpm/init.script deleted file mode 100755 index a2656be82..000000000 --- a/deploy/packages/rpm/init.script +++ /dev/null @@ -1,149 +0,0 @@ -#!/usr/bin/env bash -# -# emqx -# -# chkconfig: 2345 80 30 -# description: EMQX, a distributed, massively scalable, highly extensible MQTT message broker written in Erlang/OTP -# processname: beam -# - -# Source function library. -# shellcheck disable=SC1091 -. /etc/rc.d/init.d/functions - -RETVAL=0 -PATH=/sbin:/usr/sbin:/bin:/usr/bin -NAME=emqx -DAEMON=/usr/bin/$NAME -lockfile=/var/lock/subsys/$NAME -mkdir -p /var/run/$NAME -pidfile=/var/run/$NAME/$NAME.pid - -# Check for script, config and data dirs -[ -x /usr/bin/$NAME ] || exit 0 -[ -d /etc/$NAME ] || exit 0 -[ -d /var/lib/$NAME ] || exit 0 - -# Read configuration variable file if it is present and readable -# shellcheck disable=SC1090 -[ -r /etc/sysconfig/$NAME ] && . /etc/sysconfig/$NAME - -# `service` strips all environmental VARS so -# if no HOME was set in /etc/sysconfig/$NAME then set one here -# to the data directory for erlexec's sake -if [ -z "$HOME" ]; then - export HOME= -fi - -status -p $pidfile -l "$(basename $lockfile)" $NAME >/dev/null 2>&1 -running=$? - -find_pid() { - # shellcheck disable=SC2009 # pgrep does not support Extended Regular Expressions - ps ax | grep -E "\-progname\s+$NAME\s" | awk '{print $1}' -} - -check_pid_status() { - local pid - pid="$(find_pid)" - if [ "$pid" = "" ]; then - # prog not running? - return 1 - else - # running - return 0 - fi -} - -start() { - # Start daemons. - echo -n $"Starting emqx: " - $DAEMON start - RETVAL=$? - if [ $RETVAL -eq 0 ]; then - touch $lockfile - find_pid > $pidfile - success - else - failure $"$NAME start" - fi - echo - return $RETVAL -} - -stop() { - # Stop daemon. - echo -n $"Shutting down emqx: " - $DAEMON stop 2>/dev/null - for _ in $(seq 1 10); do - sleep 1 - check_pid_status - RETVAL=$? - if [ $RETVAL -eq 1 ]; then - break - fi - done - if [ $RETVAL -eq 1 ]; then - rm -f $lockfile $pidfile - success - echo && return 0 - else - failure $"$NAME stop" - echo && return 1 - fi -} - -hardstop() { - echo -n $"Shutting down $NAME: " - su - emqx -c "ps -ef | grep -E '\-progname\s+$NAME\s' | awk '{print \$2}' | xargs kill -9" - for _ in $(seq 1 10); do - sleep 1 - check_pid_status - RETVAL=$? - if [ $RETVAL -eq 1 ]; then - break - fi - done - if [ $RETVAL -eq 1 ]; then - rm -f $lockfile $pidfile - success - echo && return 0 - else - failure $"$NAME hardstop" - echo && return 1 - fi -} - -# See how we were called. -case "$1" in - start) - [ $running -eq 0 ] && exit 0 - start - ;; - stop) - stop - ;; - restart|force-reload) - [ $running -eq 0 ] && stop - start - ;; - hardstop) - [ $running -eq 0 ] || exit 0 - hardstop - ;; - condrestart|try-restart) - [ $running -eq 0 ] || exit 0 - restart - ;; - status) - status -p $pidfile -l "$(basename $lockfile)" $NAME - ;; - ping) - $DAEMON ping || exit $? - ;; - *) - echo $"Usage: $0 {start|stop|restart|force-reload|hardstop|condrestart|try-restart|status|ping}" - exit 1 -esac - -exit $?