whitespaces
This commit is contained in:
parent
0621f62267
commit
5e0705391e
|
@ -8,59 +8,59 @@
|
|||
# Copyright 2007-2018 Gregory Colpart <reg@evolix.fr>, Jérémy Lecour <jlecour@evolix.fr>, Evolix <info@evolix.fr>
|
||||
|
||||
get_system() {
|
||||
uname -s
|
||||
uname -s
|
||||
}
|
||||
|
||||
get_fqdn() {
|
||||
if [ "$(get_system)" = "Linux" ]; then
|
||||
hostname --fqdn
|
||||
elif [ "$(get_system)" = "OpenBSD" ]; then
|
||||
hostname
|
||||
else
|
||||
echo "OS not detected!"
|
||||
exit 1
|
||||
fi
|
||||
if [ "$(get_system)" = "Linux" ]; then
|
||||
hostname --fqdn
|
||||
elif [ "$(get_system)" = "OpenBSD" ]; then
|
||||
hostname
|
||||
else
|
||||
echo "OS not detected!"
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
get_tty() {
|
||||
if [ "$(get_system)" = "Linux" ]; then
|
||||
ps -o tty= | tail -1
|
||||
elif [ "$(get_system)" = "OpenBSD" ]; then
|
||||
env | grep SSH_TTY | cut -d"/" -f3
|
||||
else
|
||||
echo "OS not detected!"
|
||||
exit 1
|
||||
fi
|
||||
if [ "$(get_system)" = "Linux" ]; then
|
||||
ps -o tty= | tail -1
|
||||
elif [ "$(get_system)" = "OpenBSD" ]; then
|
||||
env | grep SSH_TTY | cut -d"/" -f3
|
||||
else
|
||||
echo "OS not detected!"
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
get_who() {
|
||||
who=$(LC_ALL=C who -m)
|
||||
who=$(LC_ALL=C who -m)
|
||||
|
||||
if [ -n "${who}" ]; then
|
||||
echo "${who}"
|
||||
else
|
||||
LC_ALL=C who | grep $(get_tty) | tr -s ' '
|
||||
fi
|
||||
if [ -n "${who}" ]; then
|
||||
echo "${who}"
|
||||
else
|
||||
LC_ALL=C who | grep $(get_tty) | tr -s ' '
|
||||
fi
|
||||
}
|
||||
|
||||
get_begin_date() {
|
||||
echo "$(date "+%Y") $(echo $(get_who) | cut -d" " -f3,4,5)"
|
||||
echo "$(date "+%Y") $(echo $(get_who) | cut -d" " -f3,4,5)"
|
||||
}
|
||||
|
||||
get_ip() {
|
||||
ip=$(echo $(get_who) | cut -d" " -f6 | sed -e "s/^(// ; s/)$//")
|
||||
[ -z "${ip}" ] && ip="unknown (no tty)"
|
||||
[ "${ip}" = ":0" ] && ip="localhost"
|
||||
ip=$(echo $(get_who) | cut -d" " -f6 | sed -e "s/^(// ; s/)$//")
|
||||
[ -z "${ip}" ] && ip="unknown (no tty)"
|
||||
[ "${ip}" = ":0" ] && ip="localhost"
|
||||
|
||||
echo "${ip}"
|
||||
echo "${ip}"
|
||||
}
|
||||
|
||||
get_end_date() {
|
||||
date +"%Y %b %d %H:%M"
|
||||
date +"%Y %b %d %H:%M"
|
||||
}
|
||||
|
||||
get_now() {
|
||||
date +"%Y-%m-%dT%H:%M:%S%z"
|
||||
date +"%Y-%m-%dT%H:%M:%S%z"
|
||||
}
|
||||
|
||||
test -f /etc/evomaintenance.cf && . /etc/evomaintenance.cf
|
||||
|
@ -106,18 +106,18 @@ if test -x "${GIT_BIN}"; then
|
|||
if test -d "${GIT_DIR}" && test -d "${GIT_WORK_TREE}"; then
|
||||
CHANGED_LINES=$(${GIT_BIN} status --porcelain | wc -l | tr -d ' ')
|
||||
if [ "${CHANGED_LINES}" != "0" ]; then
|
||||
STATUS=$(${GIT_BIN} status --short | tail -n 10)
|
||||
# append diff data, without empty lines
|
||||
GIT_STATUSES=$(printf "%s\n%s\n%s\n" "${GIT_STATUSES}" "${GIT_DIR} (last 10 lines)" "${STATUS}" | sed -e '/^$/d')
|
||||
STATUS=$(${GIT_BIN} status --short | tail -n 10)
|
||||
# append diff data, without empty lines
|
||||
GIT_STATUSES=$(printf "%s\n%s\n%s\n" "${GIT_STATUSES}" "${GIT_DIR} (last 10 lines)" "${STATUS}" | sed -e '/^$/d')
|
||||
fi
|
||||
fi
|
||||
# unset environment variables to prevent accidental influence on other git commands
|
||||
unset GIT_DIR GIT_WORK_TREE
|
||||
done
|
||||
if [ -n "${GIT_STATUSES}" ]; then
|
||||
echo "/!\ There are some uncommited changes. If you proceed, everything will be commited."
|
||||
echo "${GIT_STATUSES}"
|
||||
echo ""
|
||||
echo "/!\ There are some uncommited changes. If you proceed, everything will be commited."
|
||||
echo "${GIT_STATUSES}"
|
||||
echo ""
|
||||
fi
|
||||
fi
|
||||
|
||||
|
@ -163,20 +163,20 @@ if test -x "${GIT_BIN}"; then
|
|||
if test -d "${GIT_DIR}" && test -d "${GIT_WORK_TREE}"; then
|
||||
CHANGED_LINES=$(${GIT_BIN} status --porcelain | wc -l | tr -d ' ')
|
||||
if [ "${CHANGED_LINES}" != "0" ]; then
|
||||
${GIT_BIN} add --all
|
||||
${GIT_BIN} commit --message "${TEXTE}" --author="${USER} <${USER}@evolix.net>" --quiet
|
||||
# Add the SHA to the log file if something has been committed
|
||||
SHA=$(${GIT_BIN} rev-parse --short HEAD)
|
||||
STATS=$(${GIT_BIN} show --stat | tail -1)
|
||||
# append commit data, without empty lines
|
||||
GIT_COMMITS=$(printf "%s\n%s : %s –%s" "${GIT_COMMITS}" "${GIT_DIR}" "${SHA}" "${STATS}" | sed -e '/^$/d')
|
||||
${GIT_BIN} add --all
|
||||
${GIT_BIN} commit --message "${TEXTE}" --author="${USER} <${USER}@evolix.net>" --quiet
|
||||
# Add the SHA to the log file if something has been committed
|
||||
SHA=$(${GIT_BIN} rev-parse --short HEAD)
|
||||
STATS=$(${GIT_BIN} show --stat | tail -1)
|
||||
# append commit data, without empty lines
|
||||
GIT_COMMITS=$(printf "%s\n%s : %s –%s" "${GIT_COMMITS}" "${GIT_DIR}" "${SHA}" "${STATS}" | sed -e '/^$/d')
|
||||
fi
|
||||
fi
|
||||
# unset environment variables to prevent accidental influence on other git commands
|
||||
unset GIT_DIR GIT_WORK_TREE
|
||||
done
|
||||
if [ -n "${GIT_COMMITS}" ]; then
|
||||
echo "${GIT_COMMITS}" >> "${LOGFILE}"
|
||||
echo "${GIT_COMMITS}" >> "${LOGFILE}"
|
||||
fi
|
||||
fi
|
||||
|
||||
|
|
Loading…
Reference in a new issue