aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSomasis <somasissounds@gmail.com>2014-06-16 03:47:37 -0400
committerSomasis <somasissounds@gmail.com>2014-06-16 03:47:37 -0400
commitff5fc83e55057d03956788a2e766b128e13c7057 (patch)
treed3a2eedc3aeeb026d80a8e8e2ae5debddf370f24
parent0911d77b9b5f935a58c33b20cb1d2d0d3fa8cada (diff)
downloadraspui-ff5fc83e55057d03956788a2e766b128e13c7057.tar.gz
raspui-ff5fc83e55057d03956788a2e766b128e13c7057.tar.xz
raspui-ff5fc83e55057d03956788a2e766b128e13c7057.zip
don't read os-release redundantly, make sure we're in the script's directory when running
-rwxr-xr-xfunctions.sh8
-rwxr-xr-xindex.sh8
2 files changed, 10 insertions, 6 deletions
diff --git a/functions.sh b/functions.sh
index a36be18..37728cb 100755
--- a/functions.sh
+++ b/functions.sh
@@ -1,5 +1,7 @@
#!/bin/bash
+cd "$( cd "$(dirname "$0")"; pwd -P )"
+
_OLDIFS="$IFS"
IFS=$'\n'
# read /etc/*-release files, they contain information about what system is being used.
@@ -254,8 +256,10 @@ calc() {
# get_cpu: get cpu stats and export them to variables, use cached version if we're using that method
get_cpu() {
if [[ "$use_cpu_cache" == "true" && -f /tmp/raspui-cpu-stats.txt ]];then
- cpu_usage=$(cut -d':' -f1 /tmp/raspui-cpu-stats.txt)
- cpu_usage_level=$(cut -d':' -f2 /tmp/raspui-cpu-stats.txt)
+ export cpu_usage=$(cut -d':' -f1 /tmp/raspui-cpu-stats.txt)
+ export cpu_usage_level=$(cut -d':' -f2 /tmp/raspui-cpu-stats.txt)
+ elif [[ "$use_cpu_cache" == "true" && ! -f /tmp/raspui-cpu-stats.txt ]];then
+ manual_cpu_calc tocache
else
manual_cpu_calc
fi
diff --git a/index.sh b/index.sh
index 27b3189..2aae85b 100755
--- a/index.sh
+++ b/index.sh
@@ -43,11 +43,11 @@ local_ip=$(ip route | grep src | sed 's/.*src //;s/ .*//')
OLDIFS="$IFS"
IFS=$'\n'
-if [[ "$RELEASE_ID" == "arch" ]];then
+if [[ "$RELEASE_ID_LIKE" == "arch" ]];then
packages_installed=$(pacman --color never -Qq | wc -l)
package_manager_version=$(pacman --color never -Q pacman | tr ' ' '/')
-elif [[ "$RELEASE_ID" == "debian" ]];then
- packages_installed=$(apt-cache pkgnames | wc -l)
+elif [[ "$RELEASE_ID_LIKE" == "debian" ]];then
+ packages_installed="apt $(apt-cache pkgnames | wc -l)"
package_manager_version=$(apt-cache -q show apt | grep Version | cut -d ' ' -f2 | cut -d'~' -f1 | head -n1)
else
packages_installed="unknown"
@@ -152,7 +152,7 @@ else
swap_column=" <div class=\"col-md-6\">"
fi
-swap_usage_data=$(swapon -e --noheadings --raw --show=name,size,used)
+swap_usage_data=$(swapon -e --raw --show=name,size,used)
cpu_model=$(echo $(_grep 'model name' /proc/cpuinfo | cut -d':' -f2))