Commit 3f8a0f1c authored by Erik Alexandre Pucci's avatar Erik Alexandre Pucci

preinst: Modified to create the backups of inep and proxy files

This modification ensures that a previously configured INEP will be saved
before the installation of the new version of PROINFODATA agent.
Signed-off-by: default avatarErik Alexandre Pucci <eap08@c3sl.ufpr.br>
Acked-by: default avatarAryane Ast dos Santos <aras10@c3sl.ufpr.br>
parent 18076113
......@@ -22,7 +22,15 @@
# This is the preinst of proinfodata
SEED_MEC_HOME="/opt/seed_mec"
CONF="${SEED_MEC_HOME}/SEED2/client/conf/"
BKPCONF="${SEED_MEC_HOME}/SEED2/.backup/client/conf/"
MD5CONF="${SEED_MEC_HOME}/SEED2/.md5sum/client/conf/"
MD5BKPCONF="${SEED_MEC_HOME}/SEED2/.md5sum/.backup/client/conf/"
BKP="/opt/seed_mec_backup"
BKP_CONF="${BKP}/SEED2/client/conf/"
BKP_BKPCONF="${BKP}/SEED2/.backup/client/conf/"
BKP_MD5CONF="${BKP}/SEED2/.md5sum/client/conf/"
BKP_MD5BKPCONF="${BKP}/SEED2/.md5sum/.backup/client/conf/"
# This function shows some error message and aborts execution
abort() {
......@@ -35,7 +43,6 @@ if ! groupadd -f seed_mec; then
abort "error while creating the group seed_mec."
fi
# Create seed_mec user
mkdir -p ${SEED_MEC_HOME}
......@@ -46,6 +53,39 @@ if ! useradd -r -m -g seed_mec -s /bin/bash -d "${SEED_MEC_HOME}" \
fi
rmdir ${TMPSKEL}
# Check if there is a previously configured INEP and no backup before creating
# the backup for both the inep and proxy files
if test -f "${CONF}/inep" -a ! -f "${BKP_CONF}/inep"; then
# Create auxiliar directories
mkdir -p "${BKP_CONF}"
mkdir -p "${BKP_BKPCONF}"
mkdir -p "${BKP_MD5CONF}"
mkdir -p "${BKP_MD5BKPCONF}"
# Copy the inep and proxy files, and also their backup and md5sum
# counterparts. The last copied file is the inep, so the verification of its
# existence always means the other ones also exist
for FILE in "proxy" "inep"; do
if test -f "${BKPCONF}/${FILE}"; then
cp -af "${BKPCONF}/${FILE}" "${BKP_BKPCONF}/${FILE}"
else
cp -af "${CONF}/${FILE}" "${BKP_BKPCONF}/${FILE}"
fi
if test -f "${MD5CONF}/${FILE}"; then
cp -af "${MD5CONF}/${FILE}" "${BKP_MD5CONF}/${FILE}"
else
md5sum "${CONF}/${FILE}" | cut -d' ' -f1 > "${BKP_MD5CONF}/${FILE}"
fi
if test -f "${MD5BKPCONF}/${FILE}"; then
cp -af "${MD5BKPCONF}/${FILE}" "${BKP_MD5BKPCONF}/${FILE}"
else
md5sum "${CONF}/${FILE}" | cut -d' ' -f1 > \
"${BKP_MD5BKPCONF}/${FILE}"
fi
cp -af "${CONF}/${FILE}" "${BKP_CONF}/${FILE}"
done
fi
# Files to divert
DIVERTS="
/etc/init/dbus.conf \
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment