Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes #4684: Avoid using cron.d, profile.d and rsync and add pidof on AI... #282

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 7 additions & 3 deletions rudder-agent/SOURCES/check-rudder-agent
Expand Up @@ -156,6 +156,10 @@ if [ ! $(whoami) = 'root' ];then echo "You must be root"; exit; fi
# Launch each check with a certain order
check_and_fix_rudder_uuid
check_and_fix_cfengine_processes
check_and_fix_specific_rudder_agent_file /etc/init.d/rudder-agent init
check_and_fix_specific_rudder_agent_file /etc/default/rudder-agent default
check_and_fix_specific_rudder_agent_file /etc/cron.d/rudder-agent cron

# The following files are not present on AIX systems
if [ "z$(uname -s)" != "zAIX" ]; then
check_and_fix_specific_rudder_agent_file /etc/init.d/rudder-agent init
check_and_fix_specific_rudder_agent_file /etc/default/rudder-agent default
check_and_fix_specific_rudder_agent_file /etc/cron.d/rudder-agent cron
fi
32 changes: 24 additions & 8 deletions rudder-agent/SPECS/rudder-agent.spec
Expand Up @@ -206,14 +206,16 @@ make %{?_smp_mflags}
make install DESTDIR=%{buildroot}
%endif

# Prepare CFEngine 3.4.x build
# Prepare CFEngine build
cd %{_sourcedir}/cfengine-source

%if "%{is_tokyocabinet_here}" != "true"
## Define path of tokyocabinet if built before instead of being provided by the system.
%define tokyocabinet_arg "--with-tokyocabinet=%{buildroot}%{rudderdir}"
%else
%define tokyocabinet_arg ""
%endif

./configure --build=%_target --prefix=%{rudderdir} --with-workdir=%{ruddervardir}/cfengine-community --enable-static=yes --enable-shared=no %{tokyocabinet_arg}

make %{?_smp_mflags}
Expand All @@ -236,19 +238,13 @@ cd %{_sourcedir}/cfengine-source
make install DESTDIR=%{buildroot} STRIP=""

# Directories
mkdir -p %{buildroot}/etc/profile.d
mkdir -p %{buildroot}%{rudderdir}
mkdir -p %{buildroot}%{rudderdir}/etc
mkdir -p %{buildroot}%{ruddervardir}/cfengine-community/bin
mkdir -p %{buildroot}%{ruddervardir}/cfengine-community/inputs
mkdir -p %{buildroot}%{ruddervardir}/tmp
mkdir -p %{buildroot}%{ruddervardir}/tools

# ld.so.conf.d is not supported on CentOS 3
%if 0%{?rhel} != 3
mkdir -p %{buildroot}/etc/ld.so.conf.d
%endif

# Init script
# AIX does not use init scripts, instead we set up a subsystem in the post scriptlet below
%if "%{?_os}" != "aix"
Expand All @@ -259,8 +255,11 @@ mkdir -p %{buildroot}/etc/default
%endif

# Cron
# AIX does not support cron.d
%if "%{?_os}" != "aix"
mkdir -p %{buildroot}/etc/cron.d
%{install_command} -m 644 %{SOURCE5} %{buildroot}/etc/cron.d/rudder-agent
%endif

# Initial promises
cp -r %{_sourcedir}/initial-promises %{buildroot}%{rudderdir}/share/
Expand All @@ -274,9 +273,11 @@ cp -r %{_sourcedir}/initial-promises %{buildroot}%{rudderdir}/share/
# Install an empty uuid.hive file before generating an uuid
cp %{SOURCE4} %{buildroot}%{rudderdir}/etc/

# ld.so.conf.d is not supported on CentOS 3
%if "%{is_tokyocabinet_here}" != "true" && 0%{?rhel} != 3
# Install /etc/ld.so.conf.d/rudder.conf in order to use libraries
# contained in /opt/rudder/lib like tokyocabinet
mkdir -p %{buildroot}/etc/ld.so.conf.d
%{install_command} -m 644 %{SOURCE6} %{buildroot}/etc/ld.so.conf.d/rudder.conf
%endif

Expand All @@ -285,7 +286,11 @@ cp %{SOURCE4} %{buildroot}%{rudderdir}/etc/
%{install_command} -m 755 %{SOURCE8} %{buildroot}/opt/rudder/bin/vzps.py

# Install a profile script to make cf-* part of the PATH
# AIX does not support profile.d and /etc/profile should not be modified, so we don't do this on AIX at all
%if "%{?_os}" != "aix"
mkdir -p %{buildroot}/etc/profile.d
%{install_command} -m 644 %{SOURCE9} %{buildroot}/etc/profile.d/rudder-agent.sh
%endif

# Build a list of files to include in this package for use in the %files section below
find %{buildroot}%{rudderdir} %{buildroot}%{ruddervardir} -type f | sed "s,%{buildroot},," | grep -v "%{rudderdir}/etc/uuid.hive" | grep -v "%{ruddervardir}/cfengine-community/ppkeys" > %{_builddir}/file.list.%{name}
Expand Down Expand Up @@ -405,7 +410,8 @@ fi
RUDDER_UUID=`cat /opt/rudder/etc/uuid.hive 2>/dev/null || true`
if ! /var/rudder/cfengine-community/bin/cf-promises >/dev/null 2>&1 && [ "z${RUDDER_UUID}" != "zroot" ]
then
rsync --delete -aq /opt/rudder/share/initial-promises/ /var/rudder/cfengine-community/inputs/
rm -rf /var/rudder/cfengine-community/inputs/*
%{cp_a_command} /opt/rudder/share/initial-promises/* /var/rudder/cfengine-community/inputs/
fi

# Migration to CFEngine 3.5: Correct a specific Technique that breaks the most recent CFEngine versions
Expand Down Expand Up @@ -500,6 +506,14 @@ echo "INFO: A back up copy of the /var/rudder/cfengine-community/ppkeys has been
# Post Uninstallation
#=================================================

%if "%{?_os}" == "aix"
# AIX doesn't have a pidof command, let's define it
function pidof {
# Yeah, "grep -v grep" is ugly, but we can't use the [u]nique trick on a variable
ps -A | grep "$1" | grep -v grep | awk '{print $1}';
}
%endif

# Do it only during uninstallation
if [ $1 -eq 0 ]; then
# Make sure that CFEngine is not running anymore
Expand Down Expand Up @@ -533,10 +547,12 @@ rm -f %{_builddir}/file.list.%{name}
%files -n rudder-agent -f %{_builddir}/file.list.%{name}
%defattr(-, root, root, 0755)
%config(noreplace) %{rudderdir}/etc/uuid.hive
%if "%{?_os}" != "aix"
/etc/profile.d/rudder-agent.sh
/etc/init.d/rudder-agent
/etc/default/rudder-agent
/etc/cron.d/rudder-agent
%endif
%attr(0600, -, -) %dir %{ruddervardir}/cfengine-community/ppkeys
%if "%{is_tokyocabinet_here}" != "true" && 0%{?rhel} != 3
%config(noreplace) /etc/ld.so.conf.d/rudder.conf
Expand Down