#!/sbin/openrc-run # Copyright 1999-2017 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 command="/opt/distributed.net/dnetc" command_args="-e ${EMAIL} -inbase ${BUFFER_BASE_DIR}/buff-in -outbase ${BUFFER_BASE_DIR}/buff-out ${KEYSERVER_ADDRESS:+-a ${KEYSERVER_ADDRESS}}" # The dnetc daemon doesn't normally write a PID file, but we need one # to reload it. So, we force the daemon to stay in the foreground with # the -noquiet flag, and then tell start-stop-daemon to shove it into # the background and create a PID file for it with command_background. command_args_foreground="-noquiet" command_background="true" command_user="dnetc:dnetc" pidfile="/run/dnetc.pid" extra_started_commands="reload fetch flush" description="distributed.net client" description_flush="flush all output buffers" description_fetch="fill all input buffers" description_reload="restart all active clients" depend() { use net } set_cpu_share() { # fair group cpu scheduler uidpath="/sys/kernel/uids/$(id -u dnetc)" [ -d "${uidpath}" ] && echo 2 > "${uidpath}/cpu_share" unset uidpath } start_pre() { if [ -z "${EMAIL}" ] ; then eerror "you must configure your email address in /etc/conf.d/dnetc" return 1 fi set_cpu_share } reload() { ebegin "Reloading distributed.net client" start-stop-daemon --signal HUP --pidfile="${pidfile}" eend ${?} } fetch() { ebegin "Fetching distributed.net client buffers" ${command} ${command_args} -fetch eend ${?} } flush() { ebegin "Flushing distributed.net client buffers" ${command} ${command_args} -flush eend ${?} }