Merge pull request #151 from noon92/working

Changed ownership of /opt/TC2-BBS-mesh
This commit is contained in:
noon92 2025-01-07 19:21:27 +02:00 • committed by GitHub
commit b961fe0d58
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 31 additions and 113 deletions

View file

@ -0,0 +1,28 @@
#!/bin/bash
# Check if the filesystem has been resized previously
if [ ! -f /etc/.filesystem_resized ]; then
# Perform filesystem resize
resize2fs /dev/mmcblk1p5
resize2fs /dev/mmcblk1p6
echo "Resizing /dev/mmcblk1p7 can take up to 10 minutes, depending on microSD card size and speed."
resize2fs /dev/mmcblk1p7
# Create a marker file indicating filesystem resize has been done
touch /etc/.filesystem_resized
echo "Filesystem resized successfully."
fi
if [ ! -f /etc/.filesystem_swap ]; then
fallocate -l 1G /swapfile
chmod 600 /swapfile
mkswap /swapfile > /dev/null
swapon /swapfile > /dev/null
echo '/swapfile none swap sw 0 0' | tee -a /etc/fstab > /dev/null
touch /etc/.filesystem_swap
echo "Swap successfully."
fi

View file

@ -1,112 +0,0 @@
while true; do
title="Software"
option=""
option=$(dialog --cancel-label "Back" --menu "$title" 0 0 6 \
1 "Meshing Around by Spud" \
2 "The Comms Channel BBS, TC2BBS" \
3 "Curses Client for Meshtastic" \
4 "Mosquitto MQTT broker" \
5 "GPS and Telemetry" \
"" ""\
6 "Back to Main Menu" 3>&1 1>&2 2>&3)
exit_status=$? # This line checks the exit status of the dialog command
if [ $exit_status -ne 0 ]; then # Exit the loop if the user selects "Cancel" or closes the dialog
break
fi
case $option in
1) #Install Meshing Around)
#check if /opt/meshing-around exists if not git clone
if [ ! -d /opt/meshing-around ]; then
dialog --title "$software" --yesno "Meshing Around is a feature-rich bot designed to enhance your Meshtastic network experience with a variety of powerful tools and fun features\nConnectivity and utility through text-based message delivery.\nWhether you're looking to perform network tests, send messages, or even play games, mesh_bot.py has you covered.\nInstallation requires internet connection.\n\nLearn more at https://github.com/SpudGunMan/meshing-around\n\nInstall?" 0 0
if [ $? -eq 0 ]; then #unless cancel/no
if ! git clone https://github.com/spudgunman/meshing-around /opt/meshing-around; then
dialog --title "$software" --msgbox "\nCloning of Meshing Around git repo failed.\nCheck internet connectivity." 10 60
failedInstall=true
fi
fi
else
# /opt/meshing-around exists, check for updates
cd /opt/meshing-around
if ! sudo git pull; then
dialog --title "$software" --msgbox "\nFailed to update Meshing Around.\nCheck internet connectivity." 10 60
failedInstall=true
fi
# check if /opt/meshing-around/data has any .pkl files if so assume it's installed
if [ -n "$(find /opt/meshing-around/data -name '*.pkl' -print -quit)" ]; then
# todo uninstall?
dialog --title "$software" --yesno "Meshing Around appears installed and updated, do you want to edit the config file? (press ctl+o,enter to save, ctl+x to exit nano)" 0 0
if [ $? -eq 0 ]; then #unless cancel/no
sudo nano /opt/meshing-around/config.ini
fi
# set flag to not run install.sh
installed=true
echo "Restarting services..."
sudo systemctl restart mesh_bot
sudo systemctl restart pong_bot
fi
fi
# if /opt/meshing-around exists
if [ -f /opt/meshing-around/install.sh ] && [ "$installed" != true ] && [ "$failedInstall" != true ]; then
# ask what type of bot mesh or pong
dialog --title "$software" --yesno "Meshing Around can be configured to run as mesh_bot or pong_bot.\n\nRun mesh_bot?" 0 0
if [ $? -eq 0 ]; then #unless cancel/no
/opt/meshing-around/install.sh mesh
dialog --title "$software" --yesno "Would you like to edit the config file? (press ctl+o,enter to save, ctl+x to exit nano)" 0 0
if [ $? -eq 0 ]; then #unless cancel/no
sudo nano /opt/meshing-around/config.ini
echo "Restarting services..."
sudo systemctl restart mesh_bot
fi
# finished. display the contents of install_notes.txt
dialog --title "$software" --textbox /opt/meshing-around/install_notes.txt 20 60
else
/opt/meshing-around/install.sh pong
dialog --title "$software" --yesno "Would you like to edit the config file? (press ctl+o,enter to save, ctl+x to exit nano)" 0 0
if [ $? -eq 0 ]; then #unless cancel/no
sudo nano /opt/meshing-around/config.ini
echo "Restarting services..."
sudo systemctl restart pong_bot
fi
# finished. display the contents of install_notes.txt
dialog --title "$software" --textbox /opt/meshing-around/install_notes.txt 20 60
fi
fi
;;
2) #Install TC2BBS)
if git clone https://github.com/TheCommsChannel/TC2-BBS-mesh.git /opt/TC2-BBS-mesh; then
/opt/TC2-BBS-mesh/install.sh #install script
# config the TC2-BBS to localhost tcp TODO
dialog --title "$software" --msgbox "\nInstallation complete.\n\nRun \`sudo nano /opt/TC2-BBS-mesh/config.ini\` to configure." 10 60
else
dialog --title "$software" --msgbox "\nCloning of TC2-BBS git repo failed.\nCheck internet connectivity." 10 60
fi
;;
3) #Install curses client)
git clone https://github.com/pdxlocations/curses-client-for-meshtastic.git /opt/curses-client-for-meshtastic
ln -s /opt/curses-client-for-meshtastic/meshtastic-curses.py ~/meshtastic-curses.py
# config the curses client to localhost tcp TODO, permissions?
dialog --title "$software" --msgbox "\nInstallation complete.\n\nRun \`~/meshtastic-curses.py\` to launch." 10 60
;;
4) #Install mosquitto)
apt update
DEBIAN_FRONTEND=noninteractive apt install -y --option Dpkg::Options::="--force-confold" mosquitto mosquitto-clients
# config mosquitto to listen on all interfaces and allow anonymous
sudo sh -c "echo 'listener 1883 0.0.0.0\nallow_anonymous true' >> /etc/mosquitto/mosquitto.conf"
sudo systemctl restart mosquitto
dialog --title "$software" --msgbox "\nInstallation complete.\n\nMosquitto." 10 60
;;
5) #Install gpsd)
apt update
DEBIAN_FRONTEND=noninteractive apt install -y --option Dpkg::Options::="--force-confold" gpsd gpsd-clients python-gps
# do stuff TODO config gpsd and chrony
# telemetry script
sudo systemctl restart gpsd
dialog --title "$software" --msgbox "\nInstallation complete.\n\nGPSD." 10 60
;;
6)
break
;;
esac
done

View file

@ -64,7 +64,6 @@ meshing_around() { # Install Meshing Around
tc2_bbs() { # Install TC²BBS
failedInstall=false
dialog --title "$software" --yesno "The TC²-BBS system integrates with Meshtastic devices. The system allows for message handling, bulletin boards, mail systems, and a channel directory.\nInstallation requires internet connection.\n\nLearn more at https://github.com/TheCommsChannel/TC2-BBS-mesh\nIf software is already present, will attempt to update.\n\nInstall?" 0 0
if [ ! -d /opt/TC2-BBS-mesh ]; then
if [ $? -eq 0 ]; then #unless cancel/no
@ -72,6 +71,8 @@ tc2_bbs() { # Install TC²BBS
dialog --title "$software" --msgbox "\nCloning of TC²-BBS git repo failed.\nCheck internet connectivity." 10 60
return
fi
chown -R femto /opt/TC2-BBS-mesh
git config --global --add safe.directory /opt/TC2-BBS-mesh # prevents git error when updating
else
return
fi
@ -95,6 +96,7 @@ tc2_bbs() { # Install TC²BBS
fi
dialog --title "$software" --yesno "Installation/upgrade successful! \n\nInstall service?\n\nIn Linux, services automatically start on boot and restart if the software stops for any reason." 0 0
if [ $? -eq 0 ]; then #unless cancel/no
cd /opt/TC2-BBS-mesh
source venv/bin/activate
sed -i "s/pi/${SUDO_USER:-$(whoami)}/g" mesh-bbs.service
sed -i "s|/home/femto/|/opt/|g" mesh-bbs.service