Simple bash script problem

bigart

Member

Reaction score: 1
Messages: 50

I'm trying to make bash script.

This command working fine from command line:
"/usr/local/bin/rclone mount Dropbox: /dane/Dropbox/ --vfs-cache-mode=writes --allow-other --config /root/.config/rclone/rclone.conf

I want to execute this command with system startup and I did simple script.


Code:
#!/bin/sh
# PROVIDE: rclone
. /etc/rc.subr
name="rclone"
start_cmd="${name}_start"
stop_cmd="${name}_stop"
rclone_start() {
   echo "rclone starting"
   # your commands here
#/usr/local/bin/rclone mount Dropbox: /dane/Dropbox/ --vfs-cache-mode=writes --allow-other
command="/usr/local/bin/rclone mount Dropbox: /dane/Dropbox/ --vfs-cache-mode=writes --allow-other --config /root/.config/rclone/rclone.conf"
#command_args
}
rclone_stop() {
   echo "rclone stopping"
   # your commands here
umount -f /dane/Dropbox/
}
load_rc_config ${name}
run_rc_command "$1"

line without command= parameter working but after service rclone start not going to "background" after execute.
when I put command= before script not working

I tried also parameters below:

Code:
command="/usr/local/bin/rclone";
command_args="mount Dropbox: /dane/Dropbox/ --vfs-cache-mode=writes --allow-other --config /root/.config/rclone/rclone.conf";

Sorry, I'm newbie and I'm almost sure there is very simple mistake, but I don't know where ?
 

unitrunker

Aspiring Daemon

Reaction score: 238
Messages: 537

FYI - this is a Bourne shell script - which is fine because that's what rc uses.

Add a "REQUIRE" comment just after the shebang. rclone probably requires the network to be up.

# REQUIRE: NETWORKING

This will allow rcorder to run your service after networking is up and running.

See section 7:

 

ShelLuser

Son of Beastie

Reaction score: 2,023
Messages: 3,732

If you only want to run a single command during system startup then why not simply rely on crontab(5)? It'll be much easier, look into the @reboot setting.
 
Top