aboutsummaryrefslogtreecommitdiff
path: root/net-p2p/freenet05/files/freenet.sh
blob: 50c1e47294befcd2f66480fe541abab231521c01 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#!/bin/sh
#
# $FreeBSD$
#
# Under a BSDL license. Copyright 2005. Mario S F Ferreira <lioux@FreeBSD.org>

# PROVIDE: freenet
# REQUIRE: NETWORKING
# KEYWORD: FreeBSD shutdown

#
# Add the following lines to /etc/rc.conf to enable freenet:
#
#freenet_enable="YES"
#freenet_user=""
#

. /etc/rc.subr

name="freenet"
rcvar=`set_rcvar`
command="%%PREFIX%%/bin/${name}"
extra_commands="configure"

freenet_check_vars()
{
  if [ -z "${freenet_user}" ]; then
    freenet_user=$(whoami)
  fi

  if [ "x${freenet_user}" = "xroot" ]; then
    err 1 "You have to set freenet_user to a non-root user for security reasons"
  fi
}

configure_cmd="configure_cmd"
configure_cmd()
{
  freenet_check_vars
  su -l ${freenet_user} -c "${command} -c"
}

start_cmd="start_cmd"
start_cmd()
{
  freenet_check_vars
  su -l ${freenet_user} -c "${command} -i"
}

stop_cmd="stop_cmd"
stop_cmd()
{
  freenet_check_vars
  su -l ${freenet_user} -c "${command} -o"
}

status_cmd="status_cmd"
status_cmd()
{
  echo "Can't check ${name} status"
}

load_rc_config "${name}"
: ${freenet_enable="NO"}
: ${freenet_user=""}

run_rc_command "$1"