Possible to get help w/ my btsync rc.d script?

Status
Not open for further replies.

hungarianhc

Patron
Joined
Mar 11, 2014
Messages
234
I'm relatively new to scripting, especially with FreeBSD. I'm not sure where to put all the files, what good start / stop conventions are.

I installed Btsync in a jail, and I wrote a startup script for it. It seems to get the job done, but I'm sure there are ways to improve it / make it more correct. I'm hoping we can improve it, and then I'll publish a tutorial for others. Thanks!

Script:

Code:
#!/bin/sh                                                                      
#                                                                              
# $FreeBSD$                                                                    
                                                                               
# PROVIDE: Bittorrent Sync                                                     
# REQUIRE: LOGIN FILESYSTEMS                                                   
# KEYWORD: shutdown                                                            
                                                                               
. /etc/rc.subr                                                                 
                                                                               
name=btsync                                                                    
rcvar=btsync_enable                                                            
                                                                               
extra_commands=status                                                          
start_cmd="${name}_start"                                                      
stop_cmd="${name}_stop"                                                        
status_cmd="${name}_status"                                                    
pidfile=/var/run/btsync/btsync.pid                                             
                                                                               
load_rc_config $name                                                           
: ${btsync_enable:=no}                                                         
: ${btsync_msg="Nothing started."}                                             
: ${btsync_user="btsync"}
: ${btsync_group="btsync"}                                                     
                                                                               
btsync_start()                                                                 
{                                                                              
        echo "Starting BTSync..."                                              
        /usr/local/sbin/btsync --webui.listen 0.0.0.0:8888                     
        echo $! > pidfile                                                      
}                                                                              
                                                                               
btsync_stop()                                                                  
{                                                                              
        echo "Killing all btsync processes..."                                 
        killall -e btsync                                                      
}                                                                              
                                                                               
btsync_status()                                                                
{                                                                              
        echo "Checking the status, sir!"                                       
} 

run_rc_command "$1"       
 
Status
Not open for further replies.
Top