blob: ccb8345ae7bffb8053567b02c252f7236f96483a (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
|
post_install() {
_reload_udev
_enable_user_service
_restart_for_active_users
_post_msg
}
post_upgrade() {
if systemctl list-unit-files 'lianli-daemon@*.service' 2>/dev/null | grep -q '\.service'; then
cat <<MSG
NOTE: The templated system service lianli-daemon@USER.service has been removed.
Disabling any enabled instances:
MSG
for inst in $(systemctl list-units --all --no-legend 'lianli-daemon@*.service' 2>/dev/null | awk '{print $1}'); do
systemctl disable --now "$inst" 2>/dev/null || true
done
systemctl disable --now lianli-evdi-setup.service 2>/dev/null || true
fi
_reload_udev
_enable_user_service
_restart_for_active_users
_post_msg
}
post_remove() {
systemctl --global disable lianli-daemon.service 2>/dev/null || true
}
_reload_udev() {
if command -v udevadm &>/dev/null; then
udevadm control --reload-rules 2>/dev/null || true
udevadm trigger 2>/dev/null || true
# Module uevents live under /sys/module, which `udevadm trigger` skips by
# default; trigger evdi explicitly so the chmod rule applies to an already-
# loaded module without requiring reboot or rmmod+modprobe.
[ -e /sys/module/evdi ] && udevadm trigger --action=add /sys/module/evdi 2>/dev/null || true
fi
}
_enable_user_service() {
systemctl --global enable lianli-daemon.service 2>/dev/null || true
}
_restart_for_active_users() {
[ -d /run/user ] || return 0
local dir uid user
for dir in /run/user/*; do
[ -d "$dir" ] || continue
uid="${dir##*/}"
[ -S "$dir/bus" ] || continue
user="$(id -nu "$uid" 2>/dev/null)" || continue
# runuser drops the caller's env; systemctl --user needs both XDG_RUNTIME_DIR
# and DBUS_SESSION_BUS_ADDRESS to find the target user's manager.
runuser -u "$user" -- \
env XDG_RUNTIME_DIR="$dir" DBUS_SESSION_BUS_ADDRESS="unix:path=$dir/bus" \
systemctl --user daemon-reload 2>/dev/null || true
runuser -u "$user" -- \
env XDG_RUNTIME_DIR="$dir" DBUS_SESSION_BUS_ADDRESS="unix:path=$dir/bus" \
systemctl --user restart lianli-daemon.service 2>/dev/null || true
done
}
_post_msg() {
cat <<MSG
lianli-daemon.service has been enabled globally for all users — it will
auto-start on login for every account. Any user with an active session
during install has had the daemon (re)started automatically to pick up
the new binary.
Config: ~/.config/lianli/config.json (created on first run).
Desktop-mode devices (HydroShift II, Lancool 207, Universal Screen 8.8")
work out of the box — evdi auto-loads at boot and udev grants user access.
If this is a first install without a reboot, run: sudo modprobe evdi
Optional: to keep the daemon running without an active desktop login:
sudo loginctl enable-linger \$USER
MSG
}
|