Skip to content

Instantly share code, notes, and snippets.

@LuisPalacios
Last active April 15, 2023 15:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save LuisPalacios/421b9b4c1bdda72d28fd2e12a621d8c8 to your computer and use it in GitHub Desktop.
Save LuisPalacios/421b9b4c1bdda72d28fd2e12a621d8c8 to your computer and use it in GitHub Desktop.
Servicio systemd
# Este servicio comprueba si tengo acceso a internet y mientras que
# no lo tenga se queda esperando (sleep's de 1 seg). Es bastante útil
# cuando queremos que otros servicios esperen a tener internet.
#
# Crea el fichero /etc/systemd/system/internet_wait.service
# Instalar con:
# systemctl enable internet_wait.service
#
# En aquellos servicios que queremos que esperen a tener interent
# tenemos que modificar su fichero .service y añadir al final de
# las dos líneas que contienen Wants y After
# Wants=network-online.target internet_wait.service
# After=network-online.target internet_wait.service
#
[Unit]
DefaultDependencies=no
After=nss-lookup.target
Before=network-online.target
[Service]
# Tengo internet cuando el ping a google me funciona
ExecStart=sh -c 'while ! ping -c 1 8.8.8.8 >/dev/null 2>&1; do sleep 1; done'
[Install]
WantedBy=network-online.target
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment