Difference between revisions of "Writing rc.d scripts (Español)"
(update templates, see Help:Style) |
Kynikos.bot (talk | contribs) (Template:i18n is deprecated, use interlanguage links, see Help talk:I18n#"Dummy" interlanguage links and deprecation of Template:i18n) |
||
Line 1: | Line 1: | ||
[[Category:Boot process (Español)]] | [[Category:Boot process (Español)]] | ||
− | + | [[cs:Writing rc.d scripts]] | |
+ | [[en:Writing rc.d scripts]] | ||
+ | [[zh-CN:Writing rc.d scripts]] | ||
{{Article summary start}} | {{Article summary start}} | ||
{{Article summary text|Escribiendo scripts de demonios para el rc.d.}} | {{Article summary text|Escribiendo scripts de demonios para el rc.d.}} |
Revision as of 13:00, 13 June 2012
zh-CN:Writing rc.d scripts Template:Article summary start Template:Article summary text Template:Article summary heading Template:Article summary wiki Template:Article summary wiki Template:Article summary wiki Template:Article summary end
Como parte del inicio "estilo-BSD" de arch, los scripts del rc.d son usados para el inicio, detencion y reiniciacion de los demonios.
Lineas de guia
- Fuente
/etc/rc.conf
,/etc/rc.d/functions
, y opcionalmente/etc/conf.d/DAEMON_NAME
. - Los argumentos y opciones de los demenios deben ir en
/etc/conf.d/DAEMON_NAME
. Esta hecho para separar las configuraciones y mantener la consistencia. - Usar las funciones en
/etc/rc.d/functions
en vez de duplicar las funcionalidades. - Inclir al menos "start", "stop" y "restart" como argumentos en es script.
- Hay algunas funcionalidades provistas por
/etc/rc.d/functions
:- stat_busy "<message>": establece el estado busy(ocupado) como mensaje a mostrar (ej: Iniciando Demonio [OCUPADO])
- stat_done: establece el estado done (hecho) (ej: Iniciando Demonio [HECHO])
- stat_fail: establece el estado failed (e.g. Iniciando Demonio [FALLO])
- get_pid <program>: obtiene el PID del programa.
- ck_pidfile <PID-file> <program>: Chekea si el PID-file es aun valido para el programa (e.g. ck_pidfile /var/run/daemon.pid daemon || rm -f /var/run/daemon.pid)
- [add|rm]_daemon <program>: Agrega/remueve programas a los demonios activos (almacenados en
/run/daemons/
)
Ejemplo
Lo siguiente es un ejemplo para crond. Revise en /etc/rc.d
, encontrara variedad.
El archivo de configuración:
/etc/conf.d/crond
ARGS="-S -l info"
El script actual:
/etc/rc.d/crond
#!/bin/bash . /etc/rc.conf . /etc/rc.d/functions DAEMON=crond ARGS= [ -r /etc/conf.d/$DAEMON ] && . /etc/conf.d/$DAEMON PID=$(get_pid $DAEMON) case "$1" in start) stat_busy "Starting $DAEMON" [ -z "$PID" ] && $DAEMON $ARGS &>/dev/null if [ $? = 0 ]; then add_daemon $DAEMON stat_done else stat_fail exit 1 fi ;; stop) stat_busy "Stopping $DAEMON" [ -n "$PID" ] && kill $PID &>/dev/null if [ $? = 0 ]; then rm_daemon $DAEMON stat_done else stat_fail exit 1 fi ;; restart) $0 stop sleep 1 $0 start ;; *) echo "usage: $0 {start|stop|restart}" esac