mirror of https://github.com/Icinga/icinga2.git
Migrate config files from conf.d/hosts to repository.d/hosts
fixes #7398
This commit is contained in:
parent
76444027e9
commit
876099fa0a
|
@ -4,3 +4,4 @@ debian/tmp/etc/logrotate.d
|
|||
debian/tmp/etc/bash_completion.d
|
||||
tools/syntax/* usr/share/icinga2-common/syntax
|
||||
usr/share/icinga2
|
||||
usr/lib/icinga2/bin
|
||||
|
|
|
@ -64,6 +64,8 @@ case "$1" in
|
|||
|
||||
# enable default features
|
||||
enable_default_features $@
|
||||
|
||||
/usr/share/icinga2/migrate-hosts
|
||||
;;
|
||||
|
||||
abort-upgrade|abort-remove|abort-deconfigure)
|
||||
|
|
|
@ -262,6 +262,8 @@ exit 0
|
|||
%endif
|
||||
%endif
|
||||
|
||||
%post common
|
||||
/usr/share/icinga2/migrate-hosts
|
||||
|
||||
# all restart/feature actions belong to icinga2-bin
|
||||
%post bin
|
||||
|
|
|
@ -18,3 +18,9 @@
|
|||
add_subdirectory(mkclass)
|
||||
add_subdirectory(mkembedconfig)
|
||||
add_subdirectory(mkunity)
|
||||
|
||||
install(
|
||||
FILES ${CMAKE_CURRENT_SOURCE_DIR}/migrate-hosts
|
||||
DESTINATION ${CMAKE_INSTALL_DATADIR}/icinga2
|
||||
PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE
|
||||
)
|
||||
|
|
|
@ -0,0 +1,53 @@
|
|||
#!/bin/sh
|
||||
# Moves configuration files from /etc/icinga2/conf.d/hosts
|
||||
# to /etc/icinga2/repository.d
|
||||
|
||||
sysconfdir=`icinga2 variable get --current SysconfDir`
|
||||
|
||||
if [ -z "$sysconfdir" ]; then
|
||||
echo "Could not determine SysconfDir"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ ! -d $sysconfdir/icinga2/conf.d/hosts ]; then
|
||||
exit 0
|
||||
fi
|
||||
|
||||
mkdir -p $sysconfdir/icinga2/repository.d/hosts
|
||||
|
||||
for hostFile in $sysconfdir/icinga2/conf.d/hosts/*.conf; do
|
||||
host=`basename $hostFile .conf`
|
||||
|
||||
if [ "x$host" = "xlocalhost" ]; then
|
||||
target="`hostname --fqdn`"
|
||||
else
|
||||
target=$host
|
||||
fi
|
||||
|
||||
mv $sysconfdir/icinga2/conf.d/hosts/$host.conf $sysconfdir/icinga2/repository.d/hosts/$target.conf
|
||||
sed -i "s/localhost/$target/g" $sysconfdir/icinga2/repository.d/hosts/$target.conf
|
||||
|
||||
if [ -d $sysconfdir/icinga2/conf.d/hosts/$host ]; then
|
||||
mv $sysconfdir/icinga2/conf.d/hosts/$host $sysconfdir/icinga2/repository.d/hosts/$target
|
||||
sed -i "s/localhost/$target/g" $sysconfdir/icinga2/repository.d/hosts/$target/*.conf
|
||||
fi
|
||||
done
|
||||
|
||||
cat >$sysconfdir/icinga2/conf.d/hosts/README <<TEXT
|
||||
What happened to my configuration files?
|
||||
========================================
|
||||
|
||||
Your host and service configuration files were moved to the $sysconfdir/icinga2/repository.d directory.
|
||||
|
||||
This allows you to manipulate those files using the "icinga2 repository" CLI commands.
|
||||
|
||||
Here are a few commands you might want to try:
|
||||
|
||||
\$ icinga2 repository host list
|
||||
|
||||
\$ icinga2 repository service list
|
||||
|
||||
\$ icinga2 repository --help
|
||||
TEXT
|
||||
|
||||
exit 0
|
Loading…
Reference in New Issue