mirror of
https://github.com/femtofox/femtofox.git
synced 2026-11-28 19:06:44 -05:00
commit
121dcd6e4f
20 changed files with 964 additions and 455 deletions
|
|
@ -9,25 +9,21 @@ echo "tmpfs /run tmpfs rw,nodev,nosuid,size=32M 0 0" | tee -a /etc/fstab
|
|||
#echo "deb [arch=all signed-by=/etc/apt/keyrings/meshtastic-deb.asc] https://meshtastic.github.io/deb stable main" | tee /etc/apt/sources.list.d/meshtastic-deb.list >/dev/null
|
||||
|
||||
echo "Removing netdevice rules..."
|
||||
|
||||
ln -s /dev/null /etc/udev/rules.d/80-net-setup-link.rules
|
||||
|
||||
echo "Setting up kernel modules..."
|
||||
|
||||
touch /lib/modules/5.10.160/modules.order
|
||||
touch /lib/modules/5.10.160/modules.builtin
|
||||
depmod -a 5.10.160
|
||||
if [[ $? -eq 2 ]]; then echo "Error, step failed..."; fi
|
||||
|
||||
echo "Setting localtime to UTC..."
|
||||
|
||||
rm /etc/localtime
|
||||
ln -sf /usr/share/zoneinfo/UTC /etc/localtime
|
||||
|
||||
echo "Installing packages..."
|
||||
|
||||
apt update
|
||||
DEBIAN_FRONTEND=noninteractive apt install -y --option Dpkg::Options::="--force-confold" linux-firmware wireless-tools git python3.10-venv libgpiod-dev libyaml-cpp-dev libbluetooth-dev openssl libssl-dev libulfius-dev liborcania-dev evtest screen avahi-daemon protobuf-compiler telnet fonts-noto-color-emoji ninja-build chrony qrencode software-properties-common python-is-python3 python3.10-venv lsof spi-tools python3-luma.oled
|
||||
DEBIAN_FRONTEND=noninteractive apt install -y --option Dpkg::Options::="--force-confold" linux-firmware wireless-tools git python3.10-venv libgpiod-dev libyaml-cpp-dev libbluetooth-dev openssl libssl-dev libulfius-dev liborcania-dev evtest screen avahi-daemon protobuf-compiler telnet fonts-noto-color-emoji ninja-build chrony qrencode software-properties-common python-is-python3 python3.10-venv lsof spi-tools python3-luma.oled samba
|
||||
if [[ $? -eq 2 ]]; then echo "Error, step failed..."; fi
|
||||
DEBIAN_FRONTEND=noninteractive apt upgrade -y --option Dpkg::Options::="--force-confold"
|
||||
|
||||
|
|
@ -42,16 +38,13 @@ pip3 install requests pyephem pytap2 meshtastic pypubsub geopy maidenhead beauti
|
|||
if [[ $? -eq 2 ]]; then echo "Error, step failed..."; fi
|
||||
|
||||
echo "Setting MOTD..."
|
||||
|
||||
mv /etc/update-motd.d/10-help-text /etc/update-motd.d/10-help-text.bak
|
||||
mv /etc/update-motd.d/60-unminimize /etc/update-motd.d/60-unminimize.bak
|
||||
|
||||
echo "Setting hostname to femtofox..."
|
||||
|
||||
echo "femtofox" | tee /etc/hostname > /dev/null
|
||||
|
||||
echo "Configuring autostart of systemd services..."
|
||||
|
||||
systemctl enable button
|
||||
systemctl enable meshtasticd
|
||||
systemctl enable femto-runonce.service
|
||||
|
|
@ -59,6 +52,8 @@ systemctl enable femto-usb-config-tool.service
|
|||
systemctl enable femto-boot-complete.service
|
||||
systemctl enable wifi-mesh-control
|
||||
|
||||
systemctl disable unattended-upgrades
|
||||
systemctl disable smbd nmbd # samba services, can be enabled via menu
|
||||
systemctl disable NetworkManager
|
||||
systemctl disable NetworkManager-dispatcher
|
||||
systemctl disable NetworkManager-wait-online
|
||||
|
|
@ -77,7 +72,6 @@ systemctl disable veritysetup.target
|
|||
systemctl disable systemd-pstore.service
|
||||
|
||||
echo "Adding femto and pico users/groups..."
|
||||
|
||||
groupmod -n femto pico
|
||||
usermod -l femto pico
|
||||
usermod -aG sudo,input femto
|
||||
|
|
@ -85,7 +79,6 @@ echo "femto ALL=(ALL:ALL) ALL" | tee /etc/sudoers.d/femto > /dev/null
|
|||
chmod 440 /etc/sudoers.d/femto
|
||||
|
||||
# this seems messy, user:group should be set cleanly and not corrected after? OSC: somethings were owned my pico from factory
|
||||
|
||||
find / -group pico -exec chgrp femto {} \; 2>/dev/null
|
||||
find / -user pico -exec chown femto {} \; 2>/dev/null
|
||||
usermod -d /home/femto -m femto
|
||||
|
|
@ -96,6 +89,5 @@ usermod -a -G tty femto
|
|||
usermod -a -G dialout femto
|
||||
|
||||
echo "Cleaning up chroot..."
|
||||
|
||||
apt clean && rm -rf /var/lib/apt/lists/* && rm -rf /tmp/* && rm -rf /var/tmp/* && find /var/log -type f -exec truncate -s 0 {} + && : > /root/.bash_history && history -c
|
||||
exit
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@
|
|||
# /usr/local/bin/femto-runonce.sh
|
||||
#fi
|
||||
|
||||
luckfox-config load
|
||||
#luckfox-config load
|
||||
|
||||
# try enable RTC
|
||||
echo 'ds1307 0x68' | sudo tee /sys/class/i2c-adapter/i2c-3/new_device > /dev/null 2>&1
|
||||
|
|
|
|||
|
|
@ -0,0 +1,2 @@
|
|||
APT::Periodic::Update-Package-Lists "0";
|
||||
APT::Periodic::Unattended-Upgrade "0";
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
major=0
|
||||
minor=97
|
||||
patch=5
|
||||
minor=98
|
||||
patch=0
|
||||
hotfix=
|
||||
|
||||
# major, minor and patch must be numbers and populated. hotfix must be letters and can be blank.
|
||||
|
|
|
|||
253
foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/etc/samba/smb.conf
Normal file
253
foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/etc/samba/smb.conf
Normal file
|
|
@ -0,0 +1,253 @@
|
|||
#
|
||||
# Sample configuration file for the Samba suite for Debian GNU/Linux.
|
||||
#
|
||||
#
|
||||
# This is the main Samba configuration file. You should read the
|
||||
# smb.conf(5) manual page in order to understand the options listed
|
||||
# here. Samba has a huge number of configurable options most of which
|
||||
# are not shown in this example
|
||||
#
|
||||
# Some options that are often worth tuning have been included as
|
||||
# commented-out examples in this file.
|
||||
# - When such options are commented with ";", the proposed setting
|
||||
# differs from the default Samba behaviour
|
||||
# - When commented with "#", the proposed setting is the default
|
||||
# behaviour of Samba but the option is considered important
|
||||
# enough to be mentioned here
|
||||
#
|
||||
# NOTE: Whenever you modify this file you should run the command
|
||||
# "testparm" to check that you have not made any basic syntactic
|
||||
# errors.
|
||||
|
||||
#======================= Global Settings =======================
|
||||
|
||||
[global]
|
||||
|
||||
## Browsing/Identification ###
|
||||
|
||||
# Change this to the workgroup/NT-domain name your Samba server will part of
|
||||
workgroup = WORKGROUP
|
||||
|
||||
# server string is the equivalent of the NT Description field
|
||||
server string = %h server (Samba, Ubuntu)
|
||||
|
||||
#### Networking ####
|
||||
|
||||
# The specific set of interfaces / networks to bind to
|
||||
# This can be either the interface name or an IP address/netmask;
|
||||
# interface names are normally preferred
|
||||
; interfaces = 127.0.0.0/8 eth0
|
||||
|
||||
# Only bind to the named interfaces and/or networks; you must use the
|
||||
# 'interfaces' option above to use this.
|
||||
# It is recommended that you enable this feature if your Samba machine is
|
||||
# not protected by a firewall or is a firewall itself. However, this
|
||||
# option cannot handle dynamic or non-broadcast interfaces correctly.
|
||||
; bind interfaces only = yes
|
||||
|
||||
|
||||
|
||||
#### Debugging/Accounting ####
|
||||
|
||||
# This tells Samba to use a separate log file for each machine
|
||||
# that connects
|
||||
log file = /var/log/samba/log.%m
|
||||
|
||||
# Cap the size of the individual log files (in KiB).
|
||||
max log size = 1000
|
||||
|
||||
# We want Samba to only log to /var/log/samba/log.{smbd,nmbd}.
|
||||
# Append syslog@1 if you want important messages to be sent to syslog too.
|
||||
logging = file
|
||||
|
||||
# For more verbose logging:
|
||||
; log level = 3
|
||||
|
||||
# Do something sensible when Samba crashes: mail the admin a backtrace
|
||||
panic action = /usr/share/samba/panic-action %d
|
||||
|
||||
|
||||
####### Authentication #######
|
||||
|
||||
# Server role. Defines in which mode Samba will operate. Possible
|
||||
# values are "standalone server", "member server", "classic primary
|
||||
# domain controller", "classic backup domain controller", "active
|
||||
# directory domain controller".
|
||||
#
|
||||
# Most people will want "standalone server" or "member server".
|
||||
# Running as "active directory domain controller" will require first
|
||||
# running "samba-tool domain provision" to wipe databases and create a
|
||||
# new domain.
|
||||
server role = standalone server
|
||||
|
||||
obey pam restrictions = yes
|
||||
|
||||
# This boolean parameter controls whether Samba attempts to sync the Unix
|
||||
# password with the SMB password when the encrypted SMB password in the
|
||||
# passdb is changed.
|
||||
unix password sync = yes
|
||||
|
||||
# For Unix password sync to work on a Debian GNU/Linux system, the following
|
||||
# parameters must be set (thanks to Ian Kahan <<kahan@informatik.tu-muenchen.de> for
|
||||
# sending the correct chat script for the passwd program in Debian Sarge).
|
||||
passwd program = /usr/bin/passwd %u
|
||||
passwd chat = *Enter\snew\s*\spassword:* %n\n *Retype\snew\s*\spassword:* %n\n *password\supdated\ssuccessfully* .
|
||||
|
||||
# This boolean controls whether PAM will be used for password changes
|
||||
# when requested by an SMB client instead of the program listed in
|
||||
# 'passwd program'. The default is 'no'.
|
||||
pam password change = yes
|
||||
|
||||
# This option controls how unsuccessful authentication attempts are mapped
|
||||
# to anonymous connections
|
||||
map to guest = bad user
|
||||
|
||||
########## Domains ###########
|
||||
|
||||
#
|
||||
# The following settings only takes effect if 'server role = classic
|
||||
# primary domain controller', 'server role = classic backup domain controller'
|
||||
# or 'domain logons' is set
|
||||
#
|
||||
|
||||
# It specifies the location of the user's
|
||||
# profile directory from the client point of view) The following
|
||||
# required a [profiles] share to be setup on the samba server (see
|
||||
# below)
|
||||
; logon path = \\%N\profiles\%U
|
||||
# Another common choice is storing the profile in the user's home directory
|
||||
# (this is Samba's default)
|
||||
# logon path = \\%N\%U\profile
|
||||
|
||||
# The following setting only takes effect if 'domain logons' is set
|
||||
# It specifies the location of a user's home directory (from the client
|
||||
# point of view)
|
||||
; logon drive = H:
|
||||
# logon home = \\%N\%U
|
||||
|
||||
# The following setting only takes effect if 'domain logons' is set
|
||||
# It specifies the script to run during logon. The script must be stored
|
||||
# in the [netlogon] share
|
||||
# NOTE: Must be store in 'DOS' file format convention
|
||||
; logon script = logon.cmd
|
||||
|
||||
# This allows Unix users to be created on the domain controller via the SAMR
|
||||
# RPC pipe. The example command creates a user account with a disabled Unix
|
||||
# password; please adapt to your needs
|
||||
; add user script = /usr/sbin/adduser --quiet --disabled-password --gecos "" %u
|
||||
|
||||
# This allows machine accounts to be created on the domain controller via the
|
||||
# SAMR RPC pipe.
|
||||
# The following assumes a "machines" group exists on the system
|
||||
; add machine script = /usr/sbin/useradd -g machines -c "%u machine account" -d /var/lib/samba -s /bin/false %u
|
||||
|
||||
# This allows Unix groups to be created on the domain controller via the SAMR
|
||||
# RPC pipe.
|
||||
; add group script = /usr/sbin/addgroup --force-badname %g
|
||||
|
||||
############ Misc ############
|
||||
|
||||
# Using the following line enables you to customise your configuration
|
||||
# on a per machine basis. The %m gets replaced with the netbios name
|
||||
# of the machine that is connecting
|
||||
; include = /home/samba/etc/smb.conf.%m
|
||||
|
||||
# Some defaults for winbind (make sure you're not using the ranges
|
||||
# for something else.)
|
||||
; idmap config * : backend = tdb
|
||||
; idmap config * : range = 3000-7999
|
||||
; idmap config YOURDOMAINHERE : backend = tdb
|
||||
; idmap config YOURDOMAINHERE : range = 100000-999999
|
||||
; template shell = /bin/bash
|
||||
|
||||
# Setup usershare options to enable non-root users to share folders
|
||||
# with the net usershare command.
|
||||
|
||||
# Maximum number of usershare. 0 means that usershare is disabled.
|
||||
# usershare max shares = 100
|
||||
|
||||
# Allow users who've been granted usershare privileges to create
|
||||
# public shares, not just authenticated ones
|
||||
usershare allow guests = yes
|
||||
|
||||
#======================= Share Definitions =======================
|
||||
|
||||
# Un-comment the following (and tweak the other settings below to suit)
|
||||
# to enable the default home directory shares. This will share each
|
||||
# user's home directory as \\server\username
|
||||
;[homes]
|
||||
; comment = Home Directories
|
||||
; browseable = no
|
||||
|
||||
# By default, the home directories are exported read-only. Change the
|
||||
# next parameter to 'no' if you want to be able to write to them.
|
||||
; read only = yes
|
||||
|
||||
# File creation mask is set to 0700 for security reasons. If you want to
|
||||
# create files with group=rw permissions, set next parameter to 0775.
|
||||
; create mask = 0700
|
||||
|
||||
# Directory creation mask is set to 0700 for security reasons. If you want to
|
||||
# create dirs. with group=rw permissions, set next parameter to 0775.
|
||||
; directory mask = 0700
|
||||
|
||||
# By default, \\server\username shares can be connected to by anyone
|
||||
# with access to the samba server.
|
||||
# Un-comment the following parameter to make sure that only "username"
|
||||
# can connect to \\server\username
|
||||
# This might need tweaking when using external authentication schemes
|
||||
; valid users = %S
|
||||
|
||||
# Un-comment the following and create the netlogon directory for Domain Logons
|
||||
# (you need to configure Samba to act as a domain controller too.)
|
||||
;[netlogon]
|
||||
; comment = Network Logon Service
|
||||
; path = /home/samba/netlogon
|
||||
; guest ok = yes
|
||||
; read only = yes
|
||||
|
||||
# Un-comment the following and create the profiles directory to store
|
||||
# users profiles (see the "logon path" option above)
|
||||
# (you need to configure Samba to act as a domain controller too.)
|
||||
# The path below should be writable by all users so that their
|
||||
# profile directory may be created the first time they log on
|
||||
;[profiles]
|
||||
; comment = Users profiles
|
||||
; path = /home/samba/profiles
|
||||
; guest ok = no
|
||||
; browseable = no
|
||||
; create mask = 0600
|
||||
; directory mask = 0700
|
||||
|
||||
[printers]
|
||||
comment = All Printers
|
||||
browseable = no
|
||||
path = /var/spool/samba
|
||||
printable = yes
|
||||
guest ok = no
|
||||
read only = yes
|
||||
create mask = 0700
|
||||
|
||||
# Windows clients look for this share name as a source of downloadable
|
||||
# printer drivers
|
||||
[print$]
|
||||
comment = Printer Drivers
|
||||
path = /var/lib/samba/printers
|
||||
browseable = yes
|
||||
read only = yes
|
||||
guest ok = no
|
||||
# Uncomment to allow remote administration of Windows print drivers.
|
||||
# You may need to replace 'lpadmin' with the name of the group your
|
||||
# admin users are members of.
|
||||
# Please note that you also need to set appropriate Unix permissions
|
||||
# to the drivers directory for these users to have write rights in it
|
||||
; write list = root, @lpadmin
|
||||
|
||||
[home]
|
||||
path = /home/femto
|
||||
browseable = yes
|
||||
writable = yes
|
||||
read only = no
|
||||
create mask = 0775
|
||||
directory mask = 0775
|
||||
valid users = femto
|
||||
30
foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/root/.dialogrc
Normal file
30
foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/root/.dialogrc
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
#
|
||||
# Run-time configuration file for dialog
|
||||
#
|
||||
# Automatically generated by "dialog --create-rc <file>"
|
||||
#
|
||||
#
|
||||
# Types of values:
|
||||
#
|
||||
# Number - <number>
|
||||
# String - "string"
|
||||
# Boolean - <ON|OFF>
|
||||
# Attribute - (foreground,background,highlight?,underline?,reverse?)
|
||||
|
||||
# Up arrow color
|
||||
uarrow_color = (GREEN,WHITE,ON)
|
||||
|
||||
# Down arrow color
|
||||
darrow_color = uarrow_color
|
||||
|
||||
# Active form text color
|
||||
form_active_text_color = button_active_color
|
||||
|
||||
# Form text color
|
||||
form_text_color = (WHITE,CYAN,ON)
|
||||
|
||||
# Readonly form item color
|
||||
form_item_readonly_color = (BLUE,WHITE,ON)
|
||||
|
||||
# Item help-text color
|
||||
itemhelp_color = (BLACK,BLUE,OFF)
|
||||
|
|
@ -37,21 +37,69 @@ loading() {
|
|||
dialog --no-collapse --infobox "$1" 5 45
|
||||
}
|
||||
|
||||
## function to pull data from various femto scripts and convert it to the contents of a read only dialog --form
|
||||
# ingest_data() { # usage: `ingest_data "command.sh -argument" key_width value_width`
|
||||
# unset output_array #debug code, delete me
|
||||
# declare -a output_array
|
||||
# # Read the output from femto-meshtasticd-config.sh and store it in the array
|
||||
# while IFS=':' read -r key value; do
|
||||
# # Trim leading/trailing spaces from key and value
|
||||
# key=$(echo "$key" | xargs)
|
||||
# value=$(echo "$value" | xargs)
|
||||
# output_array+=("$key=$value") # Use indexed array to preserve order
|
||||
# done < <(eval $1)
|
||||
# form_contents=""
|
||||
# i=1
|
||||
# for pair in "${output_array[@]}"; do
|
||||
# key=$(cut -d'=' -f1 <<< "$pair")
|
||||
# value=$(cut -d'=' -f2- <<< "$pair")
|
||||
# form_contents+="\"$key\" $i 1 \"$value\" $i $2 $3 -1 "
|
||||
# ((i++))
|
||||
# done
|
||||
# echo "$form_contents" | sed 's/\x1b\[[0-9;]*m//g'
|
||||
# }
|
||||
## CODE TO USE THIS FUNCTION:
|
||||
# eval "$(echo -e "dialog --no-collapse --no-cancel --form \"Meshtastic node info\" 0 0 0 $(ingest_data "femto-meshtasticd-config.sh -i" 18 0) 2>/dev/null")"
|
||||
|
||||
|
||||
# function to pull data from various femto scripts and convert it a simple text string, with dialog colors
|
||||
ingest_data() { # usage: `ingest_data "command.sh -argument" key_width`
|
||||
local output_string=""
|
||||
# Read the output from femto-meshtasticd-config.sh and store output_string
|
||||
while IFS=':' read -r key value; do
|
||||
# Trim leading/trailing spaces from key and value
|
||||
key=$(replace_colors "$(echo "$key" | xargs)")
|
||||
value=$(replace_colors "$(echo "$value" | xargs)")
|
||||
if [[ -z "$key" && -z "$value" ]]; then
|
||||
output_string+="---\n"
|
||||
else
|
||||
output_string+=$(printf "%s:%*s%s\n" "$key" $(($2 - 1 - ${#key})) "" "$value\n") # save the key and value to the output_string, adding padding between them as determined by `$2 - 1 - key-length` The 1 accounts for the :
|
||||
fi
|
||||
done < <(eval $1)
|
||||
echo -e "$output_string"
|
||||
}
|
||||
|
||||
wifi_config() {
|
||||
local wifi_ssid=""
|
||||
local wifi_psk=""
|
||||
local wifi_country=""
|
||||
wifi_ssid=$(dialog --no-collapse --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 --no-collapse --title "$title2" --inputbox "Enter Wi-Fi Password:" 8 40 3>&1 1>&2 2>&3)
|
||||
wifi_country=$(dialog --no-collapse --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\""
|
||||
local title2="Wi-Fi (wlan0) Settings"
|
||||
local config=$(dialog --no-collapse --title "$title2" --form "↑ ↓ to navigate, [ESC] to cancel." 10 45 0 \
|
||||
"SSID:" 1 1 "$(grep -oP '^ *ssid="\K[^"]+' /etc/wpa_supplicant/wpa_supplicant.conf)" 1 15 24 32\
|
||||
"Password:" 2 1 "" 2 15 24 64\
|
||||
"Country Code:" 3 1 "$(grep -oP '^ *country=\K[^ ]+' /etc/wpa_supplicant/wpa_supplicant.conf)" 3 15 24 2\
|
||||
3>&1 1>&2 2>&3)
|
||||
# Parse the output
|
||||
wifi_ssid=$(echo "$config" | sed -n '1p')
|
||||
wifi_psk=$(echo "$config" | sed -n '2p')
|
||||
wifi_country=$(echo "$config" | sed -n '3p')
|
||||
|
||||
cmd="femto-network-config.sh -s \"$wifi_ssid\" -p \"$wifi_psk\"" # build the wifi setting command to send to the network config script
|
||||
[ -n "$wifi_country" ] && cmd="$cmd -c \"$wifi_country\""
|
||||
cmd="$cmd -r"
|
||||
if [ -z "$wifi_ssid" ]; then
|
||||
dialog --no-collapse --title "$title2" --msgbox "\nSSID is required to configure Wi-Fi." 8 40
|
||||
dialog --no-collapse --title "$title2" --msgbox "\nSSID is required to configure Wi-Fi." 7 40
|
||||
return
|
||||
fi
|
||||
eval $cmd
|
||||
echo "Configuring wifi..."
|
||||
eval $cmd &>/dev/null
|
||||
dialog --no-collapse --title "$title2" --msgbox "Wi-Fi Settings Saved:\nSSID: $wifi_ssid\nPassword: (hidden)\nCountry: $wifi_country\nMeshtastic Wi-Fi setting set to ON" 9 40
|
||||
if [ "$1" = "-w" ]; then
|
||||
exit 0
|
||||
|
|
@ -63,39 +111,31 @@ networking_settings() {
|
|||
local title="Networking"
|
||||
local title2="Wi-Fi (wlan0) Settings"
|
||||
wpa_supplicant_conf="/etc/wpa_supplicant/wpa_supplicant.conf"
|
||||
choice="" # zero the choice before loading the submenu
|
||||
while true; do
|
||||
local option=""
|
||||
option=$(dialog --no-collapse --cancel-label "Back" --menu "$title" 16 40 4 \
|
||||
1 "Turn Wi-Fi on/off" \
|
||||
2 "View Wi-Fi settings" \
|
||||
3 "Change Wi-Fi settings" \
|
||||
4 "View ethernet settings" \
|
||||
5 "Restart networking" \
|
||||
6 "Set hostname" \
|
||||
7 "Test internet connection" \
|
||||
"" "" \
|
||||
8 "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 -eq 1 ]; then # Exit the loop if the user selects "Cancel" or closes the dialog
|
||||
break
|
||||
fi
|
||||
|
||||
case $option in
|
||||
networking_choice=$(dialog --no-collapse --cancel-label "Back" --backtitle "IPv4 address: $(femto-network-config.sh -i)" --default-item "$networking_choice" --title "$title" --item-help --menu "" 16 40 4 \
|
||||
1 "Turn Wi-Fi on/off" "" \
|
||||
2 "View Wi-Fi settings" "" \
|
||||
3 "Change Wi-Fi settings" "" \
|
||||
4 "View ethernet settings" "" \
|
||||
5 "Restart networking" "" \
|
||||
6 "Set hostname" "" \
|
||||
7 "Test internet connection" "" \
|
||||
" " "" "" \
|
||||
8 "Back to main menu" "" 3>&1 1>&2 2>&3)
|
||||
[ $? -eq 1 ] && break # Exit the loop if the user selects "Cancel" or closes the dialog
|
||||
case $networking_choice in
|
||||
1) # Turn Wi-Fi on/off)
|
||||
if ! ip link show wlan0 &>/dev/null; then
|
||||
dialog --no-collapse --colors --msgbox "\Z1Network adapter wlan0 does not exist.\Zn\n\nIs a wifi adapter connected?" 8 40
|
||||
dialog --no-collapse --colors --msgbox "\Z1Network adapter wlan0 does not exist.\Zn\n\nIs a Wi-Fi adapter connected?" 8 40
|
||||
else
|
||||
while true; do
|
||||
choice=$(dialog --no-collapse --cancel-label "Back" --title "Enable/disable Wi-Fi" --menu "Tip: Wi-Fi can also be toggled by short-pressing the BOOT button on the Luckfox." 13 50 5 \
|
||||
1 "Turn Wi-Fi on" \
|
||||
2 "Turn Wi-Fi off" \
|
||||
"" "" \
|
||||
3 "Return to previous menu" 3>&1 1>&2 2>&3)
|
||||
exit_status=$? # This line checks the exit status of the dialog command
|
||||
if [ $exit_status -eq 1 ]; then # Exit the loop if the user selects "Cancel" or closes the dialog
|
||||
break
|
||||
fi
|
||||
choice=$(dialog --no-collapse --cancel-label "Back" --default-item "$choice" --title "Enable/disable Wi-Fi" --item-help --menu "Tip: Wi-Fi can also be toggled by short-pressing the BOOT button on the Luckfox." 13 50 5 \
|
||||
1 "Turn Wi-Fi on" "" \
|
||||
2 "Turn Wi-Fi off" "" \
|
||||
" " "" "" \
|
||||
3 "Return to previous menu" "" 3>&1 1>&2 2>&3)
|
||||
[ $? -eq 1 ] && break # Exit the loop if the user selects "Cancel" or closes the dialog
|
||||
case $choice in
|
||||
1) femto-network-config.sh -x "up" && break ;;
|
||||
2) femto-network-config.sh -x "down" && break ;;
|
||||
|
|
@ -106,14 +146,14 @@ networking_settings() {
|
|||
;;
|
||||
2) # View Wi-Fi settings)
|
||||
echo "Getting Wi-Fi configuration..."
|
||||
dialog --no-collapse --title "$title2" --colors --msgbox "$(replace_colors "$(femto-network-config.sh -w)")" 0 0
|
||||
dialog --no-collapse --title "$title2" --colors --msgbox "$(ingest_data "femto-network-config.sh -w" 15)" 0 0
|
||||
;;
|
||||
3) # Change Wi-Fi settings)
|
||||
wifi_config
|
||||
;;
|
||||
4) # View ethernet settings)
|
||||
echo "Getting ethernet configuration..."
|
||||
dialog --no-collapse --title "Ethernet (eth0) settings" --colors --msgbox "$(echo -e "$(replace_colors "$(femto-network-config.sh -e)")")" 0 0
|
||||
dialog --no-collapse --title "Ethernet (eth0) settings" --colors --msgbox "$(ingest_data "femto-network-config.sh -e" 15)" 0 0
|
||||
;;
|
||||
5) # Restart networking)
|
||||
dialog --no-collapse --title "$title2" --yesno "Wi-Fi and Ethernet will be restarted.\nMeshtastic Wi-Fi setting will be set to ON.\n\nProceed?" 10 40
|
||||
|
|
@ -122,7 +162,7 @@ networking_settings() {
|
|||
fi
|
||||
;;
|
||||
6) # set hostname)
|
||||
new_hostname=$(dialog --no-collapse --title "$title" --inputbox "Enter new hostname:" 8 40 $(hostname) 3>&1 1>&2 2>&3)
|
||||
new_hostname=$(dialog --no-collapse --title "$title" --max-input 253 --inputbox "Enter new hostname:" 8 40 $(hostname) 3>&1 1>&2 2>&3)
|
||||
if [ $? -eq 0 ]; then #unless cancel/no
|
||||
femto-network-config.sh -n "$new_hostname"
|
||||
dialog --no-collapse --title "$title" --msgbox "Femtofox is now reachable at\n$new_hostname.local" 8 40
|
||||
|
|
@ -141,77 +181,90 @@ networking_settings() {
|
|||
|
||||
# utilities
|
||||
utilities() {
|
||||
local title="Utilities"
|
||||
local title="Utilities & Tools"
|
||||
while true; do
|
||||
local option=""
|
||||
option=$(dialog --no-collapse --cancel-label "Back" --menu "$title" 21 50 4 \
|
||||
1 "View system info" \
|
||||
2 "Set system time" \
|
||||
3 "Kernel modules" \
|
||||
4 "Re-run first-boot script" \
|
||||
5 "Run USB configuration tool" \
|
||||
6 "Run OEM luckfox-config" \
|
||||
7 "Process viewer/manager" \
|
||||
8 "Disable/enable logging" \
|
||||
9 "Disable/enable activity LED" \
|
||||
10 "Reboot" \
|
||||
11 "Shutdown" \
|
||||
"" "" \
|
||||
12 "Back to main menu" 3>&1 1>&2 2>&3)
|
||||
utilities_choice=$(dialog --no-collapse --cancel-label "Back" --default-item "$utilities_choice" --item-help --menu "$title" 21 50 4 \
|
||||
1 "View system info" "" \
|
||||
2 "Set system time" "" \
|
||||
3 "Kernel modules" "" \
|
||||
4 "Re-run first-boot script" "" \
|
||||
5 "Run USB configuration tool" "" \
|
||||
6 "Run OEM luckfox-config" "" \
|
||||
7 "Process viewer/manager" "" \
|
||||
8 "Disable/enable logging" "" \
|
||||
9 "Disable/enable activity LED" "" \
|
||||
10 "Reboot" "" \
|
||||
11 "Shutdown" "" \
|
||||
" " "" "" \
|
||||
12 "Back to main menu" "" 3>&1 1>&2 2>&3)
|
||||
[ $? -eq 1 ] && break # Exit the loop if the user selects "Cancel" or closes the dialog
|
||||
|
||||
exit_status=$? # This line checks the exit status of the dialog command
|
||||
if [ $exit_status -eq 1 ]; then # Exit the loop if the user selects "Cancel" or closes the dialog
|
||||
break
|
||||
fi
|
||||
|
||||
case $option in
|
||||
1)
|
||||
case $utilities_choice in
|
||||
1) #sysinfo)
|
||||
choice="" # zero the choice before loading the submenu
|
||||
while true; do
|
||||
choice=$(dialog --no-collapse --help-button --help-label "Help" --cancel-label "Back" --menu "System info" 17 40 5 \
|
||||
1 "CPU" \
|
||||
2 "Operating system" \
|
||||
3 "Storage & memory" \
|
||||
4 "Peripherals & devices" \
|
||||
5 "Networking" \
|
||||
6 "Meshtastic node info" \
|
||||
7 "Complete system info" \
|
||||
"" "" \
|
||||
8 "Back to previous menu" 3>&1 1>&2 2>&3)
|
||||
|
||||
choice=$(dialog --no-collapse --help-button --help-label "Help" --cancel-label "Back" --default-item "$choice" --item-help --menu "System info" 17 40 5 \
|
||||
1 "CPU" "" \
|
||||
2 "Operating system" "" \
|
||||
3 "Storage & memory" "" \
|
||||
4 "Peripherals & devices" ""\
|
||||
5 "Networking" "" \
|
||||
6 "Meshtastic node info" "" \
|
||||
7 "Complete system info" "" \
|
||||
" " "" "" \
|
||||
8 "Back to previous menu" "" 3>&1 1>&2 2>&3)
|
||||
exit_status=$? # This line checks the exit status of the dialog command
|
||||
if [ $exit_status -eq 1 ]; then # Exit the loop if the user selects "Cancel" or closes the dialog
|
||||
break
|
||||
elif [ $exit_status -eq 2 ]; then # Help ("extra") button
|
||||
dialog --no-collapse --colors --title "System info help" --msgbox "To get system info in terminal (where it can be copied), enter \`\Zusudo femto-utils.sh -i\Zn\`." 7 50
|
||||
dialog --no-collapse --colors --title "System info help" --msgbox "To get system info in terminal (where it can be copied), enter \`\Zusudo femto-utils.sh -i\Zn\`.\n\nWhen getting Peripherals & Devices (or Complete System Info) without an i2c device connected, it is normal to see error messages on serial console.\n" 0 0
|
||||
else
|
||||
case $choice in
|
||||
1) # CPU)
|
||||
loading "Loading CPU info..."
|
||||
dialog --no-collapse --colors --title "CPU info" --msgbox "$(replace_colors "$(femto-utils.sh -c)")" 0 0
|
||||
dialog --no-collapse --colors --title "CPU info" --msgbox "$(ingest_data "femto-utils.sh -c" 15)" 0 0
|
||||
;;
|
||||
2) # Operating system)
|
||||
loading "Loading operating system info..."
|
||||
dialog --no-collapse --colors --extra-button --title "Operating system" --msgbox "$(replace_colors "$(femto-utils.sh -o)")" 0 0
|
||||
dialog --no-collapse --colors --title "Operating system info" --msgbox "$(ingest_data "femto-utils.sh -o" 15)" 0 0
|
||||
;;
|
||||
3) # Storage & memory)
|
||||
loading "Loading storage & memory info..."
|
||||
dialog --no-collapse --colors --title "Storage & memory" --msgbox "$(replace_colors "$(femto-utils.sh -S)")" 0 0
|
||||
dialog --no-collapse --colors --title "Storage & memory info" --msgbox "$(ingest_data "femto-utils.sh -S" 15)" 0 0
|
||||
;;
|
||||
4) # Peripherals & devices)
|
||||
loading "Loading peripherals & devices info..."
|
||||
dialog --no-collapse --colors --title "Peripherals & devices" --msgbox "$(replace_colors "$(femto-utils.sh -p)")" 0 0
|
||||
dialog --no-collapse --colors --title "Peripherals & devices info" --msgbox "$(ingest_data "femto-utils.sh -p" 15)" 0 0
|
||||
;;
|
||||
5) # Networking)
|
||||
loading "Loading networking info..."
|
||||
dialog --no-collapse --colors --title "Networking" --msgbox "$(replace_colors "$(femto-utils.sh -n)")" 0 0
|
||||
dialog --no-collapse --colors --title "Networking info" --msgbox "$(ingest_data "femto-utils.sh -n" 15)" 0 0
|
||||
;;
|
||||
6) # Meshtastic node info)
|
||||
loading "Loading Meshtastic node info..."
|
||||
dialog --no-collapse --colors --title "Meshtastic node info" --msgbox "$(replace_colors "$(femto-meshtasticd-config.sh -i)")" 0 0
|
||||
dialog --no-collapse --colors --title "Meshtastic node info" --msgbox "$(ingest_data "femto-meshtasticd-config.sh -i" 15)" 0 0
|
||||
;;
|
||||
7) # Complete system info)
|
||||
loading "Loading complete system info..."
|
||||
dialog --no-collapse --colors --title "System info" --msgbox "$(replace_colors "$(femto-utils.sh -i)")" 0 0
|
||||
dialog --no-collapse --colors --title "Meshtastic node info" --msgbox "\
|
||||
Femtofox
|
||||
CPU:
|
||||
$(ingest_data "femto-utils.sh -c" 15)
|
||||
|
||||
Operating System:
|
||||
$(ingest_data "femto-utils.sh -o" 15)
|
||||
|
||||
Storage:
|
||||
$(ingest_data "femto-utils.sh -S" 15)
|
||||
|
||||
Networking (wlan0 & eth0):
|
||||
$(ingest_data "femto-utils.sh -p" 15)
|
||||
|
||||
Peripherals:
|
||||
$(ingest_data "femto-utils.sh -n" 15)
|
||||
|
||||
Meshtasticd:
|
||||
$(ingest_data "femto-meshtasticd-config.sh -i" 15)" 0 0
|
||||
;;
|
||||
8) break ;;
|
||||
esac
|
||||
|
|
@ -234,16 +287,14 @@ utilities() {
|
|||
6) luckfox-config ;;
|
||||
7) htop ;;
|
||||
8) # logging)
|
||||
choice="" # zero the choice before loading the submenu
|
||||
while true; do
|
||||
choice=$(dialog --no-collapse --colors --title "Logging" --menu "Before deploying a Femtofox, it is advisable to disable logging to reduce SD card wear.\nCurrent state: $(replace_colors "$(femto-utils.sh -l "check")")" 14 50 2 \
|
||||
1 "Enable (default)" \
|
||||
2 "Disable" \
|
||||
"" "" \
|
||||
3 "Return to previous menu" 3>&1 1>&2 2>&3)
|
||||
exit_status=$? # This line checks the exit status of the dialog command
|
||||
if [ $exit_status -eq 1 ]; then # Exit the loop if the user selects "Cancel" or closes the dialog
|
||||
break
|
||||
fi
|
||||
choice=$(dialog --no-collapse --colors --title "Logging" --cancel-label "Back" --default-item "$choice" --item-help --menu "Before deploying a Femtofox, it is advisable to disable logging to reduce SD card wear.\nCurrent state: $(replace_colors "$(femto-utils.sh -l "check")")" 14 50 2 \
|
||||
1 "Enable (default)" "" \
|
||||
2 "Disable" "" \
|
||||
" " "" "" \
|
||||
3 "Return to previous menu" "" 3>&1 1>&2 2>&3)
|
||||
[ $? -eq 1 ] && break # Exit the loop if the user selects "Cancel" or closes the dialog
|
||||
case $choice in
|
||||
1) femto-utils.sh -l "enable" ;;
|
||||
2) femto-utils.sh -l "disable" ;;
|
||||
|
|
@ -252,16 +303,14 @@ utilities() {
|
|||
done
|
||||
;;
|
||||
9) # logging)
|
||||
choice="" # zero the choice before loading the submenu
|
||||
while true; do
|
||||
choice=$(dialog --no-collapse --colors --title "Logging" --menu "Before deploying a Femtofox, it is advisable to disable the Activity LED to save power.\nCurrent state: $(replace_colors "$(femto-utils.sh -a "check")")" 14 50 2 \
|
||||
1 "Enable (default)" \
|
||||
2 "Disable" \
|
||||
"" "" \
|
||||
3 "Return to previous menu" 3>&1 1>&2 2>&3)
|
||||
exit_status=$? # This line checks the exit status of the dialog command
|
||||
if [ $exit_status -eq 1 ]; then # Exit the loop if the user selects "Cancel" or closes the dialog
|
||||
break
|
||||
fi
|
||||
choice=$(dialog --no-collapse --colors --title "Logging" --cancel-label "Back" --default-item "$choice" --item-help --menu "Before deploying a Femtofox, it is advisable to disable the Activity LED to save power.\nCurrent state: $(replace_colors "$(femto-utils.sh -a "check")")" 14 50 2 \
|
||||
1 "Enable (default)" "" \
|
||||
2 "Disable" "" \
|
||||
" " "" "" \
|
||||
3 "Return to previous menu" "" 3>&1 1>&2 2>&3)
|
||||
[ $? -eq 1 ] && break # Exit the loop if the user selects "Cancel" or closes the dialog
|
||||
case $choice in
|
||||
1) femto-utils.sh -a "enable" ;;
|
||||
2) femto-utils.sh -a "disable" ;;
|
||||
|
|
@ -290,29 +339,24 @@ utilities() {
|
|||
|
||||
#set lora radio
|
||||
set_lora_radio() {
|
||||
choice="" # zero the choice before loading the submenu
|
||||
while true; do
|
||||
echo "Checking LoRa radio..."
|
||||
local option=""
|
||||
#Display filename, if exists: $(files=$(ls /etc/meshtasticd/config.d/* 2>/dev/null) && [ -n "$files" ] && echo "\n\nConfiguration files in use:\n$files" | paste -sd, -))
|
||||
option=$(dialog --no-collapse --colors --cancel-label "Back" --title "Meshtastic LoRa radio" --menu "Currently configured LoRa radio:\n$(replace_colors "$(femto-meshtasticd-config.sh -k)")$(ls -1 /etc/meshtasticd/config.d 2>/dev/null | paste -sd ', ' - | sed 's/^/ (/; s/$/)/; s/,/, /g' | grep -v '^ ()$')" 19 50 10 \
|
||||
"Ebyte e22-900m30s" "(SX1262_TCXO)" \
|
||||
"Ebyte e22-900m22s" "(SX1262_TCXO)"\
|
||||
"Ebyte e80-900m22s" "(SX1262_XTAL)"\
|
||||
"Heltec ht-ra62" "(SX1262_TCXO)"\
|
||||
"Seeed wio-sx1262" "(SX1262_TCXO)"\
|
||||
"Waveshare sx126x-xxxm" "(SX1262_XTAL)"\
|
||||
"AI Thinker ra-01sh" "(SX1262_XTAL)"\
|
||||
"None" "(simulated radio)"\
|
||||
"" "" \
|
||||
"Skip" "" 3>&1 1>&2 2>&3)
|
||||
|
||||
exit_status=$? # This line checks the exit status of the dialog command
|
||||
if [ $exit_status -eq 1 ]; then # Exit the loop if the user selects "Cancel" or closes the dialog
|
||||
break
|
||||
fi
|
||||
|
||||
choice=$(dialog --no-collapse --colors --cancel-label "Back" --default-item "$choice" --title "Meshtastic LoRa radio" --item-help --menu "Currently configured LoRa radio:\n$(replace_colors "$(femto-meshtasticd-config.sh -k)")$(ls -1 /etc/meshtasticd/config.d 2>/dev/null | paste -sd ', ' - | sed 's/^/ (/; s/$/)/; s/,/, /g' | grep -v '^ ()$')" 19 50 10 \
|
||||
"Ebyte e22-900m30s" "(SX1262_TCXO)" "" \
|
||||
"Ebyte e22-900m22s" "(SX1262_TCXO)" "" \
|
||||
"Ebyte e80-900m22s" "(SX1262_XTAL)" "" \
|
||||
"Heltec ht-ra62" "(SX1262_TCXO)" "" \
|
||||
"Seeed wio-sx1262" "(SX1262_TCXO)" "" \
|
||||
"Waveshare sx126x-xxxm" "(SX1262_XTAL)" "" \
|
||||
"AI Thinker ra-01sh" "(SX1262_XTAL)" "" \
|
||||
"None" "(simulated radio)" "" \
|
||||
" " "" "" \
|
||||
"Skip" "" "" 3>&1 1>&2 2>&3)
|
||||
[ $? -eq 1 ] && break # Exit the loop if the user selects "Cancel" or closes the dialog
|
||||
local radio=""
|
||||
case $option in
|
||||
case $choice in
|
||||
"Ebyte e22-900m30s")
|
||||
radio="sx1262_tcxo"
|
||||
;;
|
||||
|
|
@ -352,30 +396,24 @@ set_lora_radio() {
|
|||
meshtastic_settings() {
|
||||
local title="Meshtastic Settings"
|
||||
while true; do
|
||||
echo "Checking Meshtasticd service state..."
|
||||
local option=""
|
||||
option=$(dialog --no-collapse --colors --title "$title" --cancel-label "Back" --menu "Meshtasticd service is $(replace_colors "$(femto-meshtasticd-config.sh -S)")$(femto-meshtasticd-config.sh -k | grep -q 'simulated' && echo '\n\Z1Using simulated radio\Zn')" 19 50 4 \
|
||||
1 "View node info" \
|
||||
2 "View configuration URL & QR code" \
|
||||
3 "Set new configuration URL" \
|
||||
4 "Set LoRa radio" \
|
||||
5 "Security settings" \
|
||||
6 "Mesh connectivity test" \
|
||||
7 "Manage Meshtasticd service" \
|
||||
8 "Upgrade/install Meshtasticd" \
|
||||
9 "Uninstall Meshtasticd" \
|
||||
"" "" \
|
||||
10 "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 -eq 1 ]; then # Exit the loop if the user selects "Cancel" or closes the dialog
|
||||
break
|
||||
fi
|
||||
|
||||
case $option in
|
||||
echo "Checking Meshtasticd service state..."
|
||||
meshtastic_choice=$(dialog --no-collapse --colors --title "$title" --cancel-label "Back" --default-item "$meshtastic_choice" --item-help --menu "Meshtasticd service is $(replace_colors "$(femto-meshtasticd-config.sh -S)")$(femto-meshtasticd-config.sh -k | grep -q 'simulated' && echo '\n\Z1Warning: using simulated radio\Zn')" 20 50 4 \
|
||||
1 "View node info" "" \
|
||||
2 "View configuration URL & QR code" "" \
|
||||
3 "Set new configuration URL" "" \
|
||||
4 "Set LoRa radio" "" \
|
||||
5 "Security settings" "" \
|
||||
6 "Mesh connectivity test" "" \
|
||||
7 "Manage Meshtasticd service" "" \
|
||||
8 "Upgrade/install Meshtasticd" "" \
|
||||
9 "Uninstall Meshtasticd" "" \
|
||||
" " "" "" \
|
||||
10 "Back to main menu" "" 3>&1 1>&2 2>&3)
|
||||
[ $? -eq 1 ] && break # Exit the loop if the user selects "Cancel" or closes the dialog
|
||||
case $meshtastic_choice in
|
||||
1) # view node info)
|
||||
loading "Getting node info..."
|
||||
dialog --no-collapse --colors --title "Node info" --msgbox "$(replace_colors "$(femto-meshtasticd-config.sh -i)")" 0 0
|
||||
dialog --no-collapse --colors --title "Meshtastic node info" --msgbox "$(ingest_data "femto-meshtasticd-config.sh -i" 15)" 0 0
|
||||
;;
|
||||
2) # get current configuration URL & QR code)
|
||||
loading "Getting Meshtastic QR code and URL..."
|
||||
|
|
@ -396,21 +434,19 @@ meshtastic_settings() {
|
|||
set_lora_radio
|
||||
;;
|
||||
5) # remote admin)
|
||||
choice="" # zero the choice before loading the submenu
|
||||
while true; do
|
||||
choice=$(dialog --no-collapse --cancel-label "Back" --title "Meshtastic Security Settings" --menu "" 16 40 5 \
|
||||
1 "View/change public key" \
|
||||
2 "View/change private key" \
|
||||
"" "" \
|
||||
3 "View admin keys" \
|
||||
4 "Set admin key" \
|
||||
5 "Clear admin keys" \
|
||||
6 "Legacy admin channel" \
|
||||
"" "" \
|
||||
7 "Return to previous menu" 3>&1 1>&2 2>&3)
|
||||
exit_status=$? # This line checks the exit status of the dialog command
|
||||
if [ $exit_status -eq 1 ]; then # Exit the loop if the user selects "Cancel" or closes the dialog
|
||||
break
|
||||
fi
|
||||
choice=$(dialog --no-collapse --cancel-label "Back" --default-item "$choice" --title "Meshtastic Security Settings" --item-help --menu "" 16 40 5 \
|
||||
1 "View/change public key" "" \
|
||||
2 "View/change private key" "" \
|
||||
" " "" "" \
|
||||
3 "View admin keys" "" \
|
||||
4 "Set admin key" "" \
|
||||
5 "Clear admin keys" "" \
|
||||
6 "Legacy admin channel" "" \
|
||||
" " "" "" \
|
||||
7 "Return to previous menu" "" 3>&1 1>&2 2>&3)
|
||||
[ $? -eq 1 ] && break # Exit the loop if the user selects "Cancel" or closes the dialog
|
||||
case $choice in
|
||||
1) # view/change public key)
|
||||
loading "Getting current public key..."
|
||||
|
|
@ -463,17 +499,15 @@ meshtastic_settings() {
|
|||
fi
|
||||
;;
|
||||
6) # legacy admin)
|
||||
choice="" # zero the choice before loading the submenu
|
||||
while true; do
|
||||
loading "Getting current legacy admin state..."
|
||||
choice=$(dialog --no-collapse --colors --title "Legacy Admin" --menu "Current state: $(replace_colors "$(femto-meshtasticd-config.sh -p)")" 12 40 5 \
|
||||
1 "Enable" \
|
||||
2 "Disable (default)" \
|
||||
"" "" \
|
||||
3 "Return to previous menu" 3>&1 1>&2 2>&3)
|
||||
exit_status=$? # This line checks the exit status of the dialog command
|
||||
if [ $exit_status -eq 1 ]; then # Exit the loop if the user selects "Cancel" or closes the dialog
|
||||
break
|
||||
fi
|
||||
choice=$(dialog --no-collapse --colors --title "Legacy Admin" --default-item "$choice" --item-help --menu "Current state: $(replace_colors "$(femto-meshtasticd-config.sh -p)")" 12 40 5 \
|
||||
1 "Enable" "" \
|
||||
2 "Disable (default)" "" \
|
||||
" " "" "" \
|
||||
3 "Return to previous menu" "" 3>&1 1>&2 2>&3)
|
||||
[ $? -eq 1 ] && break # Exit the loop if the user selects "Cancel" or closes the dialog
|
||||
case $choice in
|
||||
1) # enable legacy admin)
|
||||
dialog --no-collapse --title "Legacy Admin" --yesno "Enable legacy admin channel?\n" 0 0
|
||||
|
|
@ -507,10 +541,11 @@ meshtastic_settings() {
|
|||
fi
|
||||
;;
|
||||
7) #manage meshtasticd service)
|
||||
choice="" # zero the choice before loading the submenu
|
||||
while true; do
|
||||
echo "Checking Meshtasticd service state..."
|
||||
local service_state="$(replace_colors "$(femto-meshtasticd-config.sh -S)")"
|
||||
choice=$(dialog --no-collapse --colors --cancel-label "Back" --title "Meshtasticd Service" --menu "Meshtasticd service is $service_state$(femto-meshtasticd-config.sh -k | grep -q 'simulated' && echo '\n\Z1Using simulated radio\Zn')" 17 52 5 \
|
||||
choice=$(dialog --no-collapse --colors --cancel-label "Back" --title "Meshtasticd Service" --default-item "$choice" --menu "Meshtasticd service is $service_state$(femto-meshtasticd-config.sh -k | grep -q 'simulated' && echo '\n\Z1Using simulated radio\Zn')" 17 52 5 \
|
||||
"View detailed service status" "x" \
|
||||
" " " " \
|
||||
$(if echo "$service_state" | grep -q 'enabled'; then echo "Start/restart service x"; fi) \
|
||||
|
|
@ -520,10 +555,7 @@ meshtastic_settings() {
|
|||
$(if echo "$service_state" | grep -q 'enabled'; then echo "Disable service x"; fi) \
|
||||
" " " " \
|
||||
"Back to previous menu" "x" 3>&1 1>&2 2>&3)
|
||||
exit_status=$? # This line checks the exit status of the dialog command
|
||||
if [ $exit_status -eq 1 ]; then # Exit the loop if the user selects "Cancel" or closes the dialog
|
||||
break
|
||||
fi
|
||||
[ $? -eq 1 ] && break # Exit the loop if the user selects "Cancel" or closes the dialog
|
||||
case $choice in
|
||||
"View detailed service status")
|
||||
loading "Getting Meshtasticd service status..."
|
||||
|
|
@ -586,45 +618,33 @@ meshtastic_settings() {
|
|||
help_menu() {
|
||||
while true; do
|
||||
local title="Help / About"
|
||||
local option=""
|
||||
option=$(dialog --no-collapse --cancel-label "Back" --menu "$title" 0 0 7 \
|
||||
1 "About Femtofox" \
|
||||
2 "Display pinout" \
|
||||
3 "Femtofox licensing info - short" \
|
||||
4 "Femtofox licensing info - long" \
|
||||
5 "Meshtastic licensing info" \
|
||||
6 "About Luckfox" \
|
||||
7 "About Ubuntu" \
|
||||
"" "" \
|
||||
8 "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 -eq 1 ]; then # Exit the loop if the user selects "Cancel" or closes the dialog
|
||||
break
|
||||
fi
|
||||
|
||||
case $option in
|
||||
help_choice=$(dialog --no-collapse --cancel-label "Back" --default-item "$help_choice" --item-help --menu "$title" 0 0 7 \
|
||||
1 "About Femtofox" "" \
|
||||
2 "Display pinout" "" \
|
||||
3 "Femtofox licensing info - short" "" \
|
||||
4 "Femtofox licensing info - long" "" \
|
||||
5 "Meshtastic licensing info" "" \
|
||||
6 "About Luckfox" "" \
|
||||
7 "About Ubuntu" "" \
|
||||
" " "" "" \
|
||||
8 "Back to main menu" "" 3>&1 1>&2 2>&3)
|
||||
[ $? -eq 1 ] && break # Exit the loop if the user selects "Cancel" or closes the dialog
|
||||
case $help_choice in
|
||||
1) #About Femtofox)
|
||||
dialog --no-collapse --title "About Femtofox" --backtitle "Foxbuntu $(grep -oP 'major=\K[0-9]+' /etc/foxbuntu-release).$(grep -oP 'minor=\K[0-9]+' /etc/foxbuntu-release).$(grep -oP 'patch=\K[0-9]+' /etc/foxbuntu-release)$(grep -oP 'hotfix=\K[a-z]+' /etc/foxbuntu-release)" --msgbox "$(femto-license.sh -a)" 18 65
|
||||
dialog --no-collapse --title "About Femtofox" --default-item "$choice" --backtitle "Foxbuntu $(grep -oP 'major=\K[0-9]+' /etc/foxbuntu-release).$(grep -oP 'minor=\K[0-9]+' /etc/foxbuntu-release).$(grep -oP 'patch=\K[0-9]+' /etc/foxbuntu-release)$(grep -oP 'hotfix=\K[a-z]+' /etc/foxbuntu-release)" --msgbox "$(femto-license.sh -a)" 18 65
|
||||
;;
|
||||
2) #Display pinout)
|
||||
choice="" # zero the choice before loading the submenu
|
||||
while true; do
|
||||
local option=""
|
||||
option=$(dialog --no-collapse --cancel-label "Back" --menu "Pinouts" 15 40 5 \
|
||||
1 "Femtofox Pro/CE" \
|
||||
2 "Femtofox Zero" \
|
||||
3 "Femtofox Tiny" \
|
||||
4 "Luckfox Pico Mini" \
|
||||
"" "" \
|
||||
5 "Back to Help Menu" 3>&1 1>&2 2>&3)
|
||||
|
||||
exit_status=$? # This line checks the exit status of the dialog command
|
||||
|
||||
if [ $exit_status -eq 1 ]; then # Exit the loop if the user selects "Cancel" or closes the dialog
|
||||
break
|
||||
fi
|
||||
|
||||
case $option in
|
||||
choice=$(dialog --no-collapse --cancel-label "Back" --item-help --menu "Pinouts" 15 40 5 \
|
||||
1 "Femtofox Pro/CE" "" \
|
||||
2 "Femtofox Zero" "" \
|
||||
3 "Femtofox Tiny" "" \
|
||||
4 "Luckfox Pico Mini" "" \
|
||||
" " "" "" \
|
||||
5 "Back to Help Menu" "" 3>&1 1>&2 2>&3)
|
||||
[ $? -eq 1 ] && break # Exit the loop if the user selects "Cancel" or closes the dialog
|
||||
case $choice in
|
||||
1) dialog --no-collapse --title "Femtofox" --msgbox "$(femto-pinout.sh -f)" 43 68 ;;
|
||||
2) dialog --no-collapse --title "Femtofox Zero" --msgbox "$(femto-pinout.sh -z)" 34 48 ;;
|
||||
3) dialog --no-collapse --title "Femtofox Tiny" --msgbox "$(femto-pinout.sh -t)" 38 70 ;;
|
||||
|
|
@ -680,29 +700,21 @@ while getopts ":hlwL:i" opt; do
|
|||
;;
|
||||
esac
|
||||
done
|
||||
if [ -n "$1" ]; then
|
||||
exit
|
||||
fi
|
||||
[ -n "$1" ] && exit # if there were arguments, exit before loading the menu
|
||||
|
||||
# Main menu
|
||||
while true; do
|
||||
choice=$(dialog --no-collapse --cancel-label "Exit" --menu "Femtofox Config" 16 40 5 \
|
||||
1 "Settings wizard" \
|
||||
2 "Networking" \
|
||||
3 "Meshtastic" \
|
||||
4 "Software manager" \
|
||||
5 "Utilities" \
|
||||
6 "Help" \
|
||||
"" "" \
|
||||
7 "Exit" 3>&1 1>&2 2>&3)
|
||||
|
||||
exit_status=$? # This line checks the exit status of the dialog command
|
||||
|
||||
if [ $exit_status -eq 1 ]; then # Exit the loop if the user selects "Cancel" or closes the dialog
|
||||
break
|
||||
fi
|
||||
|
||||
case $choice in
|
||||
main_menu_choice=$(dialog --no-collapse --cancel-label "Exit" --default-item "$main_menu_choice" --item-help --menu "Femtofox Config" 16 40 5 \
|
||||
1 "Settings wizard" "" \
|
||||
2 "Networking" "" \
|
||||
3 "Meshtastic" "" \
|
||||
4 "Software manager" "" \
|
||||
5 "Utilities & tools" "" \
|
||||
6 "Help" "" \
|
||||
" " "" "" \
|
||||
7 "Exit" "" 3>&1 1>&2 2>&3)
|
||||
[ $? -eq 1 ] && break # Exit the loop if the user selects "Cancel" or closes the dialog
|
||||
case $main_menu_choice in
|
||||
1) femto-install-wizard.sh ;;
|
||||
2) networking_settings ;;
|
||||
3) meshtastic_settings ;;
|
||||
|
|
@ -713,4 +725,4 @@ while true; do
|
|||
esac
|
||||
done
|
||||
|
||||
exit 0
|
||||
exit 0
|
||||
|
|
@ -60,7 +60,7 @@ done
|
|||
|
||||
while true; do
|
||||
# Create the menu options
|
||||
option=$(dialog --cancel-label "Back" --title "Kernel Modules" --menu "" 42 103 8 "${modules[@]}" 3>&1 1>&2 2>&3)
|
||||
option=$(dialog --cancel-label "Back" --title "Kernel Modules" --default-item "$selected_module" --menu "" 42 103 8 "${modules[@]}" 3>&1 1>&2 2>&3)
|
||||
|
||||
exit_status=$? # Check the exit status of the dialog command
|
||||
|
||||
|
|
@ -70,13 +70,12 @@ while true; do
|
|||
|
||||
# Get the module name from the selection
|
||||
selected_module=$option
|
||||
|
||||
# Get the full modinfo for the module and process it for dialog
|
||||
modinfo_output=$(modinfo $selected_module | sed ':a;N;$!ba;s/\n/\\n/g') # add \n to module info
|
||||
|
||||
# Check if the module is currently enabled
|
||||
if lsmod | grep -q "^$selected_module "; then
|
||||
dialog --colors --title "Disable Module" --yesno "The module '$selected_module' is currently \Z2\Zuenabled\Zn.\n\nDo you want to disable it?\n\nFull module info:\n$modinfo_output\n\nNote: Unused dependencies will be removed automatically." 25 0
|
||||
dialog --colors --title "Disable Module" --yesno "The module '$selected_module' is currently \Z4\Zuenabled\Zn.\n\nDo you want to disable it?\n\nFull module info:\n$modinfo_output\n\nNote: Unused dependencies will be removed automatically." 25 0
|
||||
if [ $? -eq 0 ]; then
|
||||
dialog --msgbox "$(module_switch $selected_module disable)" 7 60
|
||||
fi
|
||||
|
|
|
|||
|
|
@ -81,32 +81,46 @@ while getopts ":higkl:q:uU:rR:aA:cpo:sM:Stwuxm" opt; do
|
|||
echo -e "$help"
|
||||
;;
|
||||
i) # Option -i (Get important node info)
|
||||
declare -a output_array
|
||||
output=$(meshtastic --host --info)
|
||||
preset_or_settings="Use preset? $(echo "$output" | grep -oP '"usePreset":\s*\K\w+')\n"
|
||||
if echo "$output" | grep -qP '"usePreset":\s*true'; then
|
||||
preset_or_settings+="Preset: $(echo "$output" | grep -oP '"modemPreset":\s*"\K[^"]+')"
|
||||
else
|
||||
preset_or_settings+="\
|
||||
Bandwidth: $(echo "$output" | grep -oP '"bandwidth":\s*\K\w+')\n\
|
||||
Spread factor: $(echo "$output" | grep -oP '"spreadFactor":\s*\K\w+')\n\
|
||||
Coding rate: $(echo "$output" | grep -oP '"codingRate":\s*\K\w+')"
|
||||
output_array+=("Service=$(femto-meshtasticd-config.sh -S)")
|
||||
output_array+=("Version=$(echo "$output" | grep -oP '"firmwareVersion":\s*"\K[^"]+' | head -n 1)")
|
||||
output_array+=("Node name=$(echo "$output" | grep -oP 'Owner:\s*\K.*' | head -n 1)")
|
||||
output_array+=("NodeID=$(echo "!$(printf "%08x\n" $(echo "$output" | grep -oP '"myNodeNum":\s*\K\d+' | head -n 1))")")
|
||||
output_array+=("Nodenum=$(echo "$output" | grep -oP '"myNodeNum":\s*\K\d+' | head -n 1)")
|
||||
output_array+=("TX enabled=$(echo "$output" | grep -oP '"txEnabled":\s*\K\w+')")
|
||||
use_preset=$(echo "$output" | grep -oP '"usePreset":\s*\K\w+')
|
||||
output_array+=("Use preset=$use_preset")
|
||||
if [ "$use_preset" = "true" ]; then # if use-preset is true, then display the preset
|
||||
output_array+=("Preset=$(echo "$output" | grep -oP '"modemPreset":\s*"\K[^"]+')")
|
||||
else # otherwise, display the lora settings
|
||||
output_array+=("Bandwidth=$(echo "$output" | grep -oP '"bandwidth":\s*\K\w+')")
|
||||
output_array+=("Spread factor=$(echo "$output" | grep -oP '"spreadFactor":\s*\K\w+')")
|
||||
output_array+=("Coding rate=$(echo "$output" | grep -oP '"codingRate":\s*\K\w+')")
|
||||
fi
|
||||
echo -e "\
|
||||
Service status: $(femto-meshtasticd-config.sh -S)\n\
|
||||
Version: $(echo "$output" | grep -oP '"firmwareVersion":\s*"\K[^"]+' | head -n 1)\n\
|
||||
Node name: $(echo "$output" | grep -oP 'Owner:\s*\K.*' | head -n 1)\n\
|
||||
NodeID: !$(printf "%08x\n" $(echo "$output" | grep -oP '"myNodeNum":\s*\K\d+' | head -n 1)) (nodenum: $(echo "$output" | grep -oP '"myNodeNum":\s*\K\d+' | head -n 1))\n\
|
||||
TX enabled? $(txEnabled=$(echo "$output" | grep -oP '"txEnabled":\s*\K\w+'); [[ "$txEnabled" == "true" ]] && echo "\033[0;34menabled\033[0m" || echo "\033[0;31mdisabled\033[0m")\n\
|
||||
Role: $(echo "$output" | grep -oP '"role":\s*"\K[^"]+' | head -n 1)\n\
|
||||
$preset_or_settings\n\
|
||||
Frequency offset: $(echo "$output" | grep -oP '"bandwidth":\s*\K\w+')
|
||||
Region: $(echo "$output" | grep -oP '"region":\s*"\K[^"]+')\n\
|
||||
Hop limit: $(echo "$output" | grep -oP '"hopLimit":\s*\K\w+')\n\
|
||||
$(channelNum=$(echo "$output" | grep -oP '"channelNum":\s*\K\d+' | head -n 1); [[ -n "$channelNum" && "$channelNum" -gt 0 ]] && echo -e "Frequency slot: $channelNum\n")\
|
||||
$(overrideFrequency=$(echo "$output" | grep -oP '"overrideFrequency":\s*\K[0-9.]+'); [[ -n "$overrideFrequency" && $(echo "$overrideFrequency > 0" | bc) -eq 1 ]] && echo "Override freq: $overrideFrequency\n")\
|
||||
Public key: $(echo "$output" | grep -oP '"publicKey":\s*"\K[^"]+' | head -n 1)\n\
|
||||
Nodes in nodedb: $(echo "$output" | grep -oP '"![a-zA-Z0-9]+":\s*\{' | wc -l)\
|
||||
"
|
||||
output_array+=("Role=$(echo "$output" | grep -oP '"role":\s*"\K[^"]+' | head -n 1)")
|
||||
freq_offset=$(echo "$output" | grep -oP '"bandwidth":\s*\K\w+')
|
||||
if [ "$freq_offset" != 0 ]; then # only display frequency offset if not 0
|
||||
output_array+=("Override freq=$freq_offset")
|
||||
fi
|
||||
output_array+=("Region=$(echo "$output" | grep -oP '"region":\s*"\K[^"]+')")
|
||||
output_array+=("Hop limit=$(echo "$output" | grep -oP '"hopLimit":\s*\K\w+')")
|
||||
freq_slot=$(echo "$output" | grep -oP '"channelNum":\s*\K\d+' | head -n 1)
|
||||
if [ "$freq_slot" != 0 ]; then # only display frequency slot if not 0
|
||||
freq_slot+=("Freq slot=$freq_slot")
|
||||
fi
|
||||
override_freq=$(echo "$output" | grep -oP '"overrideFrequency":\s*\K[0-9.]+')
|
||||
if [ "$override_freq" != "0" ]; then # only display override frequency if not 0
|
||||
output_array+=("Override freq=$override_freq")
|
||||
fi
|
||||
output_array+=("Public key=$(echo "$output" | grep -oP '"publicKey":\s*"\K[^"]+' | head -n 1)")
|
||||
output_array+=("Nodes in db=$(echo "$output" | grep -oP '"![a-zA-Z0-9]+":\s*\{' | wc -l)")
|
||||
# now, echo the array
|
||||
for pair in "${output_array[@]}"; do
|
||||
key=$(echo "$pair" | cut -d'=' -f1)
|
||||
value=$(echo "$pair" | cut -d'=' -f2-)
|
||||
echo "$key:$value"
|
||||
done
|
||||
;;
|
||||
g) # Option -g (get config URL)
|
||||
url=$(meshtastic --host --qr-all | grep -oP '(?<=Complete URL \(includes all channels\): )https://[^ ]+') #add look for errors
|
||||
|
|
|
|||
|
|
@ -15,6 +15,7 @@ Options are:
|
|||
-c "COUNTRY" Set Wi-Fi 2-letter country code (such as US, DE)
|
||||
-r Restart Wi-Fi
|
||||
-e Get ethernet settings
|
||||
-i Get IPv4 addresses
|
||||
-w Get Wi-Fi settings
|
||||
-n "HOSTNAME" Change hostname
|
||||
-t Test internet connection
|
||||
|
|
@ -37,7 +38,7 @@ if [ $# -eq 0 ]; then
|
|||
fi
|
||||
|
||||
# Parse options
|
||||
while getopts ":hx:Ts:p:c:ewn:tr" opt; do
|
||||
while getopts ":hx:Ts:p:c:eiwn:tr" opt; do
|
||||
case ${opt} in
|
||||
h) # Option -h (help)
|
||||
echo -e "$help"
|
||||
|
|
@ -77,42 +78,52 @@ while getopts ":hx:Ts:p:c:ewn:tr" opt; do
|
|||
;;
|
||||
e) # Option -e (ethernet settings)
|
||||
status=$(ip link show eth0 | grep -o 'state [A-Za-z]*' | awk '{print $2}')
|
||||
echo -e "Ethernet status: $([ "$status" == "UP" ] && echo -e "\033[4m\033[0;34mconnected\033[0m" || echo -e "\033[0;31mdisconnected\033[0m")"
|
||||
echo -e "\
|
||||
Eth status:$([ "$status" == "UP" ] && echo -e "\033[4m\033[0;34mconnected\033[0m" || echo -e "\033[0;31mdisconnected\033[0m")"
|
||||
if [ "$status" == "UP" ]; then
|
||||
echo "IPv4 Address: $(ifconfig eth0 | grep 'inet ' | awk '{print $2}')\n\
|
||||
IPv6 Address: $(ifconfig eth0 | grep 'inet6 ' | awk '{print $2}')"
|
||||
echo -e "\
|
||||
IPv4 Address:$(ifconfig eth0 | grep 'inet ' | awk '{print $2}')
|
||||
IPv6 Address:$(ifconfig eth0 | grep 'inet6 ' | awk '{print $2}')"
|
||||
fi
|
||||
echo -e "MAC Address: $(ifconfig eth0 | grep 'ether ' | awk '{print $2}')\n\
|
||||
Hostname: $(hostname).local"
|
||||
echo -e "\
|
||||
MAC Address:$(ifconfig eth0 | grep 'ether ' | awk '{print $2}')\n\
|
||||
Hostname:$(hostname).local"
|
||||
;;
|
||||
w) # Option -w (wifi settings)
|
||||
wifi_settings="SSID: $(grep -m 1 '^\s*ssid=' "$wpa_supplicant_conf" | cut -d '"' -f 2)\n\
|
||||
Password: (hidden)\n\
|
||||
Country: $(grep -m 1 "^country=" "$wpa_supplicant_conf" | cut -d '=' -f 2)"
|
||||
wifi_settings="\
|
||||
SSID:$(grep -m 1 '^\s*ssid=' "$wpa_supplicant_conf" | cut -d '"' -f 2)\n\
|
||||
Password:(hidden)\n\
|
||||
Country:$(grep -m 1 "^country=" "$wpa_supplicant_conf" | cut -d '=' -f 2)"
|
||||
|
||||
if ip link show wlan0 2>/dev/null | grep -q "wlan0"; then
|
||||
mac_address_line="MAC address: $(ifconfig wlan0 | grep ether | awk '{print $2}')\n"
|
||||
mac_address_line="\
|
||||
MAC address:$(ifconfig wlan0 | grep ether | awk '{print $2}')"
|
||||
if [ "$(cat /etc/wifi_state.txt)" = "up" ]; then
|
||||
echo -e "Wi-Fi status: \033[4m\033[0;34menabled\033[0m\n\
|
||||
Connected to: $(iwconfig 2>/dev/null | grep -i 'ESSID' | awk -F 'ESSID:"' '{print $2}' | awk -F '"' '{print $1}' | sed 's/^$/none/')\n\
|
||||
Signal Strength: $(iwconfig 2>/dev/null | grep -i 'Signal level' | awk -F 'Signal level=' '{print $2}' | awk '{print $1}')\n\
|
||||
Current IP: $(hostname -I | awk '{print $1}')\n
|
||||
Hostname: $(hostname).local\n\
|
||||
echo -e "\
|
||||
Wi-Fi status:\033[4m\033[0;34menabled\033[0m\n\
|
||||
Connected to:$(iwconfig 2>/dev/null | grep -i 'ESSID' | awk -F 'ESSID:"' '{print $2}' | awk -F '"' '{print $1}' | sed 's/^$/none/')\n\
|
||||
Sig. strength:$(iwconfig 2>/dev/null | grep -i 'Signal level' | awk -F 'Signal level=' '{print $2}' | awk '{print $1}')\n\
|
||||
Current IP:$(hostname -I | awk '{print $1}')\n
|
||||
Hostname:$(hostname).local\n\
|
||||
$mac_address_line"
|
||||
else
|
||||
if ip link show wlan0 &>/dev/null; then # if wlan0 exists
|
||||
echo -e "Wi-Fi status: \033[0;31mdisabled\033[0m\n\
|
||||
echo -e "\
|
||||
Wi-Fi status:\033[0;31mdisabled\033[0m\n\
|
||||
\n\
|
||||
$wifi_settings"
|
||||
fi
|
||||
fi
|
||||
else
|
||||
echo -e "Wi-Fi status: \033[0;31mwlan0 not detected\033[0m\n\
|
||||
echo -e "\
|
||||
Wi-Fi status:\033[0;31mwlan0 not detected\033[0m\n\
|
||||
\n\
|
||||
Wi-Fi settings:\n\
|
||||
$wifi_settings"
|
||||
fi
|
||||
;;
|
||||
i) # Option -i (Get all IPv4 addresses)
|
||||
hostname -I | awk '{for(i=1; i<=NF; i++) {if(i>1) printf ", "; printf $i} print ""}'
|
||||
;;
|
||||
t) # Option -t (test internet connection)
|
||||
# Define ping targets and initialize counter
|
||||
targets=("1.1.1.1" "8.8.8.8")
|
||||
|
|
@ -129,7 +140,7 @@ $wifi_settings"
|
|||
if [ "$successful" -eq 0 ]; then
|
||||
echo -e "\033[0;31mNo internet connection detected.\033[0m"
|
||||
else
|
||||
echo -e "Internet connection is \033[4m\033[0;32mup\033[0m.\n\nPinged $(echo "${targets[*]}" | sed 's/ /, /g').\nReceived $successful/$total responses."
|
||||
echo -e "Internet connection is \033[4m\033[0;34mup\033[0m.\n\nPinged $(echo "${targets[*]}" | sed 's/ /, /g').\nReceived $successful/$total responses."
|
||||
fi
|
||||
;;
|
||||
r) # Option -r (restart Wi-Fi)
|
||||
|
|
|
|||
|
|
@ -13,11 +13,18 @@ if ! grep -qE '^first_boot=true' /etc/femto.conf; then # if not the first boot
|
|||
export LANG=C.UTF-8
|
||||
dialog --title "Femtofox run once utility" --yesno "\
|
||||
This does not appear to be this system's first boot.\n\
|
||||
Re-running this script will resize the filesystem to fit the SD card, allocate a swap file, add RTC support, add terminal type to .bashrc, set the eth0 MAC address to be derivative of the CPU serial number and then reboot.\n\
|
||||
\n\
|
||||
Re-running this script will:\n\
|
||||
* Resize filesystem to fit the SD card\n\
|
||||
* Allocate the swap file\n\
|
||||
* Add terminal type to user femto's .bashrc\n\
|
||||
* Set the eth0 MAC to be derivative of CPU serial number\n\
|
||||
\n\
|
||||
Finally, the Femtofox will reboot.\n\
|
||||
\n\
|
||||
Re-running this script after first boot should not cause any harm, but may not work as expected.\n\
|
||||
\n\
|
||||
Proceed?" 14 60
|
||||
Proceed?" 19 60
|
||||
if [ $? -eq 1 ]; then #if cancel/no
|
||||
exit 0
|
||||
fi
|
||||
|
|
@ -35,26 +42,24 @@ echo -e "\e[32m******* First boot *******\e[0m"
|
|||
done
|
||||
) &
|
||||
|
||||
# Disable LED to prevent boot codes from showing during this boot
|
||||
#sh -c "echo 34 > /sys/class/gpio/unexport"
|
||||
|
||||
# Perform filesystem resize
|
||||
log_message "Resizing filesystem. This can take up to 10 minutes, depending on microSD card size and speed"
|
||||
sudo resize2fs /dev/mmcblk1p5
|
||||
sudo resize2fs /dev/mmcblk1p6
|
||||
sudo resize2fs /dev/mmcblk1p7
|
||||
log_message "Resizing filesystem. This can take several minutes, depending on microSD card size and speed"
|
||||
resize2fs /dev/mmcblk1p5
|
||||
resize2fs /dev/mmcblk1p6
|
||||
resize2fs /dev/mmcblk1p7
|
||||
log_message "Resizing filesystem complete"
|
||||
|
||||
# allocate swap file
|
||||
if [ ! -f /swapfile ]; then # check if swap file already exists
|
||||
sudo fallocate -l 1G /swapfile
|
||||
sudo chmod 600 /swapfile
|
||||
sudo mkswap /swapfile > /dev/null
|
||||
sudo swapon /swapfile > /dev/null
|
||||
log_message "Allocating swap file. This can take up to 10 minutes, depending on microSD card speed"
|
||||
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 # no longer used
|
||||
log_message "Swap file allocated."
|
||||
else
|
||||
log_message "Swap file already allocated, skipping."
|
||||
log_message "Swap file already allocated, skipping"
|
||||
fi
|
||||
|
||||
# add RTC support - looks unneeded?
|
||||
|
|
@ -62,16 +67,17 @@ fi
|
|||
#log_message "Added ds1307/ds3231 RTC support."
|
||||
|
||||
# prevent randomized mac address for eth0. If `eth0`` is already present in /etc/network/interfaces, skip
|
||||
mac="$(awk '/Serial/ {print $3}' /proc/cpuinfo | tail -c 11 | sed 's/^\(.*\)/a2\1/' | sed 's/\(..\)/\1:/g;s/:$//')"
|
||||
if ! grep -q "eth0" /etc/network/interfaces; then
|
||||
log_message "Setting eth0 MAC address to derivative of CPU s/n."
|
||||
log_message "Setting eth0 MAC address to $mac (derivative of CPU s/n)"
|
||||
cat <<EOF >> /etc/network/interfaces
|
||||
# static mac address for onboard ethernet (castellated pins)
|
||||
allow-hotplug eth0
|
||||
iface eth0 inet dhcp
|
||||
hwaddress ether $(awk '/Serial/ {print $3}' /proc/cpuinfo | tail -c 11 | sed 's/^\(.*\)/a2\1/' | sed 's/\(..\)/\1:/g;s/:$//')
|
||||
hwaddress ether $mac
|
||||
EOF
|
||||
else
|
||||
log_message "eth0 already exists in /etc/network/interfaces, skipping."
|
||||
log_message "eth0 already exists in /etc/network/interfaces, skipping"
|
||||
fi
|
||||
|
||||
# Add term stuff to .bashrc
|
||||
|
|
@ -85,17 +91,8 @@ else
|
|||
echo "TERM, LANG and NCURSES_NO_UTF8_ACS already present in .bashrc, skipping"
|
||||
fi
|
||||
|
||||
# set meshtastic nodeid to derivative of CPU serial number (unique to this board)
|
||||
#seed=$(sed -n '/Serial/ s/^.*: \(.*\)$/\U\1/p' /proc/cpuinfo | bc | tail -c 9)
|
||||
#seed=$((0x$(awk '/Serial/ {print $3}' /proc/cpuinfo) & 0x3B9AC9FF)) #alternate method for generating seed - not in use
|
||||
#sed -i "s|^ExecStart=/usr/sbin/meshtasticd.*|ExecStart=/usr/sbin/meshtasticd -h $seed|" /usr/lib/systemd/system/meshtasticd.service
|
||||
#log_message "Using Luckfox CPU S/N to generate nodeid for Meshtastic."
|
||||
#systemctl daemon-reload
|
||||
#systemctl enable meshtasticd
|
||||
#systemctl restart meshtasticd
|
||||
|
||||
# remove first boot flag
|
||||
sed -i -E 's/^first_boot=.*/first_boot=false/' /etc/femto.conf
|
||||
log_message "Removing first boot flag and rebooting in 5 seconds..."
|
||||
sleep 5
|
||||
reboot
|
||||
reboot
|
||||
|
|
@ -4,47 +4,54 @@ title="Software Manager"
|
|||
package_dir="/usr/local/bin/packages"
|
||||
|
||||
install() {
|
||||
dialog --no-collapse --title "$title" --yesno "\nInstall $($package_dir/$1.sh -N)\n\nProceed?" 10 40
|
||||
if [ $? -eq 1 ]; then #if cancel/no
|
||||
return 1
|
||||
fi
|
||||
dialog --no-collapse --title "Install $($package_dir/$1.sh -N)" --yesno "\nInstallation requires internet connectivity.\n\nProceed?" 10 40
|
||||
[ $? -eq 1 ] && return 1 #if cancel/no
|
||||
|
||||
echo "Installing $($package_dir/$1.sh -N)..."
|
||||
# Run the installation script, capturing the output and displaying it in real time
|
||||
output=$($package_dir/$1.sh -i)
|
||||
echo $output
|
||||
install_status=$? # Capture the exit status of the eval command
|
||||
user_message=$(echo "$output" | awk '/user_message: / {found=1; split($0, arr, "user_message: "); print arr[2]; next} found {print}' | sed '/^$/q') # grab the user_message, if present
|
||||
#output=$(echo -e "$output" | sed '/user_message: /,$d') # remove the user message from the detailed output
|
||||
output=$(echo -e "$output" | sed '/user_message: /,$d') # remove the user message from the detailed output
|
||||
|
||||
if [ $install_status -eq 0 ]; then # if the installation was successful
|
||||
dialog --no-collapse --colors --title "$title" --beep --msgbox "\n\ZuInstallation of $($package_dir/$1.sh -N) successful!\Zn$([ -n "$user_message" ] && echo "\n\n$user_message")\n\nLog:\n$(echo $output)" 0 0 # if there's a user_message, display it with two preceeding line breaks
|
||||
dialog --no-collapse --colors --title "$title" --beep --msgbox "\ZuInstallation of $($package_dir/$1.sh -N) successful!\Zn$([ -n "$user_message" ] && echo "\n\n$user_message")\n\nLog:\n$(echo $output)" 0 0 # if there's a user_message, display it with two preceeding line breaks
|
||||
else
|
||||
dialog --no-collapse --colors --title "$title" --beep --msgbox "\n\ZuInstallation of $($package_dir/$1.sh -N) FAILED!\Zn\n\n$user_message\n\nLog:\n$(echo -e $output)" 0 0 # if there's a user_message, display it with two preceeding line breaks
|
||||
dialog --no-collapse --colors --title "$title" --beep --msgbox "\ZuInstallation of $($package_dir/$1.sh -N) FAILED!\Zn\n\n$user_message\n\nLog:\n$(echo -e $output)" 0 0 # if there's a user_message, display it with two preceeding line breaks
|
||||
fi
|
||||
}
|
||||
|
||||
uninstall() {
|
||||
dialog --no-collapse --title "$title" --yesno "\nUninstall $1\n\nProceed?" 10 40
|
||||
if [ $? -eq 1 ]; then #if cancel/no
|
||||
return 1
|
||||
fi
|
||||
dialog --no-collapse --title "Uninstall $($package_dir/$1.sh -N)" --yesno "\nReinstallation will require internet connectivity.\n\nProceed?" 10 40
|
||||
[ $? -eq 1 ] && return 1 #if cancel/no
|
||||
echo "Uninstalling $($package_dir/$1.sh -N)..."
|
||||
output=$(eval "$package_dir/$1.sh -u 2>&1 | tee /dev/tty")
|
||||
install_status=$? # Capture the exit status of the eval command
|
||||
user_message=$(echo "$output" | awk '/user_message: / {found=1; split($0, arr, "user_message: "); print arr[2]; next} found {print}' | sed '/^$/q') # grab the user_message, if present
|
||||
#output=$(echo "$output" | sed '/user_message: /,$d') # remove the user message from the detailed output
|
||||
output=$(echo "$output" | sed '/user_message: /,$d') # remove the user message from the detailed output
|
||||
if [ $install_status -eq 0 ]; then # if the installation was successful
|
||||
dialog --no-collapse --colors --title "$title" --beep --msgbox "\n\ZuUninstallation of $($package_dir/$1.sh -N) successful!\Zn$([ -n "$user_message" ] && echo "\n\n$user_message")\n\nLog:\n$(echo -e "$output")" 0 0 # if there's a user_message, display it with two preceeding line breaks
|
||||
else
|
||||
dialog --no-collapse --colors --title "$title" --beep --msgbox "\n\ZuUninstallation of $($package_dir/$1.sh -N) FAILED!\Zn\n\n$user_message\n\nLog:\n$(echo "$output")" 0 0 # if there's a user_message, display it with two preceeding line breaks
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
initialize() {
|
||||
dialog --no-collapse --title "$title" --yesno "\nIntialize $($package_dir/$1.sh -N)\n\nInitialization runs commands that require user interaction and so can only be run from terminal.\n\nProceed?" 13 50
|
||||
[ $? -eq 1 ] && return 1 #if cancel/no
|
||||
clear
|
||||
echo "Initializing $($package_dir/$1.sh -N)..."
|
||||
eval "$package_dir/$1.sh -a"
|
||||
if [ $? -eq 0 ]; then # if the installation was successful
|
||||
dialog --no-collapse --colors --title "$title" --beep --msgbox "\nInitialization of $($package_dir/$1.sh -N) successful!" 8 50 # if there's a user_message, display it with two preceeding line breaks
|
||||
else
|
||||
dialog --no-collapse --colors --title "$title" --beep --msgbox "\nInitialization of $($package_dir/$1.sh -N) FAILED!" 8 50 # if there's a user_message, display it with two preceeding line breaks
|
||||
fi
|
||||
}
|
||||
|
||||
upgrade() {
|
||||
dialog --no-collapse --title "$title" --yesno "\nUpgrade $1\n\nProceed?" 10 40
|
||||
if [ $? -eq 1 ]; then #if cancel/no
|
||||
return 1
|
||||
fi
|
||||
dialog --no-collapse --title "Upgrade $($package_dir/$1.sh -N)" --yesno "\nUpgrade requires internet connectivity.\n\nProceed?" 10 40
|
||||
[ $? -eq 1 ] && return 1 #if cancel/no
|
||||
echo "Upgrading $($package_dir/$1.sh -N)..."
|
||||
output=$(eval "$package_dir/$1.sh -g 2>&1 | tee /dev/tty")
|
||||
install_status=$? # Capture the exit status of the eval command
|
||||
|
|
@ -55,7 +62,6 @@ upgrade() {
|
|||
else
|
||||
dialog --no-collapse --colors --title "$title" --beep --msgbox "\n\ZuUpgrade of $($package_dir/$1.sh -N) FAILED!\Zn\n\n$user_message\n\nLog:\n$output" 0 0 # if there's a user_message, display it with two preceeding line breaks
|
||||
fi
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -68,7 +74,7 @@ package_intro() {
|
|||
$(if $package_dir/$1.sh -O | grep -q 'A'; then echo -e "by $($package_dir/$1.sh -A)"; fi)\n\
|
||||
$(if $package_dir/$1.sh -O | grep -q 'D'; then echo "\n$($package_dir/$1.sh -D)"; fi)\n\
|
||||
\n\
|
||||
$(echo "Currently: " && $package_dir/$1.sh -I && echo "\Zuinstalled\Zn" || echo " \Zunot installed\Zn")\n\
|
||||
$(echo "Currently: " && $package_dir/$1.sh -I && echo "\Zuinstalled\Zn" || echo "\Zunot installed\Zn")\n\
|
||||
$(if output=$($package_dir/$1.sh -L); [ -n "$output" ]; then echo "Installs to: \Zu$output\Zn\n"; fi)\
|
||||
$(if output=$($package_dir/$1.sh -C); [ -n "$output" ]; then echo "Conflicts with: \Zu$output\Zn\n"; fi)\
|
||||
An internet connection is required for installation.\n\
|
||||
|
|
@ -77,77 +83,71 @@ $(if $package_dir/$1.sh -O | grep -q 'U'; then echo "\nFor more information, vis
|
|||
}
|
||||
|
||||
package_menu() {
|
||||
choice=""
|
||||
while true; do
|
||||
echo "Loading package menu..."
|
||||
# for each line, check if it's supported by the package, display it if the current install state of the package is appropriate (example: don't display "install" if the package is already installed, don't display "stop service" for a package with no services)
|
||||
choice=$(dialog --no-collapse --title "$title" --cancel-label "Back" --menu "$($package_dir/$1.sh -N)" 17 45 5 \
|
||||
choice=$(dialog --no-collapse --title "$title" --cancel-label "Back" --default-item "$choice" --menu "$($package_dir/$1.sh -N)" 18 45 5 \
|
||||
$(if $package_dir/$1.sh -O | grep -q 'l' && $package_dir/$1.sh -I; then echo "Run software x"; fi) \
|
||||
$(if $package_dir/$1.sh -O | grep -q 'i' && ! $package_dir/$1.sh -I; then echo "Install x"; fi) \
|
||||
$(if $package_dir/$1.sh -O | grep -q 'u' && $package_dir/$1.sh -I; then echo "Uninstall x"; fi) \
|
||||
$(if $package_dir/$1.sh -O | grep -q 'a' && $package_dir/$1.sh -I; then echo "Initialize x"; fi) \
|
||||
$(if $package_dir/$1.sh -O | grep -q 'g' && $package_dir/$1.sh -I; then echo "Upgrade x"; fi) \
|
||||
$(if $package_dir/$1.sh -O | grep -q 'e' && $package_dir/$1.sh -I; then echo "Enable service x"; fi) \
|
||||
$(if $package_dir/$1.sh -O | grep -q 'd' && $package_dir/$1.sh -I; then echo "Disable service x"; fi) \
|
||||
$(if $package_dir/$1.sh -O | grep -q 's' && $package_dir/$1.sh -I; then echo "Stop service x"; fi) \
|
||||
$(if $package_dir/$1.sh -O | grep -q 'r' && $package_dir/$1.sh -I; then echo "Start/restart service x"; fi) \
|
||||
$(if $package_dir/$1.sh -O | grep -q 'S' && $package_dir/$1.sh -I; then echo "Get service status x"; fi) \
|
||||
"" "" \
|
||||
" " "" \
|
||||
"Back to software manager" "" 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
|
||||
|
||||
[ $? -eq 1 ] && break # Exit the loop if the user selects "Cancel" or closes the dialog
|
||||
# execute the actual commands
|
||||
case $choice in
|
||||
"Run software") eval "$package_dir/$1.sh -l" ;;
|
||||
"Run software") echo "Launching $($package_dir/$1.sh -N)..." && eval "$package_dir/$1.sh -l" ;;
|
||||
"Install") install $1 ;;
|
||||
"Uninstall") uninstall $1 ;;
|
||||
"Initialize") initialize $1 ;;
|
||||
"Upgrade") upgrade $1 ;;
|
||||
"Enable service") eval "$package_dir/$1.sh -e" ;;
|
||||
"Disable service") eval "$package_dir/$1.sh -d" ;;
|
||||
"Stop service") eval "$package_dir/$1.sh -s" ;;
|
||||
"Start/restart service") eval "$package_dir/$1.sh -r" ;;
|
||||
"Get service status") dialog --no-collapse --title "$title" --msgbox "$(eval "$package_dir/$1.sh -S")" 0 0 ;;
|
||||
"Enable service") echo "Enabling and starting service..." && eval "$package_dir/$1.sh -e" && eval "$package_dir/$1.sh -r" ;;
|
||||
"Disable service") echo "Disabling and stopping service..." && eval "$package_dir/$1.sh -d" && eval "$package_dir/$1.sh -s" ;;
|
||||
"Stop service") echo "Stopping service..." && eval "$package_dir/$1.sh -s" ;;
|
||||
"Start/restart service") echo "Starting/restarting service..." && eval "$package_dir/$1.sh -r" ;;
|
||||
"Get service status") echo "Getting service status..." && dialog --no-collapse --title "$title" --msgbox "$(eval "$package_dir/$1.sh -S")" 0 0 ;;
|
||||
"Back to software manager") break ;;
|
||||
esac
|
||||
done
|
||||
}
|
||||
|
||||
|
||||
# generate menu from filenames in /usr/local/bin/packages
|
||||
while true; do
|
||||
title="$title"
|
||||
option=""
|
||||
option=$(dialog --no-collapse --cancel-label "Back" --menu "$title" 0 0 6 \
|
||||
1 "The Comms Channel BBS, TC²BBS" \
|
||||
2 "Contact (Meshtastic client)" \
|
||||
3 "Meshing Around by Spud" \
|
||||
4 "Mosquitto MQTT Broker" \
|
||||
5 "Mosquitto MQTT Client" \
|
||||
"" ""\
|
||||
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) package_intro "tc2_bbs" ;;
|
||||
2) package_intro "contact_client" ;;
|
||||
3) package_intro "meshing_around" ;;
|
||||
4) package_intro "mosquitto_mqtt_broker" ;;
|
||||
5) package_intro "mosquitto_mqtt_client" ;;
|
||||
6) break ;;
|
||||
esac
|
||||
menu_entries=()
|
||||
index=1
|
||||
for file in /usr/local/bin/packages/*.sh; do
|
||||
filename=$(basename "$file" .sh)
|
||||
[[ "$filename" == "package_template" ]] && continue # skip package_template.sh
|
||||
menu_entries+=("$index" "$(/usr/local/bin/packages/"$filename".sh -N)")
|
||||
((index++))
|
||||
done
|
||||
|
||||
menu_entries+=(" " "") # add blank line and "Back to Main Menu" entry
|
||||
menu_entries+=("$index" "Back to main menu")
|
||||
software_option=$(dialog --no-collapse --cancel-label "Back" --default-item "$software_option" --menu "$title" $((9 + index)) 50 $((index + 1)) "${menu_entries[@]}" 3>&1 1>&2 2>&3)
|
||||
[ $? -eq 1 ] && break # Exit the loop if the user selects "Cancel" or closes the dialog
|
||||
|
||||
case_block=" case \$software_option in"
|
||||
index=1
|
||||
for file in /usr/local/bin/packages/*.sh; do
|
||||
filename=$(basename "$file" .sh)
|
||||
[[ "$filename" == "package_template" ]] && continue # skip package_template.sh
|
||||
case_block+="
|
||||
$index) package_intro \"$filename\" ;;"
|
||||
((index++))
|
||||
done
|
||||
|
||||
case_block+="
|
||||
$index) break ;;
|
||||
esac" #add return to main menu option
|
||||
eval "$case_block" # Execute the generated case statement
|
||||
done
|
||||
|
||||
exit 0
|
||||
|
||||
|
||||
# 4 "Mosquitto MQTT broker" \
|
||||
# 5 "GPS and Telemetry" \
|
||||
|
||||
# 4) mosquitto ;;
|
||||
# 5) gpsd ;;
|
||||
exit 0
|
||||
|
|
@ -64,24 +64,26 @@ cpu_info() {
|
|||
local cpu_speed="$(lscpu | grep "CPU min MHz" | awk '{print int($4)}')-$(lscpu | grep "CPU max MHz" | awk '{print int($4)}')mhz"
|
||||
local cpu_serial="$(awk '/Serial/ {print $3}' /proc/cpuinfo)"
|
||||
|
||||
echo -e "Core: $core\n\
|
||||
Model: $cpu_model\n\
|
||||
Architecture: $cpu_architecture\n\
|
||||
Speed: $cpu_speed x $(nproc) cores\n\
|
||||
Temperature: $cpu_temp\n\
|
||||
Serial # $cpu_serial"
|
||||
echo -e "\
|
||||
Core:$core\n\
|
||||
Model:$cpu_model\n\
|
||||
Architecture:$cpu_architecture\n\
|
||||
Speed:$cpu_speed x $(nproc) cores\n\
|
||||
Temperature:$cpu_temp\n\
|
||||
Serial #:$cpu_serial"
|
||||
}
|
||||
|
||||
storage_info() {
|
||||
local microsd_size="$(df --block-size=1 / | awk 'NR==2 {total=$2; avail=$4; total_human=sprintf("%.2f", total/1024/1024/1024); avail_human=sprintf("%.2f", avail/1024/1024/1024); printf "%.2f GB (%.2f%% free)", total_human, (avail/total)*100}')"
|
||||
local memory="$(free -m | awk 'NR==2{printf "%d MB (%.2f%% free)\n", $2, 100 - (($3/$2)*100)}')"
|
||||
local swap="$(free -m | awk 'NR==3 {if ($2 > 1000) {printf "%.2f GB (%.2f%% free)", $2/1024, ($4/$2)*100} else {printf "%d MB (%.2f%% free)", $2, ($4/$2)*100}}')"
|
||||
local mounted_drives="$([ "$(for dir in /mnt/*/; do echo -n "/mnt${dir#"/mnt"} "; done)" ] && echo "Mounted drives: $(for dir in /mnt/*; do echo -n "/mnt${dir#"/mnt"} "; done | sed 's/\/$//')")"
|
||||
local microsd_size="$(df --block-size=1 / | awk 'NR==2 {total=$2; avail=$4; total_human=sprintf("%.2f", total/1024/1024/1024); avail_human=sprintf("%.2f", avail/1024/1024/1024); printf "%.2f GB (%.2f%% free)", total_human, (avail/total)*100}')"
|
||||
local memory="$(free -m | awk 'NR==2{printf "%d MB (%.2f%% free)\n", $2, 100 - (($3/$2)*100)}')"
|
||||
local swap="$(free -m | awk 'NR==3 {if ($2 > 1000) {printf "%.2f GB (%.2f%% free)", $2/1024, ($4/$2)*100} else {printf "%d MB (%.2f%% free)", $2, ($4/$2)*100}}')"
|
||||
local mounted_drives="$( [ "$(for dir in /mnt/*/; do [ -d "$dir" ] && echo -n "/mnt${dir#"/mnt"} "; done)" ] && echo "$(for dir in /mnt/*/; do [ -d "$dir" ] && echo -n "/mnt${dir#"/mnt"} "; done | sed 's/\/$//')" || echo "none" )"
|
||||
|
||||
echo -e "microSD size: $microsd_size\n\
|
||||
Memory: $memory\n\
|
||||
Swap: $swap\n\
|
||||
$mounted_drives"
|
||||
echo -e "\
|
||||
microSD size:$microsd_size\n\
|
||||
Memory:$memory\n\
|
||||
Swap:$swap\n\
|
||||
Mnted drives:$mounted_drives"
|
||||
}
|
||||
|
||||
os_info() {
|
||||
|
|
@ -92,21 +94,22 @@ os_info() {
|
|||
local kernel_active_modules="$(lsmod | awk 'NR>1 {print $1}' | tr '\n' ' ' && echo)"
|
||||
local kernel_boot_modules="$(modules=$(sed -n '6,$p' /etc/modules | sed ':a;N;$!ba;s/\n/, /g;s/, $//'); [ -z "$modules" ] && echo "none" || echo "$modules")"
|
||||
|
||||
echo -e "Operating System: $os_version\n\
|
||||
Kernel version: $(uname -r)\n\
|
||||
Uptime: $system_uptime\n\
|
||||
Logging: $logging_enabled\n\
|
||||
Activity LED: $act_led\n\
|
||||
System time: $(date)\n\
|
||||
K modules active: $kernel_active_modules\n\
|
||||
K boot modules: $kernel_boot_modules"
|
||||
echo -e "\
|
||||
OS:$os_version\n\
|
||||
Kernel ver:$(uname -r)\n\
|
||||
Uptime:$system_uptime\n\
|
||||
Logging:$logging_enabled\n\
|
||||
Activity LED:$act_led\n\
|
||||
System time:$(date)\n\
|
||||
K mods active:$kernel_active_modules\n\
|
||||
K boot mods:$kernel_boot_modules"
|
||||
}
|
||||
|
||||
networking_info() {
|
||||
local wifi_status="$(femto-network-config.sh -w | grep -v '^$' | grep -v '^Hostname')" #remove hostname line, as it's identical to the one in ethernet settings
|
||||
local eth_status="$(femto-network-config.sh -e)"
|
||||
echo -e "$wifi_status\n\
|
||||
---
|
||||
|
||||
$eth_status"
|
||||
}
|
||||
|
||||
|
|
@ -119,7 +122,7 @@ peripherals_info() {
|
|||
local uart3_state="$([ "$(awk -F= '/^UART3_M1_STATUS/ {print $2}' /etc/luckfox.cfg)" -eq 1 ] && echo "enabled" || echo "disabled")"
|
||||
local uart4_state="$([ "$(awk -F= '/^UART4_M1_STATUS/ {print $2}' /etc/luckfox.cfg)" -eq 1 ] && echo "enabled" || echo "disabled")"
|
||||
local lora_radio="$(femto-meshtasticd-config.sh -k)"
|
||||
local usb_devices="$(lsusb | grep -v 'root hub' | awk 'NR>0{printf "USB: "; for(i=7;i<=NF;i++) printf "%s ", $i; print ""} END {if (NR == 0) printf "USB: none detected"}')"
|
||||
local usb_devices="$(lsusb | grep -v 'root hub' | awk 'NR>0{printf "USB:"; for(i=7;i<=NF;i++) printf "%s ", $i; print ""} END {if (NR == 0) printf "USB:none detected"}')"
|
||||
# gather i2c addresses
|
||||
i2c_addresses="" # initialize empty string to collect populated addresses
|
||||
while IFS= read -r line; do # iterate over each row of output (captured at end of while loop)
|
||||
|
|
@ -136,16 +139,16 @@ peripherals_info() {
|
|||
done <<< "$(echo "$(sudo i2cdetect -y 3)")"
|
||||
[[ -z "$i2c_addresses" ]] && i2c_addresses="none detected" # if no addresses found, "none detected"
|
||||
|
||||
echo -e "LoRa radio: $lora_radio\n\
|
||||
echo -e "LoRa radio:$lora_radio\n\
|
||||
$usb_devices\n\
|
||||
i2c devices: $i2c_addresses\n\
|
||||
USB mode: $usb_mode\n\
|
||||
SPI-0 state: $spi0_state\n\
|
||||
SPI-0 speed: $spi0_speed\n\
|
||||
i2c-3 state: $i2c3_state\n\
|
||||
i2c-3 speed: $i2c3_speed\n\
|
||||
UART-3 state: $uart3_state\n\
|
||||
UART-4 state: $uart4_state"
|
||||
i2c devices:$i2c_addresses\n\
|
||||
USB mode:$usb_mode\n\
|
||||
SPI-0 state:$spi0_state\n\
|
||||
SPI-0 speed:$spi0_speed\n\
|
||||
i2c-3 state:$i2c3_state\n\
|
||||
i2c-3 speed:$i2c3_speed\n\
|
||||
UART-3 state:$uart3_state\n\
|
||||
UART-4 state:$uart4_state"
|
||||
}
|
||||
|
||||
all_system_info() {
|
||||
|
|
@ -154,7 +157,7 @@ all_system_info() {
|
|||
CPU:\n\
|
||||
$(cpu_info)\n\
|
||||
\n\
|
||||
OS:\n\
|
||||
Operating System:\n\
|
||||
$(os_info)\n\
|
||||
\n\
|
||||
Storage:\n\
|
||||
|
|
|
|||
|
|
@ -46,9 +46,9 @@ EOF
|
|||
|
||||
name="Contact" # software name
|
||||
author="pdxlocations" # software author - OPTIONAL
|
||||
description="A Text-Based Console UI for Meshtastic Nodes.\nAfter install, run \`contact\` to launch." # software description - OPTIONAL (but strongly recommended!)
|
||||
description="A Text-Based Console UI for Meshtastic Nodes. Formerly called Curse Client.\nAfter install, run \`contact\` to launch." # software description - OPTIONAL (but strongly recommended!)
|
||||
URL="https://github.com/pdxlocations/contact/" # software URL. Can contain multiple URLs - OPTIONAL
|
||||
options="xiuglNADUOLIto" # script options in use by software package. For example, for a package with no service, exclude `edsr`
|
||||
options="xiuglNADUOLCI" # script options in use by software package. For example, for a package with no service, exclude `edsrS`
|
||||
launch="python /opt/contact/main.py --host" # command to launch software, if applicable
|
||||
service_name="" # the name of the service/s, such as `chrony`. REQUIRED if service options are in use. If multiple services, separate by spaces "service1 service2"
|
||||
location="/opt/contact" # install location REQUIRED if not apt installed. Generally, we use `/opt/software-name`
|
||||
|
|
@ -85,7 +85,9 @@ $launch" | sudo tee /usr/local/bin/contact > /dev/null
|
|||
# uninstall script
|
||||
uninstall() {
|
||||
rm -rf $location
|
||||
echo "Removed \`$location\`."
|
||||
rm /usr/local/bin/contact
|
||||
echo "Removed \`contact\` shortcut."
|
||||
echo "user_message: All files removed."
|
||||
exit 0 # should be `exit 1` if the installation failed
|
||||
}
|
||||
|
|
|
|||
|
|
@ -19,6 +19,7 @@ Arguments:
|
|||
Actions:
|
||||
-i Install
|
||||
-u Uninstall
|
||||
-a Interactive initialization script: code that must be run to initialize the installation prior to use, but can only be run from terminal
|
||||
-g Upgrade
|
||||
-e Enable service, if applicable
|
||||
-d Disable service, if applicable
|
||||
|
|
@ -52,7 +53,7 @@ name="Meshing Around" # software name
|
|||
author="Spud" # software author - OPTIONAL
|
||||
description="Meshing Around is a feature-rich bot designed to enhance your Meshtastic network experience with a variety of powerful tools and fun features. Connectivity and utility through text-based message delivery. Whether you're looking to perform network tests, send messages, or even play games, mesh_bot.py has you covered." # software description - OPTIONAL (but strongly recommended!)
|
||||
URL="https://github.com/SpudGunMan/meshing-around" # software URL. Can contain multiple URLs - OPTIONAL
|
||||
options="xiugedsrNADUOSLCIto" # script options in use by software package. For example, for a package with no service, exclude `edsr`
|
||||
options="xiuagedsrNADUOSLCI" # script options in use by software package. For example, for a package with no service, exclude `edsr`
|
||||
launch="" # command to launch software, if applicable
|
||||
service_name="mesh_bot pong_bot mesh_bot_reporting" # the name of the service, such as `chrony`. REQUIRED if service options are in use. If multiple services, separate by spaces "service1 service2"
|
||||
location="/opt/meshing-around" # install location REQUIRED if not apt installed. Generally, we use `/opt/software-name`
|
||||
|
|
@ -65,16 +66,13 @@ install() {
|
|||
exit 1
|
||||
fi
|
||||
if [ "$interactive" = "true" ]; then #interactive install
|
||||
"$location/install.sh" | tee /dev/tty
|
||||
echo "user_message: To change settings, run \`sudo nano $location/config.ini\`"
|
||||
exit 0
|
||||
interactive_init
|
||||
else
|
||||
echo "user_message: IMPORTANT: To complete installation, run \`sudo $location/install.sh\`\nTo change settings, run \`sudo nano $location/config.ini\`"
|
||||
exit 0
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
# uninstall script
|
||||
uninstall() {
|
||||
# stop, disable and remove the service, reload systemctl daemon, remove the installation directory and quit
|
||||
|
|
@ -96,6 +94,12 @@ uninstall() {
|
|||
exit 0
|
||||
}
|
||||
|
||||
# code that must be run to initialize the installation prior to use, but can only be run from terminal
|
||||
interactive_init() {
|
||||
"$location/install.sh" | tee /dev/tty
|
||||
echo "user_message: To change settings, run \`sudo nano $location/config.ini\`"
|
||||
exit 0
|
||||
}
|
||||
|
||||
#upgrade script
|
||||
upgrade() {
|
||||
|
|
@ -129,6 +133,9 @@ while getopts ":h$options" opt; do
|
|||
i) # Option -i (install)
|
||||
install
|
||||
;;
|
||||
a) # Option -a (interactive initialization)
|
||||
interactive_init
|
||||
;;
|
||||
u) # Option -u (uninstall)
|
||||
uninstall
|
||||
;;
|
||||
|
|
|
|||
|
|
@ -32,7 +32,8 @@ Arguments:
|
|||
-U Get URL
|
||||
-O Get options supported by this script
|
||||
-S Get service status
|
||||
-L Get Install location
|
||||
-L Get install location
|
||||
-P Get package name
|
||||
-C Get Conflicts
|
||||
-I Check if installed. Returns an error if not installed
|
||||
EOF
|
||||
|
|
@ -53,17 +54,18 @@ name="Mosquitto MQTT Broker" # software name
|
|||
author="Eclipse Foundation" # software author - OPTIONAL
|
||||
description="Eclipse Mosquitto is an open source (EPL/EDL licensed) message broker that implements the MQTT protocol versions 5.0, 3.1.1 and 3.1. Mosquitto is lightweight and is suitable for use on all devices from low power single board computers to full servers.\n\nThe MQTT protocol provides a lightweight method of carrying out messaging using a publish/subscribe model. This makes it suitable for Internet of Things messaging such as with low power sensors or mobile devices such as phones, embedded computers or microcontrollers.\n\nThe Mosquitto project also provides a C library for implementing MQTT clients, and the very popular mosquitto_pub and mosquitto_sub command line MQTT clients.\n\nMosquitto is part of the Eclipse Foundation, and is an iot.eclipse.org project. The development is driven by Cedalo." # software description - OPTIONAL (but strongly recommended!)
|
||||
URL="https://mosquitto.org/" # software URL. Can contain multiple URLs - OPTIONAL
|
||||
options="xiugedslNADUOSLCIto" # script options in use by software package. For example, for a package with no service, exclude `edsr`
|
||||
options="xiugedsrNADUOSPCI" # script options in use by software package. For example, for a package with no service, exclude `edsr`
|
||||
launch="" # command to launch software, if applicable
|
||||
service_name="mosquitto" # the name of the service/s, such as `chrony`. REQUIRED if service options are in use. If multiple services, separate by spaces "service1 service2"
|
||||
package_name="mosquitto" # apt package name, if applicable
|
||||
location="" # install location REQUIRED if not apt installed. Generally, we use `/opt/software-name`
|
||||
conflicts="" # comma delineated plain-text list of packages with which this package conflicts. Blank if none. Use the name as it appears in the $name field of the other package. Extra plaintext is allowed, such as "packageA, packageB, any other software that uses the Meshtastic CLI"
|
||||
|
||||
# install script
|
||||
install() {
|
||||
echo "apt update can take a long while..."
|
||||
DEBIAN_FRONTEND=noninteractive apt-get update -y 2>&1 | tee /dev/tty # allows output to be shown onscreen
|
||||
DEBIAN_FRONTEND=noninteractive apt-get install mosquitto -y 2>&1 | tee /dev/tty # allows output to be shown onscreen
|
||||
DEBIAN_FRONTEND=noninteractive apt-get update -y 2>&1 | tee /dev/tty | grep -q "Err" && { echo "user_message: apt update failed. Is internet connected?"; exit 1; }
|
||||
DEBIAN_FRONTEND=noninteractive apt-get install $package_name -y 2>&1 | tee /dev/tty | grep -q "Err" && { echo "user_message: apt install failed. Is internet connected?"; exit 1; }
|
||||
echo "user_message: Installation requires more setup. For a guide, see https://docs.vultr.com/how-to-install-mosquitto-mqtt-broker-on-ubuntu-24-04"
|
||||
exit 0 # should be `exit 1` if operation failed
|
||||
}
|
||||
|
|
@ -71,7 +73,7 @@ install() {
|
|||
|
||||
# uninstall script
|
||||
uninstall() {
|
||||
DEBIAN_FRONTEND=noninteractive apt remove -y mosquitto 2>&1 | tee /dev/tty
|
||||
DEBIAN_FRONTEND=noninteractive apt remove -y $package_name 2>&1 | tee /dev/tty
|
||||
/usr/local/bin/mosquitto_mqtt_broker.sh -s # stop service
|
||||
/usr/local/bin/mosquitto_mqtt_broker.sh -d # disable service
|
||||
echo "user_message: Some files may remain on system. To remove, run \`sudo apt remove --purge mosquitto -y\` and \`sudo apt autoremove -y\`."
|
||||
|
|
@ -82,14 +84,14 @@ uninstall() {
|
|||
#upgrade script
|
||||
upgrade() {
|
||||
echo "apt update can take a long while..."
|
||||
DEBIAN_FRONTEND=noninteractive apt-get update -y 2>&1 | tee /dev/tty # allows output to be shown onscreen
|
||||
DEBIAN_FRONTEND=noninteractive apt upgrade -y mosquitto 2>&1 | tee /dev/tty
|
||||
DEBIAN_FRONTEND=noninteractive apt-get update -y 2>&1 | tee /dev/tty | grep -q "Err" && { echo "user_message: apt update failed. Is internet connected?"; exit 1; }
|
||||
DEBIAN_FRONTEND=noninteractive apt upgrade -y $package_name 2>&1 | tee /dev/tty | grep -q "Err" && { echo "user_message: apt upgrade failed. Is internet connected?"; exit 1; }
|
||||
exit 0 # should be `exit 1` if operation failed
|
||||
}
|
||||
|
||||
# Check if already installed. `exit 0` if yes, `exit 1` if no
|
||||
check() {
|
||||
if dpkg -l | grep -q mosquitto; then
|
||||
if dpkg-query -W -f='${Status}' $package_name 2>/dev/null | grep -q "install ok installed"; then
|
||||
exit 0
|
||||
else
|
||||
exit 1
|
||||
|
|
@ -138,6 +140,7 @@ while getopts ":h$options" opt; do
|
|||
systemctl status $service_name
|
||||
;;
|
||||
L) echo -e $location ;;
|
||||
P) echo -e $package_name ;;
|
||||
C) echo -e $conflicts ;;
|
||||
I) # Option -I (Check if already installed)
|
||||
check
|
||||
|
|
|
|||
|
|
@ -32,7 +32,8 @@ Arguments:
|
|||
-U Get URL
|
||||
-O Get options supported by this script
|
||||
-S Get service status
|
||||
-L Get Install location
|
||||
-L Get install location
|
||||
-P Get package name
|
||||
-C Get Conflicts
|
||||
-I Check if installed. Returns an error if not installed
|
||||
EOF
|
||||
|
|
@ -53,17 +54,18 @@ name="Mosquitto MQTT Client" # software name
|
|||
author="Eclipse Foundation" # software author - OPTIONAL
|
||||
description="Eclipse Mosquitto is an open source (EPL/EDL licensed) message broker that implements the MQTT protocol versions 5.0, 3.1.1 and 3.1. Mosquitto is lightweight and is suitable for use on all devices from low power single board computers to full servers.\n\nThe MQTT protocol provides a lightweight method of carrying out messaging using a publish/subscribe model. This makes it suitable for Internet of Things messaging such as with low power sensors or mobile devices such as phones, embedded computers or microcontrollers.\n\nThe Mosquitto project also provides a C library for implementing MQTT clients, and the very popular mosquitto_pub and mosquitto_sub command line MQTT clients.\n\nMosquitto is part of the Eclipse Foundation, and is an iot.eclipse.org project. The development is driven by Cedalo." # software description - OPTIONAL (but strongly recommended!)
|
||||
URL="https://mosquitto.org/" # software URL. Can contain multiple URLs - OPTIONAL
|
||||
options="xiugedslNADUOSLCIto" # script options in use by software package. For example, for a package with no service, exclude `edsr`
|
||||
options="xiugedsrNADUOSPCI" # script options in use by software package. For example, for a package with no service, exclude `edsr`
|
||||
launch="" # command to launch software, if applicable
|
||||
service_name="" # the name of the service/s, such as `chrony`. REQUIRED if service options are in use. If multiple services, separate by spaces "service1 service2"
|
||||
location="" # install location REQUIRED if not apt installed. Generally, we use `/opt/software-name`
|
||||
package_name="mosquitto-clients" # apt package name, if applicable
|
||||
conflicts="" # comma delineated plain-text list of packages with which this package conflicts. Blank if none. Use the name as it appears in the $name field of the other package. Extra plaintext is allowed, such as "packageA, packageB, any other software that uses the Meshtastic CLI"
|
||||
|
||||
# install script
|
||||
install() {
|
||||
echo "apt update can take a long while..."
|
||||
DEBIAN_FRONTEND=noninteractive apt-get update -y 2>&1 | tee /dev/tty # allows output to be shown onscreen
|
||||
DEBIAN_FRONTEND=noninteractive apt-get install mosquitto-clients -y 2>&1 | tee /dev/tty # allows output to be shown onscreen
|
||||
DEBIAN_FRONTEND=noninteractive apt-get update -y 2>&1 | tee /dev/tty | grep -q "Err" && { echo "user_message: apt update failed. Is internet connected?"; exit 1; }
|
||||
DEBIAN_FRONTEND=noninteractive apt-get install $package_name -y 2>&1 | tee /dev/tty | grep -q "Err" && { echo "user_message: apt install failed. Is internet connected?"; exit 1; }
|
||||
echo "user_message: Installation requires more setup. For a guide, see https://docs.vultr.com/how-to-install-mosquitto-mqtt-broker-on-ubuntu-24-04"
|
||||
exit 0 # should be `exit 1` if operation failed
|
||||
}
|
||||
|
|
@ -80,14 +82,14 @@ uninstall() {
|
|||
#upgrade script
|
||||
upgrade() {
|
||||
echo "apt update can take a long while..."
|
||||
DEBIAN_FRONTEND=noninteractive apt-get update -y 2>&1 | tee /dev/tty # allows output to be shown onscreen
|
||||
DEBIAN_FRONTEND=noninteractive apt upgrade -y mosquitto-clients 2>&1 | tee /dev/tty
|
||||
DEBIAN_FRONTEND=noninteractive apt-get update -y 2>&1 | tee /dev/tty | grep -q "Err" && { echo "user_message: apt update failed. Is internet connected?"; exit 1; }
|
||||
DEBIAN_FRONTEND=noninteractive apt upgrade -y $package_name 2>&1 | tee /dev/tty | grep -q "Err" && { echo "user_message: apt upgrade failed. Is internet connected?"; exit 1; }
|
||||
exit 0 # should be `exit 1` if operation failed
|
||||
}
|
||||
|
||||
# Check if already installed. `exit 0` if yes, `exit 1` if no
|
||||
check() {
|
||||
if dpkg -l | grep -q mosquitto-clients; then
|
||||
if dpkg-query -W -f='${Status}' $package_name 2>/dev/null | grep -q "install ok installed"; then
|
||||
exit 0
|
||||
else
|
||||
exit 1
|
||||
|
|
@ -136,6 +138,7 @@ while getopts ":h$options" opt; do
|
|||
systemctl status $service_name
|
||||
;;
|
||||
L) echo -e $location ;;
|
||||
P) echo -e $package_name ;;
|
||||
C) echo -e $conflicts ;;
|
||||
I) # Option -I (Check if already installed)
|
||||
check
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ if [ $# -eq 0 ]; then
|
|||
fi
|
||||
|
||||
args="$@" # arguments to this script
|
||||
interaction="true"
|
||||
interactive="true"
|
||||
help=$(cat <<EOF
|
||||
Arguments:
|
||||
-h This message
|
||||
|
|
@ -19,6 +19,7 @@ Arguments:
|
|||
Actions:
|
||||
-i Install
|
||||
-u Uninstall
|
||||
-a Interactive initialization script: code that must be run to initialize the installation prior to use, but can only be run from terminal
|
||||
-g Upgrade
|
||||
-e Enable service, if applicable
|
||||
-d Disable service, if applicable
|
||||
|
|
@ -32,7 +33,8 @@ Arguments:
|
|||
-U Get URL
|
||||
-O Get options supported by this script
|
||||
-S Get service status
|
||||
-L Get Install location
|
||||
-L Get install location
|
||||
-P Get package name
|
||||
-C Get Conflicts
|
||||
-I Check if installed. Returns an error if not installed
|
||||
EOF
|
||||
|
|
@ -48,32 +50,36 @@ EOF
|
|||
# Messages to the user (such as configuration instructions, explanatory error messages, etc) should be given as: `echo "user_message: text"`
|
||||
# Everything following `user_message: ` will be displayed prominently to the user, so it must the last thing echoed
|
||||
|
||||
|
||||
name="name" # software name
|
||||
author="author" # software author - OPTIONAL
|
||||
description="description" # software description - OPTIONAL (but strongly recommended!)
|
||||
URL="URL" # software URL. Can contain multiple URLs - OPTIONAL
|
||||
options="xiugedsrlNADUOSLCIto" # script options in use by software package. For example, for a package with no service, exclude `edsr`
|
||||
launch="" # command to launch software, if applicable
|
||||
service_name="service_name" # the name of the service/s, such as `chrony`. REQUIRED if service options are in use. If multiple services, separate by spaces "service1 service2"
|
||||
location="/opt/location" # install location REQUIRED if not apt installed. Generally, we use `/opt/software-name`
|
||||
conflicts="package name, other package name" # comma delineated plain-text list of packages with which this package conflicts. Blank if none. Use the name as it appears in the $name field of the other package. Extra plaintext is allowed, such as "packageA, packageB, any other software that uses the Meshtastic CLI"
|
||||
name="name" # software name
|
||||
author="author" # software author - OPTIONAL
|
||||
description="description" # software description - OPTIONAL (but strongly recommended!)
|
||||
URL="URL" # software URL. Can contain multiple URLs - OPTIONAL
|
||||
options="hxiuagedsrlNADUOSLPCI" # script options in use by software package. For example, for a package with no service, exclude `edsrS`
|
||||
launch="/opt/package/run.sh" # command to launch software, if applicable
|
||||
service_name="service_name" # the name of the service/s, such as `chrony`. REQUIRED if service options are in use. If multiple services, separate by spaces "service1 service2"
|
||||
package_name="apt_package" # apt package name, if applicable. Can be multiple packages separated by spaces, but if at least one is installed the package will show as "installed" even if the others aren't
|
||||
location="/opt/location" # install location REQUIRED if not apt installed. Generally, we use `/opt/software-name`
|
||||
conflicts="package1, package2" # comma delineated plain-text list of packages with which this package conflicts. Blank if none. Use the name as it appears in the $name field of the other package. Extra plaintext is allowed, such as "packageA, packageB, any other software that uses the Meshtastic CLI"
|
||||
|
||||
# install script
|
||||
install() {
|
||||
# for apt packages, this method allows onscreen output during install:
|
||||
# DEBIAN_FRONTEND=noninteractive sudo apt-get install mosquitto -y 2>&1 | tee /dev/tty # allows output to be shown onscreen
|
||||
# DEBIAN_FRONTEND=noninteractive apt-get update -y 2>&1 | tee /dev/tty || { echo "user_message: apt update failed. Is internet connected?"; exit 1; }
|
||||
# DEBIAN_FRONTEND=noninteractive apt-get install $package_name -y 2>&1 | tee /dev/tty || { echo "user_message: apt install failed. Is internet connected?"; exit 1; }
|
||||
echo "user_message: Exit message to user, displayed prominently in post-install"
|
||||
exit 0 # should be `exit 1` if operation failed
|
||||
}
|
||||
|
||||
|
||||
# uninstall script
|
||||
uninstall() {
|
||||
echo "user_message: Exit message to user, displayed prominently in post-install"
|
||||
exit 0 # should be `exit 1` if operation failed
|
||||
}
|
||||
|
||||
# code that must be run to initialize the installation prior to use, but can only be run from terminal
|
||||
interactive_init() {
|
||||
exit 0 # should be `exit 1` if operation failed
|
||||
}
|
||||
|
||||
# upgrade script
|
||||
upgrade() {
|
||||
|
|
@ -91,14 +97,14 @@ check() {
|
|||
fi
|
||||
|
||||
# this works for apt packages
|
||||
if [ dpkg -l | grep -q package-name ] ; then
|
||||
if dpkg-query -W -f='${Status}' $package_name 2>/dev/null | grep -q "install ok installed"; then
|
||||
exit 0
|
||||
else
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
while getopts ":h$options" opt; do
|
||||
while getopts ":$options" opt; do
|
||||
case ${opt} in
|
||||
h) # Option -h (help)
|
||||
echo -e "$help"
|
||||
|
|
@ -112,6 +118,9 @@ while getopts ":h$options" opt; do
|
|||
u) # Option -u (uninstall)
|
||||
uninstall
|
||||
;;
|
||||
a) # Option -a (interactive initialization)
|
||||
interactive_init
|
||||
;;
|
||||
g) # Option -g (upgrade)
|
||||
upgrade
|
||||
;;
|
||||
|
|
@ -140,6 +149,7 @@ while getopts ":h$options" opt; do
|
|||
systemctl status $service_name
|
||||
;;
|
||||
L) echo -e $location ;;
|
||||
P) echo -e $package_name ;;
|
||||
C) echo -e $conflicts ;;
|
||||
I) # Option -I (Check if already installed)
|
||||
check
|
||||
|
|
|
|||
169
foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/packages/samba.sh
Executable file
169
foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/packages/samba.sh
Executable file
|
|
@ -0,0 +1,169 @@
|
|||
#!/bin/bash
|
||||
if [[ $EUID -ne 0 ]]; then
|
||||
echo "This script must be run as root. Try \`sudo\`."
|
||||
exit 1
|
||||
fi
|
||||
if [ $# -eq 0 ]; then
|
||||
echo "No arguments provided."
|
||||
echo -e "$help"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
args="$@" # arguments to this script
|
||||
interactive="true"
|
||||
help=$(cat <<EOF
|
||||
Arguments:
|
||||
-h This message
|
||||
Environment - must be first argument:
|
||||
-x User UI is not terminal (script interaction unavailable)
|
||||
Actions:
|
||||
-i Install
|
||||
-u Uninstall
|
||||
-a Interactive initialization script: code that must be run to initialize the installation prior to use, but can only be run from terminal
|
||||
-g Upgrade
|
||||
-e Enable service, if applicable
|
||||
-d Disable service, if applicable
|
||||
-s Stop service
|
||||
-r Start/Restart
|
||||
-l Command to run software
|
||||
Information:
|
||||
-N Get name
|
||||
-A Get author
|
||||
-D Get description
|
||||
-U Get URL
|
||||
-O Get options supported by this script
|
||||
-S Get service status
|
||||
-L Get install location
|
||||
-P Get package name
|
||||
-C Get Conflicts
|
||||
-I Check if installed. Returns an error if not installed
|
||||
EOF
|
||||
)
|
||||
|
||||
### For package maintainer:
|
||||
# Fill the following fields and choose the options that are in use by this package
|
||||
# Populate the install, uninstall and upgrade functions
|
||||
# Remember that this script may be launched in terminal, via web UI or another method, so inputs aren't really possible
|
||||
# Arguments to the script are stored in $args
|
||||
# This system supports both interactive and non-interactive installs. For non-interactive installs, $interaction="false". In this cause special instructions to the user should be given as user_message, such as `After installation, edit /opt/software/config.ini`
|
||||
# Successful operations should `exit 0`, fails should `exit 1`
|
||||
# Messages to the user (such as configuration instructions, explanatory error messages, etc) should be given as: `echo "user_message: text"`
|
||||
# Everything following `user_message: ` will be displayed prominently to the user, so it must the last thing echoed
|
||||
|
||||
user_message="To connect to network share, enter \`\\\\femtofox\\home\` in Windows, \`smb://$(hostname)/home\` in MacOS or \`smbclient //$(hostname)/femto -U femto\` in Linux.\nDefault configuration shares /home/femto. Edit \`/etc/samba/smb.conf\` to add other shares.\n\nTroubleshooting: if Windows refuses to connect, especially after succeeding previously, hit [win]+R and enter \`net use * /delete\`."
|
||||
init_instructions="To enable file sharing, run \`Initialize\` in the femto-config Samba menu, or enable the Samba service, run \`sudo smbpasswd -a femto\` to set a Samba password, and then restart the Samba service."
|
||||
|
||||
name="Samba File Sharing" # software name
|
||||
author="Software Freedom Conservancy" # software author - OPTIONAL
|
||||
description="Femtofox comes with Samba preinstalled but disabled. $init_instructions\n\n$user_message" # software description - OPTIONAL (but strongly recommended!)
|
||||
URL="https://www.samba.org/" # software URL. Can contain multiple URLs - OPTIONAL
|
||||
options="xiuagedsrNADUOSPCI" # script options in use by software package. For example, for a package with no service, exclude `edsr`
|
||||
launch="" # command to launch software, if applicable
|
||||
service_name="smbd nmbd" # the name of the service/s, such as `chrony`. REQUIRED if service options are in use. If multiple services, separate by spaces "service1 service2"
|
||||
location="" # install location REQUIRED if not apt installed. Generally, we use `/opt/software-name`
|
||||
package_name="samba" # apt package name, if applicable
|
||||
conflicts="" # comma delineated plain-text list of packages with which this package conflicts. Blank if none. Use the name as it appears in the $name field of the other package. Extra plaintext is allowed, such as "packageA, packageB, any other software that uses the Meshtastic CLI"
|
||||
|
||||
# install script
|
||||
install() {
|
||||
echo "apt update can take a long while..."
|
||||
# DEBIAN_FRONTEND=noninteractive apt-get update -y 2>&1 | tee /dev/tty | grep -q "Err" && { echo "user_message: apt update failed. Is internet connected?"; exit 1; }
|
||||
# DEBIAN_FRONTEND=noninteractive apt-get install $package_name -y 2>&1 | tee /dev/tty | grep -q "Err" && { echo "user_message: apt install failed. Is internet connected?"; exit 1; }
|
||||
if [ "$interactive" = "true" ]; then # interactive install
|
||||
interactive_init
|
||||
else # noninteractive installation (such as web-UI)
|
||||
echo -e "user_message: IMPORTANT: $init_instructions\n\n$user_message"
|
||||
exit 0 # should be `exit 1` if operation failed
|
||||
fi
|
||||
}
|
||||
|
||||
# uninstall script
|
||||
uninstall() {
|
||||
DEBIAN_FRONTEND=noninteractive apt remove -y $package_name 2>&1 | tee /dev/tty
|
||||
echo "Removing unused dependencies..."
|
||||
DEBIAN_FRONTEND=noninteractive apt autoremove -y $package_name 2>&1 | tee /dev/tty
|
||||
echo "user_message: Some files may remain on system. To remove, run \`sudo apt remove --purge $package_name -y\` and \`sudo apt autoremove -y\`."
|
||||
exit 0 # should be `exit 1` if operation failed
|
||||
}
|
||||
|
||||
# code that must be run to initialize the installation prior to use, but can only be run from terminal
|
||||
interactive_init() {
|
||||
echo -e "\nSet user \`Femto\` login password:"
|
||||
smbpasswd -a femto
|
||||
/usr/local/bin/packages/samba.sh -e
|
||||
/usr/local/bin/packages/samba.sh -r
|
||||
echo -e "user_message: Samba initialized, and service enabled and started. $user_message"
|
||||
exit 0
|
||||
}
|
||||
|
||||
#upgrade script
|
||||
upgrade() {
|
||||
echo "apt update can take a long while..."
|
||||
DEBIAN_FRONTEND=noninteractive apt-get update -y 2>&1 | tee /dev/tty | grep -q "Err" && { echo "user_message: apt update failed. Is internet connected?"; exit 1; }
|
||||
DEBIAN_FRONTEND=noninteractive apt upgrade -y $package_name 2>&1 | tee /dev/tty | grep -q "Err" && { echo "user_message: apt upgrade failed. Is internet connected?"; exit 1; }
|
||||
exit 0 # should be `exit 1` if operation failed
|
||||
}
|
||||
|
||||
# Check if already installed. `exit 0` if yes, `exit 1` if no
|
||||
check() {
|
||||
if dpkg-query -W -f='${Status}' $package_name 2>/dev/null | grep -q "install ok installed"; then
|
||||
exit 0
|
||||
else
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
while getopts ":h$options" opt; do
|
||||
case ${opt} in
|
||||
h) # Option -h (help)
|
||||
echo -e "$help"
|
||||
;;
|
||||
x) # Option -x (no user interaction available)
|
||||
interaction="false"
|
||||
;;
|
||||
i) # Option -i (install)
|
||||
install
|
||||
;;
|
||||
a) # Option -a (interactive initialization)
|
||||
interactive_init
|
||||
;;
|
||||
u) # Option -u (uninstall)
|
||||
uninstall
|
||||
;;
|
||||
g) # Option -g (upgrade)
|
||||
upgrade
|
||||
;;
|
||||
e) # Option -e (Enable service, if applicable)
|
||||
systemctl enable $service_name
|
||||
;;
|
||||
d) # Option -d (Disable service, if applicable)
|
||||
systemctl disable $service_name
|
||||
;;
|
||||
s) # Option -s (Stop service)
|
||||
systemctl stop $service_name
|
||||
;;
|
||||
r) # Option -r (Start/Restart)
|
||||
systemctl restart $service_name
|
||||
;;
|
||||
l) # Option -l (Run software)
|
||||
echo "Launching $name..."
|
||||
sudo -u ${SUDO_USER:-$(whoami)} $launch
|
||||
;;
|
||||
N) echo -e $name ;;
|
||||
A) echo -e $author ;;
|
||||
D) echo $description ;;
|
||||
U) echo -e $URL ;;
|
||||
O) echo -e $options ;;
|
||||
S) # Option -S (Get service status)
|
||||
systemctl status $service_name
|
||||
;;
|
||||
L) echo -e $location ;;
|
||||
P) echo -e $package_name ;;
|
||||
C) echo -e $conflicts ;;
|
||||
I) # Option -I (Check if already installed)
|
||||
check
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
exit 0
|
||||
|
|
@ -49,11 +49,11 @@ EOF
|
|||
# Everything following `user_message: ` will be displayed prominently to the user, so it must the last thing echoed
|
||||
|
||||
|
||||
name="TC2-BBS" # software name
|
||||
name="TC²-BBS" # software name
|
||||
author="The Comms Channel" # software author - OPTIONAL
|
||||
description="The TC²-BBS system integrates with Meshtastic devices. The system allows for message handling, bulletin boards, mail systems, and a channel directory." # software description - OPTIONAL (but strongly recommended!)
|
||||
URL="https://github.com/TheCommsChannel/TC2-BBS-mesh" # software URL. Can contain multiple URLs - OPTIONAL
|
||||
options="xiugedsrlNADUOSLCIto" # script options in use by software package. For example, for a package with no service, exclude `edsr`
|
||||
options="xiugedsrNADUOSLCI" # script options in use by software package. For example, for a package with no service, exclude `edsr`
|
||||
launch="python /opt/TC2-BBS-mesh/server.py" # command to launch software, if applicable
|
||||
service_name="mesh-bbs" # the name of the service/s, such as `chrony`. REQUIRED if service options are in use. If multiple services, separate by spaces "service1 service2"
|
||||
location="/opt/TC2-BBS-mesh" # install location REQUIRED if not apt installed. Generally, we use `/opt/software-name`
|
||||
|
|
@ -93,7 +93,9 @@ uninstall() {
|
|||
systemctl stop $service_name
|
||||
rm /etc/systemd/system/$service_name.service
|
||||
systemctl daemon-reload
|
||||
echo "Disabled and removed \`$service_name\` service."
|
||||
rm -rf $location
|
||||
echo "Removed \`$location\`."
|
||||
echo "user_message: Service removed, all files deleted."
|
||||
exit 0
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue