From 8716c8b40c7ca363fab30f256e2b1b864d68092e Mon Sep 17 00:00:00 2001
From: Lennard <27106448+SirWalross@users.noreply.github.com>
Date: Sun, 26 Jun 2022 00:08:25 +0200
Subject: [PATCH] Update overriding of commits and add detection for size of
 bash.log

---
 scripts/run.bash     | 15 +++++++++++++--
 scripts/serial_id.py |  2 +-
 2 files changed, 14 insertions(+), 3 deletions(-)

diff --git a/scripts/run.bash b/scripts/run.bash
index 37389ec..c775338 100755
--- a/scripts/run.bash
+++ b/scripts/run.bash
@@ -23,15 +23,26 @@ if [ $? -eq 0 ]; then
 fi
 echo -e "\nPython script ended"
 
+# Check if bash.log is becoming too large
+linecount=$(wc -l < bash.log)
+
+if [[ $linecount -ge 3000 ]] ; then
+    # delete the first linecount - 3000 lines
+    delete_lines=$(($linecount-3000))
+    sed -i "1,${delete_lines}d" bash.log
+fi
+
 git pull
 
-last_commit_name = $(git log -1 --pretty=%B | cat)
+last_commit_name=$(git log -1 --pretty=%B | cat)
 
-if [[ $string == *"New data"* ]]; then
+if [[ $last_commit_name == "New data" ]]
+then
     # check if the last commit was "New data"
     # if yes overwrite the commit
     git reset --soft HEAD~1
 fi
+sudo shutdown +5761
 
 git add .
 git commit -m "New data" && git push --force
\ No newline at end of file
diff --git a/scripts/serial_id.py b/scripts/serial_id.py
index aa61005..f2b1e30 100644
--- a/scripts/serial_id.py
+++ b/scripts/serial_id.py
@@ -1,4 +1,4 @@
-"""Return the id of the arduino connected to the first serial port. id 0 is for Temperaturmessung, id 1 for DMSMessung
+"""Return the id of the arduino connected to the first serial port. Id 1 is for DMSMessung, id 2 for Temperaturmessung.
 """
 import time
 import serial
-- 
GitLab