Please fix the functionality of the code - to check connections

In the old TOS 6, I used this function to check connections. It checked the gateway, DNS servers and selected IP addresses on the internet.

It indicated the start of the check and if there was a connection error, the type of connection.

After changing the syntax it is not functional.

I will ask a willing and knowledgeable person, who will not cost too much time, to make the necessary modifications fiel to make it work on the current version, please

# rainbow brightness od verze 7.x.x
# zmena intensity svetla den - noc ...  mezi 0-8  nebo -p 0-255

bright
#1 - 30
#2 - 63
#3 - 94
#4 - 127
#5 - 158
#6 - 191
#7 - 221
#8 - 255


# WINTER
# 00 08 * * * root rainbow brightness -p 4
# 00 09 * * * root rainbow brightness -p 6
# 00 10 * * * root rainbow brightness -p 8
# 00 15 * * * root rainbow brightness -p 6
# 00 16 * * * root rainbow brightness -p 4
# 00 17 * * * root rainbow brightness -p 2

# */2 * * * * /usr/bin/rainbow brightness -p 2
# 1-59/2 * * * * /usr/bin/rainbow brightness -p 10

# SPRING - AUTUMN
00 06 * * * root rainbow brightness -p 4
00 07 * * * root rainbow brightness -p 6
00 08 * * * root rainbow brightness -p 8
00 18 * * * root rainbow brightness -p 6 
00 19 * * * root rainbow brightness -p 4
00 20 * * * root rainbow brightness -p 2


# SUMMER
#00 05 * * * root rainbow brightness -p 4
#00 06 * * * root rainbow brightness -p 6
#00 07 * * * root rainbow brightness -p 8
#00 20 * * * root rainbow brightness -p 6 
#00 21 * * * root rainbow brightness -p 4
#00 22 * * * root rainbow brightness -p 2

# -------------------------------------
# check every 3 minute
# */3 * * * * root /root/connCheck.sh > /dev/null 2>&1
*/3 * * * * root /root/connCheck.sh
#!/bin/sh
# výše je deklarace scriptu
# umístění
# /root/conncheck.sh
# aktivovat  následujícím příkazem
# chmod +x /root/connCheck.sh

# check the connection to the Internet
# --- indications of activity befor test

# 1 blick
rainbow disable
sleep 1 
rainbow d000f0 enable
sleep 1

# 2 blick
rainbow disable
sleep 1
rainbow d000f0 enable
sleep 1

# 3 blick
rainbow disable
sleep 1
rainbow d000f0 enable
sleep 1
rainbow disable
sleep 1
#
rainbow 4d0000 enable

# --- check connection gateway, dns, internet ---

# "93.91.1.200-2" non-existent IP for testing functions
# check gateway ... wan, lan, pci = RED
# if !(ping -W 1 -c 1 10.48.210.229)
# testovaci pozice
if !(ping -c 1 93.91.1.200)
    
then
    rainbow power b50000 auto
    rainbow wan b50000 auto
    rainbow lan-1 b50000 enable
    rainbow lan-2 b50000 enable
    rainbow lan-3 b50000 enable
    rainbow lan-4 b50000 enable;

# check DNS ... wan, lan =  ORANGE
elif !(ping -W 1 -c 1 10.255.255.10) && !(ping -W 1 -c 10.255.255.20)
# testovaci pozice
#elif !(ping -c 1 93.91.1.200) && !(ping -c 93.91.1.201)

then
    rainbow wan db4e00 enable
    rainbow lan-1 db4e00 enable
    rainbow lan-2 db4e00 enable
    rainbow lan-3 db4e00 enable
    rainbow lan-4 db4e00 enable;

# check internet - wan, pci = PURPLE   (Amazon.de; Ceske noviny; www.emergie-info.fr)
elif !(ping -W 1 -c 1 162.219.224.163) && !(ping -W 1 -c 1 80.79.27.48) && !(ping -W 1 -c 1 46.18.193.118)
# testovaci pozice
#elif !(ping -c 1 93.91.1.200) && !(ping -c 1 46.255.231.42) && !(ping -c 1 216.58.205.228)
then
    rainbow power d000f0 enable
    rainbow wan d000f0 enable;

# if all ready - standard color
else
    rainbow power b50000 auto
    rainbow wan 0118e4 auto
    rainbow lan-1 4e4d0e auto
    rainbow lan-2 4e4d0e auto
    rainbow lan-3 4e4d0e auto
    rainbow lan-4 4e4d0e auto;

    
fi

please try:

#!/bin/sh
# Script to check the connection to the Internet
# Location: /root/conncheck.sh
# To make it executable, use the command: chmod +x /root/conncheck.sh

# The script indicates activity before starting the test by blinking the LEDs.
# Updated version of Rainbow commands for TurrisOS 7.0 and Rainbow 0.1.4

# --- Initial activity indication ---
# Sequentially turning on and off LEDs with different colors
rainbow all disable
sleep 1
rainbow all enable white
sleep 1
rainbow all disable
sleep 1
rainbow all enable cyan
sleep 1
rainbow all disable
sleep 1
rainbow all enable magenta
sleep 1
rainbow all disable
sleep 1

# Set LED to RED initially (before checks start)
rainbow all enable red

# --- Connection Checks ---
# Check gateway, DNS, and Internet

# Function to set LED colors for all interfaces
set_leds() {
    local color=$1
    rainbow power enable $color
    rainbow wan enable $color
    rainbow lan-1 enable $color
    rainbow lan-2 enable $color
    rainbow lan-3 enable $color
    rainbow lan-4 enable $color
}

# Check 1: Gateway (using a non-existent IP address for testing)
# If the ping fails, set LEDs to indicate an issue with gateway connectivity.
if ! ping -c 1 93.91.1.200 >/dev/null 2>&1; then
    set_leds red

# Check 2: DNS servers (two DNS IPs)
# If both pings fail, set LEDs to indicate an issue with DNS resolution.
elif ! ping -W 1 -c 1 10.255.255.10 >/dev/null 2>&1 && ! ping -W 1 -c 1 10.255.255.20 >/dev/null 2>&1; then
    set_leds orange

# Check 3: Internet connectivity (using public IPs)
# If all pings fail, set LEDs to indicate an issue with Internet access.
elif ! ping -W 1 -c 1 162.219.224.163 >/dev/null 2>&1 && \
     ! ping -W 1 -c 1 80.79.27.48 >/dev/null 2>&1 && \
     ! ping -W 1 -c 1 46.18.193.118 >/dev/null 2>&1; then
    rainbow power enable magenta
    rainbow wan enable magenta

# If all checks pass, set LEDs to standard colors to indicate normal operation.
else
    rainbow power auto green
    rainbow wan auto blue
    rainbow lan-1 auto yellow
    rainbow lan-2 auto yellow
    rainbow lan-3 auto yellow
    rainbow lan-4 auto yellow
fi

The brightness has to be specified as number between 0 and 8 (or 255
if -p is used).

2 Likes

I’m still groping, it doesn’t even do the initial LED sequence … I’ll come back to it

Sequentially turning on and off LEDs with different colors