Something like this is a good start! I use transmission as the torrent client instead of deluge. Also added a service for my vpn and use that as the network for the tranmission service so all traffic is routed through the vpn. ochoaprojects.github.io/posts/PlexAutomation/