#!/bin/sh /etc/rc.common
# Copyright (C) 2006 OpenWrt.org
START=50

BIN=tor
DEFAULT=/etc/default/$BIN
LOG_D=/var/log/$BIN
LIB_D=/var/lib/$BIN
RUN_D=/var/run
PID_F=$RUN_D/$BIN.pid
RUN_USER=$BIN
RUN_GROUP=$BIN

start() {
	[ -f $DEFAULT ] && . $DEFAULT
	[ -d $LIB_D ] || mkdir -p $LOG_D
	[ -d $LIB_D ] || ( mkdir -p $LIB_D && chown $RUN_USER:$RUN_GROUP $LIB_D )
	[ -d $RUN_D ] || mkdir -p $RUN_D
	[ -f $PID_F ] || ( touch $PID_F && chown $RUN_USER:$RUN_GROUP $PID_F )
	$BIN $OPTIONS
}

stop() {
	[ -f $PID_F ] && kill $(cat $PID_F)
}

