SOLVED Qbittorrent update/upgrade script

theomolenaar

Dabbler
Joined
Jun 12, 2016
Messages
43
Hi. I’m looking for a bash script to update an existing jail with qbittorrent-nox installed. I tried running as root:
pkg upgrade qbittorrent-nox but that didn’t work. Service wouldn’t start with: service qbittorrent-nox start. A search on github gave me a lot of results but no examples to do a simple update. If you have any working scripts or tips to make it work please let me know. Thanks!!
 

Jailer

Not strong, but bad
Joined
Sep 12, 2014
Messages
4,977
How did you install qbittorrent-nox, via plugin or manual install in the jail? Are you trying to automate upgrades?
 

theomolenaar

Dabbler
Joined
Jun 12, 2016
Messages
43
Whoops. Forgot to mention that part. Manual install. I want to automate upgrades. The install process I used for qbittorrent-nox can be found here
 

sretalla

Powered by Neutrality
Moderator
Joined
Jan 1, 2016
Messages
9,703
The install process I used for qbittorrent-nox can be found here
So that install method edits one of the files in the package (nano /usr/local/etc/rc.d/qbittorrent...), so when you update the package, you probably need to do the edits again.
 

theomolenaar

Dabbler
Joined
Jun 12, 2016
Messages
43
Yes edits needs to be done in the script. I tried using this:
Code:
sed 's/${qbittorrent_user=qbittorrent}/${qbittorrent_user=root}/g' /usr/local/etc/rc.d/qbittorrent
sed 's/${qbittorrent_group=qbittorrent}/${qbittorrent_group=wheel}/g' /usr/local/etc/rc.d/qbittorrent

But changes didn't get applied when viewing this file with nano right after.
 

sretalla

Powered by Neutrality
Moderator
Joined
Jan 1, 2016
Messages
9,703

theomolenaar

Dabbler
Joined
Jun 12, 2016
Messages
43
Yes editing in nano did the trick. But a fully automated upgrade script is around the corner :wink: I figured that a service qbittorrent stop would help to make this file writable but it didn’t
 

theomolenaar

Dabbler
Joined
Jun 12, 2016
Messages
43
I managed to code an automated upgrade script for qbittorrent-nox. Not entirely sure it's the best solution but hey....it works, haha.
Code:
#!/bin/bash
JAIL=qbitvpn2

iocage exec $JAIL service qbittorrent stop

# -y tells it to answer Yes to every confirmation question.
iocage exec $JAIL pkg upgrade -y qbittorrent-nox

#Change username and make a temporary file. Because changes won't be permanent. Don't know why.
iocage exec $JAIL "sed 's/qbittorrent_user=qbittorrent/qbittorrent_user=root/g' /usr/local/etc/rc.d/qbittorrent > /usr/local/etc/rc.d/qbittorrent1"
#change group in temporary file
iocage exec $JAIL "sed 's/qbittorrent_group=qbittorrent/qbittorrent_group=wheel/g' /usr/local/etc/rc.d/qbittorrent1 > /usr/local/etc/rc.d/qbittorrent2"

#Copy complete content of temporary file back to original file
iocage exec $JAIL "cat /usr/local/etc/rc.d/qbittorrent2 > /usr/local/etc/rc.d/qbittorrent"
#remove temporary files
iocage exec $JAIL "rm /usr/local/etc/rc.d/qbittorrent1 && rm /usr/local/etc/rc.d/qbittorrent2"

iocage exec $JAIL sysrc qbittorrent_enable="YES"

#restart service
iocage exec $JAIL service qbittorrent start
 
Top