| | 674 | |
| | 675 | === !FreeBSD Init Script === |
| | 676 | |
| | 677 | ==== Deluged ==== |
| | 678 | |
| | 679 | {{{ |
| | 680 | #!/bin/sh |
| | 681 | # |
| | 682 | # deluged RCng startup script |
| | 683 | # created by: R.S.A. aka .faust |
| | 684 | # mail: rsa dot aka dot f at gmail dot com |
| | 685 | # |
| | 686 | |
| | 687 | # PROVIDE: deluged |
| | 688 | # REQUIRE: NETWORKING SERVERS DAEMON ldconfig resolv |
| | 689 | # BEFORE: LOGIN |
| | 690 | # KEYWORD: shutdown |
| | 691 | |
| | 692 | # Add the following line to /etc/rc.conf.local or /etc/rc.conf to enable deluged at startup |
| | 693 | # deluged_enable="YES" |
| | 694 | # |
| | 695 | # pidfile (str): Specify the full path to the PID file |
| | 696 | # log (str): Specify the full path to the LOG file |
| | 697 | # delugew_user (str): Set to user running deluge-web |
| | 698 | # cfg_dir (str): Specify the full path to directory with deluge config files |
| | 699 | # |
| | 700 | # Warning! Rights to folders and files must be "rwx" for the user under which the run deluge |
| | 701 | |
| | 702 | . /etc/rc.subr |
| | 703 | |
| | 704 | name="deluged" |
| | 705 | rcvar=`set_rcvar` |
| | 706 | |
| | 707 | load_rc_config $name |
| | 708 | deluged_enable=${deluged_enable:=NO} |
| | 709 | |
| | 710 | log="/home/deluge/${name}.log" |
| | 711 | pidfile="/home/deluge/${name}.pid" |
| | 712 | cfg_dir="/home/deluge/config/" |
| | 713 | deluged_user="nobody" |
| | 714 | |
| | 715 | required_dirs=${cfg_dir} |
| | 716 | |
| | 717 | command_interpreter="/usr/local/bin/python" |
| | 718 | command="/usr/local/bin/${name}" |
| | 719 | start_cmd="${name}_start" |
| | 720 | |
| | 721 | deluged_start() |
| | 722 | { |
| | 723 | if [ ! -f "${pidfile}" ]; then |
| | 724 | su -m ${deluged_user} -c "/usr/local/bin/${name} -c ${cfg_dir} -l ${log} -P ${pidfile}" |
| | 725 | echo "Starting ${name}." |
| | 726 | else |
| | 727 | GETPROCESSPID=`/bin/ps -auxw | /usr/bin/awk '/deluged/ && !/awk/ && !/sh/ {print $2}'` |
| | 728 | PIDFROMFILE=`cat ${pidfile}` |
| | 729 | if [ "$GETPROCESSPID" = "$PIDFROMFILE" ]; then |
| | 730 | echo "${name} already running with PID: ${PIDFROMFILE} ?" |
| | 731 | echo "Remove ${pidfile} manually if needed." |
| | 732 | else |
| | 733 | rm -f ${pidfile} |
| | 734 | su -m ${deluged_user} -c "/usr/local/bin/${name} -c ${cfg_dir} -l ${log} -P ${pidfile}" |
| | 735 | echo "Starting ${name}." |
| | 736 | fi |
| | 737 | fi |
| | 738 | } |
| | 739 | |
| | 740 | |
| | 741 | run_rc_command "$1" |
| | 742 | }}} |
| | 743 | |
| | 744 | ==== Web UI ==== |
| | 745 | |
| | 746 | {{{ |
| | 747 | #!/bin/sh |
| | 748 | # |
| | 749 | # deluge-web RCng startup script |
| | 750 | # created by: R.S.A. aka .faust |
| | 751 | # mail: rsa dot aka dot f at gmail dot com |
| | 752 | # |
| | 753 | |
| | 754 | # PROVIDE: delugew |
| | 755 | # REQUIRE: NETWORKING SERVERS DAEMON ldconfig resolv |
| | 756 | # BEFORE: LOGIN |
| | 757 | # KEYWORD: shutdown |
| | 758 | |
| | 759 | # Add the following line to /etc/rc.conf.local or /etc/rc.conf to enable deluge-web at startup |
| | 760 | # delugew_enable="YES" |
| | 761 | # |
| | 762 | # pidfile (str): Specify the full path to the PID file |
| | 763 | # log (str): Specify the full path to the LOG file |
| | 764 | # delugew_user (str): Set to user running deluge-web |
| | 765 | # cfg_dir (str): Specify the full path to directory with deluge config files |
| | 766 | # |
| | 767 | # Warning! Rights to folders and files must be "rwx" for the user under which the run deluge |
| | 768 | . /etc/rc.subr |
| | 769 | |
| | 770 | name="delugew" |
| | 771 | rcvar=`set_rcvar` |
| | 772 | |
| | 773 | load_rc_config $name |
| | 774 | delugew_enable=${delugew_enable:=NO} |
| | 775 | |
| | 776 | log="/home/deluge/${name}.log" |
| | 777 | pidfile="/home/deluge/${name}.pid" |
| | 778 | cfg_dir="/home/deluge/config/" |
| | 779 | delugew_user="nobody" |
| | 780 | |
| | 781 | required_dirs=${cfg_dir} |
| | 782 | |
| | 783 | command_interpreter="/usr/local/bin/python" |
| | 784 | command="/usr/local/bin/deluge-web" |
| | 785 | start_cmd="${name}_start" |
| | 786 | start_postcmd="${name}_poststart" |
| | 787 | |
| | 788 | delugew_start() |
| | 789 | { |
| | 790 | if [ ! -f "${pidfile}" ]; then |
| | 791 | su -m ${delugew_user} -c "/usr/local/bin/deluge-web -f -c ${cfg_dir} -l ${log}" |
| | 792 | echo "Starting ${name}." |
| | 793 | else |
| | 794 | GETPROCESSPID=`/bin/ps -auxw | /usr/bin/awk '/deluge-web/ && !/awk/ && !/sh/ {print $2}'` |
| | 795 | PIDFROMFILE=`cat ${pidfile}` |
| | 796 | if [ "$GETPROCESSPID" = "$PIDFROMFILE" ]; then |
| | 797 | echo "${name} already running with PID: ${PIDFROMFILE} ?" |
| | 798 | echo "Remove ${pidfile} manually if needed." |
| | 799 | else |
| | 800 | rm -f ${pidfile} |
| | 801 | su -m ${delugew_user} -c "/usr/local/bin/deluge-web -f -c ${cfg_dir} -l ${log}" |
| | 802 | echo "Starting ${name}." |
| | 803 | fi |
| | 804 | fi |
| | 805 | } |
| | 806 | |
| | 807 | delugew_poststart() |
| | 808 | { |
| | 809 | echo `/bin/ps -auxw | /usr/bin/awk '/deluge-web/ && !/awk/ {print $2}'` > $pidfile |
| | 810 | } |
| | 811 | |
| | 812 | run_rc_command "$1" |
| | 813 | }}} |