diff options
-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 |