Add a DEBUG var to print messages

This commit is contained in:
Jeremy Gardais 2019-07-24 11:46:37 +02:00
parent baaf251c00
commit f18b54a572
1 changed files with 7 additions and 5 deletions

View File

@ -9,6 +9,8 @@
# }}} # }}}
# Vars {{{ # Vars {{{
DEBUG=1
CEPH_DEB_PKG_DIR=$(mktemp --directory --tmpdir="/tmp" -- ceph-deb-files-XXXXXX.tmp) CEPH_DEB_PKG_DIR=$(mktemp --directory --tmpdir="/tmp" -- ceph-deb-files-XXXXXX.tmp)
CEPH_DEB_PKG_PATTERN="ceph|rados|rbd" CEPH_DEB_PKG_PATTERN="ceph|rados|rbd"
@ -32,10 +34,10 @@ if [ "$(command -v ceph)" ]; then
cd -- "${CEPH_DEB_PKG_DIR}" > /dev/null || exit 2 cd -- "${CEPH_DEB_PKG_DIR}" > /dev/null || exit 2
## Download deb files of all ceph related packages installed on the system ## Download deb files of all ceph related packages installed on the system
printf '%b\n' "Download deb files of all ceph related packages installed on the system." [ "${DEBUG}" -eq "0" ] && printf '%b\n' "Download deb files of all ceph related packages installed on the system."
apt download -- $(dpkg -l | awk -v pattern="${CEPH_DEB_PKG_PATTERN}" '$0~pattern {print $2"="$3}') || exit 3 apt download -- $(dpkg -l | awk -v pattern="${CEPH_DEB_PKG_PATTERN}" '$0~pattern {print $2"="$3}') || exit 3
printf '%b\n' "Backup Ceph deb files in version: ${CEPH_VERSION}" [ "${DEBUG}" -eq "0" ] && printf '%b\n' "Backup Ceph deb files in version: ${CEPH_VERSION}"
tar cf "${BKP_TAR_PATH}" ./*.deb > /dev/null 2>&1 || exit 4 tar cf "${BKP_TAR_PATH}" ./*.deb > /dev/null 2>&1 || exit 4
## Remove deb files ## Remove deb files
@ -46,12 +48,12 @@ if [ "$(command -v ceph)" ]; then
## Remove temp directory ## Remove temp directory
rmdir -- "${CEPH_DEB_PKG_DIR}" rmdir -- "${CEPH_DEB_PKG_DIR}"
else else
printf '%b\n' "A backup of this version already exists: ${EXISTENT_BACKUP_TAR}" [ "${DEBUG}" -eq "0" ] && printf '%b\n' "A backup of this version already exists: ${EXISTENT_BACKUP_TAR}"
exit 1 exit 0
fi fi
else else
printf '%b\n' "Ceph doesn't seems to be available. Please take a look on \`ceph version\` command" [ "${DEBUG}" -eq "0" ] && printf '%b\n' "Ceph doesn't seems to be available. Please take a look on \`ceph version\` command"
exit 1 exit 1
fi fi