summaryrefslogtreecommitdiff
path: root/devel/viewvc/files/viewvc.in
blob: 3e51534a78d4362c430f63ff0a1f9c643bc9d47b (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
#!/bin/sh

# $FreeBSD$
#
# PROVIDE: viewvc
# REQUIRE: LOGIN
# KEYWORD: shutdown
#
# Add the following line(s) to /etc/rc.conf to enable ViewVC:
#
#  viewvc_enable="YES"
#  # optional
#  viewvc_flags="-h localhost -p PORT"
#  viewvc_user="www"
#
# To get available parameters and the default values, use the
# command %%PREFIX%%/viewvc/bin/standalone.py --help
# for more info.
#
# Note:
# If you choose a listen port less then 1024 then you have
# to use a privileged user.
# If the user www cannot access your cvs/svn repository,
# adjust the parameter viewvc_user and it should work.
#
# INFO:
# ViewVC default tcp port: 49152
# see http://viewvc.tigris.org/issues/show_bug.cgi?id=234

. /etc/rc.subr

name=viewvc
rcvar=${name}_enable
load_rc_config $name

# Set defaults
viewvc_enable=${viewvc_enable:-"NO"}
viewvc_flags=${viewvc_flags:-"-p 49152"}
viewvc_user=${viewvc_user:-"www"}

pidfile=/var/run/viewvc.pid
command=%%PYTHON_CMD%%
standalone=%%INSTDIR%%/bin/standalone.py

start_precmd=viewvc_precmd
start_cmd=viewvc_start
stop_postcmd=viewvc_cleanup

viewvc_precmd()
{
    # with param -d we get another pid so prevent this
    %%ECHO%% "${viewvc_flags}" | %%EGREP%% -q "(^\-d| \-d)" 2>&1 > /dev/null
    if [ $? -eq 0 ]; then
        %%ECHO%% "Please remove parameter -d from viewvc_flags"
        %%ECHO%%
        return 1
    fi
}

viewvc_start() {
    echo "Starting viewvc."
    %%TOUCH%% ${pidfile} && %%CHOWN%% ${viewvc_user} ${pidfile}
    /usr/sbin/daemon -cf -p ${pidfile} -u ${viewvc_user} ${standalone} ${viewvc_flags}
}

viewvc_cleanup() {
    [ -f ${pidfile} ] && %%RM%% ${pidfile}
}

run_rc_command "$1"