diff options
author | Simon Rettberg | 2020-07-06 15:13:27 +0200 |
---|---|---|
committer | Simon Rettberg | 2020-07-06 15:13:27 +0200 |
commit | 21a168e0e354ffb3ab9a1e47f651eecb740cce52 (patch) | |
tree | 4f5917ba510065a2612b28b725d21af7e519b417 | |
parent | [ldap/systemctl] Wrapper script, systemd-ize ldadp handling (diff) | |
download | tmlite-bwlp-21a168e0e354ffb3ab9a1e47f651eecb740cce52.tar.gz tmlite-bwlp-21a168e0e354ffb3ab9a1e47f651eecb740cce52.tar.xz tmlite-bwlp-21a168e0e354ffb3ab9a1e47f651eecb740cce52.zip |
[systemctl] Add support for "journal", which actually uses journalctl
-rwxr-xr-x | scripts/systemctl | 12 |
1 files 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 |