diff --git a/pandora_agents/unix/DEBIAN/make_deb_package.sh b/pandora_agents/unix/DEBIAN/make_deb_package.sh index c4f5c3e312..c0dc314c10 100644 --- a/pandora_agents/unix/DEBIAN/make_deb_package.sh +++ b/pandora_agents/unix/DEBIAN/make_deb_package.sh @@ -37,6 +37,7 @@ mkdir -p temp_package/usr/sbin/ mkdir -p temp_package/etc/pandora/plugins mkdir -p temp_package/etc/pandora/collections mkdir -p temp_package/etc/init.d/ +mkdir -p temp_package/lib/systemd/system/ mkdir -p temp_package/var/log/pandora/ mkdir -p temp_package/var/spool/pandora/data_out mkdir -p temp_package/usr/share/man/man1/ @@ -63,6 +64,7 @@ cp -aRf tentacle_client temp_package/usr/bin/ cp -aRf pandora_agent temp_package/usr/bin/ cp -aRf pandora_agent_exec temp_package/usr/bin/pandora_agent_exec cp -aRf pandora_agent_daemon temp_package/etc/init.d/pandora_agent_daemon +cp -aRf pandora_agent_daemon.service temp_package/lib/systemd/system/pandora_agent_daemon.service cp -aRf pandora_agent_logrotate temp_package/etc/logrotate.d/pandora_agent cp Linux/pandora_agent.conf temp_package/etc/pandora/ diff --git a/pandora_agents/unix/DEBIAN/postinst b/pandora_agents/unix/DEBIAN/postinst index 6fdd0d1517..148fb48447 100755 --- a/pandora_agents/unix/DEBIAN/postinst +++ b/pandora_agents/unix/DEBIAN/postinst @@ -22,7 +22,12 @@ chgrp root $PANDORA_LOG chown -R root:root $PANDORA_BIN chown -R root:root $PANDORA_EXEC_BIN -echo "Linking start-up daemon script to /etc/rc$INITLV.d"; -update-rc.d pandora_agent_daemon defaults +echo "Enabling start-up agent daemon"; +if [ -x `command -v systemctl` ]; then + systemctl daemon-reload + systemctl enable pandora_agent_daemon +else + update-rc.d pandora_agent_daemon defaults +fi -echo "Please, now setup the $PANDORA_HOME/pandora_agent.conf and before start the /etc/init.d/pandora_agent_daemon" +echo "Please, now setup the $PANDORA_HOME/pandora_agent.conf and before start the pandora_agent_daemon service" diff --git a/pandora_agents/unix/DEBIAN/prerm b/pandora_agents/unix/DEBIAN/prerm index ce2442aa9c..847c25f593 100755 --- a/pandora_agents/unix/DEBIAN/prerm +++ b/pandora_agents/unix/DEBIAN/prerm @@ -8,4 +8,9 @@ PANDORA_CFG=/etc/pandora #rm -rf $PANDORA_CFG/plugins #rm -rf $PANDORA_CFG/pandora_agent.conf -update-rc.d -f pandora_agent_daemon remove +if [ -x `command -v systemctl` ]; then + systemctl disable pandora_agent_daemon + systemctl daemon-reload +else + update-rc.d -f pandora_agent_daemon remove +fi diff --git a/pandora_agents/unix/pandora_agent_daemon b/pandora_agents/unix/pandora_agent_daemon index 4faf2ac0fb..e813baad9b 100755 --- a/pandora_agents/unix/pandora_agent_daemon +++ b/pandora_agents/unix/pandora_agent_daemon @@ -27,6 +27,10 @@ DAEMON_TENTACLE=/usr/bin/tentacle_server LOGFILE=/var/log/pandora/pandora_agent.log PANDORA_USER=root +if [ -x /lib/lsb/init-functions ]; then +. /lib/lsb/init-functions +fi + # This function replace pidof, not working in the same way in different linux distros pidof_pandora () { diff --git a/pandora_agents/unix/pandora_agent_daemon.service b/pandora_agents/unix/pandora_agent_daemon.service new file mode 100644 index 0000000000..182144d1e7 --- /dev/null +++ b/pandora_agents/unix/pandora_agent_daemon.service @@ -0,0 +1,9 @@ +[Unit] +Description=Pandora FMS agent daemon +After=network-online.target + +[Service] +ExecStart=/usr/bin/pandora_agent /etc/pandora + +[Install] +WantedBy=multi-user.target diff --git a/pandora_server/DEBIAN/make_deb_package.sh b/pandora_server/DEBIAN/make_deb_package.sh index 1ef15b86cf..169b96b928 100644 --- a/pandora_server/DEBIAN/make_deb_package.sh +++ b/pandora_server/DEBIAN/make_deb_package.sh @@ -67,6 +67,7 @@ then mkdir -p temp_package/usr/bin/ mkdir -p temp_package/usr/sbin/ mkdir -p temp_package/etc/init.d/ + mkdir -p temp_package/lib/systemd/system/ mkdir -p temp_package/etc/pandora/ mkdir -p temp_package/var/spool/pandora/data_in chmod 770 temp_package/var/spool/pandora/data_in @@ -96,6 +97,9 @@ then cp -aRf util/pandora_server temp_package/etc/init.d/ cp -aRf util/tentacle_serverd temp_package/etc/init.d/ + + cp -aRf util/pandora_server.service temp_package/lib/systemd/system/ + cp -aRf util/tentacle_serverd.service temp_package/lib/systemd/system/ cp -aRf man/man1/* temp_package/usr/share/man/man1/ diff --git a/pandora_server/DEBIAN/postinst b/pandora_server/DEBIAN/postinst index 4bca4d729e..0606e651c8 100755 --- a/pandora_server/DEBIAN/postinst +++ b/pandora_server/DEBIAN/postinst @@ -81,12 +81,15 @@ else echo "Skipping creation of pandora_server.conf: there is already one." fi -echo "Linking startup script to /etc/rc2.d" -update-rc.d pandora_server defaults - -# Tentacle server install -echo "Installing tentacle server in /etc/rc2.d/S80tentacle_serverd" -update-rc.d tentacle_serverd defaults +echo "Enabling start-up pandora & tentacle server daemons"; +if [ -x `command -v systemctl` ]; then + systemctl daemon-reload + systemctl enable pandora_server + systemctl enable tentacle_serverd +else + update-rc.d pandora_server defaults + update-rc.d tentacle_serverd defaults +fi if [ -d /etc/cron.hourly ] then diff --git a/pandora_server/DEBIAN/prerm b/pandora_server/DEBIAN/prerm index 4d91cc7df0..ce862a902a 100755 --- a/pandora_server/DEBIAN/prerm +++ b/pandora_server/DEBIAN/prerm @@ -60,10 +60,14 @@ get_distro () { GET_DISTRO="`get_distro`" DISTRO=`echo $GET_DISTRO | cut -f 1 -d ":"` -rm /etc/init.d/pandora_server -rm /etc/init.d/tentacle_serverd -update-rc.d pandora_server remove -update-rc.d tentacle_serverd remove +if [ -x `command -v systemctl` ]; then + systemctl disable pandora_server + systemctl disable tentacle_serverd + systemctl daemon-reload +else + update-rc.d pandora_server remove + update-rc.d tentacle_serverd remove +fi if [ -d /etc/cron.hourly ] then diff --git a/pandora_server/util/pandora_server b/pandora_server/util/pandora_server index ab87a5fc70..ff6a865259 100755 --- a/pandora_server/util/pandora_server +++ b/pandora_server/util/pandora_server @@ -24,6 +24,10 @@ # Description: Pandora FMS Server startup script ### END INIT INFO +if [ -x /lib/lsb/init-functions ]; then +. /lib/lsb/init-functions +fi + # If you want to run several pandora servers in this machine, just copy # this script to another name, editing PANDORA_HOME to the new .conf diff --git a/pandora_server/util/pandora_server.service b/pandora_server/util/pandora_server.service new file mode 100644 index 0000000000..2afc679dfc --- /dev/null +++ b/pandora_server/util/pandora_server.service @@ -0,0 +1,10 @@ +[Unit] +Description=Pandora FMS server daemon +After=network-online.target + +[Service] +Type=forking +ExecStart=/usr/bin/pandora_server /etc/pandora/pandora_server.conf -D + +[Install] +WantedBy=multi-user.target diff --git a/pandora_server/util/tentacle_serverd b/pandora_server/util/tentacle_serverd index f713b9d4c2..72b665fd8c 100755 --- a/pandora_server/util/tentacle_serverd +++ b/pandora_server/util/tentacle_serverd @@ -24,6 +24,10 @@ # Description: Tentacle Server startup script ### END INIT INFO +if [ -x /lib/lsb/init-functions ]; then +. /lib/lsb/init-functions +fi + # Uses a wait limit before sending a KILL signal, before trying to stop # Pandora FMS server nicely. Some big systems need some time before close # all pending tasks / threads. diff --git a/pandora_server/util/tentacle_serverd.service b/pandora_server/util/tentacle_serverd.service new file mode 100644 index 0000000000..488bc3d4a8 --- /dev/null +++ b/pandora_server/util/tentacle_serverd.service @@ -0,0 +1,11 @@ +[Unit] +Description=Tentacle server daemon +After=network-online.target + +[Service] +Type=forking +ExecStart=/usr/bin/tentacle_server -a 0.0.0.0 -p 41121 -s /var/spool/pandora/data_in -i.*\.conf:conf;.*\.md5:md5;.*\.zip:collections -d +User=pandora + +[Install] +WantedBy=multi-user.target