summaryrefslogtreecommitdiff
path: root/www/gitlab-pages/files/gitlab_pages.in
blob: 32b6b9057806d22c52be28bffcc06073408c52fd (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
#!/bin/sh
#
# $FreeBSD: head/www/gitlab-pages/files/gitlab_pages.in 468171 2018-04-24 01:01:37Z swills $
#
# PROVIDE: gitlab_pages
# REQUIRE: DAEMON NETWORKING
# KEYWORD: shutdown

#
# Add the following line to /etc/rc.conf to enable gitlab_pages:
#
# gitlab_pages_enable (bool):  Set to "NO" by default.
#                              Set it to "YES" to enable gitlab-pages
# gitlab_pages_dir (str):      Set to "/var/tmp/gitlab_pages" by default.
#                              Set it to directory to run gitlab-pages in
# gitlab_pages_user (str):     Set to "gitlab-pages" by default.
#                              Set it to user to run gitlab_pages under
# gitlab_pages_group (str):    Set to "gitlab-pages" by default.
#                              Set it to group to run gitlab-pages under
# gitlab_pages_logfile (str):  Set to "/var/log/gitlab_pages.log" by default.
#                              Set it to file to send gitlab-pages logs to
#

. /etc/rc.subr

name="gitlab_pages"
rcvar="gitlab_pages_enable"

load_rc_config $name

: ${gitlab_pages_enable:="NO"}
: ${gitlab_pages_dir:="/var/tmp/gitlab_pages"}
: ${gitlab_pages_user:="gitlab-pages"}
: ${gitlab_pages_group:="gitlab-pages"}
: ${gitlab_pages_logfile:="/var/log/gitlab_pages.log"}

export HOME=${gitlab_pages_dir}
export PATH=${PATH}:%%PREFIX%%/bin

pidfile="/var/run/${name}.pid"
gitlab_pages_chdir="${gitlab_pages_dir}"

procname=%%PREFIX%%/bin/gitlab-pages

start_precmd="gitlab_pages_startprecmd"
start_cmd="gitlab_pages_startcmd"
list_cmd="listfunc"
register_cmd="registerfunc"

listfunc()
{
        cd ${gitlab_pages_chdir} ; \
        su -m ${gitlab_pages_user} -c "env HOME=${gitlab_pages_dir} %%PREFIX%%/bin/gitlab-pages list"
}

registerfunc()
{
        cd ${gitlab_pages_chdir} ; \
        su -m ${gitlab_pages_user} -c "env HOME=${gitlab_pages_dir} %%PREFIX%%/bin/gitlab-pages register"
}

gitlab_pages_startprecmd()
{
        if [ ! -e "${pidfile}" ]; then
                install -g ${gitlab_pages_group} -o ${gitlab_pages_user} -- /dev/null "${pidfile}";
        fi
        if [ ! -d "${gitlab_pages_dir}" ]; then
                install -d -o "${gitlab_pages_user}" -g "${gitlab_pages_group}" "${gitlab_pages_dir}"
        fi
}

gitlab_pages_startcmd()
{
        cd ${gitlab_pages_chdir} ; \
        daemon -u ${gitlab_pages_user} -p ${pidfile} /usr/local/bin/gitlab-pages ${gitlab_pages_args} run < /dev/null >> ${gitlab_pages_logfile} 2>> ${gitlab_pages_logfile}
}

extra_commands="list register"
run_rc_command $1