summaryrefslogtreecommitdiff
path: root/net-p2p/i2p/files/i2p.sh.in
blob: 58161b0e8ca401baa562979338271843cdcb0e66 (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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
#!/bin/sh
#
# $FreeBSD$
#
# Under a BSDL license. Copyright 2005. Mario S F Ferreira <lioux@FreeBSD.org>

# PROVIDE: i2p
# REQUIRE: LOGIN
# KEYWORD: shutdown

#
# Add the following lines to /etc/rc.conf to enable i2p:
#
# i2p_enable="YES"
# i2p_user

. /etc/rc.subr

name="i2p"
rcvar=`set_rcvar`
command="%%PREFIX%%/sbin/i2prouter"
extra_commands="install uninstall update"

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

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

start_cmd="start_cmd"
stop_cmd="stop_cmd"
status_cmd="status_cmd"
restart_cmd="restart_cmd"
install_cmd="install_cmd"
uninstall_cmd="uninstall_cmd"
update_cmd="update_cmd"

generic_cmd()
{
  i2p_check_vars
  su -l ${i2p_user} -c "${command} ${1}"
}

start_cmd()
{
  generic_cmd start
}

stop_cmd()
{
  generic_cmd stop
}

status_cmd()
{
  generic_cmd status
}

restart_cmd()
{
  generic_cmd restart
}

install_cmd()
{
  generic_cmd install
}

uninstall_cmd()
{
  generic_cmd uninstall
}

update_cmd()
{
  generic_cmd update
}

load_rc_config "${name}"
: ${i2p_enable="NO"}
: ${i2p_user=""}

run_rc_command "$1"