evomaintenance: upstream release 23.10

This commit is contained in:
Jérémy Lecour 2023-10-09 17:03:21 +02:00 committed by Jérémy Lecour
parent a0139688c6
commit f644f8c449
Signed by: jlecour
SSH key fingerprint: SHA256:h+5LgHRKwN9lS0SsdVR5yZPeFlJE4Mt+8UtL4CcP8dY
2 changed files with 45 additions and 19 deletions

View file

@ -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 * base: dump-server-state.sh upstream release 23.06
* evocheck: 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 * 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 ### Fixed

View file

@ -1,21 +1,16 @@
#!/bin/sh #!/bin/sh
# EvoMaintenance script VERSION="23.10"
# 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"
show_version() { show_version() {
cat <<END cat <<END
evomaintenance version ${VERSION} evomaintenance version ${VERSION}
Copyright 2007-2022 Evolix <info@evolix.fr>, Copyright 2007-2023 Evolix <info@evolix.fr>,
Gregory Colpart <reg@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. and others.
evomaintenance comes with ABSOLUTELY NO WARRANTY. This is free software, evomaintenance comes with ABSOLUTELY NO WARRANTY. This is free software,
@ -47,10 +42,11 @@ Options
--no-evocheck disable evocheck execution --no-evocheck disable evocheck execution
--auto use "auto" mode --auto use "auto" mode
--no-auto use "manual" mode (default) --no-auto use "manual" mode (default)
-u, --user=USER force USER value (default: logname(1))
-v, --verbose increase verbosity -v, --verbose increase verbosity
-n, --dry-run actions are not executed -n, --dry-run actions are not executed
--help print this message and exit --help print this message and exit
--version print version and exit -V, --version print version and exit
END END
} }
@ -97,9 +93,9 @@ get_who() {
} }
get_begin_date() { get_begin_date() {
# XXX Begin end date isn't applicable when used in autosysadmin, # XXX A begin date isn't applicable when used in autosysadmin, so we
# so we use the same one as the end date. # use the same date as the end date.
if [ "${AUTOSYSADMIN}" -eq 1 ]; then if is_autosysadmin; then
get_end_date get_end_date
else else
printf "%s %s" "$(date "+%Y")" "$(get_who | cut -d" " -f3,4,5)" printf "%s %s" "$(date "+%Y")" "$(get_who | cut -d" " -f3,4,5)"
@ -108,7 +104,7 @@ get_begin_date() {
get_ip() { get_ip() {
ip=$(get_who | cut -d" " -f6 | sed -e "s/^(// ; s/)$//") 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" ip="localhost"
elif [ -z "${ip}" ]; then elif [ -z "${ip}" ]; then
ip="unknown (no tty)" ip="unknown (no tty)"
@ -126,8 +122,8 @@ get_now() {
} }
get_user() { get_user() {
if [ "${AUTOSYSADMIN}" -eq 1 ]; then if [ -n "${USER}" ]; then
echo autosysadmin echo "${USER}"
else else
logname logname
fi fi
@ -191,6 +187,10 @@ print_session_data() {
printf "Message : %s\n" "${MESSAGE}" printf "Message : %s\n" "${MESSAGE}"
} }
is_autosysadmin() {
test "${USER}" = "autosysadmin"
}
is_repository_readonly() { is_repository_readonly() {
if [ "$(get_system)" = "OpenBSD" ]; then if [ "$(get_system)" = "OpenBSD" ]; then
partition=$(stat -f '%Sd' $1) partition=$(stat -f '%Sd' $1)
@ -399,7 +399,7 @@ AUTO=${AUTO:-"0"}
EVOCHECK=${EVOCHECK:-"0"} EVOCHECK=${EVOCHECK:-"0"}
GIT_STATUS_MAX_LINES=${GIT_STATUS_MAX_LINES:-20} GIT_STATUS_MAX_LINES=${GIT_STATUS_MAX_LINES:-20}
API_ENDPOINT=${API_ENDPOINT:-""} API_ENDPOINT=${API_ENDPOINT:-""}
AUTOSYSADMIN=${AUTOSYSADMIN:-0} USER=${USER:-""}
# initialize variables # initialize variables
MESSAGE="" MESSAGE=""
@ -477,6 +477,31 @@ while :; do
# use "auto" mode # use "auto" mode
AUTO=1 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) -n|--dry-run)
# disable actual commands # disable actual commands
DRY_RUN=1 DRY_RUN=1
@ -515,7 +540,7 @@ HOSTNAME_TEXT=$(get_complete_hostname)
IP=$(get_ip) IP=$(get_ip)
BEGIN_DATE=$(get_begin_date) BEGIN_DATE=$(get_begin_date)
END_DATE=$(get_end_date) END_DATE=$(get_end_date)
USER=$(logname) USER=$(get_user)
PATH=${PATH}:/usr/sbin PATH=${PATH}:/usr/sbin