+
+\family typewriter
+./afimonio_daemon.sh
+\layout Standard
+
+Da un mensaje de ayuda.
+\layout Subsection
+
+Código Fuente
+\layout LyX-Code
+
+#!/bin/bash
+\layout LyX-Code
+
+\layout LyX-Code
+
+# Configuración
+\layout LyX-Code
+
+WAIT=10
+\layout LyX-Code
+
+DAEMON=afimonio
+\layout LyX-Code
+
+\layout LyX-Code
+
+# --------------- SCRIPT ---------------------
+\layout LyX-Code
+
+BASE_DIR="$HOME/.antifraude"
+\layout LyX-Code
+
+.
+ "$BASE_DIR/conf/$DAEMON.conf"
+\layout LyX-Code
+
+.
+ "$BASE_DIR/util.sh"
+\layout LyX-Code
+
+\layout LyX-Code
+
+ayuda () {
+\layout LyX-Code
+
+ perr "Parámetros válidos : start, stop, status"
+\layout LyX-Code
+
+}
+\layout LyX-Code
+
+\layout LyX-Code
+
+case "$1" in
+\layout LyX-Code
+
+ "start")
+\layout LyX-Code
+
+ echo -n "Iniciando demonio '$DAEMON' en modo daemon "
+\layout LyX-Code
+
+ if is_lock "$DAEMON"; then
+\layout LyX-Code
+
+ echo " ERROR!"
+\layout LyX-Code
+
+ perr "$DAEMON ya está corriendo"
+\backslash
+
+\layout LyX-Code
+
+ "(PID=`lock_pid $DAEMON`)."
+\layout LyX-Code
+
+ exit 1
+\layout LyX-Code
+
+ fi
+\layout LyX-Code
+
+ nohup "$AFIM_BINDIR/$DAEMON" > /dev/null &
+\layout LyX-Code
+
+ for i in `seq $WAIT`; do
+\layout LyX-Code
+
+ if is_lock "$DAEMON"; then
+\layout LyX-Code
+
+ echo " OK! (PID=`lock_pid $DAEMON`)"
+\layout LyX-Code
+
+ exit 0
+\layout LyX-Code
+
+ fi
+\layout LyX-Code
+
+ echo -n '.'
+\layout LyX-Code
+
+ sleep 1;
+\layout LyX-Code
+
+ done
+\layout LyX-Code
+
+ # Tardó más de 5 segundos en arrancar, algo anda mal...
+\layout LyX-Code
+
+ echo "ERROR!"
+\layout LyX-Code
+
+ perr "$DAEMON tardó más de $WAIT segundos en arrancar,"
+
+\backslash
+
+\layout LyX-Code
+
+ "probablemente haya algún problema."
+\layout LyX-Code
+
+ exit 1
+\layout LyX-Code
+
+ ;;
+\layout LyX-Code
+
+ "stop")
+\layout LyX-Code
+
+ echo -n "Parando el demonio '$DAEMON' "
+\layout LyX-Code
+
+ if ! is_lock "$DAEMON"; then
+\layout LyX-Code
+
+ echo " ERROR!"
+\layout LyX-Code
+
+ perr "$DAEMON no esta corriendo."
+\layout LyX-Code
+
+ exit 1
+\layout LyX-Code
+
+ fi
+\layout LyX-Code
+
+ kill `lock_pid $DAEMON`
+\layout LyX-Code
+
+ for i in `seq $WAIT`; do
+\layout LyX-Code
+
+ if ! is_lock "$DAEMON"; then
+\layout LyX-Code
+
+ echo " OK!"
+\layout LyX-Code
+
+ exit 0
+\layout LyX-Code
+
+ fi
+\layout LyX-Code
+
+ echo -n '.'
+\layout LyX-Code
+
+ sleep 1;
+\layout LyX-Code
+
+ done
+\layout LyX-Code
+
+ # Tardó más de 5 segundos en parar, algo anda mal...
+\layout LyX-Code
+
+ echo "ERROR!"
+\layout LyX-Code
+
+ perr "$DAEMON tardó más de $WAIT segundos en parar,"
+\backslash
+
+\layout LyX-Code
+
+ "probablemente haya algún problema."
+\layout LyX-Code
+
+ exit 1
+\layout LyX-Code
+
+ ;;
+\layout LyX-Code
+
+ "status")
+\layout LyX-Code
+
+ if is_lock "$DAEMON"; then
+\layout LyX-Code
+
+ echo "$DAEMON está corriendo actualmente"
+\backslash
+
+\layout LyX-Code
+
+ "(PID=`lock_pid $DAEMON`)."
+\layout LyX-Code
+
+ else
+\layout LyX-Code
+
+ echo "$DAEMON no está corriendo."
+\layout LyX-Code
+
+ fi
+\layout LyX-Code
+
+ ;;
+\layout LyX-Code
+
+ *) ayuda ;;
+\layout LyX-Code
+
+esac
+\layout Section
+
+CALLGEN
+\layout Subsection
+