home *** CD-ROM | disk | FTP | other *** search
/ PC Welt 2006 November (DVD) / PCWELT_11_2006.ISO / casper / filesystem.squashfs / etc / init.d / sysklogd < prev    next >
Encoding:
Text File  |  2006-07-29  |  1.7 KB  |  89 lines

  1. #! /bin/sh
  2. # /etc/init.d/sysklogd: start the system log daemon.
  3.  
  4. PATH=/bin:/usr/bin:/sbin:/usr/sbin
  5.  
  6. pidfile=/var/run/syslogd.pid
  7. binpath=/sbin/syslogd
  8.  
  9. test -x $binpath || exit 0
  10. . /lib/lsb/init-functions
  11.  
  12. # Options for start/restart the daemons
  13. #   For remote UDP logging use SYSLOGD="-r"
  14. #
  15. SYSLOGD="-u syslog"
  16.  
  17. test ! -r /etc/default/syslogd || . /etc/default/syslogd
  18.  
  19. create_xconsole()
  20. {
  21.     if [ ! -e /dev/xconsole ]; then
  22.     mknod -m 640 /dev/xconsole p
  23.     else
  24.     chmod 0640 /dev/xconsole
  25.     fi
  26.     chown root:adm /dev/xconsole
  27. }
  28.  
  29. running()
  30. {
  31.     # No pidfile, probably no daemon present
  32.     #
  33.     if [ ! -f $pidfile ]
  34.     then
  35.     return 1
  36.     fi
  37.  
  38.     pid=`cat $pidfile`
  39.  
  40.     # No pid, probably no daemon present
  41.     #
  42.     if [ -z "$pid" ]
  43.     then
  44.     return 1
  45.     fi
  46.  
  47.     if [ ! -d /proc/$pid ]
  48.     then
  49.     return 1
  50.     fi
  51.  
  52.     cmd=`cat /proc/$pid/cmdline | tr "\000" "\n"|head -n 1`
  53.  
  54.     # No syslogd?
  55.     #
  56.     if [ "$cmd" != "$binpath" ]
  57.     then
  58.     return 1
  59.     fi
  60.  
  61.     return 0
  62. }
  63.  
  64. case "$1" in
  65.   start)
  66.     log_begin_msg "Starting system log..."
  67.     create_xconsole
  68.     start-stop-daemon --start --quiet --exec $binpath -- $SYSLOGD
  69.     log_end_msg $?
  70.     ;;
  71.   stop)
  72.     log_begin_msg "Stopping system log..."
  73.     start-stop-daemon --stop --quiet --oknodo --exec $binpath --pidfile $pidfile
  74.     log_end_msg $?
  75.     ;;
  76.   restart|force-reload|reload-or-restart|reload)
  77.     log_begin_msg "Restarting system log..."
  78.     start-stop-daemon --stop --quiet --exec $binpath --pidfile $pidfile
  79.     sleep 1
  80.     start-stop-daemon --start --quiet --exec $binpath -- $SYSLOGD
  81.     log_end_msg $?
  82.     ;;
  83.   *)
  84.     log_success_msg "Usage: /etc/init.d/sysklogd {start|stop|reload|restart|force-reload|reload-or-restart}"
  85.     exit 1
  86. esac
  87.  
  88. exit 0
  89.