Advertisement
Kaze3

irssi daemon

Dec 13th, 2011
384
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.75 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. . /etc/rc.conf
  4. . /etc/rc.d/functions
  5.  
  6. DAEMON=irssi
  7. USER=htpc
  8. PID=$(pidof -o %PPID $DAEMON)
  9.  
  10. [ -r /etc/conf.d/irssi ] && . /etc/conf.d/irssi
  11.  
  12. case "$1" in
  13.   start)
  14.     stat_busy "Starting $DAEMON Service"
  15.     [ -z "$PID" ] && su $USER -c 'screen -dm -S '$DAEMON' -c ~/.irssi/screen_irssi' &> /dev/null
  16.     if [ $? != 0 ]; then
  17.       stat_fail
  18.     else
  19.       add_daemon $DAEMON
  20.       stat_done
  21.     fi
  22.     ;;
  23.   stop)
  24.     stat_busy "Stopping $DAEMON Service"
  25.     [ -n "$PID" ] && kill $PID &>/dev/null
  26.     if [ $? != 0 ]; then
  27.       stat_fail
  28.     else
  29.       rm_daemon $DAEMON
  30.       stat_done
  31.     fi
  32.     ;;
  33.   restart)
  34.     $0 stop
  35.     sleep 3
  36.     $0 start
  37.     ;;
  38.   *)
  39. echo "usage: $0 {start|stop|restart}"
  40. esac
  41.  
  42. exit 0
  43.  
  44.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement