Revision af190662
Added by Nicolas CHARLES about 7 years ago
rudder-inventory-ldap/SOURCES/rudder-inventory-ldap.init | ||
---|---|---|
message "info" "[INFO] file descriptor limit not modified (require root privileges)"
|
||
fi
|
||
|
||
# configuration
|
||
if [ "${RUDDER_MDBSIZE}" != "noauto" ]
|
||
then
|
||
if [ "${RUDDER_MDBSIZE}" = "auto" ] || [ "${RUDDER_MDBSIZE}" = "" ]
|
||
then
|
||
# calculate the value to match about 50% of RAM (this is only virtual memory)
|
||
MEMSIZE=$(sed -n '/^MemTotal/s/[^0-9]//gp' /proc/meminfo)
|
||
MDBSIZE=$((${MEMSIZE} * 1024 / 2 ))
|
||
# on 32 bits architectures max it to 500M (PAE allows more ram but not more virtual memory)
|
||
if [ "$(getconf LONG_BIT)" -ne "64" ] && [ "${MDBSIZE}" -gt 524288000 ]
|
||
then
|
||
MDBSIZE=524288000
|
||
fi
|
||
else
|
||
# set cache size to the value provided
|
||
MDBSIZE=${RUDDER_MDBSIZE}
|
||
fi
|
||
sed -i '/^[ \t]*\(maxsize\|maxsize\)/d' /opt/rudder/etc/openldap/slapd.conf
|
||
sed -i 's/^\([ \t]*suffix[ \t]\+"cn=rudder-configuration".*\)/\1\nmaxsize '${MDBSIZE}'/' /opt/rudder/etc/openldap/slapd.conf
|
||
fi
|
||
# Configure MDB parameters
|
||
/opt/rudder/bin/rudder-slapd-configure
|
||
|
||
# Parameters
|
||
if [ "$SLAPD_CONF_DIR" ]
|
rudder-inventory-ldap/SOURCES/rudder-slapd-configure | ||
---|---|---|
#!/bin/sh
|
||
|
||
# Configure maxsize in /opt/rudder/etc/openldap/slapd.conf based on
|
||
# content of /etc/default/rudder-slapd, or auto-computed based on available memory
|
||
|
||
# Script specific
|
||
PROG_NAME='rudder-slapd'
|
||
OS=`uname -s` # To adapt message printing
|
||
|
||
|
||
#====================================================================
|
||
# Message function
|
||
#====================================================================
|
||
message() {
|
||
# $1: syslog level
|
||
# $2: message
|
||
|
||
if [ $OS = "Linux" ]
|
||
then
|
||
logger -p "local4.$1" -s -t $PROG_NAME -i "$2"
|
||
else
|
||
# Try without option -s
|
||
logger -p "local4.$1" -t $PROG_NAME -i "$2"
|
||
echo "$PROG_NAME: $2"
|
||
fi
|
||
}
|
||
|
||
#====================================================================
|
||
|
||
|
||
|
||
#====================================================================
|
||
# Load specific parameters
|
||
#====================================================================
|
||
. /opt/rudder/etc/rudder-slapd.conf
|
||
|
||
if [ -f /etc/default/$PROG_NAME ]
|
||
then
|
||
. /etc/default/$PROG_NAME
|
||
message "info" "[INFO] Using /etc/default/$PROG_NAME for configuration"
|
||
fi
|
||
|
||
# configuration of mdbsize
|
||
if [ "${RUDDER_MDBSIZE}" != "noauto" ]
|
||
then
|
||
if [ "${RUDDER_MDBSIZE}" = "auto" ] || [ "${RUDDER_MDBSIZE}" = "" ]
|
||
then
|
||
# calculate the value to match about 50% of RAM (this is only virtual memory)
|
||
MEMSIZE=$(sed -n '/^MemTotal/s/[^0-9]//gp' /proc/meminfo)
|
||
MDBSIZE=$((${MEMSIZE} * 1024 / 2 ))
|
||
# on 32 bits architectures max it to 500M (PAE allows more ram but not more virtual memory)
|
||
if [ "$(getconf LONG_BIT)" -ne "64" ] && [ "${MDBSIZE}" -gt 524288000 ]
|
||
then
|
||
MDBSIZE=524288000
|
||
fi
|
||
else
|
||
# set cache size to the value provided
|
||
MDBSIZE=${RUDDER_MDBSIZE}
|
||
fi
|
||
sed -i '/^[ \t]*\(maxsize\|maxsize\)/d' /opt/rudder/etc/openldap/slapd.conf
|
||
sed -i 's/^\([ \t]*suffix[ \t]\+"cn=rudder-configuration".*\)/\1\nmaxsize '${MDBSIZE}'/' /opt/rudder/etc/openldap/slapd.conf
|
||
fi
|
||
|
rudder-inventory-ldap/SPECS/rudder-inventory-ldap.spec | ||
---|---|---|
# find there all necessary libraries for BerkeleyDB.
|
||
Source9: rudder-inventory-ldap.conf
|
||
Source10: rudder-slapd.conf
|
||
Source11: rudder-slapd-configure
|
||
|
||
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
|
||
|
||
... | ... | |
# contained in /opt/rudder/lib like BerkeleyDB
|
||
install -m 644 %{SOURCE9} %{buildroot}/etc/ld.so.conf.d/rudder-inventory-ldap.conf
|
||
|
||
# Install mdb configuration file
|
||
install -m 755 %{SOURCE11} %{buildroot}/opt/rudder/bin/rudder-slapd-configure
|
||
|
||
# Syslog configuration
|
||
mkdir -p %{buildroot}/etc/rsyslog.d
|
||
cp %{_sourcedir}/rsyslog/rudder-slapd.conf %{buildroot}/etc/rsyslog.d/rudder-slapd.conf
|
||
... | ... | |
sed -i 's/^database.*hdb/database mdb/' "${SLAPD_CONF}"
|
||
sed -i '/^idlcachesize.*/d' "${SLAPD_CONF}"
|
||
sed -i '/^cachesize.*/d' "${SLAPD_CONF}"
|
||
# Configure mdb backend
|
||
/opt/rudder/bin/rudder-slapd-configure
|
||
|
||
# Import the backed up database
|
||
/opt/rudder/sbin/slapadd -q -l ${BACKUP_LDIF}
|
||
|
||
# Start OpenLDAP
|
||
echo -n "INFO: Starting rudder-slapd..."
|
||
service rudder-slapd start >/dev/null 2>&1
|
||
echo " Done"
|
||
|
||
echo "INFO: OpenLDAP database was successfully upgraded to new format"
|
||
|
||
if [ -x /opt/rudder/bin/rudder-upgrade-ldap ]
|
||
# Import the backed up database
|
||
if /opt/rudder/sbin/slapadd -q -l ${BACKUP_LDIF}
|
||
then
|
||
echo "INFO: Running the Rudder upgrade script to replay LDAP migrations on the old database content..."
|
||
/opt/rudder/bin/rudder-upgrade-ldap
|
||
echo "ERROR: Failed to restore data from old format into the new format"
|
||
echo "You can reimport manually the data from backup file ${BACKUP_LDIF}"
|
||
else
|
||
# Start OpenLDAP
|
||
echo -n "INFO: Starting rudder-slapd..."
|
||
service rudder-slapd start >/dev/null 2>&1
|
||
echo " Done"
|
||
|
||
echo "INFO: OpenLDAP database was successfully upgraded to new format"
|
||
|
||
if [ -x /opt/rudder/bin/rudder-upgrade-ldap ]
|
||
then
|
||
echo "INFO: Running the Rudder upgrade script to replay LDAP migrations on the old database content..."
|
||
/opt/rudder/bin/rudder-upgrade-ldap
|
||
fi
|
||
|
||
echo "INFO: You can safely remove the backups in ${LDAP_BACKUP_DIR}"
|
||
echo "INFO: and ${BACKUP_LDIF}"
|
||
fi
|
||
|
||
echo "INFO: You can safely remove the backups in ${LDAP_BACKUP_DIR}"
|
||
echo "INFO: and ${BACKUP_LDIF}"
|
||
fi
|
||
fi
|
||
|
rudder-inventory-ldap/debian/postinst | ||
---|---|---|
sed -i 's/^database.*hdb/database mdb/' "${SLAPD_CONF}"
|
||
sed -i '/^idlcachesize.*/d' "${SLAPD_CONF}"
|
||
sed -i '/^cachesize.*/d' "${SLAPD_CONF}"
|
||
# Configure mdb backend
|
||
/opt/rudder/bin/rudder-slapd-configure
|
||
|
||
# Import the backed up database
|
||
/opt/rudder/sbin/slapadd -q -l ${BACKUP_LDIF}
|
||
|
||
# Start OpenLDAP
|
||
echo -n "INFO: Starting rudder-slapd..."
|
||
invoke-rc.d rudder-slapd start >/dev/null 2>&1
|
||
echo " Done"
|
||
|
||
echo "INFO: OpenLDAP database was successfully upgraded to new format"
|
||
|
||
if [ -x /opt/rudder/bin/rudder-upgrade-ldap ]
|
||
if /opt/rudder/sbin/slapadd -q -l ${BACKUP_LDIF}
|
||
then
|
||
echo "INFO: Running the Rudder upgrade script to replay LDAP migrations on the old database content..."
|
||
/opt/rudder/bin/rudder-upgrade-ldap
|
||
echo "ERROR: Failed to restore data from old format into the new format"
|
||
echo "You can reimport manually the data from backup file ${BACKUP_LDIF}"
|
||
else
|
||
# Start OpenLDAP
|
||
echo -n "INFO: Starting rudder-slapd..."
|
||
invoke-rc.d rudder-slapd start >/dev/null 2>&1
|
||
echo " Done"
|
||
|
||
echo "INFO: OpenLDAP database was successfully upgraded to new format"
|
||
|
||
if [ -x /opt/rudder/bin/rudder-upgrade-ldap ]
|
||
then
|
||
echo "INFO: Running the Rudder upgrade script to replay LDAP migrations on the old database content..."
|
||
/opt/rudder/bin/rudder-upgrade-ldap
|
||
fi
|
||
|
||
echo "INFO: You can safely remove the backups in ${LDAP_BACKUP_DIR}"
|
||
echo "INFO: and ${BACKUP_LDIF}"
|
||
fi
|
||
|
||
echo "INFO: You can safely remove the backups in ${LDAP_BACKUP_DIR}"
|
||
echo "INFO: and ${BACKUP_LDIF}"
|
||
|
||
fi
|
||
fi
|
||
|
rudder-inventory-ldap/debian/rules | ||
---|---|---|
dh_install SOURCES/inventory.schema /opt/rudder/etc/openldap/schema/
|
||
dh_install SOURCES/rudder.schema /opt/rudder/etc/openldap/schema/
|
||
dh_install SOURCES/DB_CONFIG /var/rudder/ldap/openldap-data/
|
||
dh_install SOURCES/rudder-slapd-configure /opt/rudder/bin
|
||
dh_install --SOURCEDIR=$(CURDIR)/SOURCES/ rudder-inventory-ldap /opt/rudder/etc/server-roles.d/
|
||
dh_install --SOURCEDIR=$(CURDIR)/SOURCES/ rudder-ldap /opt/rudder/etc/server-roles.d/
|
||
# dh_installmenu
|
Also available in: Unified diff
Fixes #10373: Upgrading from 4.0 to 4.1 failed on Centos7.3, and purged LDAP directory