Files
openhab/rules/salon.kodi.rules
root 1d0d343454 bcache: wirtualny przełącznik do zmiany trybu pracy bcache
Zastosowanie: włączenie szybszego, ale mniej bezpiecznego trybu
w czasie oglądania czegoś w Kodi.

  Wymaga unitu systemd toggle-bcache@.service:
---
[Unit]
Description=toggle bcache mode for all devices

[Service]
Type=oneshot
WorkingDirectory=/sys
ExecStart=/usr/bin/fd --full-path bcache/cache_mode --exec sh -c "echo %i > {}; "
ProtectSystem=strict
ProtectHome=yes
PrivateTmp=yes
ProtectControlGroups=yes
---

 Oraz regułki polkit openhab.rules:
---

polkit.addRule(function(action, subject) {
	if (action.id == "org.freedesktop.systemd1.manage-units") {
		var unit = action.lookup("unit");
		if (unit == "toggle-bcache@writethrough.service" ||
		    unit == "toggle-bcache@writeback.service") {
			var verb = action.lookup("verb");
			if (verb == "start" && subject.user == "openhabik") {
				return polkit.Result.YES;
			}
		}
	}
});
---
2019-08-13 18:46:42 +02:00

1.3 KiB