From 797d7d9e1df12f5010a4323994f32847232b6529 Mon Sep 17 00:00:00 2001
From: Sander <alexander holt>
Date: Fri, 28 Feb 2020 16:11:31 +0100
Subject: [PATCH] =?UTF-8?q?Fikset=20script=20for=20=C3=A5=20kj=C3=B8re=20o?=
 =?UTF-8?q?pp=20logging.=20Endret=20til=20=C3=A5=20kreve=20bruk=20av=20"su?=
 =?UTF-8?q?do"=20n=C3=A5r=20man=20kj=C3=B8rer=20scriptet,=20=20istedet=20f?=
 =?UTF-8?q?or=20=C3=A5=20kj=C3=B8re=20kommandoen=20inne=20i=20scriptet=20m?=
 =?UTF-8?q?ed=20sudo,=20da=20denne=20brukte=20&=20p=C3=A5=20slutten,=20som?=
 =?UTF-8?q?=20ga=20kommandolinja=20tilbake=20og=20ble=20forrvirende=20det?=
 =?UTF-8?q?=20ble=20spurt=20om=20passord.?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 runLogging | 14 ++++++++++----
 1 file changed, 10 insertions(+), 4 deletions(-)
 mode change 100644 => 100755 runLogging

diff --git a/runLogging b/runLogging
old mode 100644
new mode 100755
index b74b68f..0473c76
--- a/runLogging
+++ b/runLogging
@@ -1,6 +1,12 @@
 #!/bin/bash
+
+if ! [ $(id -u) = 0 ]; then
+   echo "This script needs to be run as root." >&2
+   exit 1
+fi
+
 clear
-echo "Starting logsystem"
-touch ~/warnings.txt
-sleep 3
-sudo glances -C glances.conf --export influxdb -q &
\ No newline at end of file
+echo "Starting logsystem..."
+sudo -u $SUDO_USER touch ~/warnings.txt # Run as normal user, so the file is created in the right home directory
+glances -C glances.conf --export influxdb -q &
+echo "Done."
-- 
GitLab