#!/sbin/runscript # Copyright 1999-2008 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 # $Header: $ opts="${opts} reload" dbhub_bin="/usr/bin/dbhub" depend() { use net provide dc-hub } check_config() { ebegin "Checking config" if [[ ! -f "${DBHUB_CONFIG_DIR}/config" ]]; then eerror "DBHub isn't configured!" eerror "Please run following command:" eerror "emerge --config net-p2p/dbhub" eend 1 return fi if ( test ${ENABLE_CAPS} == "yes" && ! ( ${dbhub_bin} -h | grep -iq 'user' ) ); then eerror "caps support not enabled!" eerror "Recompile dbhub with caps use flag," eerror "or set 'no' for ENABLE_CAPS in /etc/conf.d/dbhub" eend 1 return 1 fi eend } build_options() { dbhub_options="-- -u ${DBHUB_USER} -g ${DBHUB_GROUP}" local config_checks=( "DBHUB_CONFIG_DIR value -w" "DBHUB_USE_SYSLOG enable -s" "DBHUB_WRITE_LOG value -l" "DBHUB_DEBUG enable -d" ) ebegin "Building options list" if [ ${ENABLE_CAPS} != "yes" ]; then einfo "caps not enabled, running under ${DBHUB_USER}:${DBHUB_GROUP}" dbhub_options="--chuid ${DBHUB_USER}:${DBHUB_GROUP} --" fi for (( i=0; $i < ${#config_checks[@]}; i=$i + 1 )) do set -- set ${config_checks[$i]} test -z ${!1} && continue; if [[ $2 == "value" || ${!1} == "yes" ]]; then dbhub_options="${dbhub_options} $3" fi test "$2" == "value" && dbhub_options="${dbhub_options} ${!1}" done set -- eend } start() { check_config || return 1 build_options ebegin "Starting dbhub" start-stop-daemon --start --exec ${dbhub_bin} ${dbhub_options} eend $? } stop() { ebegin "Stoping dbhub" start-stop-daemon --stop --exec ${dbhub_bin} eend $? }