diff --git a/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/femto-config b/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/femto-config index b03459c..311b2c8 100755 --- a/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/femto-config +++ b/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/femto-config @@ -39,7 +39,7 @@ wifi_config() { local wifi_country="" wifi_ssid=$(dialog --title "$title2" --inputbox "Enter Wi-Fi SSID:" 8 40 "$(grep -oP '^ *ssid="\K[^"]+' /etc/wpa_supplicant/wpa_supplicant.conf)" 3>&1 1>&2 2>&3) # display current SSID wifi_psk=$(dialog --title "$title2" --inputbox "Enter Wi-Fi Password:" 8 40 3>&1 1>&2 2>&3) - wifi_country=$(dialog --title "$title2" --inputbox "Enter Country Code (US, DE...):" 9 40 "$(grep -oP '^ *country=\K[^ ]+' /etc/wpa_supplicant/wpa_supplicant.conf)" 3>&1 1>&2 2>&3) # display current country + wifi_country=$(dialog --title "$title2" --inputbox "Enter Country Code (US, DE...):" 8 40 "$(grep -oP '^ *country=\K[^ ]+' /etc/wpa_supplicant/wpa_supplicant.conf)" 3>&1 1>&2 2>&3) # display current country cmd="femto-network-config.sh -s \"$wifi_ssid\" -p \"$wifi_psk\"" [ -n "$wifi_country" ] && cmd="$cmd -c \"$wifi_country\"" cmd="$cmd -r" @@ -459,8 +459,15 @@ help_menu() { } # Parse options -while getopts ":lw" opt; do +while getopts ":hlw" opt; do case ${opt} in + h) + echo -e "If script is run without arguments, the main femto-config UI will load.\n\ +Options are:\n\ +-h This message\n\ +-l Set LoRa radio model menu\n\ +-w Set Wi-Fi config menu" + ;; l) # Option -l (set lora radio) set_lora_radio ;; @@ -494,7 +501,7 @@ while true; do 1) femto-install-wizard.sh ;; 2) networking_settings ;; 3) meshtasticd_settings ;; - 4) femto-software-menu.sh ;; + 4) femto-software.sh ;; 5) utilities ;; 6) help_menu ;; 7) break ;; diff --git a/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/femto-install-wizard.sh b/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/femto-install-wizard.sh index f06e954..861603c 100755 --- a/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/femto-install-wizard.sh +++ b/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/femto-install-wizard.sh @@ -45,7 +45,7 @@ wizard() { femto-config -l - key=$(dialog --title "$title" --cancel-label "Skip" --inputbox "Enter Meshtastic admin key (optional). If 3 admin keys are already in Meshtastic, more will be ignored.\n(SHIFT+INS to paste):" 8 50 3>&1 1>&2 2>&3) + key=$(dialog --title "$title" --cancel-label "Skip" --inputbox "Enter Meshtastic admin key (optional). If 3 admin keys are already in Meshtastic, more will be ignored.\n(SHIFT+INS to paste):" 11 50 3>&1 1>&2 2>&3) if [ -n "$key" ]; then #if a URL was entered femto-meshtasticd-config.sh -a "$key" pause diff --git a/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/femto-software.sh b/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/femto-software.sh new file mode 100644 index 0000000..9c0ccc1 --- /dev/null +++ b/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/femto-software.sh @@ -0,0 +1,197 @@ +#!/bin/bash + +uninstall="false" + +meshing_around() { # Install Meshing Around + failedInstall=false + #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\nIf software is already present, will attempt to update.\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+s save, ctl+x to exit editor)" 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+s save, ctl+x to exit editor)" 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 +} + + +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 + if ! git clone https://github.com/TheCommsChannel/TC2-BBS-mesh.git /opt/TC2-BBS-mesh; then + dialog --title "$software" --msgbox "\nCloning of TC²-BBS git repo failed.\nCheck internet connectivity." 10 60 + return + fi + else + return + fi + else + # /opt/meshing-around exists, check for updates + cd /opt/TC2-BBS-mesh + if ! sudo git pull; then + dialog --title "$software" --msgbox "\nFailed to update TC²-BBS.\nCheck internet connectivity." 10 60 + return + fi + fi + if [ ! -f /opt/TC2-BBS-mesh/config.ini ]; then # if the config file doesn't exist but the clone was successful, then we need to do some configuring and rejiggering + cd /opt/TC2-BBS-mesh + echo "Creating virtual environment. This can take a couple minutes." + python3 -m venv venv + source venv/bin/activate + pip install -r requirements.txt + mv example_config.ini config.ini + sed -i 's/type = serial/type = tcp/' config.ini + sed -i 's/^# hostname = 192.168.x.x/hostname = 127.0.0.1/' config.ini + 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 + 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 + cp mesh-bbs.service /etc/systemd/system/ + sudo systemctl enable mesh-bbs.service + sudo systemctl restart mesh-bbs.service + echo -e "Waiting for service to start...\n" + sleep 7 + systemctl status mesh-bbs.service + echo "\nPress any key to continue..." + read -n 1 -s -r + fi +} + + +curses_client() { # 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 +} + + +mosquitto() { # 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 +} + + +gpsd() { # 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 +} + + +help=$(cat <&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) meshing_around ;; + 2) tc2_bbs ;; + 3) curses_client ;; + 4) mosquitto ;; + 5) gpsd ;; + 6) break ;; + esac +done + +exit 0 \ No newline at end of file