From 1d0d343454b1cf3b3eea5cc8ffd2bc08e0d52ef1 Mon Sep 17 00:00:00 2001 From: root Date: Tue, 13 Aug 2019 18:46:42 +0200 Subject: [PATCH] =?UTF-8?q?bcache:=20wirtualny=20prze=C5=82=C4=85cznik=20d?= =?UTF-8?q?o=20zmiany=20trybu=20pracy=20bcache?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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; } } } }); --- --- items/virtual.items | 3 +++ rules/salon.kodi.rules | 3 +++ sitemaps/tech.sitemap | 2 ++ 3 files changed, 8 insertions(+) diff --git a/items/virtual.items b/items/virtual.items index 664fbc6..52650e7 100644 --- a/items/virtual.items +++ b/items/virtual.items @@ -1,3 +1,6 @@ /* czy jesteśmy dłużej poza domem? */ Switch sHolidayVacancy "Jesteśmy poza domem" + +Switch sBCacheWriteback "Bcache w trybie writeback" { exec=">[ON:systemctl start toggle-bcache@writeback] >[OFF:systemctl start toggle-bcache@writethrough]" } + diff --git a/rules/salon.kodi.rules b/rules/salon.kodi.rules index 24668b7..e578737 100644 --- a/rules/salon.kodi.rules +++ b/rules/salon.kodi.rules @@ -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 diff --git a/sitemaps/tech.sitemap b/sitemaps/tech.sitemap index d27f13f..cb407d9 100644 --- a/sitemaps/tech.sitemap +++ b/sitemaps/tech.sitemap @@ -3,6 +3,8 @@ sitemap pbrk label="Szczegóły techniczne" Frame { Text item=dtSunset_Time Text item=wClouds + Switch item=sHolidayVacancy + Switch item=sBCacheWriteback } Group label="Łączność" {