cleanupPartOne

I hope I didnt break a lot of things!
This commit is contained in:
SpudGunMan
2025-10-23 13:46:36 -07:00
parent 13875b7cf8
commit c87db75f2f
4 changed files with 33 additions and 33 deletions
+19 -19
View File
@@ -78,9 +78,9 @@ fi
# add user to groups for serial access
printf "\nAdding user to dialout, bluetooth, and tty groups for serial access\n"
sudo usermod -a -G dialout $USER
sudo usermod -a -G tty $USER
sudo usermod -a -G bluetooth $USER
sudo usermod -a -G dialout "$USER"
sudo usermod -a -G tty "$USER"
sudo usermod -a -G bluetooth "$USER"
# copy service files
cp etc/pong_bot.tmp etc/pong_bot.service
@@ -186,10 +186,10 @@ fi
# 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
sed -i $replace etc/mesh_bot_reporting.service
sed -i $replace etc/mesh_bot_w3.service
sed -i "$replace" etc/pong_bot.service
sed -i "$replace" etc/mesh_bot.service
sed -i "$replace" etc/mesh_bot_reporting.service
sed -i "$replace" etc/mesh_bot_w3.service
# set the correct user in the service file?
#ask if we should add a user for the bot
@@ -209,9 +209,9 @@ else
whoami=$(whoami)
fi
# set basic permissions for the bot user
sudo usermod -a -G dialout $whoami
sudo usermod -a -G tty $whoami
sudo usermod -a -G bluetooth $whoami
sudo usermod -a -G dialout "$whoami"
sudo usermod -a -G tty "$whoami"
sudo usermod -a -G bluetooth "$whoami"
echo "Added user $whoami to dialout, tty, and bluetooth groups"
sudo chown -R "$whoami:$whoami" "$program_path/logs"
@@ -227,15 +227,15 @@ fi
# set the correct user in the service file
replace="s|User=pi|User=$whoami|g"
sed -i $replace etc/pong_bot.service
sed -i $replace etc/mesh_bot.service
sed -i $replace etc/mesh_bot_reporting.service
sed -i $replace etc/mesh_bot_w3.service
sed -i "$replace" etc/pong_bot.service
sed -i "$replace" etc/mesh_bot.service
sed -i "$replace" etc/mesh_bot_reporting.service
sed -i "$replace" etc/mesh_bot_w3.service
replace="s|Group=pi|Group=$whoami|g"
sed -i $replace etc/pong_bot.service
sed -i $replace etc/mesh_bot.service
sed -i $replace etc/mesh_bot_reporting.service
sed -i $replace etc/mesh_bot_w3.service
sed -i "$replace" etc/pong_bot.service
sed -i "$replace" etc/mesh_bot.service
sed -i "$replace" etc/mesh_bot_reporting.service
sed -i "$replace" etc/mesh_bot_w3.service
printf "\n service files updated\n"
if [[ $(echo "${bot}" | grep -i "^p") ]]; then
@@ -355,7 +355,7 @@ else
else
printf "\nCron job already exists, skipping\n"
fi
printf "Reference following commands:\n\n" "$service" > install_notes.txt
printf "Reference following commands:\n\n" > install_notes.txt
printf "sudo systemctl status %s.service\n" "$service" >> install_notes.txt
printf "sudo systemctl start %s.service\n" "$service" >> install_notes.txt
printf "sudo systemctl restart %s.service\n\n" "$service" >> install_notes.txt
+4 -4
View File
@@ -5,12 +5,12 @@
cd "$(dirname "$0")"
if [ ! -f "config.ini" ]; then
if [[ ! -f "config.ini" ]]; then
cp config.template config.ini
fi
# activate the virtual environment if it exists
if [ -d "venv" ]; then
if [[ -d "venv" ]]; then
source venv/bin/activate
else
echo "Virtual environment not found, this tool just launches the .py in venv"
@@ -22,9 +22,9 @@ if [[ "$1" == pong* ]]; then
python3 pong_bot.py
elif [[ "$1" == mesh* ]]; then
python3 mesh_bot.py
elif [ "$1" == "html" ]; then
elif [[ "$1" == "html" ]]; then
python3 etc/report_generator.py
elif [ "$1" == "html5" ]; then
elif [[ "$1" == "html5" ]]; then
python3 etc/report_generator5.py
elif [[ "$1" == add* ]]; then
python3 script/addFav.py
+7 -6
View File
@@ -254,12 +254,12 @@ def handle_ping(message_from_id, deviceID, message, hop, snr, rssi, isDM, chann
# append SNR/RSSI or hop info
if hop.startswith("Gateway") or hop.startswith("MQTT"):
msg += f" [GW]"
msg += " [GW]"
elif hop.startswith("Direct"):
msg += f" [RF]"
msg += " [RF]"
else:
#flood
msg += f" [F]"
msg += " [F]"
if (float(snr) != 0 or float(rssi) != 0) and "Hops" not in hop:
msg += f"\nSNR:{snr} RSSI:{rssi}"
@@ -528,7 +528,8 @@ def handle_satpass(message_from_id, deviceID, message='', vox=False):
userList = message.split("satpass ")[1].split(" ")[0]
#split userList and make into satList overrided the config.ini satList
satList = userList.split(",")
except:
except Exception as e:
logger.error(f"Exception occurred: {e}")
return "example use:🛰️satpass 25544,33591"
# Detailed satellite pass
@@ -905,8 +906,8 @@ def handleGolf(message, nodeID, deviceID):
if last_cmd == "new" and nodeID != 0:
# create new player
msg = f"Welcome to 🏌️GolfSim⛳️\n"
msg += f"Clubs: (D)river, (L)ow Iron, (M)id Iron, (H)igh Iron, (G)ap Wedge, Lob (W)edge (C)addie\n"
msg = "Welcome to 🏌️GolfSim⛳️\n"
msg += "Clubs: (D)river, (L)ow Iron, (M)id Iron, (H)igh Iron, (G)ap Wedge, Lob (W)edge (C)addie\n"
msg += playGolf(nodeID=nodeID, message=message, last_cmd=last_cmd)
return msg
+3 -4
View File
@@ -56,7 +56,7 @@ echo "Backing up data/ directory..."
backup_file="data_backup.tar.gz"
path2backup="data/"
#copy custom_scheduler.py if it exists
if [ -f "modules/custom_scheduler.py" ]; then
if [[ -f "modules/custom_scheduler.py" ]]; then
echo "Including custom_scheduler.py in backup..."
cp modules/custom_scheduler.py data/
fi
@@ -71,8 +71,7 @@ fi
# Build a config_new.ini file merging user config with new defaults
echo "Merging configuration files..."
python3 script/configMerge.py > ini_merge_log.txt 2>&1
if [ -f ini_merge_log.txt ]; then
if [[ -f ini_merge_log.txt ]]; then
if grep -q "Error during configuration merge" ini_merge_log.txt; then
echo "Configuration merge encountered errors. Please check ini_merge_log.txt for details."
else
@@ -83,7 +82,7 @@ else
fi
# if service was stopped earlier, restart it
if [ "$service_stopped" = true ]; then
if [[ "$service_stopped" = true ]]; then
echo "Restarting services..."
systemctl start mesh_bot.service
systemctl start pong_bot.service