summarylogtreecommitdiffstats
path: root/PKGBUILD
blob: 604c8c7098a1ecf877e1c75c4ef76e5d7f6a4663 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
# Maintainer: Georg Pichler <georg.pichler@gmail.com>

_rtfm=n # you want documentation? (y / n)
_other_agents=n # you want agents for other operating systems? (y / n)
_agent=n # agent is in seperate package check_mk-agent

pkgname=check_mk
pkgver=1.2.8p23
pkgrel=1
pkgdesc="A comprehensive IT monitoring solution in the tradition of Nagios"
license=('GPL2')
arch=('i686' 'x86_64')
url="http://mathias-kettner.com/check_mk.html"
depends=( 'python2'
	  'nagios>=4.0.0'
	  'nagios-plugins'
	  'xinetd'
	  'mod_python2'
	  'apache'
	  'monitoring-plugins'
	  )
optdepends=('pnp4nagios: Graphing performance data')
source=(
  "https://mathias-kettner.de/download/${pkgname}-${pkgver}.tar.gz"
  'init.d.check_mk'
  'check_mk_templates.cfg.patch'
  'mkp.patch'
  'check_mk.patch'
  'setup.sh.patch'
)
md5sums=('d15fb411f364661c65a6adc3a35b5d39'
         '078175f2851419ae53346a06a42f9f2c'
         'e10a352fff0563bddeb788c7f9aee759'
         '5e8cb4a9ca2b7e17c1c902be43808653'
         'dff7c1d42947b4b54e2953dd31def78a'
         '7c426024053ec772d21ce042776f9497')

install="${pkgname}.install"
backup=( 'etc/nagios/htpasswd.users' )

package() {
  cd "${srcdir}/${pkgname}-${pkgver}"

  # patch setup file
  patch "./setup.sh" "${srcdir}/setup.sh.patch"

  DESTDIR="${pkgdir}" \
    wwwuser='http' \
    nagios_binary='/usr/bin/nagios' \
    nagios_startscript='/usr/bin/true' \
    nagpipe='/var/nagios/rw/nagios.cmd' \
    check_result_path='/var/nagios/spool/checkresults' \
    nagios_status_file='/var/nagios/status.dat' \
    check_icmp_path='/usr/lib/monitoring-plugins/check_icmp' \
    apache_config_dir='/etc/httpd/conf/extra' \
    livesock='/var/nagios/rw/live' \
    nagios_startscript='/usr/share/check_mk/init.d.check_mk' \
    nagios_version='4.2.2' \
      ./setup.sh
      
  # Fix python shebangs:
  cd "${pkgdir}"
  for f in `grep -rl '#!/usr/bin/python' .`; do
      sed -i 's_#!/usr/bin/python_#!/usr/bin/env python2_g' "${f}"
  done
  # Fix other python2 stuff:
  patch "./usr/share/check_mk/check_mk_templates.cfg" "${srcdir}/check_mk_templates.cfg.patch"
  patch "./usr/bin/mkp" "${srcdir}/mkp.patch"
  patch "./usr/bin/check_mk" "${srcdir}/check_mk.patch"
  
  # Add symlinks for the agent:
  mkdir -p "./usr/bin" "./etc/xinetd.d"
  ln -s "/usr/share/check_mk/agents/check_mk_agent.linux" "./usr/bin/check_mk_agent"
  ln -s "/usr/share/check_mk/agents/xinetd.conf" "./etc/xinetd.d/check_mk"
  mv "./usr/share/check_mk/agents/waitmax" "./usr/bin/waitmax"
  ln -s "/usr/bin/waitmax" "./usr/share/check_mk/agents/waitmax"

  # Add init.d dummy script
  cp "${srcdir}/init.d.check_mk" "./usr/share/check_mk/init.d.check_mk"
  
  # Use proper webapps directory for apache config
  mkdir -p "./etc/webapps/check_mk"
  mv "./etc/httpd/conf/extra/zzz_check_mk.conf" "./etc/webapps/check_mk/apache.example.conf"

  # Fixing directory permissions
  chmod 0775 "./etc/nagios"
  chmod 0775 "./etc/nagios/objects"
  chmod 0750 "./etc/sudoers.d"

  # Change directory owners
  chown -R nagios:nagios "var/lib/check_mk"
  chmod -R 0775 "var/lib/check_mk"
  chown nagios:nagios "etc/check_mk/conf.d"
  chmod 0775 "etc/check_mk/conf.d"
  chown nagios:nagios "etc/check_mk/multisite.d"
  chmod 0775 "etc/check_mk/multisite.d"
  
  # Remove docs if the user wants it:
  [[ "${_rtfm}" = "n" ]] && rm -rf "./usr/share/doc"
  # Remove agents if the user wants it:
  if [[ "${_other_agents}" = "n" ]]; then
    rm -rf "./usr/share/check_mk/agents/windows/"
    rm -f "./usr/share/check_mk/agents/check_mk_agent."{freebsd,macosx,openvms,netbsd,aix,hpux,solaris,openbsd}
  fi
  # Remove agent if the user wants it:
  if [[ "${_agent}" = "n" ]]; then
    rm -rf "./etc/xinetd.d/"
    rm -f "./usr/bin/check_mk_agent"
  fi
}