Commit fcb9254c authored by Marian Babik's avatar Marian Babik
Browse files

init fix

parent c89c9f57
......@@ -2,12 +2,12 @@
set -e
_term() {
omd stop
if [ -f /var/run/crond.pid ]; then
if [[ -f /var/run/crond.pid ]]; then
kill -9 `cat /var/run/crond.pid`
rm -f /var/run/crond.pid
fi
rm -rf /opt/omd/sites/etf/etc/nagios/conf.d/wlcg/
omd stop
}
trap _term SIGINT SIGTERM
......@@ -31,23 +31,28 @@ echo "${plugins}"
echo ""
echo "Starting xinetd ..."
export XINETD_LANG="en_US" && /usr/sbin/xinetd -stayalive -pidfile /var/run/xinetd.pid
if [[ -n $CHECK_MK_USER_ID ]] ; then
if [[ -n ${CHECK_MK_USER_ID} ]] ; then
echo "Changing $CHECK_MK_SITE uid to $CHECK_MK_USER_ID"
/usr/sbin/usermod -u $CHECK_MK_USER_ID $CHECK_MK_SITE
chown -R $CHECK_MK_SITE /etc/ncgx /var/cache/ncgx /var/cache/nap
chown -R $CHECK_MK_SITE /usr/libexec/grid-monitoring/probes/
/usr/sbin/usermod -u ${CHECK_MK_USER_ID} ${CHECK_MK_SITE}
chown -R ${CHECK_MK_SITE} /etc/ncgx /var/cache/ncgx /var/cache/nap
chown -R ${CHECK_MK_SITE} /usr/libexec/grid-monitoring/probes/
fi
if [[ -n $CHECK_MK_GROUP_ID ]] ; then
if [[ -n ${CHECK_MK_GROUP_ID} ]] ; then
echo "Creating group with gid $CHECK_MK_GROUP_ID"
/usr/sbin/groupadd -g $CHECK_MK_GROUP_ID sec
/usr/sbin/groupmems -g sec -a $CHECK_MK_SITE
/usr/sbin/groupadd -g ${CHECK_MK_GROUP_ID} sec
/usr/sbin/groupmems -g sec -a ${CHECK_MK_SITE}
fi
echo "Initialising ..."
if [[ -d /opt/omd/sites/etf/etc/nagios/conf.d/wlcg/ ]]; then
rm -rf /opt/omd/sites/etf/etc/nagios/conf.d/wlcg/
fi
echo "Starting crond ..."
/usr/sbin/crond -m off -p -s
echo "Copying certificates ..."
if [ ! -f /etc/grid-security/hostcert.pem ]; then
if [[ ! -f /etc/grid-security/hostcert.pem ]]; then
echo "Failed to find certificates in /etc/grid-security"
exit
fi
......@@ -58,13 +63,13 @@ chown -R ${CHECK_MK_SITE}.${CHECK_MK_SITE} /opt/omd/sites/etf/etc/nagios/globus/
echo "Configuring access ..."
echo "Configured admins: $CHECK_MK_ADMINS"
sed -i "s|admin_users.*|admin_users = [$CHECK_MK_ADMINS]|" /opt/omd/sites/$CHECK_MK_SITE/etc/check_mk/multisite.mk
sed -i "s|admin_users.*|admin_users = [$CHECK_MK_ADMINS]|" /opt/omd/sites/${CHECK_MK_SITE}/etc/check_mk/multisite.mk
if [ -f /etc/check_mk/contacts.mk ]; then
cp /etc/check_mk/contacts.mk /opt/omd/sites/$CHECK_MK_SITE/etc/check_mk/conf.d/wato/
if [[ -f /etc/check_mk/contacts.mk ]]; then
cp /etc/check_mk/contacts.mk /opt/omd/sites/${CHECK_MK_SITE}/etc/check_mk/conf.d/wato/
fi
if [ -g /etc/check_mk/users.mk ]; then
cp /etc/check_mk/users.mk /opt/omd/sites/$CHECK_MK_SITE/etc/check_mk/conf.d/wato/
if [[ -g /etc/check_mk/users.mk ]]; then
cp /etc/check_mk/users.mk /opt/omd/sites/${CHECK_MK_SITE}/etc/check_mk/conf.d/wato/
fi
cp /etc/ncgx/templates/generic/handlers.cfg /opt/omd/sites/etf/etc/nagios/conf.d/
......@@ -72,10 +77,10 @@ cp /etc/ncgx/templates/generic/handlers.cfg /opt/omd/sites/etf/etc/nagios/conf.d
omd start
rm -f /opt/omd/sites/etf/etc/nagios/conf.d/handlers.cfg
echo "Configuring main.mk: $ETF_HOSTED_BY"
if [ -z "${ETF_HOSTED_BY}" ]; then
if [[ -z "${ETF_HOSTED_BY}" ]]; then
echo " Variable ETF_HOSTED_BY is not defined, not touching main.mk"
else
if grep -q all_hosts /opt/omd/sites/$CHECK_MK_SITE/etc/check_mk/main.mk; then
if grep -q all_hosts /opt/omd/sites/${CHECK_MK_SITE}/etc/check_mk/main.mk; then
sed "s/all_hosts.*/all_hosts += [ \"${ETF_HOSTED_BY}\" ]/g" -i /opt/omd/sites/$CHECK_MK_SITE/etc/check_mk/main.mk
else
echo "all_hosts += [ \"${ETF_HOSTED_BY}\" ]" >> /opt/omd/sites/$CHECK_MK_SITE/etc/check_mk/main.mk
......@@ -83,7 +88,7 @@ else
fi
echo "Configuring ETF ..."
if [ -z "${ETF_NAGIOS_HOST}" ]; then
if [[ -z "${ETF_NAGIOS_HOST}" ]]; then
echo " Variable ETF_NAGIOS_HOST is not defined, using hostname"
ETF_NAGIOS_HOST=`hostname`
echo "NAGIOS_HOST = \"${ETF_NAGIOS_HOST}\"" >> /etc/ncgx/ncgx.cfg
......@@ -93,14 +98,14 @@ fi
su etf -c "ncgx --log | tee /opt/omd/sites/etf/var/log/ncgx.log"
su - etf -c "cmk -II; cmk -O"
if [ "${NSTREAM_ENABLED}" -eq "1" ] ; then
if [[ "${NSTREAM_ENABLED}" -eq "1" ]] ; then
echo "Nagios stream enabled ..."
else
echo "Nagios stream disabled ..."
/usr/bin/disable_nstream
fi
if [ "${ABRT_ENABLED}" -eq "1" ] ; then
if [[ "${ABRT_ENABLED}" -eq "1" ]] ; then
echo "Enabling abrt ..."
sed -e "s/OpenGPGCheck = yes/OpenGPGCheck = no/g" -i /etc/abrt/abrt-action-save-package-data.conf
/usr/sbin/abrtd
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment