mirror of https://github.com/Icinga/icinga2.git
parent
70fe95bbba
commit
8cf5b33e70
|
@ -19,8 +19,10 @@ add_subdirectory(mkclass)
|
||||||
add_subdirectory(mkembedconfig)
|
add_subdirectory(mkembedconfig)
|
||||||
add_subdirectory(mkunity)
|
add_subdirectory(mkunity)
|
||||||
|
|
||||||
|
configure_file(migrate-hosts.cmake ${CMAKE_CURRENT_BINARY_DIR}/migrate-hosts @ONLY)
|
||||||
|
|
||||||
install(
|
install(
|
||||||
FILES ${CMAKE_CURRENT_SOURCE_DIR}/migrate-hosts
|
FILES ${CMAKE_CURRENT_BINARY_DIR}/migrate-hosts
|
||||||
DESTINATION ${CMAKE_INSTALL_DATADIR}/icinga2
|
DESTINATION ${CMAKE_INSTALL_DATADIR}/icinga2
|
||||||
PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE
|
PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE
|
||||||
)
|
)
|
||||||
|
|
|
@ -1,53 +0,0 @@
|
||||||
#!/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
|
|
|
@ -0,0 +1,75 @@
|
||||||
|
#!/bin/sh
|
||||||
|
# Moves configuration files from /etc/icinga2/conf.d/hosts
|
||||||
|
# to /etc/icinga2/repository.d
|
||||||
|
|
||||||
|
icinga2bin=@CMAKE_INSTALL_FULL_SBINDIR@/icinga2
|
||||||
|
sysconfdir=`$icinga2bin 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
|
||||||
|
|
||||||
|
host_count=0
|
||||||
|
service_count=0
|
||||||
|
|
||||||
|
for hostFile in $sysconfdir/icinga2/conf.d/hosts/*.conf; do
|
||||||
|
host_count=$(($host_count + 1))
|
||||||
|
|
||||||
|
host=`basename $hostFile .conf`
|
||||||
|
|
||||||
|
if [ "x$host" = "xlocalhost" ]; then
|
||||||
|
target="`hostname -f`"
|
||||||
|
else
|
||||||
|
target=$host
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ ! -e $sysconfdir/icinga2/repository.d/hosts/$target.conf ]; then
|
||||||
|
mv $sysconfdir/icinga2/conf.d/hosts/$host.conf $sysconfdir/icinga2/repository.d/hosts/$target.conf
|
||||||
|
sed "s/localhost/$target/g" $sysconfdir/icinga2/repository.d/hosts/$target.conf > $sysconfdir/icinga2/repository.d/hosts/$target.conf.tmp
|
||||||
|
mv $sysconfdir/icinga2/repository.d/hosts/$target.conf.tmp $sysconfdir/icinga2/repository.d/hosts/$target.conf
|
||||||
|
else
|
||||||
|
rm -f $sysconfdir/icinga2/conf.d/hosts/$host.conf
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -d $sysconfdir/icinga2/conf.d/hosts/$host ]; then
|
||||||
|
service_count=$(($service_count + 1))
|
||||||
|
|
||||||
|
if [ ! -e $sysconfdir/icinga2/repository.d/hosts/$target ]; then
|
||||||
|
mv $sysconfdir/icinga2/conf.d/hosts/$host $sysconfdir/icinga2/repository.d/hosts/$target
|
||||||
|
for file in $sysconfdir/icinga2/repository.d/hosts/$target/*.conf; do
|
||||||
|
sed "s/localhost/$target/g" $file > $file.tmp
|
||||||
|
mv $file.tmp $file
|
||||||
|
done
|
||||||
|
else
|
||||||
|
rm -rf $sysconfdir/icinga2/conf.d/hosts/$host
|
||||||
|
fi
|
||||||
|
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
|
||||||
|
|
||||||
|
echo "Migrated $host_count host(s) and $service_count service(s)."
|
||||||
|
|
||||||
|
exit 0
|
Loading…
Reference in New Issue