From 21a168e0e354ffb3ab9a1e47f651eecb740cce52 Mon Sep 17 00:00:00 2001 From: Simon Rettberg Date: Mon, 6 Jul 2020 15:13:27 +0200 Subject: [systemctl] Add support for "journal", which actually uses journalctl --- scripts/systemctl | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/scripts/systemctl b/scripts/systemctl index e3afe73..ae9ef41 100755 --- a/scripts/systemctl +++ b/scripts/systemctl @@ -9,6 +9,12 @@ if [ $# -eq 0 ]; then fi declare -A services +declare -a args +if [[ "$op" == "journal" ]]; then + args=( journalctl "--no-hostname" "-n" "100" "-u" ) +else + args=( systemctl "$op" ) +fi services["dmsd"]="start stop restart" services["lighttpd"]="restart" @@ -23,7 +29,7 @@ one_fail= cmpop="${op##*-}" for service in "$@"; do ok= - [[ "$op" =~ ^(is-active|status|cat)$ ]] && ok=1 + [[ "$op" =~ ^(is-active|status|cat|journal)$ ]] && ok=1 str="${service%.service}" noa="${str%%@*}" [[ "$noa" != "$str" ]] && str="${noa}@" @@ -36,11 +42,11 @@ for service in "$@"; do done fi if [ -n "$ok" ]; then - if systemctl "$op" "$service"; then + if "${args[@]}" "$service"; then one_ok=1 else one_fail=1 - [[ "$op" != "status" ]] && systemctl status "$service" + [[ "$op" != "status" && "$op" != "journal" ]] && systemctl status "$service" fi else echo "Operation '$op' not allowed on '$service'" >&2 -- cgit v1.2.3-55-g7522