evomaintenance: upstream release 23.10
This commit is contained in:
parent
a0139688c6
commit
f644f8c449
|
@ -74,6 +74,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||
* base: dump-server-state.sh upstream release 23.06
|
||||
* evocheck: upstream release 23.06
|
||||
* base: add evobsd_alias_fwupdate variable and make kshrc file a template so we can set or not a fw_update alias to servers that need it
|
||||
* evomaintenance: upstream release 23.10
|
||||
|
||||
### Fixed
|
||||
|
||||
|
|
|
@ -1,21 +1,16 @@
|
|||
#!/bin/sh
|
||||
|
||||
# EvoMaintenance script
|
||||
# Dependencies (all OS): git postgresql-client
|
||||
# Dependencies (Debian): sudo
|
||||
|
||||
# Copyright 2007-2022 Evolix <info@evolix.fr>, Gregory Colpart <reg@evolix.fr>,
|
||||
# Jérémy Lecour <jlecour@evolix.fr> and others.
|
||||
|
||||
VERSION="22.01"
|
||||
VERSION="23.10"
|
||||
|
||||
show_version() {
|
||||
cat <<END
|
||||
evomaintenance version ${VERSION}
|
||||
|
||||
Copyright 2007-2022 Evolix <info@evolix.fr>,
|
||||
Copyright 2007-2023 Evolix <info@evolix.fr>,
|
||||
Gregory Colpart <reg@evolix.fr>,
|
||||
Jérémy Lecour <jlecour@evolix.fr>
|
||||
Jérémy Lecour <jlecour@evolix.fr>,
|
||||
Brice Waegeneire <bwaegeneire@evolix.fr>,
|
||||
Mathieu Trossevin <mtrossevin@evolix.fr>
|
||||
and others.
|
||||
|
||||
evomaintenance comes with ABSOLUTELY NO WARRANTY. This is free software,
|
||||
|
@ -47,10 +42,11 @@ Options
|
|||
--no-evocheck disable evocheck execution
|
||||
--auto use "auto" mode
|
||||
--no-auto use "manual" mode (default)
|
||||
-u, --user=USER force USER value (default: logname(1))
|
||||
-v, --verbose increase verbosity
|
||||
-n, --dry-run actions are not executed
|
||||
--help print this message and exit
|
||||
--version print version and exit
|
||||
-V, --version print version and exit
|
||||
END
|
||||
}
|
||||
|
||||
|
@ -97,9 +93,9 @@ get_who() {
|
|||
}
|
||||
|
||||
get_begin_date() {
|
||||
# XXX Begin end date isn't applicable when used in autosysadmin,
|
||||
# so we use the same one as the end date.
|
||||
if [ "${AUTOSYSADMIN}" -eq 1 ]; then
|
||||
# XXX A begin date isn't applicable when used in autosysadmin, so we
|
||||
# use the same date as the end date.
|
||||
if is_autosysadmin; then
|
||||
get_end_date
|
||||
else
|
||||
printf "%s %s" "$(date "+%Y")" "$(get_who | cut -d" " -f3,4,5)"
|
||||
|
@ -108,7 +104,7 @@ get_begin_date() {
|
|||
|
||||
get_ip() {
|
||||
ip=$(get_who | cut -d" " -f6 | sed -e "s/^(// ; s/)$//")
|
||||
if [ "${AUTOSYSADMIN}" -eq 1 ] || [ "${ip}" = ":0" ]; then
|
||||
if is_autosysadmin || [ "${ip}" = ":0" ]; then
|
||||
ip="localhost"
|
||||
elif [ -z "${ip}" ]; then
|
||||
ip="unknown (no tty)"
|
||||
|
@ -126,8 +122,8 @@ get_now() {
|
|||
}
|
||||
|
||||
get_user() {
|
||||
if [ "${AUTOSYSADMIN}" -eq 1 ]; then
|
||||
echo autosysadmin
|
||||
if [ -n "${USER}" ]; then
|
||||
echo "${USER}"
|
||||
else
|
||||
logname
|
||||
fi
|
||||
|
@ -191,6 +187,10 @@ print_session_data() {
|
|||
printf "Message : %s\n" "${MESSAGE}"
|
||||
}
|
||||
|
||||
is_autosysadmin() {
|
||||
test "${USER}" = "autosysadmin"
|
||||
}
|
||||
|
||||
is_repository_readonly() {
|
||||
if [ "$(get_system)" = "OpenBSD" ]; then
|
||||
partition=$(stat -f '%Sd' $1)
|
||||
|
@ -399,7 +399,7 @@ AUTO=${AUTO:-"0"}
|
|||
EVOCHECK=${EVOCHECK:-"0"}
|
||||
GIT_STATUS_MAX_LINES=${GIT_STATUS_MAX_LINES:-20}
|
||||
API_ENDPOINT=${API_ENDPOINT:-""}
|
||||
AUTOSYSADMIN=${AUTOSYSADMIN:-0}
|
||||
USER=${USER:-""}
|
||||
|
||||
# initialize variables
|
||||
MESSAGE=""
|
||||
|
@ -477,6 +477,31 @@ while :; do
|
|||
# use "auto" mode
|
||||
AUTO=1
|
||||
;;
|
||||
--autosysadmin)
|
||||
# Deprecated, backward compatibility
|
||||
# author change as autosysadmin
|
||||
printf 'WARNING: "--autosysadmin" is deprecated, use "--user autosysadmin".\n' >&2
|
||||
USER="autosysadmin"
|
||||
;;
|
||||
-u|--user)
|
||||
# user options, with value speparated by space
|
||||
if [ -n "$2" ]; then
|
||||
USER=$2
|
||||
shift
|
||||
else
|
||||
printf 'ERROR: "--user" requires a non-empty option argument.\n' >&2
|
||||
exit 1
|
||||
fi
|
||||
;;
|
||||
--user=?*)
|
||||
# message options, with value speparated by =
|
||||
USER=${1#*=}
|
||||
;;
|
||||
--user=)
|
||||
# message options, without value
|
||||
printf 'ERROR: "--user" requires a non-empty option argument.\n' >&2
|
||||
exit 1
|
||||
;;
|
||||
-n|--dry-run)
|
||||
# disable actual commands
|
||||
DRY_RUN=1
|
||||
|
@ -515,7 +540,7 @@ HOSTNAME_TEXT=$(get_complete_hostname)
|
|||
IP=$(get_ip)
|
||||
BEGIN_DATE=$(get_begin_date)
|
||||
END_DATE=$(get_end_date)
|
||||
USER=$(logname)
|
||||
USER=$(get_user)
|
||||
|
||||
PATH=${PATH}:/usr/sbin
|
||||
|
||||
|
|
Loading…
Reference in a new issue