Want more features on Pastebin? Sign Up, it's FREE!
Guest

btsync rc.d service script

By: kozec on Jul 19th, 2013  |  syntax: Bash  |  size: 0.75 KB  |  views: 51  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. #!/bin/bash
  2.  
  3. . /etc/rc.conf
  4. . /etc/rc.d/functions
  5. . /etc/conf.d/crond
  6.  
  7. USER=root                       # changeme...
  8.  
  9. HOME=$(egrep "^"$USER /etc/passwd | cut -d: -f6)
  10. PIDFILE="$HOME"/.config/btsync/sync.pid
  11. PID=$(cat $PIDFILE 2>/dev/null)
  12. case $1 in
  13. start)
  14.         stat_busy "Starting BitTorrent Sync service"
  15.        
  16.         if su $USER -- /usr/bin/btsync-wrapper --config "$HOME"/.config/btsync/btsync.conf 1>/dev/null ; then
  17.                 add_daemon btsync
  18.                 stat_done
  19.         else
  20.                 stat_fail
  21.                 exit 1
  22.         fi
  23.         ;;
  24.  
  25. stop)
  26.         stat_busy "Stopping BitTorrent Sync service"
  27.         if [[ ! -z $PID ]]  && kill "$PID" &>/dev/null; then
  28.                 rm_daemon btsync
  29.                 stat_done
  30.         else
  31.                 stat_fail
  32.                 exit 1
  33.         fi
  34.         ;;
  35.  
  36. restart)
  37.         $0 stop
  38.         $0 start
  39.         ;;
  40.  
  41. *)
  42.         echo "Usage: $0 {start|stop|restart}" >&2
  43.         exit 1
  44.  
  45. esac
clone this paste RAW Paste Data