initsys.sh finds the init system (running systemd, then OpenRC, then sysvinit, else none) and installs/starts/stops/removes the service for it: the unit, an openrc-run script or an LSB script. install.sh, uninstall.sh and the .deb scripts use it; the .deb no longer depends on systemd; the AppImage asks for the helper's socket instead of systemctl; hints in the program name the command of the init system found. The OpenRC and the sysv scripts were run for real (Debian 13 chroot with OpenRC, start-stop-daemon). Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
28 lines
1.4 KiB
Shell
Executable file
28 lines
1.4 KiB
Shell
Executable file
#!/bin/sh
|
|
set -e
|
|
# The person who installed (sudo or pkexec) is added to the group that may talk to the helper; others add themselves:
|
|
# sudo usermod -aG zapretgui NAME
|
|
if [ "$1" = configure ]; then
|
|
getent group zapretgui >/dev/null || groupadd --system zapretgui
|
|
WHO="${SUDO_USER:-}"
|
|
[ -z "$WHO" ] && [ -n "${PKEXEC_UID:-}" ] && WHO="$(getent passwd "$PKEXEC_UID" | cut -d: -f1)"
|
|
if [ -n "$WHO" ] && [ "$WHO" != root ] && id "$WHO" >/dev/null 2>&1; then
|
|
usermod -aG zapretgui "$WHO" && echo "zapretgui: $WHO was added to the group zapretgui (log in again for it to apply)"
|
|
else
|
|
echo "zapretgui: add each person who uses it to the group: sudo usermod -aG zapretgui NAME"
|
|
fi
|
|
command -v update-desktop-database >/dev/null && update-desktop-database -q /usr/share/applications || true
|
|
command -v gtk-update-icon-cache >/dev/null && gtk-update-icon-cache -q /usr/share/icons/hicolor || true
|
|
# The helper service goes to whatever init system runs this machine (systemd: the unit is a file of this package; OpenRC and
|
|
# sysvinit, e.g. Devuan: an init script from /opt/zapretgui/init). initsys.sh finds it by itself.
|
|
if [ -r /opt/zapretgui/initsys.sh ]; then
|
|
. /opt/zapretgui/initsys.sh
|
|
zg_service_install || true
|
|
zg_service_start || true
|
|
elif [ -d /run/systemd/system ]; then
|
|
systemctl daemon-reload || true
|
|
systemctl enable zapretgui-helper.service || true
|
|
systemctl restart zapretgui-helper.service || true
|
|
fi
|
|
fi
|
|
exit 0
|