update wcs

This commit is contained in:
Esteban Mackay Q 2023-09-10 19:55:42 -05:00
parent 4946b8a59b
commit c3998687ba
2 changed files with 25 additions and 11 deletions

View File

@ -1,5 +1,5 @@
#!/bin/bash
cd /tmp/
cd /opt/
if [ "$(uname -m | grep '64')" != "" ]; then
# echo "ARCH: 64-bit"
wget -qO gotty.tar.gz https://github.com/yudai/gotty/releases/latest/download/gotty_linux_amd64.tar.gz

View File

@ -13,12 +13,23 @@ sudo cat > /usr/local/bin/autoap.sh <<- "EOF"
# Tiempo de espera entre los chequeos en segundos
TIEMPO_ESPERA=30
# Lista de servicios para verificar y detener si no hay conexión a Internet
SERVICIOS=("http.server-dw.service" "http.server-mmdvmh.service" "http.server-dvs.service" "http.server-ysf.service" "hbmon.service" "hbmon2.service" "hbmon-js.service" "http.server-fdmr.service" "http.server-fdmr2.service" "daprs-board.service")
# Funcion para verificar el estado de Internet
verificar_internet() {
ping -c 5 noip.com > /dev/null 2>&1
return $?
}
# Funcion para detener un servicio si está habilitado
detener_servicio() {
servicio="$1"
if sudo systemctl is-enabled "$servicio" >/dev/null 2>&1; then
sudo systemctl stop "$servicio"
fi
}
# Bucle infinito para monitorear
while true; do
# Verificar el estado de la interfaz wlan0
@ -37,10 +48,9 @@ while true; do
:
else
# Internet no esta disponible, realiza acciones necesarias
if sudo systemctl is-enabled http.server-mmdvmh.service >/dev/null 2>&1; then
# Detiene http.server-mmdvmh.service si esta habilitado
sudo systemctl stop http.server-mmdvmh.service
fi
for servicio in "${SERVICIOS[@]}"; do
detener_servicio "$servicio"
done
wifi-connect
fi
fi
@ -52,11 +62,15 @@ while true; do
sleep $TIEMPO_ESPERA
done
EOF
sudo cat > /usr/local/bin/apoff.sh <<- "EOF"
#!/bin/bash
# Lista de servicios a verificar y reiniciar si están habilitados
SERVICIOS=("http.server-dw.service" "http.server-mmdvmh.service" "http.server-dvs.service" "http.server-ysf.service" "hbmon.service" "hbmon2.service" "hbmon-js.service" "http.server-fdmr.service" "http.server-fdmr2.service" "daprs-board.service")
while true; do
# Verifica si wifi-connect está corriendo como proceso
if pgrep -x "wifi-connect" >/dev/null; then
@ -65,11 +79,12 @@ while true; do
# Si la respuesta de ping es positiva, reinicia autoap.service
sudo systemctl restart autoap.service
# Verifica si http.server-mmdvmh.service está habilitado
if sudo systemctl is-enabled http.server-mmdvmh.service >/dev/null 2>&1; then
# Inicia http.server-mmdvmh.service si está habilitado
sudo systemctl restart http.server-mmdvmh.service
fi
# Verifica y reinicia los servicios habilitados de la lista
for servicio in "${SERVICIOS[@]}"; do
if sudo systemctl is-enabled "$servicio" >/dev/null 2>&1; then
sudo systemctl restart "$servicio"
fi
done
fi
fi
@ -78,7 +93,6 @@ while true; do
done
EOF
sudo chmod +x /usr/local/bin/apoff.sh
sudo chmod +x /usr/local/bin/autoap.sh