Merge pull request #274 from femtofox/new_working

Add web-terminal and add public and private key settings to install wizard
This commit is contained in:
noon92 2025-02-04 20:57:58 +02:00 • committed by GitHub
commit 55717f583a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
8 changed files with 224 additions and 109 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 127 KiB

After

Width:  |  Height:  |  Size: 173 KiB

Before After
Before After

View file

@ -37,6 +37,12 @@ echo "Installing dependencies for meshing-around and meshtastic cli..."
pip3 install requests pyephem pytap2 meshtastic pypubsub geopy maidenhead beautifulsoup4 dadjokes schedule wikipedia googlesearch-python
if [[ $? -eq 2 ]]; then echo "Error, step failed..."; fi
echo "Downloading ttyd and enabling service..."
wget -qO- https://api.github.com/repos/tsl0922/ttyd/releases/latest | \
grep "browser_download_url" | grep "armhf" | cut -d '"' -f 4 | xargs wget -O /opt/ttyd
chmod +x /opt/ttyd
systemctl enable ttyd
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

View file

@ -0,0 +1,14 @@
[Unit]
Description=TTYD
After=syslog.target
After=network.target
[Service]
ExecStart=/opt/ttyd -W -6 login
Type=simple
Restart=always
User=root
Group=root
[Install]
WantedBy=multi-user.target

View file

@ -191,19 +191,21 @@ utilities() {
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" "" \
8 "Disable/enable web terminal" "" \
9 "Disable/enable logging" "" \
10 "Disable/enable activity LED" "" \
11 "Reboot" "" \
12 "Shutdown" "" \
" " "" "" \
12 "Back to main menu" "" 3>&1 1>&2 2>&3)
13 "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 $utilities_choice in
1) #sysinfo)
choice="" # zero the choice before loading the submenu
sysinfo_choice="" # zero the choice before loading the submenu
while true; do
choice=$(dialog --no-collapse --help-button --help-label "Help" --cancel-label "Back" --default-item "$choice" --item-help --menu "System info" 17 40 5 \
echo $sysinfo_choice
sysinfo_choice=$(dialog --no-collapse --help-button --help-label "Help" --cancel-label "Back" --default-item "$sysinfo_choice" --item-help --menu "System info" 17 40 5 \
1 "CPU" "" \
2 "Operating system" "" \
3 "Storage & memory" "" \
@ -219,7 +221,7 @@ utilities() {
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\`.\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
case $sysinfo_choice in
1) # CPU)
loading "Loading CPU info..."
dialog --no-collapse --colors --title "CPU info" --msgbox "$(ingest_data "femto-utils.sh -c" 15)" 0 0
@ -286,9 +288,32 @@ $(ingest_data "femto-meshtasticd-config.sh -i" 15)" 0 0
;;
6) luckfox-config ;;
7) htop ;;
8) # logging)
8)
choice="" # zero the choice before loading the submenu
while true; do
echo "Checking web terminal status..."
ttyd_state=$(replace_colors "$(femto-utils.sh -t "check")")
choice=$(dialog --no-collapse --colors --title "Web Terminal" --cancel-label "Back" --default-item "$choice" --item-help --menu "Web terminal available at \Zuhttp://$(hostname)local:7681\Zn\nCurrent state: $ttyd_state" 14 57 2 \
$(if ! echo "$ttyd_state" | grep -q 'enabled and running'; then echo "Enable and start (default) x  "; fi) \
$(if echo "$ttyd_state" | grep -q 'enabled'; then echo "Disable and stop x  "; fi) \
$(if echo "$ttyd_state" | grep -q 'enabled'; then echo "Start/restart ttyd service x  "; fi) \
$(if echo "$ttyd_state" | grep -q 'enabled'; then echo "View detailed service status x  "; fi) \
" " "" "" \
"Return to previous menu" "x" "" 3>&1 1>&2 2>&3)
[ $? -eq 1 ] && break # Exit the loop if the user selects "Cancel" or closes the dialog
case $choice in
"Enable and start (default)") femto-utils.sh -t "enable" ;;
"Disable and stop") femto-utils.sh -t "disable" ;;
"Start/restart ttyd service") femto-utils.sh -t "start" ;;
"View detailed service status") dialog --no-collapse --title "ttyd service status" --msgbox "$(systemctl status ttyd)" 0 0 ;;
"Return to previous menu") break ;;
esac
done
;;
9) # logging)
choice="" # zero the choice before loading the submenu
while true; do
echo "Checking current logging status..."
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" "" \
@ -302,9 +327,10 @@ $(ingest_data "femto-meshtasticd-config.sh -i" 15)" 0 0
esac
done
;;
9) # logging)
10) # activity LED)
choice="" # zero the choice before loading the submenu
while true; do
echo "Checking current activity LED status..."
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" "" \
@ -318,21 +344,21 @@ $(ingest_data "femto-meshtasticd-config.sh -i" 15)" 0 0
esac
done
;;
10) # reboot)
11) # reboot)
dialog --no-collapse --title "$title" --yesno "Reboot now?\n\nTip: Reboot can also be triggered by long-pressing the BOOT button on the luckfox." 10 45
if [ $? -eq 0 ]; then #unless cancel/no
loading "Rebooting..."
femto-utils.sh -r
fi
;;
11) # shutdown)
12) # shutdown)
dialog --no-collapse --colors --title "$title" --yesno "Shut down now?\n\nTo power system back on, disconnect/reconnect power.\n\nThe system shutdown command prevents damage to the filesystem from power interrupts, but does not stop power consumption.\n\nTip: You can also shut down the Femtofox by pressing the BOOT button for 5 seconds or by running \`\Zusudo halt\Zn\`." 14 60
if [ $? -eq 0 ]; then #unless cancel/no
loading "Shutting down...\n\nPower consumption will not stop."
femto-utils.sh -s
fi
;;
12) return ;;
13) return ;;
esac
done
}
@ -343,7 +369,7 @@ set_lora_radio() {
while true; do
echo "Checking LoRa radio..."
#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, -))
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 \
choice=$(dialog --no-collapse --colors --cancel-label "Cancel" --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)" "" \
@ -537,7 +563,7 @@ meshtastic_settings() {
dialog --no-collapse --title "Meshtastic Connectivity Test" --yesno "Will send \"test\" to channel 0 and wait for acknowledgement. Will try up to 3 times.\n\nPerform test?" 10 45
if [ $? -eq 0 ]; then #unless cancel/no
dialog --no-collapse --infobox "Performing mesh connectivity test.\n\nThis may take a while..." 6 45
dialog --no-collapse --colors --title "Meshtasticd service status" --msgbox "$(replace_colors "$(femto-meshtasticd-config.sh -w)")" 0 0
dialog --no-collapse --colors --title "Meshtasticd connectivity test" --msgbox "$(replace_colors "$(femto-meshtasticd-config.sh -w)")" 0 0
fi
;;
7) #manage meshtasticd service)

View file

@ -9,10 +9,8 @@ if [[ $EUID -ne 0 ]]; then
exit 1
fi
# pause
pause() {
echo "Press any key to continue..."
read -n 1 -s -r
loading() {
dialog --no-collapse --infobox "$1" 5 45
}
title="Install Wizard"
@ -32,30 +30,61 @@ wizard() {
femto-config -w
fi
femto-config -l #set lora radio model
dialog --title "$title" --cancel-label "Skip" --yesno "\nConfigure Meshtastic?" 8 40
if [ $? -eq 0 ]; then #unless cancel/no
newurl=$(dialog --title "Meshtastic URL" --cancel-label "Skip" --inputbox "New Meshtasticd URL (SHIFT+INS to paste):" 8 50 3>&1 1>&2 2>&3)
newurl=$(dialog --title "Meshtastic URL" --inputbox "New Meshtasticd URL (SHIFT+INS to paste):" 8 50 3>&1 1>&2 2>&3)
if [ -n "$newurl" ]; then #if a URL was entered
femto-meshtasticd-config.sh -q "$newurl"
pause
loading "Sending URL..."
dialog --no-collapse --colors --title "Meshtastic URL" --msgbox "$(femto-meshtasticd-config.sh -q "$newurl" && echo -e "\n\Z4Command successful!\Zn\n" || echo -e "\n\Z1Command failed.\Zn\n")" 0 0
fi
loading "Getting current public key..."
key=$(femto-meshtasticd-config.sh -u)
if [ -n "$key" ]; then
dialog --no-collapse --title "Meshtastic public key" --yesno "Current public key:\n$key\n\nSet new key?" 9 55
if [ $? -eq 0 ]; then #unless cancel/no
key=$(dialog --no-collapse --title "Meshtastic public key" --inputbox "New Meshtastic public key (SHIFT+INS to paste):" 8 60 3>&1 1>&2 2>&3)
if [ $? -eq 0 ]; then #unless cancel/no
loading "Sending command..."
dialog --no-collapse --colors --title "Meshtastic public key" --msgbox "$(femto-meshtasticd-config.sh -U "$key" && echo -e "\n\Z4Command successful!\Zn\n" || echo -e "\n\Z1Command failed.\Zn\n")" 0 0
fi
fi
else
dialog --no-collapse --colors --title "Meshtastic public key" --msgbox "\Z1Failed to communicate with Meshtasticd.\Zn\n\nIs the service running?\n" 0 0
fi
loading "Getting current private key..."
key=$(femto-meshtasticd-config.sh -u)
if [ -n "$key" ]; then
dialog --no-collapse --title "Meshtastic private key" --yesno "Current private key:\n$key\n\nSet new key?" 9 55
if [ $? -eq 0 ]; then #unless cancel/no
key=$(dialog --no-collapse --title "Meshtastic private key" --inputbox "New Meshtastic private key (SHIFT+INS to paste):" 8 60 3>&1 1>&2 2>&3)
if [ $? -eq 0 ]; then #unless cancel/no
loading "Sending command..."
dialog --no-collapse --colors --title "Meshtastic private key" --msgbox "$(femto-meshtasticd-config.sh -R "$key" && echo -e "\n\Z4Command successful!\Zn\n" || echo -e "\n\Z1Command failed.\Zn\n")" 0 0
fi
fi
else
dialog --no-collapse --colors --title "Meshtastic private key" --msgbox "\Z1Failed to communicate with Meshtasticd.\Zn\n\nIs the service running?\n" 0 0
fi
femto-config -l
key=$(dialog --title "$title" --cancel-label "Skip" --inputbox "Enter Meshtastic admin key (optional). If 3 admin keys are already in Meshtastic, more will be ignored.\n(SHIFT+INS to paste):" 11 50 3>&1 1>&2 2>&3)
if [ -n "$key" ]; then #if a URL was entered
femto-meshtasticd-config.sh -a "$key"
pause
loading "Sending key..."
dialog --no-collapse --colors --title "Meshtastic URL" --msgbox "$(femto-meshtasticd-config.sh -A "$key" && echo -e "\n\Z4Command successful!\Zn\n" || echo -e "\n\Z1Command failed.\Zn\n")" 0 0
fi
dialog --no-collapse --infobox "Getting current legacy admin state..." 5 45
state=$(sudo femto-meshtasticd-config.sh -p)
if echo "$state" | grep -q "True"; then
state="\Z4Enabled\Zn"
elif echo "$state" | grep -q "False"; then
state="\Z1Disabled\Zn"
elif echo "$state" | grep -q "Error"; then
state="\Z1Error\Zn"
if echo "$state" | grep -q "enabled"; then # poor man's replace ansi colors
state="\Z4enabled\Zn"
elif echo "$state" | grep -q "disabled"; then
state="\Z1disabled\Zn"
elif echo "$state" | grep -q "error"; then
state="\Z1error\Zn"
fi
while true; do
choice=$(dialog --no-collapse --colors --cancel-label "Skip" --title "Meshtasticd Legacy Admin" --menu "Current state: $state" 12 40 5 \
@ -69,18 +98,14 @@ wizard() {
fi
case $choice in
1) # enable legacy admin)
dialog --no-collapse --title "$title" --yesno "Enable legacy admin channel?\n" 0 0
if [ $? -eq 0 ]; then #unless cancel/no
dialog --no-collapse --infobox "Sending command..." 5 45
dialog --no-collapse --colors --title "$title" --msgbox "$(femto-meshtasticd-config.sh -o "true" && echo -e "\n\Z4Command successful!\Zn\n" || echo -e "\n\Z1Command failed.\Zn\n")" 0 0
fi
dialog --no-collapse --infobox "Sending command..." 5 45
dialog --no-collapse --colors --title "$title" --msgbox "$(femto-meshtasticd-config.sh -o "true" && echo -e "\n\Z4Command successful!\Zn\n" || echo -e "\n\Z1Command failed.\Zn\n")" 0 0
break
;;
2) # disable legacy admin)
dialog --no-collapse --title "$title" --yesno "Disable legacy admin channel?\n" 0 0
if [ $? -eq 0 ]; then #unless cancel/no
dialog --no-collapse --infobox "Sending command..." 5 45
dialog --no-collapse --colors --title "$title" --msgbox "$(femto-meshtasticd-config.sh -o "false" && echo -e "\n\Z4Command successful!\Zn\n" || echo -e "\n\Z1Command failed.\Zn\n")" 0 0
fi
dialog --no-collapse --infobox "Sending command..." 5 45
dialog --no-collapse --colors --title "$title" --msgbox "$(femto-meshtasticd-config.sh -o "false" && echo -e "\n\Z4Command successful!\Zn\n" || echo -e "\n\Z1Command failed.\Zn\n")" 0 0
break
;;
3) break ;;
esac

View file

@ -19,10 +19,10 @@ fi
femtofox="\
┌──────────┬────┬─────┬────┬───────────────┬───┬───────────────┐\n\
│⚪:⛊KILL ●│● │USB-C│ ●│● PWR-IN │✚ ▬│ 3.3-5V ⚪│\n\
│⚪:♥KILL ●│● │USB-C│ ●│● PWR-IN │✚ ▬│ 3.3-5V ⚪│\n\
├───────┐ ●│● └─────┘ ●│● └───┘ │\n\
│ USB-C │ ●│● ●│● ┌─────────────────────────────┐ │\n\
│ PWR ⛊ │ ●│● LUCKFOX ●│● │ ┌─────────────┐ │ │\n\
│ PWR ♥ │ ●│● LUCKFOX ●│● │ ┌─────────────┐ │ │\n\
│ DEBUG │ ●│● PICO MINI ●│● │ │ │ │ │\n\
├───────┘ ●│● ●│● │ │ │ │ │\n\
├───┐ ●│● FOXHOLE ●│● │ E │ │ │ │\n\
@ -40,77 +40,78 @@ femtofox="\
│ ● TX+ │ │● ● ● ●│ │ │ │\n\
├──────────────────┘ └───────┘ └─────────────────────────────┘ │\n\
│ ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ■ │\n\
│⚪● ● ● ● ● ● ⛊ ⛊ ⛊ ● ⛊ ⛊ ● ● ● ● ● ● ● ●⚪│\n\
│⚪● ● ● ● ● ● ♥ ♥ ♥ ● ● ♥ ♥ ● ● ● ● ● ● ●⚪│\n\
└──────────────────────────────────────────────────────────────┘\n\
\n\
R M M \n\
G X G C I O 3 G S S 3 \n\
N E N L S S V N C D V \n\
D N D K O I 3 D L A 3 \n\
● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ● ■ \n\
● ● ● ● ● ● ⛊ ⛊ ⛊ ● ● ⛊ ⛊ ● ● ● ● ● ● ● \n\
● ● ● ● ● ● ♥ ♥ ♥ ● ● ♥ ♥ ● ● ● ● ● ● ● \n\
C B I G G G G S S G R T G R R T G 5 5 \n\
S U R N P N P R R N X X N S X X N V V \n\
0 S Q D I D I A A D 2 2 D T 4 4 D \n\
Y O O 1 0 \n\
⛊ Denotes Pro features: \n\
♥ Denotes Pro features: \n\
On Community Edition, PWR/DEBUG USB-C replaced by 4pin UART2. \n\
PWR/DEBUG USB-C also carries serial with no added adapter. \n\
KILL: add PWR switch or thermal cutoff/fuse & remove resistor. "
KILL: add PWR switch or thermal cutoff/fuse & remove resistor."
femtofox_zero="\
┌────┐ ┌────┐ \n\
│⚪ \ / ⚪│ \n\
│ \ / │ \n\
│ └─────────┘ │ \n\
│ ┌─────────────────┐ │ \n\
│ ●│● USB-C ●│● │ \n\
│ ●│● ●│● │ \n\
│ ●│● ●│● │ \n\
│ ●│● LUCKFOX ●│● │ \n\
│ ●│● PICO MINI ●│● │ \n\
│ ●│● ●│● │ \n\
│ ●│● FOXHOLE ●│● │ \n\
│ ●│● ●│● │ \n\
│ ●│● ●│● │ \n\
│ ●│● ●│● │ \n\
│ ●│● ●│● │ \n\
│ └────●─●─●─●─●────┘ │ \n\
├───┐ ┌─────────────┐ ┌───┤ \n\
GND │ ● │ │ HT-RA62 │ │ ● │ GND \n\
3V3 │ ● │ │ ┌───────┐ │ │ ● │ 3V3 \n\
UART4-RX │ ● │ │ │ │ │ │ ● │ I2C SDA \n\
UART4-TX │ ● │ │ │ WIO │ │ │ ● │ I2C SCL \n\
├───┘ │ │SX 1262│ │ └───┤ \n\
│ │ └───────┘ │ ● │ UNUSED \n\
│ └─────────────┘ ● │ GND \n\
│⚪ ETH ⚪│ \n\
└────────●─●─●─●─●────────┘ \n\
R R G T T \n\
X X N X X \n\
┌────┐ ┌────┐
│⚪ \ / ⚪│
│ \ / │
│ └─────────┘ │
│ ┌─────────────────┐ │
│ ●│● USB-C ●│● │
│ ●│● ●│● │
│ ●│● ●│● │
│ ●│● LUCKFOX ●│● │
│ ●│● PICO MINI ●│● │
│ ●│● ●│● │
│ ●│● FOXHOLE ●│● │
│ ●│● ●│● │
│ ●│● ●│● │
│ ●│● ●│● │
│ ●│● ●│● │
│ └────●─●─●─●─●────┘ │
├───┐ ┌─────────────┐ ┌───┤
GND │ ● │ │ HT-RA62 │ │ ● │ GND
3V3 │ ● │ │ ┌───────┐ │ │ ● │ 3V3
UART4-RX │ ● │ │ │ │ │ │ ● │ I2C SDA
UART4-TX │ ● │ │ │ WIO │ │ │ ● │ I2C SCL
├───┘ │ │SX 1262│ │ └───┤
│ │ └───────┘ │ ● │ UNUSED
│ └─────────────┘ ● │ GND
│⚪ ETH ⚪│
└────────●─●─●─●─●────────┘
R R G T T
X X N X X
- + D - + \n"
femtofox_tiny="coming soon"
luckfox="\
┌────┬───────┬────┐ \n\
VBUS 3.3-5V ●│● │ USB-C │ ●│● 1V8 OUT \n\
GND ●│● │ │ ●│● GND \n\
3V3 IN/OUT ●│● └───────┘ ●│● 145, SARADC-IN1 1.8V\n\
UART2-TX DEBUG, 42 ●│● ●│● 144, SARADC-IN0 1.8V\n\
UART2-RX DEBUG, 43 ●│● [BTN] ●│● 4 \n\
CS0, 48 ●│● ●│● 55, IRQ \n\
CLK, 49 ●│● ●│● 54, BUSY \n\
MOSI, 50 ●│● ●│● 59, I2C SCL \n\
MISO, 51 ●│● ●│● 58, I2C SDA \n\
UART4-RX, 52 ●│● ●│● 57, NRST, UART3-RX \n\
UART4-TX, 53 ●│● ETH ●│● 56, RXEN, UART3-TX \n\
└──●──●──●──●──●──┘ \n\
R R G T T \n\
X X N X X \n\
- + D - + \n\
GPIO BANK 0 (3.3v): 4 \n\
GPIO BANK 1 (3.3v): 42 43 48 49 50 51 52 53 54 55 56 57 58 59\n\
┌────┬───────┬────┐
VBUS 3.3-5V ●│● │ USB-C │ ●│● 1V8 OUT
GND ●│● │ │ ●│● GND
3V3 IN/OUT ●│● └───────┘ ●│● 145, SARADC-IN1 1.8V
UART2-TX DEBUG, 42 ●│● ●│● 144, SARADC-IN0 1.8V
UART2-RX DEBUG, 43 ●│● [BTN] ●│● 4
CS0, 48 ●│● ●│● 55, IRQ
CLK, 49 ●│● ●│● 54, BUSY
MOSI, 50 ●│● ●│● 59, I2C SCL
MISO, 51 ●│● ●│● 58, I2C SDA
UART4-RX, 52 ●│● ●│● 57, NRST, UART3-RX
UART4-TX, 53 ●│● ETH ●│● 56, RXEN, UART3-TX
└──●──●──●──●──●──┘
R R G T T
X X N X X
- + D - +
GPIO BANK 0 (3.3v): 4
GPIO BANK 1 (3.3v): 42 43 48 49 50 51 52 53 54 55 56 57 58 59
GPIO BANK 4 (1.8v): 144 145 "
# Parse options
@ -137,4 +138,5 @@ while getopts "hlfzt" opt; do
exit 1
;;
esac
done
done
exit

View file

@ -41,7 +41,7 @@ for i in {1..5}; do
echo "Time Zone updated to:\n$(timedatectl show --property=Timezone --value) $(date +%Z) (UTC$(date +%:z))\nSystem time updated to:\n$(date)\n\nNew time successfully saved to RTC.\nTime & date are also set automatically from internet, if connected."
return 0
else
echo "System time updated to:\n$(date)\n\nUnable to communicate with RTC module. An RTC module can remember system time between reboots/power outages.\nTime & date are also set automatically from internet, if connected."
echo "System time updated to:\n$(date) ($(date +"UTC%z" | sed -E 's/GMT([+-])0?([0-9]{1,2})00/GMT\1\2/'))\n\nUnable to communicate with RTC module. An RTC module can remember system time between reboots/power outages.\nTime & date are also set automatically from internet, if connected."
return 0
fi
fi
@ -66,6 +66,12 @@ while getopts ":t:T:h" opt; do
done
if [ $arg_count -eq 0 ]; then # if the script was launched with no arguments, then load the UI.
echo "Loading current time settings..."
current_timezone=$(timedatectl show --property=Timezone --value)
dialog --no-collapse --title "$title" --yesno "Current system time: $(date +"%H:%M:%S")\nCurrent time zone: $current_timezone ($(date +"UTC%z" | sed -E 's/GMT([+-])0?([0-9]{1,2})00/GMT\1\2/'))\n$(hwclock >/dev/null 2>&1 && echo "RTC module found!" || echo "RTC module not found.")\n\nSet new time and timezone?" 10 60
if [ $? -eq 1 ]; then #unless cancel/no
exit 0
fi
# Fetch available time zones
echo "Loading time zones..."
timezones=$(timedatectl list-timezones)
@ -77,8 +83,7 @@ if [ $arg_count -eq 0 ]; then # if the script was launched with no arguments, th
# Convert options array to string
options_str=$(printf '%s\n' "${options[@]}")
current_timezone=$(timedatectl show --property=Timezone --value)
# Show timezone selection menu with preselection of current timezone
selected_timezone=$(dialog --title "Select Time Zone" \
--default-item "$current_timezone" \
@ -92,7 +97,7 @@ if [ $arg_count -eq 0 ]; then # if the script was launched with no arguments, th
exit 1
fi
DATE=$(dialog --title "Select Date" --calendar "Current date: $(date "+%B %d, %Y")\nPress [TAB] to select." 0 0 $(date +%d) $(date +%m) $(date +%Y) 3>&1 1>&2 2>&3)
DATE=$(dialog --title "Select Date" --calendar "Current date: $(date "+%B %d, %Y") \nPress [TAB] to select." 0 0 $(date +%d) $(date +%m) $(date +%Y) 3>&1 1>&2 2>&3)
if [ $? -ne 0 ]; then
exit 1
fi

View file

@ -18,6 +18,8 @@ Options are:
-n Networking info
-o OS info
-S Storage & RAM info
-t "enable" Enable/disable/start/stop/check ttyd (http based terminal). Options: "enable" "disable" "start" "stop" "check"
EOF
)
@ -89,20 +91,22 @@ Mnted drives:$mounted_drives"
os_info() {
local os_version="Foxbuntu v$(grep -oP 'major=\K[0-9]+' /etc/foxbuntu-release).$(grep -oP 'minor=\K[0-9]+' /etc/foxbuntu-release)$(output=$(grep -o 'patch=[1-9][0-9]*' /etc/foxbuntu-release | cut -d= -f2) && [ -n "$output" ] && echo ".$output")$(grep -oP 'hotfix=\K[a-z]+' /etc/foxbuntu-release) ($(lsb_release -d | awk -F'\t' '{print $2}') $(lsb_release -c | awk -F'\t' '{print $2}'))"
local system_uptime="$(uptime -p | awk '{$1=""; print $0}' | sed -e 's/ day\b/d/g' -e 's/ hour\b/h/g' -e 's/ hours\b/h/g' -e 's/ minute\b/m/g' -e 's/ minutes\b/m/g' | sed 's/,//g')"
local logging_enabled="$(logging "check" | sed 's/\x1b\[[0-9;]*m//g')"
local act_led="$(femto-utils.sh -a "check" | sed -r 's/\x1B\[[0-9;]*[mK]//g')" #remove color from output
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")"
local ttyd_enabled="$(ttyd "check" | sed 's/\x1b\[[0-9;]*m//g')"
local logging_enabled="$(logging "check" | sed 's/\x1b\[[0-9;]*m//g')"
local act_led="$(femto-utils.sh -a "check" | sed -r 's/\x1B\[[0-9;]*[mK]//g')" #remove color from output
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"
K boot mods:$kernel_boot_modules\n\
Web terminal:$ttyd_enabled\n\
Logging:$logging_enabled\n\
Activity LED:$act_led"
}
networking_info() {
@ -195,7 +199,41 @@ logging() {
fi
}
while getopts ":harsl:ipcnoS" opt; do
ttyd() {
if [ "$1" = "disable" ]; then
systemctl disable ttyd
systemctl stop ttyd
echo "Disabled ttyd service."
exit 0
elif [ "$1" = "enable" ]; then
systemctl enable ttyd
echo "Enabled ttyd service."
systemctl start ttyd
exit 0
elif [ "$1" = "check" ]; then
if systemctl is-enabled ttyd &>/dev/null; then
if echo "$(systemctl status ttyd)" | grep -q "active (running)"; then
echo -e "\033[4m\033[0;34menabled and running\033[0m"
elif echo "$(systemctl status ttyd)" | grep -q "inactive (dead)"; then
echo -e "\033[4m\033[0;31menabled but not running\033[0m"
exit 1
else
echo "unknown"
fi
else
echo -e "\033[4m\033[0;31mdisabled\033[0m"
exit 1
fi
elif [ "$1" = "start" ]; then
echo "Starting/restarting ttyd service..."
systemctl restart ttyd
elif [ "$1" = "stop" ]; then
echo "Stopping ttyd service..."
systemctl stop ttyd
fi
}
while getopts ":harsl:ipcnoSt:" opt; do
case ${opt} in
h) # Option -h (help)
echo -e $help
@ -213,15 +251,14 @@ while getopts ":harsl:ipcnoS" opt; do
logger "User requested system halt"
halt
;;
l) # Option -l (Logging enable/disable/check)
logging $OPTARG
;;
l) logging $OPTARG ;; # Option -l (Logging enable/disable/check)
i) all_system_info ;; # Option -i (sysinfo)
p) peripherals_info ;; # Option -p (Peripherals info)
c) cpu_info ;; # Option -c (CPU info)
n) networking_info ;; # Option -n (Networing info)
o) os_info ;; # Option -o (OS info)
S) storage_info ;; # Option -S (Storage & RAM info)
t) ttyd $OPTARG ;; # Option -t (ttyd)
\?) # Unknown option)
echo -e "Unknown argument $1.\n$help"
;;