Skip to content
Permalink
Browse files

Fixed and unified .f12 scripts.

Previously, some scripts did not find or even used the wrong (obsolete)
.site file, this has been fixed.

Furthermore, *all* .f12 scripts now start with the same (modulo path) few
lines, calculating SITE and ROOT.

Change-Id: I159ab92b60fe03c557cdb70bf4945297dd1704df
  • Loading branch information
svenpanne committed Sep 14, 2017
1 parent d7eae2c commit 8c55775df3156d8a490d0a6a6d3f6f1456d714f1
14 .f12 100644 → 100755
@@ -1,11 +1,15 @@
#!/bin/bash
SITE=${SITE:-$(cat .site || true)}
set -e

SITE=${SITE:-$(cat .site 2>/dev/null || true)}
SITE=${SITE:-$(omd sites --bare | head -n 1)}
sed -e "s#@BINDIR@#/omd/sites/$SITE/bin#g" \
-e "s#@VARDIR@#/omd/sites/$SITE/var/check_mk#g" \
-e "s#@CHECK_ICMP@#/omd/sites/$SITE/lib/nagios/plugins/check_icmp#g" \
ROOT=/omd/sites/$SITE

sed -e "s#@BINDIR@#$ROOT/bin#g" \
-e "s#@VARDIR@#$ROOT/var/check_mk#g" \
-e "s#@CHECK_ICMP@#$ROOT/lib/nagios/plugins/check_icmp#g" \
-e "s#@PNPURL@#/$SITE/pnp4nagios/#g" \
-e "s#@CGIURL@#/$SITE/nagios/cgi-bin#g" \
< check_mk_templates.cfg > /tmp/check_mk_templates.cfg

sudo mv /tmp/check_mk_templates.cfg /omd/sites/$SITE/etc/nagios/conf.d
sudo mv /tmp/check_mk_templates.cfg $ROOT/etc/nagios/conf.d
14 .werks/.f12 100644 → 100755
@@ -1,13 +1,17 @@
#!/bin/bash
SITE=${SITE:-$(cat ../.site)}
set -e

SITE=${SITE:-$(cat ../.site 2>/dev/null || true)}
SITE=${SITE:-$(omd sites --bare | head -n 1)}
sudo mkdir -p /omd/sites/$SITE/share/check_mk/werks/
ROOT=/omd/sites/$SITE

sudo mkdir -p $ROOT/share/check_mk/werks/
make -C .. .werks/werks
sudo install -m 644 -g $SITE -o $SITE werks /omd/sites/$SITE/share/check_mk/werks/werks
sudo install -m 644 -g $SITE -o $SITE werks $ROOT/share/check_mk/werks/werks
make -C .. enterprise/werks
sudo install -m 644 -g $SITE -o $SITE ../enterprise/werks /omd/sites/$SITE/share/check_mk/werks/werks-cmc
sudo install -m 644 -g $SITE -o $SITE ../enterprise/werks $ROOT/share/check_mk/werks/werks-cmc
make -C .. managed/werks
sudo install -m 644 -g $SITE -o $SITE ../managed/werks /omd/sites/$SITE/share/check_mk/werks/werks-cme
sudo install -m 644 -g $SITE -o $SITE ../managed/werks $ROOT/share/check_mk/werks/werks-cme

if [ -z $ONLY_COPY ]; then
sudo omd restart $SITE apache
@@ -1,7 +1,11 @@
#!/bin/bash
SITE=${SITE:-$(cat ../.site 2>/dev/null)}
set -e

SITE=${SITE:-$(cat ../.site 2>/dev/null || true)}
SITE=${SITE:-$(omd sites --bare | head -n 1)}
echo "Installing to /omd/sites/$SITE/lib/nagios/plugins"
ROOT=/omd/sites/$SITE

echo "Installing to $ROOT/lib/nagios/plugins"
make

RSYNC_OPTS="-a
@@ -10,5 +14,5 @@
--exclude=Makefile
--exclude=*.cc"

sudo rsync $RSYNC_OPTS ./ /omd/sites/$SITE/lib/nagios/plugins
sudo rsync $RSYNC_OPTS --delete-after ./ /omd/sites/$SITE/share/doc/check_mk/treasures/active_checks
sudo rsync $RSYNC_OPTS ./ $ROOT/lib/nagios/plugins
sudo rsync $RSYNC_OPTS --delete-after ./ $ROOT/share/doc/check_mk/treasures/active_checks
9 agents/.f12 100644 → 100755
@@ -1,9 +1,12 @@
#!/bin/bash
set -e

SITE=${SITE:-$(cat ../.site 2>/dev/null || true)}
SITE=${SITE:-$(omd sites --bare | head -n 1)}
sudo rsync -varx --delete --exclude=.f12* --exclude=.gitignore --exclude=baked* ./ /omd/sites/$SITE/share/check_mk/agents/
if [ -e /etc/check_mk ]
then
ROOT=/omd/sites/$SITE

sudo rsync -varx --delete --exclude=.f12* --exclude=.gitignore --exclude=baked* ./ $ROOT/share/check_mk/agents/
if [ -e /etc/check_mk ]; then
sudo install -m 644 cfg_examples/logwatch.cfg /etc/check_mk/
fi
sudo install -m 755 check_mk_agent.linux /usr/bin/check_mk_agent
@@ -1,6 +1,10 @@
#!/bin/bash
set -e

SITE=${SITE:-$(cat ../../.site 2>/dev/null || true)}
SITE=${SITE:-$(omd sites --bare | head -n 1)}
ROOT=/omd/sites/$SITE

# sudo mkdir -p /usr/lib/check_mk_agent/plugins
# sudo install -m 755 * /usr/lib/check_mk_agent/plugins || true
sudo rsync -va --exclude=.f12 ./ /omd/sites/$SITE/share/check_mk/agents/plugins/
sudo rsync -va --exclude=.f12 ./ $ROOT/share/check_mk/agents/plugins/
8 agents/special/.f12 100644 → 100755
@@ -1,5 +1,9 @@
#!/bin/bash
set -e

SITE=${SITE:-$(cat ../../.site 2>/dev/null || true)}
SITE=${SITE:-$(omd sites --bare | head -n 1)}
sudo cp agent_* /omd/sites/$SITE/share/check_mk/agents/special/
sudo cp lib/cmk_special_agent_api.py /omd/sites/$SITE/lib/python/
ROOT=/omd/sites/$SITE

sudo cp agent_* $ROOT/share/check_mk/agents/special/
sudo cp lib/cmk_special_agent_api.py $ROOT/lib/python/
6 agents/windows/.f12 100644 → 100755
@@ -1,5 +1,9 @@
#!/bin/bash
set -e

SITE=${SITE:-$(cat ../../.site 2>/dev/null || true)}
SITE=${SITE:-$(omd sites --bare | head -n 1)}
ROOT=/omd/sites/$SITE

make || true
sudo rsync -varx -v CONTENTS *.exe /omd/sites/$SITE/share/check_mk/agents/windows/
sudo rsync -varx -v CONTENTS *.exe $ROOT/share/check_mk/agents/windows/
8 agents/windows/msibuild/.f12 100644 → 100755
@@ -1,4 +1,8 @@
#!/bin/bash
SITE=${SITE:-$(cat ../.site 2>/dev/null || true)}
set -e

SITE=${SITE:-$(cat ../../../.site 2>/dev/null || true)}
SITE=${SITE:-$(omd sites --bare | head -n 1)}
sudo cp -p msi-update /omd/sites/$SITE/bin
ROOT=/omd/sites/$SITE

sudo cp -p msi-update $ROOT/bin
@@ -1,4 +1,8 @@
#!/bin/bash
set -e

SITE=${SITE:-$(cat ../../../.site 2>/dev/null || true)}
SITE=${SITE:-$(omd sites --bare | head -n 1)}
sudo install -m 755 * /omd/sites/$SITE/share/check_mk/agents/windows/plugins
ROOT=/omd/sites/$SITE

sudo install -m 755 * $ROOT/share/check_mk/agents/windows/plugins
14 bin/.f12 100644 → 100755
@@ -1,14 +1,16 @@
#!/bin/bash
set -e

SITE=${SITE:-$(cat ../.site 2>/dev/null || true)}
SITE=${SITE:-$(omd sites --bare | head -n 1)}
OMD_ROOT=/omd/sites/${SITE}
ROOT=/omd/sites/$SITE

make
sudo install -m 755 check_mk livedump mkeventd mkeventd_open514 mkevent mkbackup mkbench $OMD_ROOT/bin/
sudo ln -sf check_mk $OMD_ROOT/bin/cmk
sudo chown root.omd $OMD_ROOT/bin/mkeventd_open514
sudo chmod 4750 $OMD_ROOT/bin/mkeventd_open514
echo "Installed to $OMD_ROOT/bin"
sudo install -m 755 check_mk livedump mkeventd mkeventd_open514 mkevent mkbackup mkbench $ROOT/bin/
sudo ln -sf check_mk $ROOT/bin/cmk
sudo chown root.omd $ROOT/bin/mkeventd_open514
sudo chmod 4750 $ROOT/bin/mkeventd_open514
echo "Installed to $ROOT/bin"

if [ -z $ONLY_COPY ]; then
sudo omd restart $SITE mkeventd
8 checkman/.f12 100644 → 100755
@@ -1,5 +1,9 @@
#!/bin/bash
set -e

SITE=${SITE:-$(cat ../.site 2>/dev/null || true)}
SITE=${SITE:-$(omd sites --bare | head -n 1)}
sudo rsync -var --delete ./ /omd/sites/$SITE/share/check_mk/checkman/
sudo rm -f /omd/sites/$SITE/share/check_mk/checkman/.f12
ROOT=/omd/sites/$SITE

sudo rsync -var --delete ./ $ROOT/share/check_mk/checkman/
sudo rm -f $ROOT/share/check_mk/checkman/.f12
7 checks/.f12 100644 → 100755
@@ -1,6 +1,9 @@
#!/bin/bash
set -e

SITE=${SITE:-$(cat ../.site 2>/dev/null || true)}
SITE=${SITE:-$(omd sites --bare | head -n 1)}
echo "TARGET: /omd/sites/$SITE/share/check_mk/checks"
sudo rsync -ar --delete-after ./ /omd/sites/$SITE/share/check_mk/checks/
ROOT=/omd/sites/$SITE

echo "TARGET: $ROOT/share/check_mk/checks"
sudo rsync -ar --delete-after ./ $ROOT/share/check_mk/checks/
10 cmk_base/.f12 100644 → 100755
@@ -1,11 +1,13 @@
#!/bin/bash
set -e

SITE=${SITE:-$(cat ../.site 2>/dev/null || true)}
SITE=${SITE:-$(omd sites --bare | head -n 1)}
OMD_ROOT=/omd/sites/${SITE}
ROOT=/omd/sites/$SITE

sudo rsync \
--exclude=cee \
--exclude=cee.py \
-a * $OMD_ROOT/lib/python/cmk_base/
sudo pycompile -q $OMD_ROOT/lib/python/cmk_base/cmk_base
echo "Installed to $OMD_ROOT/lib/python/cmk_base/"
-a * $ROOT/lib/python/cmk_base/
sudo pycompile -q $ROOT/lib/python/cmk_base/cmk_base
echo "Installed to $ROOT/lib/python/cmk_base/"
9 doc/.f12 100644 → 100755
@@ -1,8 +1,9 @@
#!/bin/bash
# man -l check_mk.1 >/dev/tty </dev/tty
# exit
set -e

SITE=${SITE:-$(cat ../.site 2>/dev/null || true)}
SITE=${SITE:-$(omd sites --bare | head -n 1)}
echo "TARGET: /omd/sites/$SITE/share/check_mk/checks"
sudo rsync -ar --delete-after ./ /omd/sites/$SITE/share/doc/check_mk/
ROOT=/omd/sites/$SITE

echo "TARGET: $ROOT/share/check_mk/checks"
sudo rsync -ar --delete-after ./ $ROOT/share/doc/check_mk/
6 doc/helpers/.f12 100644 → 100755
@@ -1,4 +1,8 @@
#!/bin/bash
set -e

SITE=${SITE:-$(cat ../../.site 2>/dev/null || true)}
SITE=${SITE:-$(omd sites --bare | head -n 1)}
sudo install -m 755 guitest /omd/sites/$SITE/bin/guitest
ROOT=/omd/sites/$SITE

sudo install -m 755 guitest $ROOT/bin/guitest
10 doc/predictive/.f12 100644 → 100755
@@ -1,11 +1,13 @@
# compile helper file. Installs the files into a local
# OMD site and into the local agent
#!/bin/bash
set -e

SITE=${SITE:-$(cat ../../.site 2>/dev/null || true)}
SITE=${SITE:-$(omd sites --bare | head -n 1)}
ROOT=/omd/sites/$SITE

sudo install -m 755 foo.agentplugin /usr/lib/check_mk_agent/plugins/foo
sudo install -m 644 foo.check /omd/sites/$SITE/local/share/check_mk/checks/foo
sudo install -m 644 foo.wato /omd/sites/$SITE/local/share/check_mk/web/plugins/wato/foo.py
sudo install -m 644 foo.check $ROOT/local/share/check_mk/checks/foo
sudo install -m 644 foo.wato $ROOT/local/share/check_mk/web/plugins/wato/foo.py

if [ -z $ONLY_COPY ]; then
sudo omd restart $SITE apache
8 doc/treasures/checks/.f12 100644 → 100755
@@ -1,5 +1,9 @@
#!/bin/bash
set -e

SITE=${SITE:-$(cat ../../../.site 2>/dev/null || true)}
SITE=${SITE:-$(omd sites --bare | head -n 1)}
echo "TARGET: /omd/sites/$SITE/share/check_mk/checks"
sudo rsync -var ./ /omd/sites/$SITE/local/share/check_mk/checks/
ROOT=/omd/sites/$SITE

echo "TARGET: $ROOT/share/check_mk/checks"
sudo rsync -var ./ $ROOT/local/share/check_mk/checks/
8 inventory/.f12 100644 → 100755
@@ -1,6 +1,10 @@
#!/bin/bash
set -e

SITE=${SITE:-$(cat ../.site 2>/dev/null || true)}
SITE=${SITE:-$(omd sites --bare | head -n 1)}
echo "TARGET: /omd/sites/$SITE/share/check_mk/inventory"
sudo rsync -ar --delete-after ./ /omd/sites/$SITE/share/check_mk/inventory/
ROOT=/omd/sites/$SITE

echo "TARGET: $ROOT/share/check_mk/inventory"
sudo rsync -ar --delete-after ./ $ROOT/share/check_mk/inventory/

10 lib/.f12 100644 → 100755
@@ -1,8 +1,10 @@
#!/bin/bash
set -e

SITE=${SITE:-$(cat ../.site 2>/dev/null || true)}
SITE=${SITE:-$(omd sites --bare | head -n 1)}
OMD_ROOT=/omd/sites/${SITE}
ROOT=/omd/sites/$SITE

sudo rsync -a *.py $OMD_ROOT/lib/python/cmk/
sudo pycompile -q $OMD_ROOT/lib/python/cmk/
echo "Installed to $OMD_ROOT/lib/python/cmk/"
sudo rsync -a *.py $ROOT/lib/python/cmk/
sudo pycompile -q $ROOT/lib/python/cmk/
echo "Installed to $ROOT/lib/python/cmk/"
@@ -3,10 +3,11 @@

SITE=${SITE:-$(cat ../.site 2>/dev/null || true)}
SITE=${SITE:-$(omd sites --bare | head -n 1)}
ROOT=/omd/sites/$SITE

LANG=C make -C .. config.h
LANG=C make -j4
sudo install -v src/livestatus.o /omd/sites/$SITE/lib/mk-livestatus/livestatus.o
sudo install -v src/livestatus.o $ROOT/lib/mk-livestatus/livestatus.o

(cd api/python ; bash .f12 )

7 livestatus/api/c++/.f12 100644 → 100755
@@ -1 +1,8 @@
#!/bin/bash
set -e

SITE=${SITE:-$(cat ../../../.site 2>/dev/null || true)}
SITE=${SITE:-$(omd sites --bare | head -n 1)}
ROOT=/omd/sites/$SITE

make
5 livestatus/api/python/.f12 100644 → 100755
@@ -1,8 +1,11 @@
#!/bin/bash
set -e

SITE=${SITE:-$(cat ../../../.site 2>/dev/null || true)}
SITE=${SITE:-$(omd sites --bare | head -n 1)}
ROOT=/omd/sites/$SITE

sudo rsync livestatus.py /omd/sites/$SITE/lib/python/
sudo rsync livestatus.py $ROOT/lib/python/
if [ -z $ONLY_COPY ]; then
if [ "$SITE" != - ] ; then
sudo omd restart $SITE apache
10 notifications/.f12 100644 → 100755
@@ -1,5 +1,9 @@
#!/bin/bash
SITE=${SITE:-$(cat ../.site)}
set -e

SITE=${SITE:-$(cat ../.site 2>/dev/null || true)}
SITE=${SITE:-$(omd sites --bare | head -n 1)}
sudo mkdir -p /omd/sites/$SITE/share/check_mk/notifications
sudo cp -vp * /omd/sites/$SITE/share/check_mk/notifications
ROOT=/omd/sites/$SITE

sudo mkdir -p $ROOT/share/check_mk/notifications
sudo cp -vp * $ROOT/share/check_mk/notifications
15 omd/packages/maintenance/.f12 100644 → 100755
@@ -1,13 +1,18 @@
SITE=${SITE:-$(cat ../../.site || true)}
#!/bin/bash
set -e

SITE=${SITE:-$(cat ../../../.site 2>/dev/null || true)}
SITE=${SITE:-$(omd sites --bare | head -n 1)}
ROOT=/omd/sites/$SITE

echo "Installing to site \"$SITE\"..."
sudo install -m 755 diskspace /omd/sites/$SITE/bin
sudo install -m 755 merge-crontabs /omd/sites/$SITE/bin
sudo install -m 755 diskspace $ROOT/bin
sudo install -m 755 merge-crontabs $ROOT/bin
for F in ../*/diskspace; do
sudo cp $F /omd/sites/$SITE/share/diskspace
sudo cp $F $ROOT/share/diskspace
done

sudo cp skel/etc/cron.d/* /omd/sites/$SITE/etc/cron.d
sudo cp skel/etc/cron.d/* $ROOT/etc/cron.d
sudo omd restart $SITE crontab

sudo omd restart $SITE apache
7 omd/packages/mod_python/.f12 100644 → 100755
@@ -1,8 +1,11 @@
#!/bin/bash -e
SITE=${SITE:-$(cat ../../.site 2>/dev/null || true)}
set -e

SITE=${SITE:-$(cat ../../../.site 2>/dev/null || true)}
SITE=${SITE:-$(omd sites --bare | head -n 1)}
ROOT=/omd/sites/$SITE

echo '#define OMD_VERSION "$(omd versions | grep default | cut -d' ' -f1)"' > mod_python-*/src/omd_version.h
make -C mod_python-* clean all
sudo make install OMD_ROOT=/omd/sites/$SITE
sudo make install OMD_ROOT=$ROOT
sudo omd restart $SITE apache
4 omd/packages/msitools/.f12 100644 → 100755
@@ -1,3 +1,7 @@
#!/bin/bash
set -e

SITE=${SITE:-$(cat ../../../.site 2>/dev/null || true)}
SITE=${SITE:-$(omd sites --bare | head -n 1)}
ROOT=/omd/sites/$SITE

8 omd/packages/nagios/.f12 100644 → 100755
@@ -1,3 +1,9 @@
#!/bin/bash
sudo install -v -m 755 merge-nagios-config /omd/versions/default/bin/merge-nagios-config
set -e

SITE=${SITE:-$(cat ../../../.site 2>/dev/null || true)}
SITE=${SITE:-$(omd sites --bare | head -n 1)}
ROOT=/omd/sites/$SITE

sudo install -v -m 755 merge-nagios-config /omd/versions/default/bin/merge-nagios-config
sudo install -s -v -m 755 nagios-*.*.*/base/nagios /omd/versions/default/bin/nagios
5 omd/packages/nagvis/.f12 100644 → 100755
@@ -1,4 +1,9 @@
#!/bin/bash
set -e

SITE=${SITE:-$(cat ../../../.site 2>/dev/null || true)}
SITE=${SITE:-$(omd sites --bare | head -n 1)}
ROOT=/omd/sites/$SITE

for hook in *.hook; do
sudo cp -v $hook /omd/versions/default/lib/omd/hooks/${hook%*.hook}

0 comments on commit 8c55775

Please sign in to comment.
You can’t perform that action at this time.