mirror of
https://github.com/uhi22/pyPLC.git
synced 2024-11-20 01:13:58 +00:00
feature: automatic path name in sharter.sh
This commit is contained in:
parent
940da180e6
commit
9855095294
1 changed files with 15 additions and 11 deletions
26
starter.sh
26
starter.sh
|
@ -1,5 +1,8 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
|
# enter in the pyPLC directory, so that all subsequent pathes can be relative to this.
|
||||||
|
cd "$( dirname "${BASH_SOURCE[0]}" )"
|
||||||
|
|
||||||
# Function to start tcpdump
|
# Function to start tcpdump
|
||||||
start_tcpdump() {
|
start_tcpdump() {
|
||||||
INTERFACE="eth0" # Change this to the interface you want to monitor
|
INTERFACE="eth0" # Change this to the interface you want to monitor
|
||||||
|
@ -24,7 +27,7 @@ signal_handler() {
|
||||||
# Set trap for signals: SIGINT (2), SIGTERM (15)
|
# Set trap for signals: SIGINT (2), SIGTERM (15)
|
||||||
trap 'signal_handler' 2 15
|
trap 'signal_handler' 2 15
|
||||||
|
|
||||||
# Todo: explain this
|
# Set options for the bash: exit on error, treat unused variables as error, print the input as it is read.
|
||||||
set -euv
|
set -euv
|
||||||
|
|
||||||
# Keep all IPv6 addresses on the interface down event.
|
# Keep all IPv6 addresses on the interface down event.
|
||||||
|
@ -35,6 +38,7 @@ sysctl net.ipv6.conf.eth0.keep_addr_on_down=1
|
||||||
# Shut down and activate the interface.
|
# Shut down and activate the interface.
|
||||||
# Todo: Why this needed? On raspberry, where the NetworkManager is not runnning, this disturbs, because
|
# Todo: Why this needed? On raspberry, where the NetworkManager is not runnning, this disturbs, because
|
||||||
# afterwards the pyPlc does not see the interfaces IPv6 address.
|
# afterwards the pyPlc does not see the interfaces IPv6 address.
|
||||||
|
# Todo: make this configurable, for the cases we need this.
|
||||||
# ip link set eth0 down
|
# ip link set eth0 down
|
||||||
sleep 1
|
sleep 1
|
||||||
# ip link set eth0 up
|
# ip link set eth0 up
|
||||||
|
@ -43,12 +47,15 @@ sleep 1
|
||||||
# show the addresses
|
# show the addresses
|
||||||
ip addr
|
ip addr
|
||||||
|
|
||||||
# todo: flexible path name
|
# print the current directory to log. Should be the pyPLC directory.
|
||||||
mkdir -p /home/pi/myprogs/pyPLC/log
|
pwd
|
||||||
|
|
||||||
|
# create directory for the log files.
|
||||||
|
mkdir -p log
|
||||||
# prepare the file names for the log files
|
# prepare the file names for the log files
|
||||||
date=$(date "+%Y-%m-%d_%H%M%S")
|
date=$(date "+%Y-%m-%d_%H%M%S")
|
||||||
logfile=/home/pi/myprogs/pyPLC/log/"$date"_pevNoGui.log
|
logfile=./log/"$date"_pevNoGui.log
|
||||||
tcpdump_logfile=/home/pi/myprogs/pyPLC/log/"$date"_tcpdump.pcap
|
tcpdump_logfile=./log/"$date"_tcpdump.pcap
|
||||||
|
|
||||||
echo "logfile: $logfile"
|
echo "logfile: $logfile"
|
||||||
echo "tcpdump_logfile: $tcpdump_logfile"
|
echo "tcpdump_logfile: $tcpdump_logfile"
|
||||||
|
@ -60,12 +67,9 @@ echo "$date" >> "$logfile"
|
||||||
git log --oneline -1 >> "$logfile" || echo "Not a git repo" >> "$logfile"
|
git log --oneline -1 >> "$logfile" || echo "Not a git repo" >> "$logfile"
|
||||||
ip addr >> "$logfile"
|
ip addr >> "$logfile"
|
||||||
pwd >> "$logfile"
|
pwd >> "$logfile"
|
||||||
# Todo: flexible path name
|
|
||||||
cd /home/pi/myprogs/pyPLC/
|
# call the pyPlc python script
|
||||||
#/usr/bin/python3 /home/user/projects/pyPLC/pevNoGui.py | tee -a "$logfile"
|
PYTHONUNBUFFERED=1 /usr/bin/python3 pevNoGui.py | tee -a "$logfile"
|
||||||
#stdbuf -oL -eL /usr/bin/python3 /home/user/projects/pyPLC/pevNoGui.py | tee -a "$logfile"
|
|
||||||
#PYTHONUNBUFFERED=1 /usr/bin/python3 /home/user/projects/pyPLC/pevNoGui.py | stdbuf -oL -eL tee -a "$logfile"
|
|
||||||
PYTHONUNBUFFERED=1 /usr/bin/python3 /home/pi/myprogs/pyPLC/pevNoGui.py | tee -a "$logfile"
|
|
||||||
pwd >> "$logfile"
|
pwd >> "$logfile"
|
||||||
date >> "$logfile"
|
date >> "$logfile"
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue