#!/sbin/openrc-run
# Copyright 2023-2026 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2

export SSD_NICELEVEL SSD_IONICELEVEL
QBITTORRENT_USER=${QBITTORRENT_USER:-qbittorrent}
QBITTORRENT_GROUP=${QBITTORRENT_GROUP:-qbittorrent}
QBITTORRENT_DIRECTORY=${QBITTORRENT_DIRECTORY:-/var/lib/qbittorrent}

description="BitTorrent client in C++ and Qt"
command="/usr/bin/qbittorrent-nox"
command_args="${QBITTORRENT_OPTS}"
pidfile="/run/${RC_SVCNAME}.pid"
command_background="yes"
command_user="${QBITTORRENT_USER}:${QBITTORRENT_GROUP}"

depend() {
    need localmount
	use net
}

start_pre() {
    checkpath -q -d -o ${command_user} ${QBITTORRENT_DIRECTORY}
}
