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;
			}
		}
	}
});
---
This commit is contained in:
root
2019-08-13 18:46:42 +02:00
parent 0a74850811
commit 1d0d343454
3 changed files with 8 additions and 0 deletions

View File

@@ -8,6 +8,8 @@ then
Mpd_quodlibet_StartStop_expected.postUpdate(Mpd_quodlibet_StartStop.state)
Mpd_quodlibet_StartStop.sendCommand(OFF)
sBCacheWriteback.sendCommand(ON)
end
@@ -41,5 +43,6 @@ then
sendCommand(sOWFS01, ON)
}
sBCacheWriteback.sendCommand(OFF)
end