Initial Commit

Start new branch for development on new 64bit x75 platfom.
This commit is contained in:
Cameron Thompson
2024-07-07 20:15:59 -04:00
parent 88d300303c
commit bfd4b31fea
83 changed files with 599 additions and 0 deletions

View File

@@ -0,0 +1,27 @@
#!/bin/bash
# Define the command to execute when the ethernet port breaks
command_to_execute="/usrdata/socat-at-bridge/atcmd 'AT+CFUN=1,1'"
# Define the monitoring function
watch() {
while true; do
# Extract the last 60 lines of dmesg and count the specific pattern occurrences
count=$(dmesg | tail -60 | grep -e "eth0: cmd = 0xff, should be 0x47" -e "eth0: pci link is down" | grep -c "eth0")
# Check if the count of patterns is 4 or more
if [ "$count" -ge 4 ]; then
echo "Condition met, executing command..."
eval "$command_to_execute"
# Optionally, add a break here if you want the script to stop after executing the command
# break
fi
# Sleep for 3 seconds before checking again
sleep 3
done
}
# Initial delay before starting monitoring
sleep 30
watch

View File

@@ -0,0 +1,28 @@
#!/bin/bash
# Define the hostname or IP address to ping
HOSTNAME="google.com"
# Number of pings to attempt
PING_COUNT=6
# Initialize a counter for successful pings
success_count=0
# Attempt to ping the specified number of times
for i in $(seq 1 $PING_COUNT); do
# Ping the hostname with a timeout of 1 second per ping
if ping -c 1 -W 1 $HOSTNAME &> /dev/null; then
((success_count++))
else
echo "Ping attempt $i failed."
fi
done
# Check if all pings failed
if [ $success_count -eq 0 ]; then
echo "All $PING_COUNT ping attempts failed, executing AT command."
/bin/atcmd 'AT+CFUN=1,1'
else
echo "$success_count out of $PING_COUNT ping attempts were successful."
fi

View File

@@ -0,0 +1,14 @@
[Unit]
Description=Ping Watchdog Service
Wants=network.target
After=network.target
[Service]
Type=simple
ExecStartPre=/bin/sleep 60 # Sleep for 60 seconds to ensure the network is ready
ExecStart=/usrdata/simpleadmin/console/services/ping_watchdog.sh
Restart=on-failure
RestartSec=30s
[Install]
WantedBy=multi-user.target