I want to write an upstart script for BitTorrent Sync that starts btsync like "btsync --config day.conf" in the morning and restarts it with "btsync --config night.conf" at night. This way, I would be able to limit the upload rate in the "day.conf" file and remove any limits in the "night.conf" file. I want to use cron to then start btsync with the right config file.
I currently have in /etc/init/btsync.conf
setuid patrick
setgid patrick
start on runlevel [2345]
stop on runlevel [016]
expect fork
instance $CONF
chdir /home/patrick/programs/btsync
exec ./btsync --config $CONF
I can then start btsync with something like:
sudo initctl start btsync CONF=btsync-day.conf
which I could put into /etc/crontab and it would work. But I think that using the instance stanza is not the right thing to do, as I am not running instances really. Btsync can not be running multiple instances. Also to stop the job, I have to stop it using the right CONF= variable, but I would rather be able to just stop it without needing to specify the right instance.
Is there a better way to do this in upstart?