diff --git a/CHANGELOG.md b/CHANGELOG.md index c8c33dc..145b456 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,7 @@ and this project **does not adhere to [Semantic Versioning](http://semver.org/sp ### Added +* Add `--autosysadmin` flag * Commit change in /etc of lxc containers ### Changed diff --git a/evomaintenance.sh b/evomaintenance.sh index 78b1dc8..22e4f4a 100755 --- a/evomaintenance.sh +++ b/evomaintenance.sh @@ -47,6 +47,7 @@ Options --no-evocheck disable evocheck execution --auto use "auto" mode --no-auto use "manual" mode (default) + --autosysadmin author change as autosysadmin -v, --verbose increase verbosity -n, --dry-run actions are not executed --help print this message and exit @@ -97,9 +98,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 +109,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,7 +127,7 @@ get_now() { } get_user() { - if [ "${AUTOSYSADMIN}" -eq 1 ]; then + if is_autosysadmin; then echo autosysadmin else logname @@ -191,6 +192,10 @@ print_session_data() { printf "Message : %s\n" "${MESSAGE}" } +is_autosysadmin() { + test "${AUTOSYSADMIN}" -eq 1 +} + is_repository_readonly() { if [ "$(get_system)" = "OpenBSD" ]; then partition=$(stat -f '%Sd' $1) @@ -515,7 +520,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