multiline blob of text for log file and git commit

This commit is contained in:
Jérémy Lecour 2018-09-05 18:45:46 +02:00 committed by Jérémy Lecour
parent 5fd01a1614
commit 72b43f314e

View file

@ -34,19 +34,22 @@ if [ "${TEXTE}" = "" ]; then
fi fi
# recapitulatif # recapitulatif
echo "hostname = ${HOSTNAME}" BLOB=$(cat <<END
echo "user = ${USER}" Time : $NOW
echo "IP = ${IP}" Host : $HOSTNAME
echo "begin date = ${BEGIN_YEAR} ${BEGIN_DATE}" User : $USER
echo "details = ${TEXTE}" IP : $IP
Begin : $BEGIN_YEAR $BEGIN_DATE
Message : $TEXTE
END
)
echo "${BLOB}"
echo "To cancel, [Ctrl+C] else press [Enter]" echo "To cancel, [Ctrl+C] else press [Enter]"
read enter read enter
# write log # write log
LOG_TEXTE=$(echo "${TEXTE}" | sed 's/"/\\\"/g') echo "----------\n${BLOB}" >> "${LOGFILE}"
echo "${NOW} hostname=\"${HOSTNAME}\" user=\"${USER}\" ip=\"${IP}\" begin_date=\"${BEGIN_YEAR} ${BEGIN_DATE}\" message=\"${LOG_TEXTE}\"" >> "${LOGFILE}"
# git commit # git commit
GIT_BIN=$(command -v git) GIT_BIN=$(command -v git)
@ -54,7 +57,7 @@ GIT_BIN=$(command -v git)
if test -x "${GIT_BIN}"; then if test -x "${GIT_BIN}"; then
export GIT_DIR=/etc/.git export GIT_DIR=/etc/.git
${GIT_BIN} add . ${GIT_BIN} add .
${GIT_BIN} commit --all --message "${LOG_TEXTE}" --author="${USER} <${USER}@evolix.net>" --quiet ${GIT_BIN} commit --all --message "${TEXTE}" --message "${BLOB}" --author="${USER} <${USER}@evolix.net>" --quiet
fi fi
# insert into PG # insert into PG