diff --git a/etc/mesh_bot.tmp b/etc/mesh_bot.tmp index dd8e1dc..e4e0a9f 100644 --- a/etc/mesh_bot.tmp +++ b/etc/mesh_bot.tmp @@ -7,8 +7,12 @@ Description=MESH-BOT After=network.target [Service] +Type=simple +User=pi +Group=pi WorkingDirectory=/dir/ ExecStart=/usr/bin/bash python3 mesh_bot.py +ExecStop=/usr/bin/bash pkill -f mesh_bot.py # Disable Python's buffering of STDOUT and STDERR, so that output from the # service shows up immediately in systemd's logs diff --git a/etc/pong_bot.tmp b/etc/pong_bot.tmp index fb8052e..24f391b 100644 --- a/etc/pong_bot.tmp +++ b/etc/pong_bot.tmp @@ -7,8 +7,12 @@ Description=PONG-BOT After=network.target [Service] +Type=simple +User=pi +Group=pi WorkingDirectory=/dir/ ExecStart=/usr/bin/bash python3 pong_bot.py +ExecStop=/usr/bin/bash pkill -f pong_bot.py # Disable Python's buffering of STDOUT and STDERR, so that output from the # service shows up immediately in systemd's logs diff --git a/install.sh b/install.sh index d6d5f86..689bddc 100755 --- a/install.sh +++ b/install.sh @@ -62,6 +62,10 @@ if [ $venv == "y" ]; then sed -i $replace etc/mesh_bot.service replace="python3 pong_bot.py|/dir/launch.sh pong" sed -i $replace etc/pong_bot.service + replace="pkill -f mesh_bot.py|pkill -f launch.sh" + sed -i $replace etc/mesh_bot.service + replace="pkill -f pong_bot.py|pkill -f launch.sh" + sed -i $replace etc/pong_bot.service # install dependencies pip install -U -r requirements.txt @@ -86,9 +90,15 @@ read bot program_path=$(pwd) cp etc/pong_bot.tmp etc/pong_bot.service cp etc/mesh_bot.tmp etc/mesh_bot.service +# set the correct path in the service file replace="s|/dir/|$program_path/|g" sed -i $replace etc/pong_bot.service sed -i $replace etc/mesh_bot.service +# set the correct user in the service file? +whoami=$(whoami) +replace="s|user=pi|user=$whoami|g" +sed -i $replace etc/pong_bot.service +sed -i $replace etc/mesh_bot.service printf "\n service files updated\n" # ask if emoji font should be installed for linux