Skip to content

Commit

Permalink
Make the IGNORED_SERVICES array configurable
Browse files Browse the repository at this point in the history
  • Loading branch information
Antiz96 committed Jul 15, 2024
1 parent 3ef0a2a commit a9429ff
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions admin/checkservices
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ STATUS=1 # display status after systemctl
USER_SLICE=0 # act on users services

# ignored service list
IGNORED_SERVICE=("getty@tty.*.service")
IGNORED_SERVICES=("getty@tty.*.service" "systemd-logind.service" "dbus-broker.service")

# print $* as an arrow line
arrow() {
Expand Down Expand Up @@ -105,7 +105,7 @@ confirm() {

# get running systemd services
get_services() {
systemctl --no-legend --full --type service --state running | tr -d '' | awk '{print $1}' | grep -v $(printf -- '-e %s ' "${IGNORED_SERVICE[@]}")
systemctl --no-legend --full --type service --state running | tr -d '' | awk '{print $1}' | grep -v $(printf -- '-e %s ' "${IGNORED_SERVICES[@]}")
}

# get systemd services with updated mapped files
Expand Down Expand Up @@ -252,14 +252,15 @@ usage() {
echo " -s/-S: display (or not) status of restarted service (default: $STATUS)" >&2
echo " -u/-U: act (or not) on services in users slice (default: $USER_SLICE)" >&2
echo " -z/-Z: serialize (or not) action (default: $SERIALIZE)" >&2
echo " -i [service_name.service]: list of services to ignore (space separated)" >&2
exit 2
}

# parse command line arguments
# set options as global vars
argparse() {
local opt
while getopts 'AahFfLlPpRrSsUuZz' opt; do
while getopts 'AahFfLlPpRrSsUuZzi' opt; do
case $opt in
A) AUTOCONFIRM=0;; a) AUTOCONFIRM=1;;
F) FAILED=0;; f) FAILED=1;;
Expand All @@ -269,6 +270,13 @@ argparse() {
S) STATUS=0;; s) STATUS=1;;
U) USER_SLICE=0;; u) USER_SLICE=1;;
Z) SERIALIZE=0;; z) SERIALIZE=1;;
i|ignore) shift $((OPTIND-1))
while [[ "$1" != "" && "$1" != -* && "$1" == *.service ]]; do
IGNORED_SERVICES+=("$1")
shift
done
OPTIND=1
;;
*) usage;;
esac
done
Expand Down

0 comments on commit a9429ff

Please sign in to comment.