From cda094fb8998adcb13132eccbaff864f5474a43b Mon Sep 17 00:00:00 2001 From: Adnan Hodzic Date: Mon, 10 Feb 2020 18:16:56 +0100 Subject: [PATCH] code improvements for snap to work in strict confinement --- scripts/cpufreqctl.sh | 2 +- snap/snapcraft.yaml | 14 ++++++++++---- source/core.py | 2 +- 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/scripts/cpufreqctl.sh b/scripts/cpufreqctl.sh index 008f0da..81c5453 100755 --- a/scripts/cpufreqctl.sh +++ b/scripts/cpufreqctl.sh @@ -1,7 +1,7 @@ #!/usr/bin/env bash VERSION='20' -cpucount=`nproc` +cpucount=`cat /proc/cpuinfo|grep processor|wc -l` FLROOT=/sys/devices/system/cpu DRIVER=auto VERBOSE=0 diff --git a/snap/snapcraft.yaml b/snap/snapcraft.yaml index d13f3bf..897aad6 100644 --- a/snap/snapcraft.yaml +++ b/snap/snapcraft.yaml @@ -26,17 +26,23 @@ parts: apps: auto-cpufreq: command: bin/auto-cpufreq - environment: - LC_ALL: C.UTF-8 - LANG: C.UTF-8 - PKG_MARKER: SNAP plugs: - cpu-control - system-observe - hardware-observe - system-files + environment: + LC_ALL: C.UTF-8 + LANG: C.UTF-8 + PKG_MARKER: SNAP + service: command: bin/auto-cpufreq --daemon 2>&1 | tee -a /var/log/auto-cpufreq.log + plugs: + - cpu-control + - system-observe + - hardware-observe + - system-files environment: LC_ALL: C.UTF-8 LANG: C.UTF-8 diff --git a/source/core.py b/source/core.py index 9972fd8..676f6d9 100644 --- a/source/core.py +++ b/source/core.py @@ -321,7 +321,7 @@ def sysinfo(): # get distro information in snap env. if os.getenv("PKG_MARKER") == "SNAP": - searchfile = open("/usr/lib/os-release", "r") + searchfile = open("/var/lib/snapd/hostfs/etc/os-release", "r") for line in searchfile: if line.startswith('NAME='): distro = line[5:line.find('$')].strip("\"")