summaryrefslogtreecommitdiff
path: root/security/bitwarden-ruby/files/bitwarden-api.in
blob: 00fe822b1e75a94457a9d2aa4b4b0b1986fd9509 (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
#!/bin/sh
#
# Created by: Mark Felder <feld@FreeBSD.org>
# $FreeBSD$
#

# PROVIDE: bitwarden-api
# REQUIRE: LOGIN
# KEYWORD: shutdown

#
# Add the following line to /etc/rc.conf to enable `bitwarden-api':
#
# bitwarden_api_enable="YES"

. /etc/rc.subr
name=bitwarden_api

rcvar=bitwarden_api_enable
load_rc_config ${name}

: ${bitwarden_api_enable:=NO}
: ${bitwarden_api_port:=4567}
: ${bitwarden_api_signups:=NO}
: ${bitwarden_api_user:=www}
: ${bitwarden_api_group:=www}
: ${bitwarden_api_chdir=/usr/local/www/bitwarden-ruby}

pidfile="/var/run/bitwarden/${name}.pid"
procname=%%RUBY_WITH_SUFFIX%%
command="%%PREFIX%%/bin/rackup"
command_args="-P ${pidfile} -p ${bitwarden_api_port} -E production config.ru 2>&1 | logger -t bitwarden &"
start_precmd="start_precmd"

start_precmd()
{
        if [ ! -e /var/run/bitwarden ] ; then
                install -d -o ${bitwarden_api_user} -g ${bitwarden_api_group} /var/run/bitwarden;
        fi

        checkyesno bitwarden_api_signups
        if [ "$?" -eq 0 ]; then
                export ALLOW_SIGNUPS=1
                echo "Bitwarden Signups Enabled"
        fi
}

run_rc_command "$1"