aboutsummaryrefslogblamecommitdiffstats
path: root/community/icinga2/APKBUILD
blob: 74adb286f7fb67efacfcb6468ad0f3509cd229ea (plain) (tree)
1
2
3
4
5
6
7
8
9


                                                           
             
        

                                                                     
                                             
                      
                            
                                                             
                                                                               

                                                    
                            
                                                                                                        
                                                                                          
                      
                   




                      
 
         



                                                                                          










                                                                 


                                                   
                                                             


                                  

 
         
                           

 
           
                            
                                       





                                                                            
 











                                                                                                                  



                                             
                                      




                                                             
                                                       







                                                                             
                         

           
                          

             
                            





                                               
 



                                                                                                               
       

                                       
 

                                                                              
 
 
                                                                                                                                                                   

                                                                                                                                               
# Contributor: Francesco Colista <fcolista@alpinelinux.org>
# Maintainer: Francesco Colista <fcolista@alpinelinux.org>
pkgname=icinga2
pkgver=2.12.3
pkgrel=1
pkgdesc="An open source host, service and network monitoring program"
url="http://www.icinga.org"
arch="all !armhf !armv7 !s390x !mips !mips64"
license="GPL-2.0-only"
depends="monitoring-plugins"
makedepends="$depends_dev cmake bison flex boost-dev yajl-dev
	postgresql-dev mariadb-connector-c-dev openssl-dev libedit-dev samurai"
install="$pkgname.pre-install $pkgname.post-install"
pkgusers="icinga"
pkggroups="icinga icingacmd"
subpackages="$pkgname-doc $pkgname-bash-completion:bashcomp:noarch $pkgname-vim::noarch $pkgname-openrc"
source="$pkgname-$pkgver.tar.gz::https://github.com/Icinga/icinga2/archive/v$pkgver.tar.gz
	$pkgname.initd
	boost.patch
	"

# secfixes:
#   2.11.3-r1:
#     - CVE-2020-14001

build() {
	if [ "$CBUILD" != "$CHOST" ]; then
		CMAKE_CROSSOPTS="-DCMAKE_SYSTEM_NAME=Linux -DCMAKE_HOST_SYSTEM_NAME=Linux"
	fi
	cmake -B build \
		-DCMAKE_BUILD_TYPE=None \
		-DICINGA2_GIT_VERSION_INFO=OFF \
		-DICINGA2_UNITY_BUILD=FALSE \
		-DCMAKE_INSTALL_PREFIX=/usr \
		-DCMAKE_INSTALL_SYSCONFDIR=/etc \
		-DICINGA2_RUNDIR=/run \
		-DCMAKE_INSTALL_SBINDIR=/usr/sbin \
		-DCMAKE_INSTALL_LIBDIR=/usr/lib \
		-DCMAKE_INSTALL_LOCALSTATEDIR=/var \
		-DICINGA2_SYSCONFIGFILE=/etc/icinga2 \
		-DICINGA2_PLUGINDIR=/usr/lib/monitoring-plugins \
		-DICINGA2_USER=icinga \
		-DICINGA2_GROUP=icingacmd \
		-DICINGA2_COMMAND_GROUP=icingacmd \
		-DINSTALL_SYSTEMD_SERVICE_AND_INITSCRIPT=no \
		-GNinja \
		. $CMAKE_CROSSOPTS
	ninja -C build
}

check() {
	ninja -C build test
}

package() {
	cd "$builddir"/build
	DESTDIR="$pkgdir" ninja install
	mv "$pkgdir/etc/icinga2/conf.d" "$pkgdir/etc/icinga2/conf.d.example"
	mkdir "$pkgdir/etc/icinga2/conf.d"
	rm "$pkgdir/etc/icinga2/features-enabled/checker.conf"
	rm "$pkgdir/etc/icinga2/features-enabled/mainlog.conf"
	rm "$pkgdir/etc/icinga2/features-enabled/notification.conf"
	rm -r "$pkgdir/run"

	mkdir -p "$pkgdir/usr/lib/tmpfiles.d"
	cat > "$pkgdir/usr/lib/tmpfiles.d/icinga2.conf" <<- EOF
d /run/icinga2 0750 icinga icingacmd -
d /run/icinga2/cmd 2750 icinga icingacmd -
EOF
	cd ..

	install -Dm644 tools/syntax/vim/ftdetect/icinga2.vim "$pkgdir/usr/share/vim/vimfiles/ftdetect/icinga2.vim"
	install -Dm644 tools/syntax/vim/syntax/icinga2.vim "$pkgdir/usr/share/vim/vimfiles/syntax/icinga2.vim"
	install -Dm644 tools/syntax/nano/icinga2.nanorc "$pkgdir/usr/share/nano/icinga2.nanorc"

	chmod 750 "$pkgdir/etc/icinga2" \
		"$pkgdir/var/lib/icinga2" \
		"$pkgdir/var/spool/icinga2" \
		"$pkgdir/var/cache/icinga2" \
		"$pkgdir/var/log/icinga2"
	mkdir -p "$pkgdir/run/icinga2"
	chown -R icinga:icinga "$pkgdir"/etc/icinga2
	chown -R icinga:icinga "$pkgdir"/var/lib/icinga2
	chown icinga:icinga "$pkgdir"/var/spool/icinga2
	chown -R icinga:icingacmd "$pkgdir"/var/cache/icinga2
	chown -R icinga:icingacmd "$pkgdir"/var/log/icinga2
	chown -R icinga:icingacmd "$pkgdir"/run/icinga2

	install -Dm755 "$srcdir"/$pkgname.initd "$pkgdir"/etc/init.d/$pkgname
	cat >"$pkgdir"/usr/share/doc/$pkgname/README.alpine <<EOF

Add the web server user to the icingacmd group in order to grant it write
permissions to the external command pipe and livestatus socket:

For nginx, as example:
# adduser nginx icingacmd

For Apache:
# adduser apache icingacmd

For lighttpd:
# adduser lighttpd icingacmd
EOF
}

bashcomp() {
	depends="bash"
	pkgdesc="Bash completions for $pkgname"

	mkdir -p "$subpkgdir"/usr/share/bash-completion/completions
	mv "$pkgdir"/etc/bash_completion.d/$pkgname "$subpkgdir"/usr/share/bash-completion/completions/$pkgname
}

vim() {
	pkgdesc="$pkgdesc (vim syntax)"
	depends=

	mkdir -p "$subpkgdir"/usr/share/vim
	cp -r "$builddir"/tools/syntax/vim "$subpkgdir"/usr/share/vim/vimfiles
}

sha512sums="28b87e03a8ffeb7a1d19ddf9555151b826f7bf1fd33b0139c2fc8abe7c89d66d96089d5b32d0aaccc3876040514b2bfbde9970416d5ec4ea3b023b17c0fb1799  icinga2-2.12.3.tar.gz
46890756104563b1a4bc60b5952a2d63f5263883cfe702de7ccc4616dfe5b20d380ff1bc190482741a06bcfe7e662ad14a6965e26b9ce916ef56a1248d6b524c  icinga2.initd
6f5b457dd4ef8d08fd4063a1a9babdc81d8f6789547448180795a30b46c4868ff1c520cc6e9b9140c866e0b62c9caae30ef4af53a963e29a0d2b4280acac1360  boost.patch"