Skip to content

Commit

Permalink
Added udev rules and better permissions for statime.
Browse files Browse the repository at this point in the history
  • Loading branch information
davidv1992 authored and rnijveld committed Feb 21, 2024
1 parent 8d0c38b commit 49a9914
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 1 deletion.
1 change: 1 addition & 0 deletions docs/examples/conf/41-statime.rules
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
KERNEL=="ptp[0-9]*", SUBSYSTEM=="ptp", GROUP="statime", MODE="0660"
2 changes: 1 addition & 1 deletion docs/examples/conf/statime.service
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ Environment="RUST_LOG=info"
RuntimeDirectory=statime
User=statime
Group=statime
AmbientCapabilities=CAP_SYS_TIME CAP_NET_BIND_SERVICE CAP_NET_RAW
AmbientCapabilities=CAP_SYS_TIME CAP_NET_BIND_SERVICE CAP_NET_RAW CAP_NET_ADMIN

[Install]
WantedBy=multi-user.target
5 changes: 5 additions & 0 deletions pkg/deb/postinst
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,11 @@ if [ "$1" = "configure" ] || [ "$1" = "abort-upgrade" ] || [ "$1" = "abort-decon
fi
deb-systemd-invoke $_dh_action statime.service >/dev/null || true
fi

if [ -d /run/udev ]; then
udevadm control -R
udevadm trigger
fi
fi

#DEBHELPER#
10 changes: 10 additions & 0 deletions pkg/deb/postrm
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,23 @@ if [ "$1" = "remove" ]; then
if [ -x "/usr/bin/deb-systemd-helper" ]; then
deb-systemd-helper mask statime.service >/dev/null || true
fi

if [ -d /run/udev ]; then
udevadm control -R
udevadm trigger
fi
fi

if [ "$1" = "purge" ]; then
if [ -x "/usr/bin/deb-systemd-helper" ]; then
deb-systemd-helper purge statime.service >/dev/null || true
deb-systemd-helper unmask statime.service >/dev/null || true
fi

if [ -d /run/udev ]; then
udevadm control -R
udevadm trigger
fi
fi

#DEBHELPER#
7 changes: 7 additions & 0 deletions pkg/rpm/scriptlets.toml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@ if [ $1 -eq 1 ] ; then
create_user
link_man_page
init_systemd_service
udevadm control -R
udevadm trigger
fi
'''

Expand All @@ -64,4 +67,8 @@ if [ $1 -ge 1 ] ; then
systemd_postun_with_restart statime.service
systemd_triggers
fi
#trigger udev regardless of upgrade or removal
udevadm control -R
udevadm trigger
'''
2 changes: 2 additions & 0 deletions statime-linux/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ assets = [
["docs/examples/conf/statime.toml.default", "/etc/statime/statime.toml", "644"],
["docs/examples/conf/statime.preset", "/lib/systemd/system-preset/50-statime.preset", "644"],
["docs/examples/conf/statime.service", "/lib/systemd/system/statime.service", "644"],
["docs/examples/conf/41-statime.rules", "/etc/udev/41-statime.rules", "644"],
["../COPYRIGHT", "/usr/share/doc/statime/COPYRIGHT", "644"],
["../LICENSE-APACHE", "/usr/share/doc/statime/LICENSE-APACHE", "644"],
["../LICENSE-MIT", "/usr/share/doc/statime/LICENSE-MIT", "644"],
Expand All @@ -79,6 +80,7 @@ assets = [
{ source = "docs/examples/conf/statime.toml.default", dest = "/etc/statime/statime.toml", mode = "644", config = true },
{ source = "docs/examples/conf/statime.preset", dest = "/lib/systemd/system-preset/50-statime.preset", mode = "644" },
{ source = "docs/examples/conf/statime.service", dest = "/lib/systemd/system/statime.service", mode = "644" },
{ source = "docs/examples/conf/41-statime.rules", dest = "/etc/udev/41-statime.rules", mode = "644" },
{ source = "../COPYRIGHT", dest = "/usr/share/doc/statime/COPYRIGHT", mode = "644", doc = true },
{ source = "../LICENSE-APACHE", dest = "/usr/share/doc/statime/LICENSE-APACHE", mode = "644", doc = true },
{ source = "../LICENSE-MIT", dest = "/usr/share/doc/statime/LICENSE-MIT", mode = "644", doc = true },
Expand Down

0 comments on commit 49a9914

Please sign in to comment.