Skip to content

Commit b2f3332

Browse files
committedApr 26, 2024
etc: scripts: Add iptsd-systemd script
This script lets you run systemctl commands (e.g. start, stop, status) on all available iptsd instances (or a subset of them).
1 parent 5773bda commit b2f3332

File tree

3 files changed

+61
-0
lines changed

3 files changed

+61
-0
lines changed
 

‎etc/meson.build

+7
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,13 @@ if service_manager.contains('systemd')
4949

5050
install_data(unit, install_dir: unitdir)
5151
install_data(rule, install_dir: rulesdir)
52+
53+
install_data(
54+
'scripts/iptsd-systemd',
55+
install_dir: bindir,
56+
install_mode: 'rwxr-xr-x',
57+
)
58+
5259
install_data(
5360
'systemd/iptsd-find-service',
5461
install_dir: bindir,

‎etc/scripts/iptsd-systemd

+53
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
#!/bin/bash
2+
# SPDX-License-Identifier: GPL-2.0-or-later
3+
4+
set -euo pipefail
5+
6+
function run-iptsd-systemd() {
7+
local -r script_dir="$(dirname "$(realpath "${BASH_SOURCE[0]}")")"
8+
9+
source "${script_dir}/iptsd-foreach"
10+
11+
local foreach_args=()
12+
local show_help=""
13+
14+
while getopts ":t:i:h" args; do
15+
case "${args}" in
16+
i)
17+
foreach_args+=("-i" "${OPTARG}")
18+
;;
19+
t)
20+
foreach_args+=("-t" "${OPTARG}")
21+
;;
22+
*)
23+
show_help="1"
24+
;;
25+
esac
26+
done
27+
28+
shift $((OPTIND - 1))
29+
30+
if (("$#" == 0)); then
31+
show_help="1"
32+
fi
33+
34+
if [ -n "${show_help}" ]; then
35+
echo "Usage: iptsd-systemd [OPTIONS] -- COMMAND"
36+
echo "Run systemctl commands for all instances of iptsd"
37+
echo ""
38+
echo "Options:"
39+
echo " -h Print this help message and exit"
40+
echo " -t TEXT:{any,touchscreen,touchpad} Selects all devices with the given type"
41+
echo " -i INTEGER Selects a single device by its index"
42+
43+
return 0
44+
fi
45+
46+
# shellcheck disable=SC2016
47+
run-iptsd-foreach "${foreach_args[@]}" -- \
48+
systemctl "$@" 'iptsd@$(systemd-escape --path "{}").service'
49+
}
50+
51+
if [ "${BASH_SOURCE[0]}" = "${0}" ]; then
52+
run-iptsd-systemd "$@"
53+
fi

‎iptsd.spec

+1
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ kernel driver, and sends them back to the kernel using uinput devices.
7373
%{_bindir}/iptsd-perf
7474
%{_bindir}/iptsd-plot
7575
%{_bindir}/iptsd-show
76+
%{_bindir}/iptsd-systemd
7677
%{_unitdir}/iptsd@.service
7778
%{_udevrulesdir}/50-iptsd.rules
7879
%{_datadir}/iptsd/*

0 commit comments

Comments
 (0)
Please sign in to comment.