Revision 54146c01
Added by Alexis Mousset over 6 years ago
rudder-agent/SOURCES/Makefile | ||
---|---|---|
mkdir -p $(DESTDIR)/usr/bin
|
||
mkdir -p $(DESTDIR)/etc/cron.d
|
||
|
||
# Systemd files
|
||
ifeq (true,$(USE_SYSTEMD))
|
||
mkdir -p $(DESTDIR)/lib/systemd/system
|
||
$(INSTALL) -m 644 systemd/rudder-agent.service $(DESTDIR)/lib/systemd/system/rudder-agent.service
|
||
$(INSTALL) -m 644 systemd/cf-execd.service $(DESTDIR)/lib/systemd/system/cf-execd.service
|
||
$(INSTALL) -m 644 systemd/cf-serverd.service $(DESTDIR)/lib/systemd/system/cf-serverd.service
|
||
endif
|
||
|
||
# Init files
|
||
ifneq (true,$(USE_SYSTEMD))
|
||
ifneq (true,$(NO_INIT))
|
||
mkdir -p $(DESTDIR)/etc/init.d
|
||
mkdir -p $(DESTDIR)/etc/default
|
||
$(INSTALL) -m 755 rudder-agent.init $(DESTDIR)/etc/init.d/rudder-agent
|
||
$(INSTALL) -m 755 rudder.init $(DESTDIR)/etc/init.d/rudder
|
||
$(INSTALL) -m 644 rudder-agent.default $(DESTDIR)/etc/default/rudder-agent
|
||
endif
|
||
endif
|
||
|
||
# cron files
|
rudder-agent/SOURCES/rudder-agent-postinst | ||
---|---|---|
set -e
|
||
|
||
CFRUDDER_FIRST_INSTALL="$1"
|
||
CFRUDDER_OS="$2"
|
||
CFRUDDER_USE_SYSTEMD="$3"
|
||
|
||
CFE_DIR="/var/rudder/cfengine-community"
|
||
RUDDER_CMD="/opt/rudder/bin/rudder"
|
||
LOG_FILE="/var/log/rudder/install/rudder-agent.log"
|
||
|
||
if [ -z "$1" ]
|
||
if [ -z "$1" ] || [ -z "$2" ] || [ -z "$3" ]
|
||
then
|
||
echo "Usage: $0 <CFRUDDER_FIRST_INSTALL>"
|
||
echo "Usage: $0 <CFRUDDER_FIRST_INSTALL> <CFRUDDER_OS> <CFRUDDER_USE_SYSTEMD>"
|
||
echo " This should only be called from a package postinstall command"
|
||
echo " You may want to run 'rudder agent factory-reset' instead"
|
||
exit 1
|
||
fi
|
||
|
||
echo "`date` - Starting rudder-agent post installation script" >> ${LOG_FILE}
|
||
|
||
# Do this at first install
|
||
if [ ${CFRUDDER_FIRST_INSTALL} -eq 1 ]
|
||
then
|
||
# Set rudder-agent as service
|
||
if [ ${CFRUDDER_OS} = "aix" ]
|
||
then
|
||
/usr/bin/mkssys -s rudder-agent -p "${CFE_DIR}/bin/cf-execd" -a "-F" -u root -S -n15 -f9 -R
|
||
/usr/sbin/mkitab "rudder-agent:23456789:once:/usr/bin/startsrc -s rudder-agent"
|
||
# No need to tell init to re-read /etc/inittab, it does it automatically every 60 seconds
|
||
elif [ ${CFRUDDER_OS} != "deb" ]
|
||
# Deb packaging handles service activation
|
||
then
|
||
if [ "${CFRUDDER_USE_SYSTEMD}" = "true" ]
|
||
then
|
||
/bin/systemctl daemon-reload
|
||
/bin/systemctl enable rudder-agent cf-execd cf-serverd
|
||
else
|
||
chkconfig --add rudder-agent
|
||
chkconfig rudder-agent on
|
||
fi
|
||
fi
|
||
fi
|
||
|
||
if [ -f /var/rudder/tmp/migration-rudder-service-rename ]
|
||
then
|
||
# Rename only happens on non-systemd systems
|
||
if type chkconfig > /dev/null
|
||
then
|
||
chkconfig --add rudder-agent
|
||
fi
|
||
|
||
if [ -f /var/rudder/tmp/migration-rudder-service-enabled ]
|
||
then
|
||
if type chkconfig > /dev/null
|
||
then
|
||
chkconfig --add rudder-agent
|
||
chkconfig rudder-agent on
|
||
fi
|
||
|
||
if type update-rc.d > /dev/null
|
||
then
|
||
update-rc.d rudder-agent enable
|
||
fi
|
||
fi
|
||
fi
|
||
|
||
if [ -f /var/rudder/tmp/migration-rudder-service-systemd ]
|
||
then
|
||
# We are making the migration from sysv to systemd
|
||
if type chkconfig > /dev/null
|
||
then
|
||
chkconfig --del rudder-agent
|
||
fi
|
||
|
||
if type update-rc.d > /dev/null
|
||
then
|
||
update-rc.d rudder-agent remove
|
||
fi
|
||
|
||
rm -f /etc/init.d/rudder-agent
|
||
rm -f /etc/default/rudder-agent
|
||
/bin/systemctl daemon-reload
|
||
|
||
if [ -f /var/rudder/tmp/migration-rudder-service-enabled ]
|
||
then
|
||
/bin/systemctl enable rudder-agent cf-execd
|
||
|
||
if [ -f /var/rudder/tmp/migration-rudder-cf-serverd-disabled ]
|
||
then
|
||
# Keep cf-serverd disabled
|
||
/bin/true
|
||
else
|
||
/bin/systemctl enable cf-serverd
|
||
fi
|
||
fi
|
||
fi
|
||
|
||
# Delete all flag files
|
||
rm -f /var/rudder/tmp/migration-rudder-service-rename
|
||
rm -f /var/rudder/tmp/migration-rudder-service-systemd
|
||
rm -f /var/rudder/tmp/migration-rudder-service-enabled
|
||
rm -f /var/rudder/tmp/migration-rudder-cf-serverd-disabled
|
||
|
||
# Remove the rudder service
|
||
if [ -f /etc/init.d/rudder ]
|
||
then
|
||
if type chkconfig > /dev/null
|
||
then
|
||
chkconfig --del rudder || true
|
||
fi
|
||
if type update-rc.d > /dev/null
|
||
then
|
||
update-rc.d rudder remove
|
||
fi
|
||
rm -f /etc/init.d/rudder
|
||
fi
|
||
|
||
# Reload the linker cache (to acknowledge LMDB's presence if needed)
|
||
if [ -f /etc/ld.so.conf.d/rudder.conf ]; then
|
||
echo "Found /etc/ld.so.conf.d/rudder.conf, running ldconfig" >> ${LOG_FILE}
|
rudder-agent/SOURCES/rudder-agent-preinst | ||
---|---|---|
#!/bin/sh
|
||
set -e
|
||
|
||
CFE_DIR="/var/rudder/cfengine-community"
|
||
RUDDER_CMD="/opt/rudder/bin/rudder"
|
||
LOG_FILE="/var/log/rudder/install/rudder-agent.log"
|
||
|
||
CFRUDDER_FIRST_INSTALL="$1"
|
||
CFRUDDER_OS="$2"
|
||
CFRUDDER_USE_SYSTEMD="$3"
|
||
|
||
if [ -z "$1" ] || [ -z "$2" ] || [ -z "$3" ]
|
||
then
|
||
echo "Usage: $0 <CFRUDDER_FIRST_INSTALL> <CFRUDDER_OS> <CFRUDDER_USE_SYSTEMD>"
|
||
echo " This should only be called from a package preinstall command"
|
||
exit 1
|
||
fi
|
||
|
||
echo "`date` - Starting rudder-agent pre installation script" >> ${LOG_FILE}
|
||
|
||
# Restart daemons if we stopped them, otherwise not
|
||
if [ ${CFRUDDER_FIRST_INSTALL} -ne 1 ]
|
||
then
|
||
# Part of the package now, but create it anyway in case
|
||
# of upgrade from a very old version
|
||
mkdir -p /var/rudder/tmp
|
||
|
||
if [ "${CFRUDDER_USE_SYSTEMD}" = "true" ]
|
||
then
|
||
if [ -f /etc/init.d/rudder-agent ]
|
||
then
|
||
# we are migrating from sysv to systemd
|
||
touch /var/rudder/tmp/migration-rudder-service-systemd
|
||
|
||
if type chkconfig > /dev/null
|
||
then
|
||
# If old rudder-agent service is here and enabled
|
||
if chkconfig --list rudder-agent 2>&1 | grep -q -e 3:on -e B:on
|
||
then
|
||
touch /var/rudder/tmp/migration-rudder-service-enabled
|
||
fi
|
||
|
||
# If old rudder service is here and enabled
|
||
if chkconfig --list rudder 2>&1 | grep -q -e 3:on -e B:on
|
||
then
|
||
touch /var/rudder/tmp/migration-rudder-service-enabled
|
||
fi
|
||
fi
|
||
|
||
if test /etc/rc`/sbin/runlevel | cut -d' ' -f2`.d/S??rudder-agent
|
||
then
|
||
touch /var/rudder/tmp/migration-rudder-service-enabled
|
||
fi
|
||
|
||
if test /etc/rc`/sbin/runlevel | cut -d' ' -f2`.d/S??rudder
|
||
then
|
||
touch /var/rudder/tmp/migration-rudder-service-enabled
|
||
fi
|
||
|
||
# Test if cf-serverd is disabled
|
||
if [ -f /etc/default/rudder-agent ]
|
||
then
|
||
if grep -q '^CFENGINE_COMMUNITY_RUN_1="0"' /etc/default/rudder-agent
|
||
then
|
||
touch /var/rudder/tmp/migration-rudder-cf-serverd-disabled
|
||
fi
|
||
fi
|
||
fi
|
||
else
|
||
if [ -f /etc/init.d/rudder ]
|
||
then
|
||
# We are migrating from a pre-4.3 to 4.3
|
||
touch /var/rudder/tmp/migration-rudder-service-rename
|
||
|
||
# If old rudder service is here and enabled
|
||
if type chkconfig > /dev/null
|
||
then
|
||
if chkconfig --list rudder 2>&1 | grep -q -e 3:on -e B:on
|
||
then
|
||
touch /var/rudder/tmp/migration-rudder-service-enabled
|
||
fi
|
||
fi
|
||
|
||
if test /etc/rc`/sbin/runlevel | cut -d' ' -f2`.d/S??rudder
|
||
then
|
||
touch /var/rudder/tmp/migration-rudder-service-enabled
|
||
fi
|
||
fi
|
||
fi
|
||
fi
|
||
|
rudder-agent/SOURCES/rudder.init | ||
---|---|---|
#!/bin/sh
|
||
|
||
#==============================================
|
||
# Start/stop script for all Rudder components #
|
||
#==============================================
|
||
#
|
||
### BEGIN INIT INFO
|
||
# Provides: rudder
|
||
# Required-Start: $local_fs $remote_fs $network $syslog
|
||
# Required-Stop: $local_fs $remote_fs $network $syslog
|
||
# Default-Start: 2 3 4 5
|
||
# Default-Stop: 0 1 6
|
||
# Short-Description: Rudder server
|
||
# Description: Rudder server including all components required to run
|
||
### END INIT INFO
|
||
#
|
||
# Copyright (C) 2011-2015 Normation
|
||
#
|
||
# This program is free software; you can redistribute it and/or
|
||
# modify it under the terms of the GNU General Public License
|
||
# as published by the Free Software Foundation; either version 2
|
||
# of the License, or (at your option) any later version.
|
||
#
|
||
# This program is distributed in the hope that it will be useful,
|
||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||
# GNU General Public License for more details.
|
||
#
|
||
# GPL License: http://www.gnu.org/licenses/gpl.txt
|
||
#
|
||
#====================================================================
|
||
|
||
# Utility functions
|
||
|
||
get_service_name()
|
||
{
|
||
# This script detects the closest match for the given service
|
||
# If only one version is available, return it
|
||
# If multiple versions (postgresql91/postgresql94), return the latest one
|
||
# Arguments:
|
||
## Service name
|
||
if type systemctl >/dev/null 2>&1; then
|
||
SERVICE_NAME=$(systemctl list-unit-files --type service | awk -F'.' '{print $1}' | grep -E "^${1}[0-9]*$" | tail -n 1)
|
||
fi
|
||
if [ -z "${SERVICE_NAME}" ] && type chkconfig >/dev/null 2>&1; then
|
||
SERVICE_NAME=$(chkconfig 2>/dev/null | awk '{ print $1 }' | grep "${1}" | tail -n 1)
|
||
fi
|
||
if [ -z "${SERVICE_NAME}" ]; then
|
||
SERVICE_NAME=$(ls -1 /etc/init.d | grep "${1}" | tail -n 1)
|
||
fi
|
||
|
||
# If we can not get the service name, fallback to the user-supplied name
|
||
if [ -z "${SERVICE_NAME}" ]; then
|
||
SERVICE_NAME="${1}"
|
||
fi
|
||
|
||
echo ${SERVICE_NAME}
|
||
}
|
||
|
||
service_action()
|
||
{
|
||
# Arguments:
|
||
## Service name
|
||
## Action to trigger (start/stop/...)
|
||
## Is the role present on this machine (0/1)
|
||
|
||
# If the role is present, run the action
|
||
if [ "${3}" -eq 1 ]; then
|
||
printf " * ${1}...\t"
|
||
service "${1}" "${2}" >/dev/null 2>&1
|
||
|
||
if [ "${?}" -ne 0 ]; then
|
||
printf "${RED}FAILED, please run \"service ${1} ${2}\" for more details${NORMAL}\n"
|
||
RETURN=1
|
||
else
|
||
printf "${GREEN}OK${NORMAL}\n"
|
||
fi
|
||
|
||
fi
|
||
}
|
||
|
||
service_status()
|
||
{
|
||
# Arguments:
|
||
## Service human-friendly name
|
||
## Service name
|
||
## Is the role present on this machine (0/1)
|
||
|
||
printf " * ${1}\t"
|
||
if [ "${3}" -ne 1 ]; then
|
||
# If the role is present, run the action
|
||
printf "${YELLOW}Not installed${NORMAL}\n"
|
||
elif service "${2}" status >/dev/null 2>&1; then
|
||
printf "${GREEN}OK${NORMAL}\n"
|
||
else
|
||
printf "${RED}Not running, please restart with \"service ${2} restart\" ${NORMAL}\n"
|
||
RETURN=1
|
||
fi
|
||
}
|
||
|
||
service_details()
|
||
{
|
||
# Arguments:
|
||
## Service human-friendly name
|
||
## Service name
|
||
## Is the role present on this machine (0/1)
|
||
|
||
printf "\n * ${BLUE}${1}${NORMAL}:"
|
||
if [ "${3}" -eq 1 ]; then
|
||
echo ""
|
||
${COPYPASTE}
|
||
service "${2}" status || RETURN=${?}
|
||
${COPYPASTE}
|
||
else
|
||
printf " ${YELLOW}Not installed${NORMAL}\n"
|
||
fi
|
||
}
|
||
|
||
# Variables
|
||
|
||
## Environment setup - neutral locale
|
||
LANG=C
|
||
LANGUAGE=C
|
||
LC_ALL=C
|
||
|
||
export LANG LANGUAGE LC_ALL
|
||
|
||
# Ensure this script is run as root
|
||
if [ "$(id -u)" != "0" ]; then
|
||
echo "Please run this script as root" 1>&2
|
||
exit 1
|
||
fi
|
||
|
||
## Colors configuration (enable colors only if stdout is a terminal)
|
||
if [ -t 1 ]; then
|
||
GREEN="\\033[1;32m"
|
||
RED="\\033[1;31m"
|
||
BLUE="\\033[1;34m"
|
||
PINK="\\033[1;35m"
|
||
WHITE="\\033[0;02m"
|
||
WHITELIGHT="\\033[1;08m"
|
||
YELLOW="\\033[1;33m"
|
||
CYAN="\\033[1;36m"
|
||
NORMAL="\\033[0;39m"
|
||
COPYPASTE="printf ${GREEN}---8<---${NORMAL}\n"
|
||
else
|
||
GREEN=""
|
||
RED=""
|
||
BLUE=""
|
||
PINK=""
|
||
WHITE=""
|
||
WHITELIGHT=""
|
||
YELLOW=""
|
||
CYAN=""
|
||
NORMAL=""
|
||
COPYPASTE="printf ---8<---\n"
|
||
fi
|
||
|
||
## Active roles
|
||
|
||
HAVE_SLAPD=0
|
||
HAVE_POSTGRESQL=0
|
||
HAVE_JETTY=0
|
||
HAVE_AGENT=1
|
||
|
||
### Check slapd's status if we are rudder-inventory-ldap
|
||
[ -e /opt/rudder/etc/server-roles.d/rudder-inventory-ldap ] && HAVE_SLAPD=1
|
||
|
||
### Check PostgreSQL's status if we are rudder-db
|
||
[ -e /opt/rudder/etc/server-roles.d/rudder-db ] && HAVE_POSTGRESQL=1
|
||
|
||
### Check Jetty's status if we are rudder-webapp or rudder-inventory-endpoint
|
||
[ -e /opt/rudder/etc/server-roles.d/rudder-inventory-endpoint ] && HAVE_JETTY=1
|
||
[ -e /opt/rudder/etc/server-roles.d/rudder-webapp ] && HAVE_JETTY=1
|
||
|
||
## Service names
|
||
|
||
RUDDER_SLAPD=rudder-slapd
|
||
RUDDER_JETTY=rudder-jetty
|
||
RUDDER_AGENT=rudder-agent
|
||
POSTGRESQL=$(get_service_name postgresql)
|
||
|
||
## Default return code
|
||
RETURN=0
|
||
|
||
# Main
|
||
|
||
start_services()
|
||
{
|
||
printf "${GREEN}Starting Rudder services:${NORMAL}\n"
|
||
|
||
service_action "${RUDDER_SLAPD}" start "${HAVE_SLAPD}"
|
||
service_action "${POSTGRESQL}" start "${HAVE_POSTGRESQL}"
|
||
service_action "${RUDDER_JETTY}" start "${HAVE_JETTY}"
|
||
service_action "${RUDDER_AGENT}" start "${HAVE_AGENT}"
|
||
}
|
||
|
||
stop_services()
|
||
{
|
||
printf "${GREEN}Stopping Rudder services:${NORMAL}\n"
|
||
|
||
# Stop Rudder applications before databases to prevent
|
||
# hangs at shutdown due to still active client connexions
|
||
# and connexion failure from appearing in rudder-jetty
|
||
# logs.
|
||
service_action "${RUDDER_AGENT}" stop "${HAVE_AGENT}"
|
||
service_action "${RUDDER_JETTY}" stop "${HAVE_JETTY}"
|
||
service_action "${POSTGRESQL}" stop "${HAVE_POSTGRESQL}"
|
||
service_action "${RUDDER_SLAPD}" stop "${HAVE_SLAPD}"
|
||
}
|
||
|
||
details_services()
|
||
{
|
||
printf "${GREEN}Detailed component status:${NORMAL}\n"
|
||
|
||
service_details "Agent" "${RUDDER_AGENT}" "${HAVE_AGENT}"
|
||
service_details "LDAP DB" "${RUDDER_SLAPD}" "${HAVE_SLAPD}"
|
||
service_details "SQL DB" "${POSTGRESQL}" "${HAVE_POSTGRESQL}"
|
||
service_details "Application" "${RUDDER_JETTY}" "${HAVE_JETTY}"
|
||
}
|
||
|
||
status_services()
|
||
{
|
||
printf "${GREEN}Component status:${NORMAL}\n"
|
||
|
||
service_status "Agent" "${RUDDER_AGENT}" "${HAVE_AGENT}"
|
||
service_status "LDAP DB" "${RUDDER_SLAPD}" "${HAVE_SLAPD}"
|
||
service_status "SQL DB" "${POSTGRESQL}" "${HAVE_POSTGRESQL}"
|
||
service_status "Application" "${RUDDER_JETTY}" "${HAVE_JETTY}"
|
||
}
|
||
|
||
case "$1" in
|
||
start)
|
||
start_services
|
||
;;
|
||
stop)
|
||
stop_services
|
||
;;
|
||
restart)
|
||
stop_services
|
||
echo ""
|
||
start_services
|
||
;;
|
||
status)
|
||
status_services
|
||
;;
|
||
details)
|
||
details_services
|
||
;;
|
||
*)
|
||
echo "Usage: $0 {start|stop|restart|status|details}"
|
||
exit 1
|
||
;;
|
||
esac
|
||
|
||
exit ${RETURN}
|
rudder-agent/SOURCES/systemd/rudder-agent.service | ||
---|---|---|
[Unit]
|
||
Description=Rudder agent umbrella service
|
||
Documentation=man:rudder(8)
|
||
Documentation=https://www.rudder-project.org/doc
|
||
After=syslog.target
|
||
# Dependencies register themselves with a WantedBy/RequiredBy
|
||
# currently they are rudder-cf-serverd and rudder-cf-execd
|
||
|
||
[Service]
|
||
Type=oneshot
|
||
RemainAfterExit=yes
|
||
# This is required for the service to be able to
|
||
# pass these commands to its dependencies
|
||
ExecStart=/bin/true
|
||
ExecReload=/bin/true
|
||
|
||
[Install]
|
||
WantedBy=multi-user.target
|
rudder-agent/SOURCES/systemd/rudder-cf-execd.service | ||
---|---|---|
[Unit]
|
||
Description=CFEngine Execution Scheduler
|
||
After=syslog.target
|
||
ConditionPathExists=/var/rudder/cfengine-community/bin/cf-execd
|
||
ConditionPathExists=/var/rudder/cfengine-community/inputs/promises.cf
|
||
ConditionPathExists=!/opt/rudder/etc/disable-agent
|
||
ReloadPropagatedFrom=rudder-agent.service
|
||
PartOf=rudder-agent.service
|
||
|
||
[Service]
|
||
Type=simple
|
||
ExecStart=/var/rudder/cfengine-community/bin/cf-execd --no-fork
|
||
ExecReload=/bin/kill -HUP $MAINPID
|
||
Restart=always
|
||
RestartSec=10
|
||
KillMode=process
|
||
|
||
[Install]
|
||
WantedBy=multi-user.target
|
||
RequiredBy=rudder-agent.service
|
rudder-agent/SOURCES/systemd/rudder-cf-serverd.service | ||
---|---|---|
[Unit]
|
||
Description=CFEngine file server
|
||
After=syslog.target
|
||
After=network.target
|
||
ConditionPathExists=/var/rudder/cfengine-community/bin/cf-serverd
|
||
ConditionPathExists=/var/rudder/cfengine-community/inputs/promises.cf
|
||
ConditionPathExists=!/opt/rudder/etc/disable-agent
|
||
ReloadPropagatedFrom=rudder-agent.service
|
||
PartOf=rudder-agent.service
|
||
|
||
[Service]
|
||
Type=simple
|
||
ExecStart=/var/rudder/cfengine-community/bin/cf-serverd --no-fork
|
||
ExecReload=/bin/kill -HUP $MAINPID
|
||
Restart=always
|
||
RestartSec=10
|
||
|
||
[Install]
|
||
WantedBy=multi-user.target
|
||
WantedBy=rudder-agent.service
|
rudder-agent/SPECS/rudder-agent.spec | ||
---|---|---|
# Same goes for the use of the local PCRE install vs. a bundled one
|
||
%define use_system_pcre true
|
||
|
||
# Default to using systemd for service management
|
||
%define use_systemd true
|
||
|
||
# Perl and fusion
|
||
%if "%{real_name}" == "rudder-agent"
|
||
%define use_system_fusion false
|
||
... | ... | |
%endif
|
||
|
||
%if "%{real_name}" == "rudder-agent"
|
||
# Replaces rudder-cfengine-community since 2.4.0~beta3
|
||
Provides: rudder-cfengine-community
|
||
Obsoletes: rudder-cfengine-community
|
||
|
||
# Use our own dependency generator
|
||
%global _use_internal_dependency_generator 0
|
||
... | ... | |
%define no_ldso true
|
||
%endif
|
||
|
||
#### Use systemd everywhere except on: AIX, RHEL<7, SLES<12, Fedora<15
|
||
%if "%{?_os}" == "aix"
|
||
%define use_systemd false
|
||
%endif
|
||
|
||
%if 0%{?rhel} && 0%{?rhel} < 7
|
||
%define use_systemd false
|
||
%endif
|
||
|
||
%if 0%{?suse_version} && 0%{?suse_version} < 1315
|
||
%define use_systemd false
|
||
%endif
|
||
|
||
%if 0%{?fedora} && 0%{?fedora} < 15
|
||
%define use_systemd false
|
||
%endif
|
||
####
|
||
|
||
%if 0%{?rhel} && 0%{?rhel} == 3
|
||
%define no_ldso true
|
||
%endif
|
||
|
||
make install DESTDIR=%{buildroot} USE_SYSTEM_OPENSSL=%{use_system_openssl} USE_SYSTEM_LMDB=%{use_system_lmdb} USE_SYSTEM_PCRE=%{use_system_pcre} NO_INIT=%{no_init} NO_CRON=%{no_cron} NO_LD=%{no_ld} NO_PROFILE=%{no_profile} USE_SYSTEM_FUSION=%{use_system_fusion} USE_SYSTEM_PERL=%{use_system_perl} NO_LDSO=%{no_ldso} USE_HTTPS=%{use_https}
|
||
make install DESTDIR=%{buildroot} USE_SYSTEM_OPENSSL=%{use_system_openssl} USE_SYSTEM_LMDB=%{use_system_lmdb} USE_SYSTEM_PCRE=%{use_system_pcre} USE_SYSTEMD=%{use_systemd} NO_INIT=%{no_init} NO_CRON=%{no_cron} NO_LD=%{no_ld} NO_PROFILE=%{no_profile} USE_SYSTEM_FUSION=%{use_system_fusion} USE_SYSTEM_PERL=%{use_system_perl} NO_LDSO=%{no_ldso} USE_HTTPS=%{use_https}
|
||
|
||
# Build a list of files to include in this package for use in the %files section below
|
||
find %{buildroot} -type f -o -type l | sed "s,%{buildroot},," | sed "s,\.py$,\.py*," | grep -v "%{rudderdir}/etc/uuid.hive" | grep -v "/etc/bash_completion.d" | grep -v "%{ruddervardir}/cfengine-community/ppkeys" > %{_builddir}/file.list.%{name}
|
||
... | ... | |
# Pre Installation
|
||
#=================================================
|
||
|
||
# Do this only during upgrade process
|
||
if [ $1 -eq 2 ];then
|
||
%if "%{?_os}" != "aix"
|
||
# Keep a backup copy of Rudder agent init and cron files to prevent http://www.rudder-project.org/redmine/issues/3995
|
||
for i in init.d default cron.d; do
|
||
if [ -f /etc/${i}/rudder-agent ]; then
|
||
mkdir -p /var/backups/rudder
|
||
if [ "${i}" = "init.d" ]; then mode=755; else mode=644; fi
|
||
%{install_command} -m ${mode} /etc/${i}/rudder-agent /var/backups/rudder/rudder-agent.$(basename ${i} .d)-$(date +%Y%m%d) && echo "INFO: A back up copy of /etc/${i}/rudder-agent has been created in /var/backups/rudder"
|
||
fi
|
||
done
|
||
%else
|
||
echo "INFO: No init script / cron script backup necessary on AIX builds yet. Skipping..."
|
||
%endif
|
||
CFRUDDER_FIRST_INSTALL=0
|
||
if [ $1 -eq 1 ];then
|
||
then
|
||
CFRUDDER_FIRST_INSTALL=1
|
||
fi
|
||
|
||
/opt/rudder/share/package-scripts/rudder-agent-preinst "${CFRUDDER_FIRST_INSTALL}" "%{?_os}" "%{use_systemd}"
|
||
|
||
%post
|
||
#=================================================
|
||
# Post Installation
|
||
#=================================================
|
||
|
||
# Do this at first install
|
||
CFRUDDER_FIRST_INSTALL=0
|
||
|
||
if [ $1 -eq 1 ]
|
||
then
|
||
# Set rudder-agent as service
|
||
%if "%{?_os}" == "aix"
|
||
/usr/bin/mkssys -s rudder-agent -p %{ruddervardir}/cfengine-community/bin/cf-execd -a "-F" -u root -S -n15 -f9 -R
|
||
/usr/sbin/mkitab "rudder-agent:23456789:once:/usr/bin/startsrc -s rudder-agent"
|
||
# No need to tell init to re-read /etc/inittab, it does it automatically every 60 seconds
|
||
%else
|
||
RUDDER_AGENT_INIT_ENABLED=$(LANG=C chkconfig --list 2>/dev/null | grep -Ec "rudder-agent.*on")
|
||
|
||
if [ "${RUDDER_AGENT_INIT_ENABLED}" -ne 0 ]
|
||
then
|
||
chkconfig --del rudder-agent
|
||
fi
|
||
chkconfig --add rudder
|
||
%endif
|
||
%if 0%{?rhel} && 0%{?rhel} >= 6
|
||
if [ "${RUDDER_AGENT_INIT_ENABLED}" -ne 0 ]
|
||
then
|
||
chkconfig rudder-agent off
|
||
fi
|
||
chkconfig rudder on
|
||
%endif
|
||
CFRUDDER_FIRST_INSTALL=1
|
||
fi
|
||
|
||
# mandatory with systemd wrapper for old init
|
||
%if 0%{?suse_version} && 0%{?suse_version} >= 1315
|
||
systemctl daemon-reload
|
||
... | ... | |
fi
|
||
%endif
|
||
|
||
/opt/rudder/share/package-scripts/rudder-agent-postinst "${CFRUDDER_FIRST_INSTALL}"
|
||
/opt/rudder/share/package-scripts/rudder-agent-postinst "${CFRUDDER_FIRST_INSTALL}" "%{?_os}" "%{use_systemd}"
|
||
|
||
%preun
|
||
#=================================================
|
||
... | ... | |
# Changelog
|
||
#=================================================
|
||
%changelog
|
||
%if "%{real_name}" == "rudder-agent"
|
||
* Wed Apr 27 2011 - Matthieu CERDA <matthieu.cerda@normation.com> 2.2-beta1-2
|
||
- The packages now builds correctly on both x86 and x86_64 archs, and on EL4/CentOS 4.
|
||
* Tue Mar 1 2011 - Jonathan CLARKE <jonathan.clarke@normation.com> 2.2-beta1-1
|
||
- Release 2.2.beta1
|
||
* Fri Feb 25 2011 - Jonathan CLARKE <jonathan.clarke@normation.com> 2.2-beta0-4
|
||
- Fix bug in postinstall script - stop daemons before replacing them!
|
||
* Fri Feb 25 2011 - Jonathan CLARKE <jonathan.clarke@normation.com> 2.2-beta0-3
|
||
- Fix bug to get initial promises in RPM, using the right git branch
|
||
* Fri Feb 25 2011 - Jonathan CLARKE <jonathan.clarke@normation.com> 2.2-beta0-2
|
||
- Fix bug to get initial promises in RPM
|
||
* Fri Feb 25 2011 - Jonathan CLARKE <jonathan.clarke@normation.com> 2.2-beta0-1
|
||
- Initial package
|
||
%else
|
||
* Fri May 30 2014 - Matthieu CERDA <matthieu.cerda@normation.com> 2.11-beta1
|
||
- Initial package, using rudder-agent as a base
|
||
- Removed fusion-inventory code
|
||
- Removed legacy code
|
||
%endif
|
||
* Wed Nov 22 2017 - Rudder Team <rudder-dev@rudder-project.org> %{version}
|
||
- See https://www.rudder-project.org/site/documentation/user-manual/ for changelogs
|
rudder-agent/debian/changelog | ||
---|---|---|
rudder-agent (2.3.0~alpha~git-0) lenny; urgency=low
|
||
|
||
* Bump package number to follow git development
|
||
* See https://www.rudder-project.org/site/documentation/user-manual/ for changelogs
|
||
|
||
-- Jonathan CLARKE <jonathan.clarke@normation.com> Mon, 07 Mar 2011 11:47:27 +0000
|
||
|
||
rudder-agent (2.2.0~beta1-0) lenny; urgency=low
|
||
|
||
* Release 2.2.beta1
|
||
|
||
-- Jonathan Clarke <jonathan.clarke@normation.com> Tue, 01 Mar 2011 17:28:31 +0100
|
||
|
||
rudder-agent (3.1.4-0) lenny; urgency=low
|
||
|
||
* CFEngine version number correction
|
||
|
||
-- Nicolas Perron <nicolas.perron@normation.com> Fri, 25 Feb 2011 20:00:18 +0100
|
||
|
||
rudder-agent (3.1.2-0) lenny; urgency=low
|
||
|
||
* New upstream version
|
||
|
||
-- Nicolas Perron <nicolas.perrone@normation.com> Wed, 23 Feb 2011 18:16:27 +0100
|
||
-- Rudder Team <rudder-dev@rudder-project.org> Wed, 22 Nov 2017 11:47:27 +0000
|
rudder-agent/debian/control | ||
---|---|---|
# The dependencies below are defined in order to use rudder-agent
|
||
# for the server. This will add capabilities to send inventories
|
||
# from the server itself.
|
||
Provides: rudder-cfengine-community, rudder-agent
|
||
Conflicts: rudder-cfengine-community, rudder-agent-thin
|
||
Replaces: rudder-cfengine-community, rudder-server-root (<< 2.4.0~beta2)
|
||
Breaks: rudder-server-root (<< 2.4.0~beta2)
|
||
Provides: rudder-agent
|
||
Conflicts: rudder-agent-thin
|
||
Description: Configuration management and audit tool - agent
|
||
Rudder is an open source configuration management and audit solution.
|
||
.
|
rudder-agent/debian/postinst | ||
---|---|---|
|
||
# Is this the first installation?
|
||
CFRUDDER_FIRST_INSTALL=0
|
||
CFRUDDER_USE_SYSTEMD=0
|
||
|
||
if [ ! -x /var/rudder/cfengine-community/bin/cf-execd ]; then CFRUDDER_FIRST_INSTALL=1; fi
|
||
if type systemctl > /dev/null ; then CFRUDDER_USE_SYSTEMD=1; fi
|
||
|
||
/opt/rudder/share/package-scripts/rudder-agent-postinst "${CFRUDDER_FIRST_INSTALL}"
|
||
/opt/rudder/share/package-scripts/rudder-agent-postinst "${CFRUDDER_FIRST_INSTALL}" "deb" "${CFRUDDER_USE_SYSTEMD}"
|
||
;;
|
||
|
||
abort-upgrade|abort-remove|abort-deconfigure)
|
rudder-agent/debian/preinst | ||
---|---|---|
#!/bin/sh
|
||
# preinst script for normation-openldap-framework
|
||
#
|
||
# see: dh_installdeb(1)
|
||
|
||
set -e
|
||
|
||
# summary of how this script can be called:
|
||
# * <new-preinst> `install'
|
||
# * <new-preinst> `install' <old-version>
|
||
# * <new-preinst> `upgrade' <old-version>
|
||
# * <old-preinst> `abort-upgrade' <new-version>
|
||
# for details, see http://www.debian.org/doc/debian-policy/ or
|
||
# the debian-policy package
|
||
|
||
# Is this the first installation?
|
||
CFRUDDER_FIRST_INSTALL=0
|
||
CFRUDDER_USE_SYSTEMD=0
|
||
|
||
if type systemctl > /dev/null ; then CFRUDDER_USE_SYSTEMD=1; fi
|
||
|
||
case "$1" in
|
||
install)
|
||
CFRUDDER_FIRST_INSTALL=1
|
||
;;
|
||
|
||
upgrade)
|
||
;;
|
||
|
||
abort-upgrade)
|
||
exit 0
|
||
;;
|
||
|
||
*)
|
||
echo "preinst called with unknown argument \`$1'" >&2
|
||
exit 1
|
||
;;
|
||
esac
|
||
|
||
/opt/rudder/share/package-scripts/rudder-agent-postinst "${CFRUDDER_FIRST_INSTALL}" "deb" "${CFRUDDER_USE_SYSTEMD}"
|
||
|
||
# dh_installdeb will replace this with shell code automatically
|
||
# generated by other debhelper scripts.
|
||
|
||
#DEBHELPER#
|
||
|
||
exit 0
|
rudder-agent/debian/rules | ||
---|---|---|
dh_testdir
|
||
dh_testroot
|
||
cd SOURCES && $(MAKE) clean $(MAKE_OPTIONS)
|
||
rm -f debian/rudder.init
|
||
dh_clean
|
||
|
||
install: build
|
||
... | ... | |
dh_installdirs
|
||
cd SOURCES && $(MAKE) install $(MAKE_OPTIONS) DESTDIR=$(CURDIR)/debian/tmp
|
||
# let this file be managed by dh_installinit
|
||
mv $(CURDIR)/debian/tmp/etc/init.d/rudder debian/rudder.init
|
||
mv $(CURDIR)/debian/tmp/etc/init.d/rudder-agent debian/rudder-agent.init
|
||
|
||
# Build architecture-independent files here.
|
||
binary-indep: install
|
||
... | ... | |
# dh_installmime
|
||
# dh_python
|
||
# Init script and configuration files
|
||
dh_installinit --name=rudder --no-start -R # restart after upgrade (instead of stop, upgrade, start)
|
||
dh_installinit --no-start -R # restart after upgrade (instead of stop, upgrade, start)
|
||
# dh_installinfo
|
||
dh_installman
|
||
dh_link
|
rudder-server-root/SOURCES/rudder-server.init | ||
---|---|---|
#!/bin/sh
|
||
|
||
#==============================================
|
||
# Start/stop script for all Rudder components #
|
||
#==============================================
|
||
#
|
||
### BEGIN INIT INFO
|
||
# Provides: rudder
|
||
# Required-Start: $local_fs $remote_fs $network $syslog
|
||
# Required-Stop: $local_fs $remote_fs $network $syslog
|
||
# Default-Start: 2 3 4 5
|
||
# Default-Stop: 0 1 6
|
||
# Short-Description: Rudder server
|
||
# Description: Rudder server including all components required to run
|
||
### END INIT INFO
|
||
#
|
||
# Copyright (C) 2011-2015 Normation
|
||
#
|
||
# This program is free software; you can redistribute it and/or
|
||
# modify it under the terms of the GNU General Public License
|
||
# as published by the Free Software Foundation; either version 2
|
||
# of the License, or (at your option) any later version.
|
||
#
|
||
# This program is distributed in the hope that it will be useful,
|
||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||
# GNU General Public License for more details.
|
||
#
|
||
# GPL License: http://www.gnu.org/licenses/gpl.txt
|
||
#
|
||
#====================================================================
|
||
|
||
# Utility functions
|
||
|
||
get_service_name()
|
||
{
|
||
# This script detects the closest match for the given service
|
||
# If only one version is available, return it
|
||
# If multiple versions (postgresql91/postgresql94), return the latest one
|
||
# Arguments:
|
||
## Service name
|
||
if type systemctl >/dev/null 2>&1; then
|
||
SERVICE_NAME=$(systemctl list-unit-files --type service | awk -F'.' '{print $1}' | grep -E "^${1}[0-9]*$" | tail -n 1)
|
||
fi
|
||
if [ -z "${SERVICE_NAME}" ] && type chkconfig >/dev/null 2>&1; then
|
||
SERVICE_NAME=$(chkconfig 2>/dev/null | awk '{ print $1 }' | grep "${1}" | tail -n 1)
|
||
fi
|
||
if [ -z "${SERVICE_NAME}" ]; then
|
||
SERVICE_NAME=$(ls -1 /etc/init.d | grep "${1}" | tail -n 1)
|
||
fi
|
||
|
||
# If we can not get the service name, fallback to the user-supplied name
|
||
if [ -z "${SERVICE_NAME}" ]; then
|
||
SERVICE_NAME="${1}"
|
||
fi
|
||
|
||
echo ${SERVICE_NAME}
|
||
}
|
||
|
||
service_action()
|
||
{
|
||
# Arguments:
|
||
## Service name
|
||
## Action to trigger (start/stop/...)
|
||
## Is the role present on this machine (0/1)
|
||
|
||
# If the role is present, run the action
|
||
if [ "${3}" -eq 1 ]; then
|
||
printf " * ${1}...\t"
|
||
service "${1}" "${2}" >/dev/null 2>&1
|
||
|
||
if [ "${?}" -ne 0 ]; then
|
||
printf "${RED}FAILED, please run \"service ${1} ${2}\" for more details${NORMAL}\n"
|
||
RETURN=1
|
||
else
|
||
printf "${GREEN}OK${NORMAL}\n"
|
||
fi
|
||
|
||
fi
|
||
}
|
||
|
||
service_status()
|
||
{
|
||
# Arguments:
|
||
## Service human-friendly name
|
||
## Service name
|
||
## Is the role present on this machine (0/1)
|
||
|
||
printf " * ${1}\t"
|
||
if [ "${3}" -ne 1 ]; then
|
||
# If the role is present, run the action
|
||
printf "${YELLOW}Not installed${NORMAL}\n"
|
||
elif service "${2}" status >/dev/null 2>&1; then
|
||
printf "${GREEN}OK${NORMAL}\n"
|
||
else
|
||
printf "${RED}Not running, please restart with \"service ${2} restart\" ${NORMAL}\n"
|
||
RETURN=1
|
||
fi
|
||
}
|
||
|
||
service_details()
|
||
{
|
||
# Arguments:
|
||
## Service human-friendly name
|
||
## Service name
|
||
## Is the role present on this machine (0/1)
|
||
|
||
printf "\n * ${BLUE}${1}${NORMAL}:"
|
||
if [ "${3}" -eq 1 ]; then
|
||
echo ""
|
||
${COPYPASTE}
|
||
service "${2}" status || RETURN=${?}
|
||
${COPYPASTE}
|
||
else
|
||
printf " ${YELLOW}Not installed${NORMAL}\n"
|
||
fi
|
||
}
|
||
|
||
# Variables
|
||
|
||
## Environment setup - neutral locale
|
||
LANG=C
|
||
LANGUAGE=C
|
||
LC_ALL=C
|
||
|
||
export LANG LANGUAGE LC_ALL
|
||
|
||
# Ensure this script is run as root
|
||
if [ "$(id -u)" != "0" ]; then
|
||
echo "Please run this script as root" 1>&2
|
||
exit 1
|
||
fi
|
||
|
||
## Colors configuration (enable colors only if stdout is a terminal)
|
||
if [ -t 1 ]; then
|
||
GREEN="\\033[1;32m"
|
||
RED="\\033[1;31m"
|
||
BLUE="\\033[1;34m"
|
||
PINK="\\033[1;35m"
|
||
WHITE="\\033[0;02m"
|
||
WHITELIGHT="\\033[1;08m"
|
||
YELLOW="\\033[1;33m"
|
||
CYAN="\\033[1;36m"
|
||
NORMAL="\\033[0;39m"
|
||
COPYPASTE="printf ${GREEN}---8<---${NORMAL}\n"
|
||
else
|
||
GREEN=""
|
||
RED=""
|
||
BLUE=""
|
||
PINK=""
|
||
WHITE=""
|
||
WHITELIGHT=""
|
||
YELLOW=""
|
||
CYAN=""
|
||
NORMAL=""
|
||
COPYPASTE="printf ---8<---\n"
|
||
fi
|
||
|
||
## Active roles
|
||
|
||
HAVE_SLAPD=0
|
||
HAVE_POSTGRESQL=0
|
||
HAVE_JETTY=0
|
||
HAVE_AGENT=1
|
||
|
||
### Check slapd's status if we are rudder-inventory-ldap
|
||
[ -e /opt/rudder/etc/server-roles.d/rudder-inventory-ldap ] && HAVE_SLAPD=1
|
||
|
||
### Check PostgreSQL's status if we are rudder-db
|
||
[ -e /opt/rudder/etc/server-roles.d/rudder-db ] && HAVE_POSTGRESQL=1
|
||
|
||
### Check Jetty's status if we are rudder-webapp or rudder-inventory-endpoint
|
||
[ -e /opt/rudder/etc/server-roles.d/rudder-inventory-endpoint ] && HAVE_JETTY=1
|
||
[ -e /opt/rudder/etc/server-roles.d/rudder-webapp ] && HAVE_JETTY=1
|
||
|
||
## Service names
|
||
|
||
RUDDER_SLAPD=rudder-slapd
|
||
RUDDER_JETTY=rudder-jetty
|
||
RUDDER_AGENT=rudder-agent
|
||
POSTGRESQL=$(get_service_name postgresql)
|
||
|
||
## Default return code
|
||
RETURN=0
|
||
|
||
# Main
|
||
|
||
start_services()
|
||
{
|
||
printf "${GREEN}Starting Rudder services:${NORMAL}\n"
|
||
|
||
service_action "${RUDDER_SLAPD}" start "${HAVE_SLAPD}"
|
||
service_action "${POSTGRESQL}" start "${HAVE_POSTGRESQL}"
|
||
service_action "${RUDDER_JETTY}" start "${HAVE_JETTY}"
|
||
service_action "${RUDDER_AGENT}" start "${HAVE_AGENT}"
|
||
}
|
||
|
||
stop_services()
|
||
{
|
||
printf "${GREEN}Stopping Rudder services:${NORMAL}\n"
|
||
|
||
# Stop Rudder applications before databases to prevent
|
||
# hangs at shutdown due to still active client connexions
|
||
# and connexion failure from appearing in rudder-jetty
|
||
# logs.
|
||
service_action "${RUDDER_AGENT}" stop "${HAVE_AGENT}"
|
||
service_action "${RUDDER_JETTY}" stop "${HAVE_JETTY}"
|
||
service_action "${POSTGRESQL}" stop "${HAVE_POSTGRESQL}"
|
||
service_action "${RUDDER_SLAPD}" stop "${HAVE_SLAPD}"
|
||
}
|
||
|
||
details_services()
|
||
{
|
||
printf "${GREEN}Detailed component status:${NORMAL}\n"
|
||
|
||
service_details "Agent" "${RUDDER_AGENT}" "${HAVE_AGENT}"
|
||
service_details "LDAP DB" "${RUDDER_SLAPD}" "${HAVE_SLAPD}"
|
||
service_details "SQL DB" "${POSTGRESQL}" "${HAVE_POSTGRESQL}"
|
||
service_details "Application" "${RUDDER_JETTY}" "${HAVE_JETTY}"
|
||
}
|
||
|
||
status_services()
|
||
{
|
||
printf "${GREEN}Component status:${NORMAL}\n"
|
||
|
||
service_status "Agent" "${RUDDER_AGENT}" "${HAVE_AGENT}"
|
||
service_status "LDAP DB" "${RUDDER_SLAPD}" "${HAVE_SLAPD}"
|
||
service_status "SQL DB" "${POSTGRESQL}" "${HAVE_POSTGRESQL}"
|
||
service_status "Application" "${RUDDER_JETTY}" "${HAVE_JETTY}"
|
||
}
|
||
|
||
case "$1" in
|
||
start)
|
||
start_services
|
||
;;
|
||
stop)
|
||
stop_services
|
||
;;
|
||
restart)
|
||
stop_services
|
||
echo ""
|
||
start_services
|
||
;;
|
||
status)
|
||
status_services
|
||
;;
|
||
details)
|
||
details_services
|
||
;;
|
||
*)
|
||
echo "Usage: $0 {start|stop|restart|status|details}"
|
||
exit 1
|
||
;;
|
||
esac
|
||
|
||
exit ${RETURN}
|
Also available in: Unified diff
Fixes #11684: Replace rudder-agent init script by systemd units on compatible OSes