shinken-solutions / shinken

Flexible and scalable monitoring framework
http://www.shinken-monitoring.org
GNU Affero General Public License v3.0
1.13k stars 336 forks source link

Individual init scripts don't restart correctly on Centos #1901

Closed goetzk closed 3 years ago

goetzk commented 7 years ago

Hi, I had a quick look for existing issues so apologies if this has already been reported.

OS:

[root@shinken-test-centos ~]# lsb_release -a
LSB Version:    :base-4.0-amd64:base-4.0-noarch:core-4.0-amd64:core-4.0-noarch
Distributor ID: CentOS
Description:    CentOS release 6.8 (Final)
Release:    6.8
Codename:   Final

Shinken:

[root@shinken-test-centos ~]# pip list |grep Shinken
You are using pip version 7.1.0, however version 9.0.1 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
Shinken (2.4.3)
[root@shinken-test-centos ~]# 

This is from a test run

[root@shinken-test-centos ~]# bash -x /etc/init.d/shinken-arbiter restart
+ bash -x /etc/init.d/shinken-arbiter restart
+ SHORTNAME=arbiter
+ NAME=shinken-arbiter
++ readlink -f /etc/init.d/shinken-arbiter
+ SCRIPT=/etc/rc.d/init.d/shinken-arbiter
++ dirname /etc/rc.d/init.d/shinken-arbiter
+ curdir=/etc/rc.d/init.d
+ export SHINKEN_MODULE_FILE=shinken-arbiter
+ SHINKEN_MODULE_FILE=shinken-arbiter
+ case "$1" in
+ /etc/rc.d/init.d/shinken restart arbiter
/etc/rc.d/init.d/shinken: line 67: cd: /etc/rc.d/init.d/../../var: No such file or directory
/etc/rc.d/init.d/shinken: line 68: cd: /etc/rc.d/init.d/../../etc: No such file or directory
Restarting arbiter
Doing config check
+ exit 0                                                   [  OK  ]
++ printf '\033]0;%s@%s:%s\007' root shinken-test-centos '~'

It appears to be the result of init.d being a symlink.

[root@shinken-test-centos ~]# ls -lh /etc/init.d
lrwxrwxrwx 1 root root 11 Feb 22 04:05 /etc/init.d -> rc.d/init.d

The root cause appears to be in /etc/rc.d/init.d/shinken where it has

## Default paths:
test "$BIN" || BIN=$(cd $curpath/.. && pwd)
test "$VAR" || VAR=$(cd $curpath/../../var && pwd)
test "$ETC" || ETC=$(cd $curpath/../../etc && pwd)

These paths are not defined yet when run via the arbiter, so /var and /etc/ cause errors. /bin/ succeeds by pure chance - the /bin has been left off the path so due to that bug there is no error in the test.

magicdrums commented 7 years ago

change line 67 and 68 From: test "$VAR" || VAR=$(cd $curpath/../../var && pwd) test "$ETC" || ETC=$(cd $curpath/../../etc && pwd) To: test "$VAR" || VAR=$(cd $curpath/../../../var && pwd) test "$ETC" || ETC=$(cd $curpath/../../../etc && pwd)

SOLVED! Issue

goetzk commented 7 years ago

The same init script is used on Debian systems, your fix will result in a broken init script on that platform. The correct fix depends a lot on why things are this way.

The change was made in commit 55bb897f43ef12647777717a0ba956e57e4d49ee , from which it is reasonable to assume it is supposed to decouple the directories from /usr/local/.

https://github.com/naparuba/shinken/commit/55bb897f43ef12647777717a0ba956e57e4d49ee#diff-c29ab6c44241bcf83345e349892e0cc6L37

I suggest that the correct fix is one or both of:

magicdrums commented 7 years ago

I do not know if the solution that applies solve on debian systems since I use centos, but if I think you should use the option of systemd or make the configuration chkconfig as they say.

hvad commented 7 years ago

Or you can use script in directory for_fedora... Centos/EPEL and Fedora Init or Systemd script work fine.

2017-06-01 21:37 GMT+02:00 Victor Pereira notifications@github.com:

I do not know if the solution that applies solve on debian systems since I use centos, but if I think you should use the option of systemd or make the configuration chkconfig as they say.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/naparuba/shinken/issues/1901#issuecomment-305598358, or mute the thread https://github.com/notifications/unsubscribe-auth/AAwrYPPF94BGJIhRaZc-WQ4Ne5B2Bmq4ks5r_xMGgaJpZM4M-nLQ .

-- David Hannequin

goetzk commented 7 years ago

@hvad do you think it would be feasible to install that init script / systemd unit on Centos by default?

hvad commented 7 years ago

@goetzk that i do on rpm package.